Created
February 23, 2016 18:14
-
-
Save flippyhead/eb6459d48801d6c22ad0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dates = {} | |
| Template.documentsTable.rendered = -> | |
| @autorun -> | |
| Session.get 'query' | |
| dates = {} | |
| @autorun => | |
| page = (Session.get('limit') / 10) - 1 | |
| @$('#documents-table--table tbody tr:last') | |
| .addClass('pageRow') | |
| .removeClass('hidden') | |
| .find('td.page') | |
| .text(page) | |
| Template.documentsTable.helpers | |
| hasDocuments: -> | |
| @?.count() > 0 | |
| hasAnyDocuments: -> | |
| return unless count = Count.find().fetch()[0] | |
| {total, query, tags} = count | |
| !!query or tags?.length or total > 0 | |
| isReady: -> | |
| !!Count.find().fetch()[0] | |
| heading: -> | |
| return false unless Session.get('sort') is 'updatedAt' | |
| date = @updatedAtAgo() | |
| if not dates[date]? or dates[date] is @_id | |
| dates[date] = @_id | |
| date | |
| else | |
| false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <template name="documentsTable"> | |
| {{#if hasAnyDocuments }} | |
| {{#if hasDocuments }} | |
| <table id="documents-table--table" class="table documents-index--table"> | |
| <tbody> | |
| {{#each this}} | |
| {{#if heading}} | |
| <tr class="documents-table--row-heading"> | |
| <td></td> | |
| <td>{{heading}}</td> | |
| </tr> | |
| {{/if}} | |
| {{> documentsRow}} | |
| <tr class="hidden pageRow"> | |
| <td class="page documents-row--controls"></td> | |
| <td><hr /></td> | |
| </tr> | |
| {{/each}} | |
| </tbody> | |
| </table> | |
| {{else}} | |
| <div class="no-results"> | |
| No documents matching your search could be found. | |
| </div> | |
| {{/if}} | |
| {{else}} | |
| {{#if isReady }} | |
| {{> documentsHelp}} | |
| {{/if}} | |
| {{/if}} | |
| </template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment