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",
|
||||
|
|
161
public/js/app.js
161
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) }
|
||||
# We are supposed to exist already.
|
||||
throw 500 if (i = @findIndex(project)) < 0
|
||||
|
||||
if (idx = @findIndex(project)) > -1
|
||||
if project.milestones?
|
||||
@push "list.#{idx}.milestones", milestone
|
||||
else
|
||||
@set "list.#{idx}.milestones", [ milestone ]
|
||||
# Have milestones already?
|
||||
if project.milestones?
|
||||
@push "list.#{i}.milestones", milestone
|
||||
j = @data.list[i].milestones.length - 1 # index in milestones
|
||||
else
|
||||
# We are supposed to exist already.
|
||||
throw 500
|
||||
@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,18 +84,25 @@ 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 []
|
||||
|
||||
for p, i in @data.list
|
||||
continue unless p.milestones?
|
||||
for m, j in p.milestones
|
||||
# Run a comparator here inserting into index.
|
||||
idx = sortedIndexCmp index, m, do @comparator
|
||||
# Log.
|
||||
index.splice idx, 0, [ i, j ]
|
||||
# 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.
|
||||
idx = sortedIndexCmp index, m, do @comparator
|
||||
# Log.
|
||||
index.splice idx, 0, [ i, j ]
|
||||
|
||||
# Save the index.
|
||||
@set 'index', index
|
||||
|
@ -104,16 +115,14 @@ module.exports = new Model
|
|||
# Init the projects.
|
||||
@set 'list', lscache.get('projects') or []
|
||||
|
||||
# Persist projects in local storage (sans milestones).
|
||||
@observe 'list', (projects) ->
|
||||
# Persist projects in local storage (sans milestones).
|
||||
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}}
|
||||
<tr>
|
||||
<td>
|
||||
<a class="milestone" href="#{{project.owner}}/{{project.name}}/{{number}}">{{ 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>
|
||||
<div class="outer bar">
|
||||
<div class="inner bar {{(stats.isOnTime) ? 'green' : 'red'}}" style="width:{{stats.progress.points}}%"></div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/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}}/{{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(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>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{{/}}
|
||||
|
||||
{{/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: ->
|
||||
|
@ -68,4 +69,4 @@ module.exports = Ractive.extend
|
|||
} if err
|
||||
|
||||
# Say we are ready.
|
||||
@set 'ready', yes
|
||||
@set 'ready', yes
|
Loading…
Reference in New Issue