Sorts work by date

This commit is contained in:
Kenneth Jao 2016-09-16 08:43:07 -04:00
parent 415a621f6c
commit 60dfa22485
2 changed files with 13 additions and 11 deletions

View File

@ -32,8 +32,14 @@
</div> </div>
</div> </div>
{{#if myClasses}} {{#if myClasses}}
<div id="classFilterHolder">
<h3>Filters</h3>
{{#each types}}
{{> sideTypeFilter}}
{{/each}}
</div>
<div id="classListHolder"> <div id="classListHolder">
<h3>Enrolled</h3> <h3>By Class </h3>
{{#if calCreWork}} {{#if calCreWork}}
<h3 id="calCreWork">-- Pick a class</h3> <h3 id="calCreWork">-- Pick a class</h3>
{{else}} {{else}}
@ -46,13 +52,6 @@
{{> sidebarClasses}} {{> sidebarClasses}}
{{/each}} {{/each}}
</div> </div>
</div>
<div id="classFilterHolder">
<h3>Filters</h3>
{{#each types}}
{{> sideTypeFilter}}
{{/each}}
</div> </div>
{{/if}} {{/if}}
</div> </div>

View File

@ -136,8 +136,8 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
found.mine = false; found.mine = false;
} }
} }
if (classDisp.indexOf(courses[i]) !== -1) found.selected = true; // Filter selected. if (classDisp.indexOf(courses[i]) !== -1) found.selected = true; // Filter selected.
array.push(found); array.push(found);
var thisWork = work.find({ var thisWork = work.find({
class: courses[i] class: courses[i]
@ -176,6 +176,7 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
for (j = 0; j < thisWork.length; j++) { for (j = 0; j < thisWork.length; j++) {
thisWork[j].classid = courses[i]; thisWork[j].classid = courses[i];
thisWork[j].realDate = thisWork[j].dueDate; thisWork[j].realDate = thisWork[j].dueDate;
thisWork[j].numberDate = Date.parse(thisWork[j].realDate);
thisWork[j].dueDate = moment(thisWork[j].dueDate).calendar(null, { thisWork[j].dueDate = moment(thisWork[j].dueDate).calendar(null, {
sameDay: '[Today]', sameDay: '[Today]',
nextDay: '[Tomorrow]', nextDay: '[Tomorrow]',
@ -212,7 +213,9 @@ Template.registerHelper('myClasses', () => { // Gets all classes and respective
thisWork[j].doneRatio = "#FF1A1A"; thisWork[j].doneRatio = "#FF1A1A";
} }
} }
array[i].thisClassWork = thisWork; array[i].thisClassWork = thisWork.sort(function(a, b) {
return parseFloat(a.numberDate) - parseFloat(b.numberDate);
});
} }
Session.set("noclass", false); Session.set("noclass", false);
Session.set("calendarClasses", array); Session.set("calendarClasses", array);