mirror of
https://github.com/flarum/framework.git
synced 2024-11-27 11:03:37 +08:00
Rework discussion/post components
This commit is contained in:
parent
d4e573b629
commit
ff6c7455f5
|
@ -5,12 +5,12 @@ import ActionButton from '../ui/controls/action-button';
|
|||
|
||||
export default Ember.Component.extend({
|
||||
tagName: 'article',
|
||||
templateName: 'components/discussions/post',
|
||||
layoutName: 'components/discussions/post-full',
|
||||
|
||||
// controls: null,
|
||||
|
||||
contentComponent: function() {
|
||||
return 'discussions/post-'+this.get('post.type');
|
||||
return 'discussions/post-content-'+this.get('post.type');
|
||||
}.property('post.type'),
|
||||
|
||||
classNames: ['post'],
|
|
@ -7,7 +7,7 @@ export default Ember.Component.extend({
|
|||
layoutName: 'components/ui/controls/item-list',
|
||||
|
||||
listItems: function() {
|
||||
if (!this.get('items')) return [];
|
||||
if (!Ember.isArray(this.get('items'))) return [];
|
||||
var listItems = [];
|
||||
this.get('items').forEach(function(item) {
|
||||
if (item.tagName != 'li') {
|
||||
|
|
|
@ -34,48 +34,12 @@ var Discussion = DS.Model.extend({
|
|||
return this.get('posts').split(',');
|
||||
}.property('posts'),
|
||||
|
||||
readTime: DS.attr('date'),
|
||||
readNumber: DS.attr('number'),
|
||||
unreadCount: function() {
|
||||
return this.get('lastPostNumber') - this.get('readNumber');
|
||||
}.property('lastPostNumber', 'readNumber'),
|
||||
|
||||
//--------------------------------
|
||||
// Prototype generated properties
|
||||
|
||||
// category: function() {
|
||||
// var categories = [null, 'Announcements', 'General', 'Support', 'Feedback', 'Core', 'Plugins', 'Themes'];
|
||||
// return categories[Math.floor(Math.random() * categories.length)];
|
||||
// }.property(),
|
||||
category: DS.attr('string'),
|
||||
|
||||
_recent: function() {
|
||||
var cutoff = new Date('September 19, 2014');
|
||||
return this.get('lastTime') > cutoff;
|
||||
}.property('lastTime'),
|
||||
|
||||
unread: function() {
|
||||
return Math.round(Math.random() * (this.get('_recent') ? 0.8 : 0) * this.get('postsCount'));
|
||||
}.property(),
|
||||
|
||||
// sticky: function() {
|
||||
// return Math.random() > (this.get('_recent') ? 0.95 : 0.99);
|
||||
// }.property(),
|
||||
sticky: DS.attr('boolean'),
|
||||
|
||||
excerpt: function() {
|
||||
// return 'I want to get your thoughts on this one TV Addicts: what new show have you been getting into this year, and why?';
|
||||
// return 'Here\'s the near-final game list, in no particular order. The list may be subject to amendments, as we\'re still chasing up copies of some games.';
|
||||
// return 'Nominating for the Annual General Meeting is easy. Read this to find out how.'
|
||||
return 'There are many apps made with Ninetech in the Mac App Store. If you\'d like, take a moment to share your Nintech-made apps in this thread.';
|
||||
}.property(),
|
||||
|
||||
locked: function() {
|
||||
return Math.random() > 0.95;
|
||||
}.property(),
|
||||
|
||||
following: function() {
|
||||
return Math.random() > 0.95;
|
||||
}.property()
|
||||
isUnread: Ember.computed.bool('unreadCount')
|
||||
});
|
||||
|
||||
export default Discussion;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
{{/link-to}}
|
||||
|
||||
<div class="count">
|
||||
{{#if discussion.unread}}
|
||||
{{#if discussion.isUnread}}
|
||||
<strong>{{abbreviate-number discussion.unreadCount}}</strong> unread
|
||||
{{else}}
|
||||
<strong>{{abbreviate-number discussion.repliesCount}}</strong> replies
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
{{#if post.deleteTime}}
|
||||
<i class="post-icon fa fa-trash-o"></i>
|
||||
{{/if}}
|
||||
|
||||
<header>
|
||||
<h3 class="user">
|
||||
{{#link-to "user" post.user}}{{user-avatar post.user}} {{post.user.username}}{{/link-to}}
|
||||
</h3>
|
||||
</header>
|
||||
|
||||
<div class="post-body">
|
||||
{{{post.contentHtml}}}
|
||||
</div>
|
||||
|
||||
<aside class="post-meta">
|
||||
<ul>
|
||||
{{!-- {{menu-list items=meta}} --}}
|
||||
{{#if post.likes}}
|
||||
<li>
|
||||
<a href="">{{fa-icon "thumbs-o-up"}} {{post.likes}}</a>
|
||||
·
|
||||
<a href="">Like</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
</ul>
|
||||
</aside>
|
|
@ -0,0 +1,23 @@
|
|||
{{#if post.deleteTime}}
|
||||
{{fa-icon "trash-o" class="post-icon"}}
|
||||
{{/if}}
|
||||
|
||||
<header>
|
||||
<h3 class="user">
|
||||
{{#link-to "user" post.user}}{{user-avatar post.user}} {{post.user.username}}{{/link-to}}
|
||||
</h3>
|
||||
{{#link-to "discussion" post.discussion (query-params start=post.number) class="time"}}
|
||||
{{abbreviate-time post.time}}
|
||||
{{/link-to}}
|
||||
{{#if post.editTime}}
|
||||
<span class="post-edited" {{bind-attr title=editDescription}}>{{fa-icon "pencil"}}</span>
|
||||
{{/if}}
|
||||
</header>
|
||||
|
||||
<div class="post-body">
|
||||
{{{post.contentHtml}}}
|
||||
</div>
|
||||
|
||||
<aside class="post-meta">
|
||||
{{ui/controls/item-list items=meta}}
|
||||
</aside>
|
|
@ -0,0 +1,4 @@
|
|||
<div class="activity">
|
||||
{{fa-icon "pencil" class="post-icon"}}
|
||||
{{#link-to "user" post.user}}{{post.user.username}}{{/link-to}} changed the title from <strong class="old-title">{{post.oldTitle}}</strong> to <strong class="new-title">{{post.newTitle}}</strong>.
|
||||
</div>
|
3
ember/app/templates/components/discussions/post-full.hbs
Normal file
3
ember/app/templates/components/discussions/post-full.hbs
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{ui/controls/dropdown-button items=controls}}
|
||||
|
||||
{{dynamic-component type=contentComponent post=post}}
|
|
@ -1,4 +0,0 @@
|
|||
<div class="activity">
|
||||
<i class="post-icon fa fa-pencil"></i>
|
||||
{{#link-to "user" post.user}}{{post.user.username}}{{/link-to}} named the discussion: <strong>{{post.content}}</strong>.
|
||||
</div>
|
|
@ -1,12 +0,0 @@
|
|||
{{!-- {{#if view.controls}}
|
||||
<div class="controls btn-group">
|
||||
<button data-toggle="dropdown" class="dropdown-toggle btn btn-default btn-icon btn-xs">{{fa-icon "caret-down"}}</button>
|
||||
{{menu-list items=controls class="dropdown-menu pull-right"}}
|
||||
</div>
|
||||
{{/if}} --}}
|
||||
|
||||
{{#link-to "discussion" post.discussion (query-params start=post.number) class="time"}}
|
||||
{{abbreviate-time post.time}}
|
||||
{{/link-to}}
|
||||
|
||||
{{dynamic-component type=contentComponent post=post}}
|
|
@ -1,17 +1,15 @@
|
|||
<header class="page-header discussion-header">
|
||||
{{partial "partials/discussion-header"}}
|
||||
<h1>{{title}}</h1>
|
||||
</header>
|
||||
|
||||
<nav class="discussion-nav">
|
||||
{{view view.sidebar viewName="sidebar"}}
|
||||
{{ui/controls/item-list items=view.sidebarItems}}
|
||||
</nav>
|
||||
|
||||
<section class="items posts">
|
||||
{{#each item in postStream}}
|
||||
|
||||
{{#discussion-item item=item}}
|
||||
{{#if item.post}}{{discussion-post post=item.post}}{{/if}}
|
||||
{{/discussion-item}}
|
||||
|
||||
{{/each}}
|
||||
<section class="discussion-posts stream posts">
|
||||
{{#each item in stream}}
|
||||
{{#discussions/stream-item item=item loadRange="loadRange"}}
|
||||
{{#if item.post}}{{discussions/post-full post=item.post}}{{/if}}
|
||||
{{/discussions/stream-item}}
|
||||
{{/each}}
|
||||
</section>
|
|
@ -25,7 +25,7 @@
|
|||
{{else}}
|
||||
<ul class="discussions-list">
|
||||
{{#each discussion in content}}
|
||||
{{discussions/discussion-listing discussion=discussion}}
|
||||
{{discussions/discussion-listing discussion=discussion searchQuery=searchQuery}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user