Persisted copied steps to backend; Require login to view dashboard SPA
parent
f16cec0602
commit
35a9f1b332
4
Gemfile
4
Gemfile
|
@ -1,5 +1,5 @@
|
|||
source 'http://rubygems.org'
|
||||
source 'http://rails-assets.org'
|
||||
source 'https://rubygems.org'
|
||||
source 'https://rails-assets.org'
|
||||
|
||||
ruby '2.2.0'
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ GIT
|
|||
sprockets-rails (~> 2.0)
|
||||
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
remote: http://rails-assets.org/
|
||||
remote: https://rubygems.org/
|
||||
remote: https://rails-assets.org/
|
||||
specs:
|
||||
actionmailer (4.1.0)
|
||||
actionpack (= 4.1.0)
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
controller = ($scope, Data) ->
|
||||
#TODO: We really really need an error handler / reporter at this point.
|
||||
nope = (e) ->
|
||||
alert 'Doh!'
|
||||
console.error e
|
||||
#TODO: We need a way of creating a "new" sequence. If you load a sequence,
|
||||
# there is no way to clear out of it.
|
||||
Data
|
||||
.findAll('sequence', {})
|
||||
.catch (error) -> console.error error
|
||||
.catch(nope)
|
||||
|
||||
$scope.dragControlListeners =
|
||||
accept: (sourceItemHandleScope, destSortableScope) -> true
|
||||
itemMoved: (event) -> debugger
|
||||
|
@ -23,7 +27,7 @@ controller = ($scope, Data) ->
|
|||
message_type: message_type
|
||||
sequence_id: $scope.sequence._id
|
||||
).then((step) -> $scope.sequence.steps.push(step))
|
||||
.catch((e) -> console.error e)
|
||||
.catch(nope)
|
||||
$scope.load = (seq) ->
|
||||
Data.loadRelations('sequence', seq._id, ['step'])
|
||||
$scope.sequence = seq
|
||||
|
@ -32,22 +36,28 @@ controller = ($scope, Data) ->
|
|||
Data
|
||||
.create('sequence', params)
|
||||
.then((seq) -> $scope.load(seq)) # Load child resources of the new seqnce
|
||||
.catch((e) -> console.error(e))
|
||||
.catch(nope)
|
||||
$scope.deleteSequence = (seq) ->
|
||||
return unless hasSequence()
|
||||
Data
|
||||
.destroy('sequence', seq._id)
|
||||
.then(() -> $scope.sequence = null)
|
||||
.catch((e) -> console.error(e))
|
||||
.catch(nope)
|
||||
$scope.saveSequence = (seq) ->
|
||||
Data
|
||||
.save('sequence', seq._id)
|
||||
.then((s) -> console.log(s))
|
||||
.catch((e) -> console.error(e))
|
||||
.catch(nope)
|
||||
$scope.copy = (obj, index) ->
|
||||
# Let's try:
|
||||
# Data.create('step', the_step_to_copy)
|
||||
$scope.sequence.steps.splice((index + 1), 0, angular.copy(obj))
|
||||
return unless hasSequence()
|
||||
yep = (step) -> $scope.sequence.steps.splice((index + 1), 0, step)
|
||||
Data
|
||||
.create('step',
|
||||
sequence_id: $scope.sequence._id
|
||||
message_type: obj.message_type
|
||||
command: obj.command || {}
|
||||
).then(yep)
|
||||
.catch(nope)
|
||||
$scope.remove = (index) ->
|
||||
step = $scope.sequence.steps[index]
|
||||
Data.destroy('step', step._id).catch((e) -> console.error e)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# A non-resourceful controller for the 'glue' that holds this SPA together.
|
||||
# Let's try not to overwhelm this control and write as much API as possible.
|
||||
class DashboardController < ApplicationController
|
||||
before_action :authenticate_user!
|
||||
def index
|
||||
end
|
||||
end
|
||||
|
|
|
@ -145,10 +145,10 @@
|
|||
|
||||
|
||||
<div class="row" as-sortable="dragControlListeners" ng-model="sequenceList">
|
||||
<div ng-repeat='seq in sequence.steps track by $id(seq)' as-sortable-item>
|
||||
<div ng-repeat='step in sequence.steps track by $id(step)' as-sortable-item>
|
||||
|
||||
<div class="row">
|
||||
<ng-include src="'sequence-builder/' + seq.message_type" >
|
||||
<ng-include src="'sequence-builder/' + step.message_type" >
|
||||
</ng-include>
|
||||
</div><div>
|
||||
</div>
|
||||
|
@ -161,7 +161,7 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="small-12 columns">
|
||||
<div ng-repeat="seq in storedSequences track by $id(seq)">
|
||||
<div ng-repeat="step in storedSequences track by $id(step)">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div class="icon-group">
|
||||
<a href="#"><i class="fa fa-angle-up"></i></a>
|
||||
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
||||
<i class="fa fa-clipboard" ng-click="copy(cmd, $index)"></i></a>
|
||||
<i class="fa fa-clipboard" ng-click="copy(step, $index)"></i></a>
|
||||
<i class="fa fa-bars" as-sortable-item-handle></i>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div class="icon-group">
|
||||
<a href="#"><i class="fa fa-angle-up"></i></a>
|
||||
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
||||
<i class="fa fa-clipboard" ng-click="copy(cmd, $index)"></i></a>
|
||||
<i class="fa fa-clipboard" ng-click="copy(step, $index)"></i></a>
|
||||
<i class="fa fa-bars" as-sortable-item-handle></i>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div class="icon-group">
|
||||
<a href="#"><i class="fa fa-angle-up"></i></a>
|
||||
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
||||
<i class="fa fa-clipboard" ng-click="copy(cmd, $index)"></i></a>
|
||||
<i class="fa fa-clipboard" ng-click="copy(step, $index)"></i></a>
|
||||
<i class="fa fa-bars" as-sortable-item-handle></i>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div class="icon-group">
|
||||
<a href="#"><i class="fa fa-angle-up"></i></a>
|
||||
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
||||
<i class="fa fa-clipboard" ng-click="copy(cmd, $index)"></i></a>
|
||||
<i class="fa fa-clipboard" ng-click="copy(step, $index)"></i></a>
|
||||
<i class="fa fa-bars" as-sortable-item-handle></i>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div class="icon-group">
|
||||
<a href="#"><i class="fa fa-angle-up"></i></a>
|
||||
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
||||
<i class="fa fa-clipboard" ng-click="copy(cmd, $index)"></i></a>
|
||||
<i class="fa fa-clipboard" ng-click="copy(step, $index)"></i></a>
|
||||
<i class="fa fa-bars" as-sortable-item-handle></i>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<div class="icon-group">
|
||||
<a href="#"><i class="fa fa-angle-up"></i></a>
|
||||
<i class="fa fa-trash" ng-click="remove($index)"></i>
|
||||
<i class="fa fa-clipboard" ng-click="copy(cmd, $index)"></i></a>
|
||||
<i class="fa fa-clipboard" ng-click="copy(step, $index)"></i></a>
|
||||
<i class="fa fa-bars" as-sortable-item-handle></i>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
Loading…
Reference in New Issue