fix rewriting of index; milestones displayed from index
This commit is contained in:
parent
079c18668a
commit
082251f352
8
Makefile
8
Makefile
|
@ -2,8 +2,14 @@ install:
|
|||
npm install
|
||||
bower install
|
||||
|
||||
build:
|
||||
build-app:
|
||||
./node_modules/.bin/browserify -e ./src/app.coffee -o public/js/app.js -d
|
||||
|
||||
watch-app:
|
||||
./node_modules/.bin/watchify -e ./src/app.coffee -o public/js/app.js -d
|
||||
|
||||
build:
|
||||
build-app
|
||||
grunt
|
||||
|
||||
serve:
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
"grunt-watchify": "~0.1.0",
|
||||
"coffeeify": "~0.7.0L",
|
||||
"ractivate": "~0.2.0",
|
||||
"browserify": "~6.1.0"
|
||||
"browserify": "~6.1.0",
|
||||
"watchify": "~2.1.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
139
public/js/app.js
139
public/js/app.js
File diff suppressed because one or more lines are too long
|
@ -16,27 +16,26 @@ module.exports = new Model
|
|||
|
||||
# Return a sort order comparator.
|
||||
comparator: ->
|
||||
{ list } = @data
|
||||
{ list, sortBy } = @data
|
||||
|
||||
# Convert existing index into actual project milestone.
|
||||
deIdx = (fn) =>
|
||||
([ i, j ], b) =>
|
||||
fn list[i].milestones[j], b
|
||||
|
||||
switch @data.sortBy
|
||||
# From highest progress.
|
||||
switch sortBy
|
||||
# From highest progress points.
|
||||
when 'progress' then deIdx (a, b) ->
|
||||
# By progress points.
|
||||
$ = { 'progress': { 'points': 0 } }
|
||||
a.stats ?= $ ; b.progress ?= $
|
||||
|
||||
a.stats.progress.points - b.stats.progress.points
|
||||
|
||||
# From most delayed in days.
|
||||
when 'priority' then deIdx (a, b) =>
|
||||
0
|
||||
when 'priority' then deIdx (a, b) ->
|
||||
throw 'Not implemented'
|
||||
|
||||
# Whatever sort order...
|
||||
# The "whatever" sort order...
|
||||
else -> 0
|
||||
|
||||
find: (project) ->
|
||||
|
@ -53,18 +52,23 @@ module.exports = new Model
|
|||
findIndex: ({ owner, name }) ->
|
||||
_.findIndex @data.list, { owner, name }
|
||||
|
||||
# Add a milestone for a project.
|
||||
addMilestone: (project, milestone) ->
|
||||
# Add in the stats.
|
||||
_.extend milestone, { 'stats': stats(milestone) }
|
||||
|
||||
if (idx = @findIndex(project)) > -1
|
||||
if project.milestones?
|
||||
@push "list.#{idx}.milestones", milestone
|
||||
else
|
||||
@set "list.#{idx}.milestones", [ milestone ]
|
||||
else
|
||||
# We are supposed to exist already.
|
||||
throw 500
|
||||
throw 500 if (i = @findIndex(project)) < 0
|
||||
|
||||
# Have milestones already?
|
||||
if project.milestones?
|
||||
@push "list.#{i}.milestones", milestone
|
||||
j = @data.list[i].milestones.length - 1 # index in milestones
|
||||
else
|
||||
@set "list.#{i}.milestones", [ milestone ]
|
||||
j = 0 # index in milestones
|
||||
|
||||
# Now index this milestone.
|
||||
@sort [ i, j ], milestone
|
||||
|
||||
# Save an error from loading milestones or issues
|
||||
saveError: (project, err) ->
|
||||
|
@ -80,12 +84,19 @@ module.exports = new Model
|
|||
clear: ->
|
||||
@set 'list', []
|
||||
|
||||
# Sort an already sorted index.
|
||||
sort: ->
|
||||
# Sort/or insert into an already sorted index.
|
||||
sort: (ref, m) ->
|
||||
# Get or initialize the index.
|
||||
index = @data.index or []
|
||||
|
||||
# Do one.
|
||||
if m
|
||||
idx = sortedIndexCmp index, m, do @comparator
|
||||
index.splice idx, 0, ref
|
||||
# Do all.
|
||||
else
|
||||
for p, i in @data.list
|
||||
# TODO: need to show projects that failed too...
|
||||
continue unless p.milestones?
|
||||
for m, j in p.milestones
|
||||
# Run a comparator here inserting into index.
|
||||
|
@ -104,16 +115,14 @@ module.exports = new Model
|
|||
# Init the projects.
|
||||
@set 'list', lscache.get('projects') or []
|
||||
|
||||
@observe 'list', (projects) ->
|
||||
# Persist projects in local storage (sans milestones).
|
||||
@observe 'list', (projects) ->
|
||||
lscache.set 'projects', _.pluckMany projects, [ 'owner', 'name' ]
|
||||
# Update the index.
|
||||
do @sort
|
||||
, 'init': no
|
||||
|
||||
# Reset our index and re-sort.
|
||||
@observe 'sortBy', ->
|
||||
# Use pop as Ractive is glitchy.
|
||||
# Use pop as Ractive is glitchy when resetting arrays.
|
||||
( @pop 'index' while @data.index.length ) if @data.index?
|
||||
# Run the sort again.
|
||||
do @sort
|
|
@ -5,22 +5,34 @@
|
|||
</div>
|
||||
|
||||
<table>
|
||||
{{#project.milestones}}
|
||||
{{#projects.index}}
|
||||
{{# { index: this } }}
|
||||
|
||||
{{# { p: projects.list[index[0]] } }}
|
||||
{{#if p.owner == project.owner && p.name == project.name }}
|
||||
|
||||
{{# { milestone: project.milestones[index[1]] } }}
|
||||
<tr>
|
||||
<td>
|
||||
<a class="milestone" href="#{{project.owner}}/{{project.name}}/{{number}}">{{ title }}</a>
|
||||
<a class="milestone" href="#{{project.owner}}/{{project.name}}/{{milestone.number}}">{{ milestone.title }}</a>
|
||||
</td>
|
||||
<td style="width:1%">
|
||||
<div class="progress">
|
||||
<span class="percent">{{Math.floor(stats.progress.points)}}%</span>
|
||||
<span class="due">{{{ format.due(due_on) }}}</span>
|
||||
<span class="percent">{{Math.floor(milestone.stats.progress.points)}}%</span>
|
||||
<span class="due">{{{ format.due(milestone.due_on) }}}</span>
|
||||
<div class="outer bar">
|
||||
<div class="inner bar {{(stats.isOnTime) ? 'green' : 'red'}}" style="width:{{stats.progress.points}}%"></div>
|
||||
<div class="inner bar {{(milestone.stats.isOnTime) ? 'green' : 'red'}}" style="width:{{milestone.stats.progress.points}}%"></div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/project.milestones}}
|
||||
{{/}}
|
||||
|
||||
{{/if}}
|
||||
{{/}}
|
||||
|
||||
{{/}}
|
||||
{{/projects.index}}
|
||||
</table>
|
||||
|
||||
<div class="footer">
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
<a class="project" href="#{{owner}}/{{name}}">{{owner}}/{{name}}</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="milestone" href="#{{owner}}/{{name}}/{{milestone.number}}">{{ title }}</a>
|
||||
<a class="milestone" href="#{{owner}}/{{name}}/{{milestone.number}}">{{ milestone.title }}</a>
|
||||
</td>
|
||||
<td style="width:1%">
|
||||
<div class="progress">
|
||||
<span class="percent">{{Math.floor(milestone.stats.progress.points)}}%</span>
|
||||
<span class="due">{{{ format.due(due_on) }}}</span>
|
||||
<span class="due">{{{ format.due(milestone.due_on) }}}</span>
|
||||
<div class="outer bar">
|
||||
<div class="inner bar {{(milestone.stats.isOnTime) ? 'green' : 'red'}}" style="width:{{milestone.stats.progress.points}}%"></div>
|
||||
</div>
|
||||
|
|
|
@ -17,6 +17,7 @@ module.exports = Ractive.extend
|
|||
'components': { Milestones }
|
||||
|
||||
'data':
|
||||
'projects': projects
|
||||
'ready': no
|
||||
|
||||
onrender: ->
|
||||
|
|
Loading…
Reference in New Issue