Cleanup posts template.

No issue.

* Fix indentation (it was surprisingly hard for me to grok what was happening
  without indentation).
* Utilize `alternateActive` from `core/client/utils/link-view.js` to
  maintain the `active` state. Observing `childViews` is deprecated (and
  may not work properly in future versions of Ember).
* Remove now unused `item-view`.
This commit is contained in:
Robert Jackson 2014-12-31 21:06:05 -05:00
parent d2bb1dd613
commit b56c26c597
3 changed files with 21 additions and 30 deletions

View File

@ -14,24 +14,24 @@
{{#view "paginated-scroll-box" tagName="section" classNames="content-list-content js-content-scrollbox"}}
<ol class="posts-list">
{{#each post in model itemController="posts/post" itemView="post-item-view" itemTagName="li"}}
{{#link-to "posts.post" post class="permalink" title="Edit this post"}}
<h3 class="entry-title">{{post.title}}</h3>
<section class="entry-meta">
<span class="status">
{{#if post.isPublished}}
{{#if post.page}}
<span class="page">Page</span>
{{else}}
<time datetime="{{unbound post.published_at}}" class="date published">
Published {{gh-format-timeago post.published_at}}
</time>
{{/if}}
{{else}}
<span class="draft">Draft</span>
{{/if}}
</span>
</section>
{{/link-to}}
{{#link-to "posts.post" post class="permalink" alternateActive=view.active title="Edit this post"}}
<h3 class="entry-title">{{post.title}}</h3>
<section class="entry-meta">
<span class="status">
{{#if post.isPublished}}
{{#if post.page}}
<span class="page">Page</span>
{{else}}
<time datetime="{{unbound post.published_at}}" class="date published">
Published {{gh-format-timeago post.published_at}}
</time>
{{/if}}
{{else}}
<span class="draft">Draft</span>
{{/if}}
</span>
</section>
{{/link-to}}
{{/each}}
</ol>
{{/view}}

View File

@ -1,9 +0,0 @@
var ItemView = Ember.View.extend({
classNameBindings: ['active'],
active: Ember.computed('childViews.firstObject.active', function () {
return this.get('childViews.firstObject.active');
})
});
export default ItemView;

View File

@ -1,7 +1,7 @@
import itemView from 'ghost/views/item-view';
var PostItemView = Ember.View.extend({
classNameBindings: ['active', 'isFeatured:featured', 'isPage:page'],
var PostItemView = itemView.extend({
classNameBindings: ['isFeatured:featured', 'isPage:page'],
active: null,
isFeatured: Ember.computed.alias('controller.model.featured'),