change sort order
This commit is contained in:
parent
95a6d45f02
commit
426f064dc5
3
TODO.md
3
TODO.md
|
@ -3,8 +3,6 @@
|
||||||
##Release: Assembly
|
##Release: Assembly
|
||||||
|
|
||||||
- [ ] use Browserify as an app build pipeline
|
- [ ] use Browserify as an app build pipeline
|
||||||
- [ ] sort milestones on index and project page based on priority (most delayed first); Trend - actual = difference in days and those overdue come first
|
|
||||||
- [ ] sort on name using https://github.com/npm/node-semver/blob/master/semver.js if detected
|
|
||||||
|
|
||||||
###Git
|
###Git
|
||||||
|
|
||||||
|
@ -33,6 +31,7 @@
|
||||||
|
|
||||||
###Misc
|
###Misc
|
||||||
|
|
||||||
|
- [ ] extend from Eventful object that disposes of mediator subscriptions on teardown
|
||||||
- [ ] the deploy script needs to disable autoreload; `make watch` should start a static web server and also launch a build script with a flag saying which files to include in the head (uncompressed, with live reload); standard build script should minify scripts
|
- [ ] the deploy script needs to disable autoreload; `make watch` should start a static web server and also launch a build script with a flag saying which files to include in the head (uncompressed, with live reload); standard build script should minify scripts
|
||||||
- [ ] vendor module so we can proxy require all `window` libs
|
- [ ] vendor module so we can proxy require all `window` libs
|
||||||
- [ ] show a countdown clock towards the end of the milestone or show overdue
|
- [ ] show a countdown clock towards the end of the milestone or show overdue
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -12,7 +12,10 @@ module.exports = new Model
|
||||||
'name': 'models/projects'
|
'name': 'models/projects'
|
||||||
|
|
||||||
'data':
|
'data':
|
||||||
'sortBy': 'name'
|
# Current sort order.
|
||||||
|
'sortBy': 'priority'
|
||||||
|
# Sort functions.
|
||||||
|
'sortFns': [ 'progress', 'priority', 'name' ]
|
||||||
|
|
||||||
# Return a sort order comparator.
|
# Return a sort order comparator.
|
||||||
comparator: ->
|
comparator: ->
|
||||||
|
@ -128,7 +131,7 @@ module.exports = new Model
|
||||||
continue unless p.milestones?
|
continue unless p.milestones?
|
||||||
for m, j in p.milestones
|
for m, j in p.milestones
|
||||||
# Run a comparator here inserting into index.
|
# Run a comparator here inserting into index.
|
||||||
idx = sortedIndexCmp index, data, do @comparator
|
idx = sortedIndexCmp index, [ p, m ], do @comparator
|
||||||
# Log.
|
# Log.
|
||||||
index.splice idx, 0, [ i, j ]
|
index.splice idx, 0, [ i, j ]
|
||||||
|
|
||||||
|
@ -151,7 +154,7 @@ module.exports = new Model
|
||||||
# Reset our index and re-sort.
|
# Reset our index and re-sort.
|
||||||
@observe 'sortBy', ->
|
@observe 'sortBy', ->
|
||||||
# Use pop as Ractive is glitchy when resetting arrays.
|
# Use pop as Ractive is glitchy when resetting arrays.
|
||||||
( @pop 'index' while @data.index.length ) if @data.index?
|
@set 'index', null
|
||||||
# Run the sort again.
|
# Run the sort again.
|
||||||
do @sort
|
do @sort
|
||||||
, 'init': no
|
, 'init': no
|
|
@ -1,6 +1,6 @@
|
||||||
<div id="projects">
|
<div id="projects">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<a href="#" class="sort"><Icons icon="sort-alphabet"/> Sorted by priority</a>
|
<a class="sort" on-click="sortBy"><Icons icon="sort-alphabet"/> Sorted by {{projects.sortBy}}</a>
|
||||||
<h2>Milestones</h2>
|
<h2>Milestones</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div id="projects">
|
<div id="projects">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<a href="#" class="sort"><Icons icon="sort-alphabet"/> Sorted by priority</a>
|
<a class="sort" on-click="sortBy"><Icons icon="sort-alphabet"/> Sorted by {{projects.sortBy}}</a>
|
||||||
<h2>Projects</h2>
|
<h2>Projects</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,7 @@
|
||||||
{ Ractive } = require '../../modules/vendor.coffee'
|
Table = require './table.coffee'
|
||||||
|
|
||||||
mediator = require '../../modules/mediator.coffee'
|
module.exports = Table.extend
|
||||||
projects = require '../../models/projects.coffee'
|
|
||||||
format = require '../../utils/format.coffee'
|
|
||||||
Icons = require '../icons.coffee'
|
|
||||||
|
|
||||||
module.exports = Ractive.extend
|
|
||||||
|
|
||||||
'name': 'views/milestones'
|
'name': 'views/milestones'
|
||||||
|
|
||||||
'template': require '../../templates/tables/milestones.html'
|
'template': require '../../templates/tables/milestones.html'
|
||||||
|
|
||||||
'data': { format }
|
|
||||||
|
|
||||||
'components': { Icons }
|
|
||||||
|
|
||||||
'adapt': [ Ractive.adaptors.Ractive ]
|
|
|
@ -1,18 +1,7 @@
|
||||||
{ Ractive } = require '../../modules/vendor.coffee'
|
Table = require './table.coffee'
|
||||||
|
|
||||||
mediator = require '../../modules/mediator.coffee'
|
module.exports = Table.extend
|
||||||
format = require '../../utils/format.coffee'
|
|
||||||
Icons = require '../icons.coffee'
|
|
||||||
projects = require '../../models/projects.coffee'
|
|
||||||
|
|
||||||
module.exports = Ractive.extend
|
|
||||||
|
|
||||||
'name': 'views/projects'
|
'name': 'views/projects'
|
||||||
|
|
||||||
'template': require '../../templates/tables/projects.html'
|
'template': require '../../templates/tables/projects.html'
|
||||||
|
|
||||||
'data': { format }
|
|
||||||
|
|
||||||
'components': { Icons }
|
|
||||||
|
|
||||||
'adapt': [ Ractive.adaptors.Ractive ]
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
{ Ractive } = require '../../modules/vendor.coffee'
|
||||||
|
|
||||||
|
format = require '../../utils/format.coffee'
|
||||||
|
Icons = require '../icons.coffee'
|
||||||
|
projects = require '../../models/projects.coffee'
|
||||||
|
|
||||||
|
module.exports = Ractive.extend
|
||||||
|
|
||||||
|
'name': 'views/table'
|
||||||
|
|
||||||
|
'data': { format }
|
||||||
|
|
||||||
|
'components': { Icons }
|
||||||
|
|
||||||
|
'adapt': [ Ractive.adaptors.Ractive ]
|
||||||
|
|
||||||
|
onconstruct: ->
|
||||||
|
# Change sort order.
|
||||||
|
@on 'sortBy', ->
|
||||||
|
fns = projects.data.sortFns
|
||||||
|
|
||||||
|
idx = 1 + fns.indexOf projects.data.sortBy
|
||||||
|
idx = 0 if idx is fns.length
|
||||||
|
|
||||||
|
projects.set 'sortBy', fns[idx]
|
Loading…
Reference in New Issue