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