diff --git a/src/PBSlib.coffee b/src/PBSlib.coffee index a4e1fb2..a7b4d54 100644 --- a/src/PBSlib.coffee +++ b/src/PBSlib.coffee @@ -95,16 +95,21 @@ class PBS calculateDelays: (item) => if !item.dependant? or item.dependant.length is 0 then return no - lowestFDelay = 0; fDelay = no; cDelay = 0 - for j,i of item.dependant - x = @toActivity i - if !isNaN(x.permittedDelay) or x.permittedDelay < lowestFDelay or fDelay is no - @log "activity", i, "dependant on", item.id, "has the lowest delay for now ("+(x.permittedDelay or 0)+")" - lowestFDelay = x.permittedDelay or 0 - cDelay = x.chainedDelay or 0 - fDelay = yes olDelay = item.chainedDelay - item.chainedDelay = lowestFDelay + cDelay + if item.critical + @log item.id, 'is critical: no chained delays' + item.chainedDelay = 0 + else + lowestFDelay = 0; fDelay = no; cDelay = 0 + for j,i of item.dependant + x = @toActivity i + if !isNaN(x.permittedDelay) or x.permittedDelay < lowestFDelay or fDelay is no + @log "activity", i, "dependant on", item.id, "has the lowest delay for now ("+(x.permittedDelay or 0)+")" + lowestFDelay = x.permittedDelay or 0 + cDelay = x.chainedDelay or 0 + fDelay = yes + olDelay = item.chainedDelay + item.chainedDelay = lowestFDelay + cDelay @log "chained delay of", item.id, "is", item.chainedDelay return item.chainedDelay isnt olDelay @@ -142,10 +147,15 @@ class PBS return @ calculate: (options,cb) -> - h = @highestID() + # Calculate startDay, endDay, freeDelay for x,i in @list - @log '('+x.id+'/'+h+')' + @log '('+i+'/'+@list.length+')' @calculateEndDay x + # Calculate Critical Paths + for x,i in @list + if !x.depends? or x.depends.length is 0 + @calculateCriticalPaths [x.id] + # Calculate chained Delays finished = no; i = 0 while !finished i++; finished = yes @@ -153,10 +163,9 @@ class PBS if @calculateDelays x finished = no @log "Done calculating delays. Took", i, "iterations" - for x,i in @list - if !x.depends? or x.depends.length is 0 - @calculateCriticalPaths [x.id] + # Compile resource information @compileResources() + # done results = activities: @list days: @days diff --git a/src/app.coffee b/src/app.coffee index b96e71e..b460db4 100644 --- a/src/app.coffee +++ b/src/app.coffee @@ -42,9 +42,9 @@ pertApp.config ($stateProvider,$urlRouterProvider,$locationProvider) -> pertController = ($scope) -> $scope.toLocalStorage = (data,options) -> options ?= {} - data ?= [] - if !data.push? and !data.activities?.push? - return swal 'Error', 'data is not a valid PBSlib object', 'error' + data ?= activities: [], resources: [] + if not data.activities?.push? + return swal 'Error', 'invalid data format. Try resetting', 'error' try sdata = JSON.stringify data console.log "Saving: "+sdata diff --git a/src/controllers.coffee b/src/controllers.coffee index 11f88d3..b300846 100644 --- a/src/controllers.coffee +++ b/src/controllers.coffee @@ -12,16 +12,16 @@ pertApp.controller 'tableController', ($scope) -> tableController $scope, (data) -> data.activities or [] pertApp.controller 'resourceTableController', ($scope) -> tableController $scope, (data) -> data.resources or [] - pertApp.controller 'pertDiagController', ($scope) -> $scope.buildGraph = (data) -> if !data? then return nodes = data.days.map (x) -> {id: x, label: ""+x} connections = [] data.activities.forEach (x) -> + maxDuration = x.duration + (x.permittedDelay or 0) + (x.chainedDelay or 0) connections.push 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 maxDuration isnt x.duration then x.duration+"/"+maxDuration else x.duration)+")" color: if x.critical then 'red' else if !x.permittedDelay then 'orange' if x.permittedDelay > 0 connections.push @@ -55,17 +55,36 @@ pertApp.controller 'ganttDiagController', ($scope) -> $scope.buildTimeline $scope.fromLocalStorage() $scope.buildTimeline $scope.fromLocalStorage() +areYouSure = (text,cb) -> + swal { + title: "Are you sure?" + text: text + type: "warning" + showCancelButton: true + confirmButtonColor: "#DD6B55" + confirmButtonText: "Yes" + closeOnConfirm: yes + }, cb + pertApp.controller 'rawEditorController', ($scope) -> - $scope.reset = -> - $scope.toLocalStorage { activities: [], resources: [] } - $scope.saveData = -> + $scope.reset = (askConfirm) -> + doIt = -> $scope.toLocalStorage { activities: [], resources: [] } + if askConfirm + areYouSure "ALL data will be lost!", doIt + else doIt() + $scope.saveData = (askConfirm) -> try data = JSON.parse $scope.taData catch e - swal 'Invalid Data', e, 'error' - $scope.toLocalStorage data - $scope.reloadData = -> - $scope.taData = JSON.stringify $scope.fromLocalStorage silent: yes, raw: yes + return swal 'Invalid Data', e, 'error' + doIt = -> $scope.toLocalStorage data + if askConfirm then areYouSure "Current saved data will be replaced by the data in the RawEditor", doIt + else doIt() + $scope.reloadData = (askConfirm) -> + doIt = -> + $scope.taData = JSON.stringify $scope.fromLocalStorage silent: yes, raw: yes + if askConfirm then areYouSure "Current saved data will be replaced by the data in the RawEditor", doIt + else doIt() $scope.$on 'dataChanged', $scope.reloadData $scope.reloadData() diff --git a/src/pert.html b/src/pert.html index be3b876..104455b 100644 --- a/src/pert.html +++ b/src/pert.html @@ -1,4 +1,16 @@
+

How to read the Graph

+ Arrow: every arrow is an activity and the ID and duration (in days) are shown over the arrow, like this: activityID (minimumDuration/maximumDuration) +
+

The color of the arrow tells the type of the activity:

+ +
+

Every circle represents the day of the start of one or more activities and/or the day of the end of one or more activities.

diff --git a/src/rawedit.html b/src/rawedit.html index 91e2131..c0d0c48 100644 --- a/src/rawedit.html +++ b/src/rawedit.html @@ -3,10 +3,10 @@

The RawEditor is intended for importing, exporting your data and debugging.
Keep backups outside of this application if you rely on your data

- - -