Enable removing Tasks from a Workflow
Add .remove() method to every Task instance in a Workbook, what it actually does is sending a messages to the parent container which does the actual deletion. Change-Id: I0ac70bef4c2c9f241b15eff9a94f3909b733b2ff Closes-Bug: #1436387
This commit is contained in:
parent
0efc6355f7
commit
f219a63e21
|
@ -206,6 +206,9 @@
|
|||
});
|
||||
return self;
|
||||
},
|
||||
remove: function() {
|
||||
this.emit('change', 'taskRemove', this.getID());
|
||||
},
|
||||
_getPrettyJSON: function() {
|
||||
var json = fields.frozendict._getPrettyJSON.apply(this, arguments);
|
||||
delete json.name;
|
||||
|
@ -216,7 +219,8 @@
|
|||
'baseKey': 'task',
|
||||
'baseName': 'Task ',
|
||||
'group': true,
|
||||
'additive': false
|
||||
'additive': false,
|
||||
'removable': true
|
||||
},
|
||||
'name': {
|
||||
'@class': fields.string.extend({}, {
|
||||
|
@ -495,7 +499,7 @@
|
|||
'@class': fields.dictionary.extend({
|
||||
create: function(json, parameters) {
|
||||
var self = fields.dictionary.create.call(this, json, parameters);
|
||||
self.on('childChange', function(child, op) {
|
||||
self.on('childChange', function(child, op, arg) {
|
||||
if ( op === 'taskType' ) {
|
||||
var taskId = child.getID(),
|
||||
params = child._parameters,
|
||||
|
@ -503,6 +507,8 @@
|
|||
taskData = child.toJSON();
|
||||
params.id = taskId;
|
||||
self.set(taskPos, TaskFactory(taskData, params));
|
||||
} else if ( op === 'taskRemove' ) {
|
||||
self.remove(arg);
|
||||
}
|
||||
});
|
||||
return self;
|
||||
|
|
|
@ -57,6 +57,7 @@ describe('workbook model logic', function() {
|
|||
|
||||
expect(getWorkflow(workflowID).instanceof(models.DirectWorkflow)).toBe(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('defines task structure transformations', function() {
|
||||
|
@ -73,6 +74,17 @@ describe('workbook model logic', function() {
|
|||
workbook.get('workflows').push({name: 'Workflow 1'}, {id: workflowID});
|
||||
});
|
||||
|
||||
it('a task deletion works in conjunction with tasks logic', function() {
|
||||
var workflow = getWorkflow(workflowID),
|
||||
params = utils.extend(workflow._parameters, {id: taskID});
|
||||
|
||||
workflow.get('tasks').push({name: 'Task 1'}, params);
|
||||
expect(getTask(taskID)).toBeDefined();
|
||||
|
||||
getTask(taskID).remove();
|
||||
expect(getTask(taskID)).toBeUndefined();
|
||||
});
|
||||
|
||||
describe("which start with the 'direct' workflow:", function() {
|
||||
beforeEach(function() {
|
||||
var workflow = getWorkflow(workflowID),
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
if ( attrs.onAdd && attrs.additive !== 'false' ) {
|
||||
scope.additive = true;
|
||||
}
|
||||
if ( attrs.onRemove ) {
|
||||
if ( attrs.onRemove && attrs.removable !== 'false' ) {
|
||||
scope.removable = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
var groupMixin = Barricade.Blueprint.create(function() {
|
||||
var self = this,
|
||||
additive = utils.getMeta(self, 'additive');
|
||||
additive = utils.getMeta(self, 'additive'),
|
||||
removable = utils.getMeta(self, 'removable');
|
||||
|
||||
if ( additive === undefined ) {
|
||||
additive = true;
|
||||
|
@ -17,6 +18,14 @@
|
|||
self.isAdditive = function() {
|
||||
return additive;
|
||||
};
|
||||
|
||||
if ( removable === undefined ) {
|
||||
removable = false;
|
||||
}
|
||||
self.isRemovable = function() {
|
||||
return removable;
|
||||
};
|
||||
|
||||
self.setType('group');
|
||||
|
||||
return self;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<collapsible-group title="{$ title $}" additive="{$ value.isAdditive() $}"
|
||||
on-add="value.add()">
|
||||
<collapsible-group
|
||||
title="{$ title $}" additive="{$ value.isAdditive() $}" on-add="value.add()"
|
||||
removable="{$ value.isRemovable() $}" on-remove="value.remove()">
|
||||
<div ng-repeat="row in value | extractRows track by row.id">
|
||||
<div ng-class="{'three-columns': row.index !== undefined }">
|
||||
<div ng-repeat="item in row | extractItems track by item.id"
|
||||
|
|
|
@ -187,7 +187,7 @@ describe('merlin directives', function() {
|
|||
expect(body.hasClass('collapsing')).toBe(true);
|
||||
});
|
||||
|
||||
it('requires to specify just `on-remove` to make group removable', function() {
|
||||
it('requires to specify `on-remove` to make group removable', function() {
|
||||
var element1, element2;
|
||||
$scope.remove = function() {};
|
||||
element1 = makeGroupElement('');
|
||||
|
@ -197,6 +197,14 @@ describe('merlin directives', function() {
|
|||
expect(getGroupRemoveBtn(element2).hasClass('ng-hide')).toBe(false);
|
||||
});
|
||||
|
||||
it('`removable` attribute set explicitly to `false` makes group not removable', function() {
|
||||
var element;
|
||||
$scope.remove = function() {};
|
||||
element = makeGroupElement('on-remove="remove()" removable="false"');
|
||||
|
||||
expect(getGroupRemoveBtn(element).hasClass('ng-hide')).toBe(true);
|
||||
});
|
||||
|
||||
it('requires to specify `on-add` to make group additive', function() {
|
||||
var element1, element2;
|
||||
$scope.add = function() {};
|
||||
|
|
Loading…
Reference in New Issue