added a few features

This commit is contained in:
Enrico Fasoli 2015-03-16 11:44:08 +01:00
parent 12172f34c4
commit 147973d7bc
2 changed files with 10 additions and 2 deletions

View File

@ -11,6 +11,7 @@ buildGraph = (data) ->
connections.push connections.push
from: x.startDay, to: x.endDay from: x.startDay, to: x.endDay
label: x.id+" ("+(if x.permittedDelay > 0 then x.duration+"/"+(x.duration+x.permittedDelay) else x.duration)+")" label: x.id+" ("+(if x.permittedDelay > 0 then x.duration+"/"+(x.duration+x.permittedDelay) else x.duration)+")"
color: if !x.permittedDelay then 'red'
if x.permittedDelay > 0 if x.permittedDelay > 0
connections.push connections.push
from: x.endDay from: x.endDay

View File

@ -40,6 +40,8 @@ module.exports = class Pert
item.depends.forEach (x) => item.depends.forEach (x) =>
@log "checking permittedDelay to dependency", x, "of", item @log "checking permittedDelay to dependency", x, "of", item
i = @toActivity x i = @toActivity x
if !i.dependant? then i.dependant = [item.id]
else i.dependant.push item.id
if !i.permittedDelay? if !i.permittedDelay?
i.permittedDelay = item.startDay - @calculateEndDay i i.permittedDelay = item.startDay - @calculateEndDay i
@log "written permittedDelay to dependency", x, "of", item, "as", i.permittedDelay @log "written permittedDelay to dependency", x, "of", item, "as", i.permittedDelay
@ -61,10 +63,15 @@ module.exports = class Pert
@list = data @list = data
return @ return @
calculate: (options) -> calculate: (options,cb) ->
h = @highestID() h = @highestID()
@list.forEach (x) => @list.forEach (x) =>
@log '('+x.id+'/'+h+')' @log '('+x.id+'/'+h+')'
@calculateEndDay x @calculateEndDay x
results = activities: @list, days: @days results = activities: @list, days: @days
if options?.json then JSON.stringify results else results if options?.json
if cb? then cb(JSON.stringify results)
JSON.stringify results
else
if cb? then cb(results)
results