mirror of
https://github.com/fazo96/pbs.git
synced 2025-01-27 14:34:19 +01:00
fixed raweditor
This commit is contained in:
parent
9ae7972d53
commit
43fd9c7055
@ -35,9 +35,10 @@ pertApp.config ($stateProvider,$urlRouterProvider) ->
|
|||||||
|
|
||||||
pertController = ($scope) ->
|
pertController = ($scope) ->
|
||||||
$scope.toLocalStorage = (data,options) ->
|
$scope.toLocalStorage = (data,options) ->
|
||||||
options = options || {}
|
options ?= {}
|
||||||
|
data ?= []
|
||||||
try
|
try
|
||||||
console.log data
|
console.log "Saving: "+data
|
||||||
localStorage.setItem 'ganttpert', JSON.stringify data
|
localStorage.setItem 'ganttpert', JSON.stringify data
|
||||||
unless options.silent
|
unless options.silent
|
||||||
swal 'Ok', 'Data updated', 'success'
|
swal 'Ok', 'Data updated', 'success'
|
||||||
@ -54,8 +55,15 @@ pertController = ($scope) ->
|
|||||||
unless options.silent
|
unless options.silent
|
||||||
swal 'JSON Error', e, 'error'
|
swal 'JSON Error', e, 'error'
|
||||||
if options.raw
|
if options.raw
|
||||||
|
console.log 'Loading: []'
|
||||||
return []
|
return []
|
||||||
else return activities: [], days: []
|
else
|
||||||
|
console.log 'Loading: {list: [], days: []}'
|
||||||
|
return list: [], days: []
|
||||||
if options.raw
|
if options.raw
|
||||||
|
console.log 'Loading: '+jdata
|
||||||
return jdata
|
return jdata
|
||||||
else return new Pert(jdata).calculate()
|
else
|
||||||
|
r = new Pert(jdata).calculate()
|
||||||
|
console.log 'Loading: '+r
|
||||||
|
return r
|
||||||
|
@ -46,7 +46,18 @@ pertApp.controller 'ganttDiagController', ($scope) ->
|
|||||||
$scope.buildTimeline $scope.fromLocalStorage()
|
$scope.buildTimeline $scope.fromLocalStorage()
|
||||||
|
|
||||||
pertApp.controller 'rawEditorController', ($scope) ->
|
pertApp.controller 'rawEditorController', ($scope) ->
|
||||||
$scope.rawdata = $scope.fromLocalStorage silent: yes, raw: yes
|
$scope.saveData = ->
|
||||||
|
try
|
||||||
|
data = JSON.parse $scope.taData
|
||||||
|
catch e
|
||||||
|
return swal 'Error', 'The data entered is invalid', 'error'
|
||||||
|
$scope.toLocalStorage data
|
||||||
|
$scope.reloadData = ->
|
||||||
|
$scope.taData = JSON.stringify $scope.fromLocalStorage silent: yes, raw: yes
|
||||||
|
$scope.$on 'dataChanged', ->
|
||||||
|
$scope.reloadData()
|
||||||
|
#$('#ta').val JSON.stringify $scope.fromLocalStorage silent: yes, raw: yes
|
||||||
|
$scope.reloadData()
|
||||||
|
|
||||||
pertApp.controller 'editorController', ($scope) ->
|
pertApp.controller 'editorController', ($scope) ->
|
||||||
$scope.clone = (id) ->
|
$scope.clone = (id) ->
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<div ng-controller="rawEditorController">
|
<div ng-controller="rawEditorController">
|
||||||
<textarea id="ta" class="form-control" rows="10">{{rawdata}}</textarea>
|
<textarea id="ta" class="form-control" ng-model="taData" rows="10"></textarea>
|
||||||
<button class="btn btn-primary" ng-click="toLocalStorage($('#ta').val())">Save</button>
|
<button class="btn btn-primary" ng-click="saveData()">Save</button>
|
||||||
|
<button class="btn btn-info" ng-click="reloadData()">Reload</button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user