mirror of
https://github.com/fazo96/pbs.git
synced 2025-01-26 14:24:20 +01:00
bugfix and cleanup
This commit is contained in:
parent
2f0a9a8da1
commit
d551a9c6db
@ -38,6 +38,8 @@ pertController = ($scope) ->
|
||||
$scope.toLocalStorage = (data,options) ->
|
||||
options ?= {}
|
||||
data ?= []
|
||||
if !data.push?
|
||||
return swal 'Error', 'data is not a list', 'error'
|
||||
try
|
||||
console.log "Saving: "+data
|
||||
localStorage.setItem 'ganttpert', JSON.stringify data
|
||||
@ -50,21 +52,23 @@ pertController = ($scope) ->
|
||||
$scope.fromLocalStorage = (options) ->
|
||||
options = options || {}
|
||||
data = localStorage.getItem options.name || 'ganttpert'
|
||||
if data is null then data = "[]"
|
||||
try
|
||||
jdata = JSON.parse data
|
||||
if jdata is null then jdata = []
|
||||
catch e
|
||||
unless options.silent
|
||||
swal 'JSON Error', e, 'error'
|
||||
if options.raw
|
||||
console.log 'Loading: []'
|
||||
#console.log 'Loading: []'
|
||||
return []
|
||||
else
|
||||
console.log 'Loading: {list: [], days: []}'
|
||||
#console.log 'Loading: {list: [], days: []}'
|
||||
return list: [], days: []
|
||||
if options.raw
|
||||
console.log 'Loading: '+jdata
|
||||
#console.log 'Loading: '+jdata
|
||||
return jdata
|
||||
else
|
||||
r = new Pert(jdata).calculate()
|
||||
console.log 'Loading: '+r
|
||||
#console.log 'Loading: '+r
|
||||
return r
|
||||
|
@ -12,7 +12,6 @@ pertApp.controller 'pertDiagController', ($scope) ->
|
||||
if !data? then return
|
||||
nodes = data.days.map (x) -> {id: x, label: ""+x}
|
||||
connections = []
|
||||
console.log data.criticalPaths
|
||||
data.activities.forEach (x) ->
|
||||
connections.push
|
||||
from: x.startDay, to: x.endDay
|
||||
@ -101,18 +100,16 @@ pertApp.controller 'editorController', ($scope) ->
|
||||
catch e
|
||||
return swal 'Error', 'duration must be an integer', 'error'
|
||||
try
|
||||
id = parseInt id
|
||||
catch e
|
||||
return
|
||||
unless isNaN id
|
||||
id = parseInt id
|
||||
for i,dep of deps
|
||||
try
|
||||
deps[i] = parseInt dep
|
||||
unless isNaN dep
|
||||
deps[i] = parseInt dep
|
||||
catch e
|
||||
return
|
||||
newdata = $scope.fromLocalStorage silent: yes, raw: yes
|
||||
if !newdata? or newdata is null or !newdata.push?
|
||||
newdata = []
|
||||
console.log newdata
|
||||
newdata.push { id: id, duration: dur, depends: deps }
|
||||
$scope.toLocalStorage newdata, silent: yes
|
||||
|
||||
|
@ -106,7 +106,6 @@ class Pert
|
||||
finished = no
|
||||
@log "Done calculating delays. Took", i, "iterations"
|
||||
for x,i in @list
|
||||
console.log x
|
||||
if !x.depends? or x.depends.length is 0
|
||||
@calculateCriticalPaths [x.id]
|
||||
results = activities: @list, days: @days, criticalPaths: @criticalPaths
|
||||
|
Loading…
Reference in New Issue
Block a user