mirror of
https://github.com/fazo96/pbs.git
synced 2025-01-27 14:34:19 +01:00
improvements to editor
This commit is contained in:
parent
b49c947919
commit
131938a76e
@ -1,8 +1,11 @@
|
|||||||
pertApp.controller 'tableController', ($scope) ->
|
pertApp.controller 'tableController', ($scope) ->
|
||||||
$scope.list = []
|
$scope.list = []
|
||||||
ls = $scope.fromLocalStorage()
|
$scope.refreshTable = ->
|
||||||
if ls?
|
ls = $scope.fromLocalStorage()
|
||||||
$scope.list = ls.activities
|
if ls?
|
||||||
|
$scope.list = ls.activities
|
||||||
|
$scope.$on 'dataChanged', $scope.refreshTable
|
||||||
|
$scope.refreshTable()
|
||||||
|
|
||||||
pertApp.controller 'pertDiagController', ($scope) ->
|
pertApp.controller 'pertDiagController', ($scope) ->
|
||||||
$scope.buildGraph = (data) ->
|
$scope.buildGraph = (data) ->
|
||||||
@ -60,26 +63,32 @@ pertApp.controller 'rawEditorController', ($scope) ->
|
|||||||
$scope.reloadData()
|
$scope.reloadData()
|
||||||
|
|
||||||
pertApp.controller 'editorController', ($scope) ->
|
pertApp.controller 'editorController', ($scope) ->
|
||||||
|
$scope.list = []
|
||||||
$scope.clone = (id) ->
|
$scope.clone = (id) ->
|
||||||
for i,j of $scope.fromLocalStorage({raw: yes, silent: yes}).activities
|
for i,j of $scope.fromLocalStorage({raw: yes, silent: yes})
|
||||||
if j.id is id
|
if j.id is id
|
||||||
$scope.addNew j.id, j.duration, j.depends
|
$scope.addNew j.id, j.duration, j.depends
|
||||||
swal 'Ok', id+' has been cloned', 'success'
|
swal 'Ok', id+' has been cloned', 'success'
|
||||||
return
|
return
|
||||||
swal 'Ops', 'could not find '+id, 'warning'
|
swal 'Ops', 'could not find '+id, 'warning'
|
||||||
|
|
||||||
$scope.delete = (id) ->
|
$scope.delete = (index,id) ->
|
||||||
newdata = $scope.fromLocalStorage raw: yes
|
newdata = $scope.fromLocalStorage raw: yes
|
||||||
l = []
|
l = []
|
||||||
for i,j of newdata
|
if id? then for i,j of newdata
|
||||||
if j.id isnt id
|
if id isnt j.id
|
||||||
l.push j
|
l.push j
|
||||||
|
else for i,j of newdata
|
||||||
|
if parseInt(i) isnt index
|
||||||
|
l.push j
|
||||||
|
diff = newdata.length - l.length
|
||||||
$scope.toLocalStorage l, silent: yes
|
$scope.toLocalStorage l, silent: yes
|
||||||
swal 'Ok', 'done', 'success'
|
if diff isnt 1
|
||||||
|
swal 'Done', diff+' item(s) deleted', 'warning'
|
||||||
|
|
||||||
$scope.addNew = (id, dur, deps) ->
|
$scope.addNew = (id, dur, deps) ->
|
||||||
dur ?= $('#new-duration').val()
|
dur ?= $('#new-duration').val().trim()
|
||||||
id ?= $('#new-id').val()
|
id ?= $('#new-id').val().trim()
|
||||||
if !deps?
|
if !deps?
|
||||||
deps = $('#new-deps').val().split(' ')
|
deps = $('#new-deps').val().split(' ')
|
||||||
if deps.length is 1 and deps[0] is ''
|
if deps.length is 1 and deps[0] is ''
|
||||||
@ -88,12 +97,20 @@ pertApp.controller 'editorController', ($scope) ->
|
|||||||
dur = parseInt dur
|
dur = parseInt dur
|
||||||
catch e
|
catch e
|
||||||
return swal 'Error', 'duration must be an integer', 'error'
|
return swal 'Error', 'duration must be an integer', 'error'
|
||||||
|
try
|
||||||
|
id = parseInt id
|
||||||
|
catch e
|
||||||
|
return
|
||||||
|
for i,dep of deps
|
||||||
|
try
|
||||||
|
deps[i] = parseInt dep
|
||||||
|
catch e
|
||||||
|
return
|
||||||
newdata = $scope.fromLocalStorage silent: yes, raw: yes
|
newdata = $scope.fromLocalStorage silent: yes, raw: yes
|
||||||
newdata.push { id: id, duration: dur, depends: deps }
|
newdata.push { id: id, duration: dur, depends: deps }
|
||||||
$scope.toLocalStorage newdata, silent: yes
|
$scope.toLocalStorage newdata, silent: yes
|
||||||
|
|
||||||
$scope.refreshEditor = ->
|
$scope.refreshEditor = ->
|
||||||
console.log 'drawing editor'
|
|
||||||
data = $scope.fromLocalStorage { silent: yes, raw: yes }
|
data = $scope.fromLocalStorage { silent: yes, raw: yes }
|
||||||
$scope.list = data || []
|
$scope.list = data || []
|
||||||
$scope.$on 'dataChanged', $scope.refreshEditor
|
$scope.$on 'dataChanged', $scope.refreshEditor
|
||||||
|
@ -1,26 +1,6 @@
|
|||||||
<div ng-controller="editorController" class="activity-list">
|
<div ng-controller="editorController" class="pbs-editor">
|
||||||
<div class="panel panel-default" ng-repeat="item in list">
|
|
||||||
<div class="panel-heading">
|
|
||||||
<div class="input-group">
|
|
||||||
<span class="input-group-addon">ID</span>
|
|
||||||
<input class="form-control" value="{{item.id}}" placeholder="id">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="panel-body">
|
|
||||||
<div class="input-group duration">
|
|
||||||
<span class="input-group-addon">Duration</span>
|
|
||||||
<input class="form-control" value="{{item.duration}}" placeholder="(days)">
|
|
||||||
</div>
|
|
||||||
<div class="input-group dependencies">
|
|
||||||
<span class="input-group-addon">Dependencies</span>
|
|
||||||
<input class="form-control" placeholder="id1 id2 id3" value="{{item.depends.join(' ')}}">
|
|
||||||
</div>
|
|
||||||
<button ng-click="delete(item.id)" class="btn btn-danger">Delete</button>
|
|
||||||
<button ng-click="clone(item.id)" class="btn btn-warn">Clone</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- new item -->
|
<!-- new item -->
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default new-activity-panel">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<span class="input-group-addon">ID</span>
|
<span class="input-group-addon">ID</span>
|
||||||
@ -39,4 +19,28 @@
|
|||||||
<button ng-click="addNew()" class="btn btn-primary">Add</button>
|
<button ng-click="addNew()" class="btn btn-primary">Add</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- item list -->
|
||||||
|
<table id="tab" class="table">
|
||||||
|
<tr>
|
||||||
|
<td><b>#</b></td>
|
||||||
|
<td><b>ID</b></td>
|
||||||
|
<td><b>Duration (days)</b></td>
|
||||||
|
<td><b>Dependencies</b></td>
|
||||||
|
<td><b>Commands</b></td>
|
||||||
|
</tr>
|
||||||
|
<tr ng-repeat="item in list">
|
||||||
|
<td>{{$index + 1}}</td>
|
||||||
|
<td>{{item.id}}</td>
|
||||||
|
<td>{{item.duration}}</td>
|
||||||
|
<td>{{item.depends || []}}</td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-info" ng-click="clone(item.id)">
|
||||||
|
<i class="fa fa-copy"></i>
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-danger" ng-click="delete($index)">
|
||||||
|
<i class="fa fa-remove"></i>
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
<table id="tab" class="table" ng-controller="tableController">
|
<table id="tab" class="table" ng-controller="tableController">
|
||||||
<tr>
|
<tr>
|
||||||
<td><b>#</b></td>
|
<td><b>#</b></td>
|
||||||
|
<td><b>ID</b></td>
|
||||||
<td><b>Duration (days)</b></td>
|
<td><b>Duration (days)</b></td>
|
||||||
<td><b>Start Day</b></td>
|
<td><b>Start Day</b></td>
|
||||||
<td><b>End Day</b></td>
|
<td><b>End Day</b></td>
|
||||||
<td><b>Possible Delay</b></td>
|
<td><b>Possible Delay</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr ng-repeat="item in list">
|
<tr ng-repeat="item in list">
|
||||||
|
<td>{{$index + 1}}</td>
|
||||||
<td>{{item.id}}</td>
|
<td>{{item.id}}</td>
|
||||||
<td>{{item.duration}}</td>
|
<td>{{item.duration}}</td>
|
||||||
<td>{{item.startDay}}</td>
|
<td>{{item.startDay}}</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user