Merge pull request #9393 from nextcloud/bugfix/noid/fix-workflow-rules
Fix workflow rules
This commit is contained in:
commit
ec0623045b
|
@ -19,376 +19,377 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
Handlebars.registerHelper('selectItem', function(currentValue, itemValue) {
|
Handlebars.registerHelper('selectItem', function(currentValue, itemValue) {
|
||||||
if (currentValue === itemValue) {
|
if (currentValue === itemValue) {
|
||||||
return 'selected="selected"';
|
return 'selected="selected"';
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
});
|
});
|
||||||
|
|
||||||
Handlebars.registerHelper('getOperators', function(classname) {
|
Handlebars.registerHelper('getOperators', function(classname) {
|
||||||
var check = OCA.WorkflowEngine.getCheckByClass(classname);
|
var check = OCA.WorkflowEngine.getCheckByClass(classname);
|
||||||
if (!_.isUndefined(check)) {
|
if (!_.isUndefined(check)) {
|
||||||
return check['operators'];
|
return check['operators'];
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
OCA.WorkflowEngine = _.extend(OCA.WorkflowEngine || {}, {
|
OCA.WorkflowEngine = _.extend(OCA.WorkflowEngine || {}, {
|
||||||
availablePlugins: [],
|
availablePlugins: [],
|
||||||
availableChecks: [],
|
availableChecks: [],
|
||||||
|
|
||||||
getCheckByClass: function(className) {
|
getCheckByClass: function(className) {
|
||||||
var length = OCA.WorkflowEngine.availableChecks.length;
|
var length = OCA.WorkflowEngine.availableChecks.length;
|
||||||
for (var i = 0; i < length; i++) {
|
for (var i = 0; i < length; i++) {
|
||||||
if (OCA.WorkflowEngine.availableChecks[i]['class'] === className) {
|
if (OCA.WorkflowEngine.availableChecks[i]['class'] === className) {
|
||||||
return OCA.WorkflowEngine.availableChecks[i];
|
return OCA.WorkflowEngine.availableChecks[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 888b d888 888 888
|
* 888b d888 888 888
|
||||||
* 8888b d8888 888 888
|
* 8888b d8888 888 888
|
||||||
* 88888b.d88888 888 888
|
* 88888b.d88888 888 888
|
||||||
* 888Y88888P888 .d88b. .d88888 .d88b. 888 .d8888b
|
* 888Y88888P888 .d88b. .d88888 .d88b. 888 .d8888b
|
||||||
* 888 Y888P 888 d88""88b d88" 888 d8P Y8b 888 88K
|
* 888 Y888P 888 d88""88b d88" 888 d8P Y8b 888 88K
|
||||||
* 888 Y8P 888 888 888 888 888 88888888 888 "Y8888b.
|
* 888 Y8P 888 888 888 888 888 88888888 888 "Y8888b.
|
||||||
* 888 " 888 Y88..88P Y88b 888 Y8b. 888 X88
|
* 888 " 888 Y88..88P Y88b 888 Y8b. 888 X88
|
||||||
* 888 888 "Y88P" "Y88888 "Y8888 888 88888P'
|
* 888 888 "Y88P" "Y88888 "Y8888 888 88888P'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class OCA.WorkflowEngine.Operation
|
* @class OCA.WorkflowEngine.Operation
|
||||||
*/
|
*/
|
||||||
OCA.WorkflowEngine.Operation =
|
OCA.WorkflowEngine.Operation =
|
||||||
OC.Backbone.Model.extend({
|
OC.Backbone.Model.extend({
|
||||||
defaults: {
|
defaults: {
|
||||||
'class': 'OCA\\WorkflowEngine\\Operation',
|
'class': 'OCA\\WorkflowEngine\\Operation',
|
||||||
'name': '',
|
'name': '',
|
||||||
'checks': [],
|
'checks': [],
|
||||||
'operation': ''
|
'operation': ''
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* .d8888b. 888 888 888 d8b
|
* .d8888b. 888 888 888 d8b
|
||||||
* d88P Y88b 888 888 888 Y8P
|
* d88P Y88b 888 888 888 Y8P
|
||||||
* 888 888 888 888 888
|
* 888 888 888 888 888
|
||||||
* 888 .d88b. 888 888 .d88b. .d8888b 888888 888 .d88b. 88888b. .d8888b
|
* 888 .d88b. 888 888 .d88b. .d8888b 888888 888 .d88b. 88888b. .d8888b
|
||||||
* 888 d88""88b 888 888 d8P Y8b d88P" 888 888 d88""88b 888 "88b 88K
|
* 888 d88""88b 888 888 d8P Y8b d88P" 888 888 d88""88b 888 "88b 88K
|
||||||
* 888 888 888 888 888 888 88888888 888 888 888 888 888 888 888 "Y8888b.
|
* 888 888 888 888 888 888 88888888 888 888 888 888 888 888 888 "Y8888b.
|
||||||
* Y88b d88P Y88..88P 888 888 Y8b. Y88b. Y88b. 888 Y88..88P 888 888 X88
|
* Y88b d88P Y88..88P 888 888 Y8b. Y88b. Y88b. 888 Y88..88P 888 888 X88
|
||||||
* "Y8888P" "Y88P" 888 888 "Y8888 "Y8888P "Y888 888 "Y88P" 888 888 88888P'
|
* "Y8888P" "Y88P" 888 888 "Y8888 "Y8888P "Y888 888 "Y88P" 888 888 88888P'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class OCA.WorkflowEngine.OperationsCollection
|
* @class OCA.WorkflowEngine.OperationsCollection
|
||||||
*
|
*
|
||||||
* collection for all configurated operations
|
* collection for all configurated operations
|
||||||
*/
|
*/
|
||||||
OCA.WorkflowEngine.OperationsCollection =
|
OCA.WorkflowEngine.OperationsCollection =
|
||||||
OC.Backbone.Collection.extend({
|
OC.Backbone.Collection.extend({
|
||||||
model: OCA.WorkflowEngine.Operation,
|
model: OCA.WorkflowEngine.Operation,
|
||||||
url: OC.generateUrl('apps/workflowengine/operations')
|
url: OC.generateUrl('apps/workflowengine/operations')
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 888 888 d8b
|
* 888 888 d8b
|
||||||
* 888 888 Y8P
|
* 888 888 Y8P
|
||||||
* 888 888
|
* 888 888
|
||||||
* Y88b d88P 888 .d88b. 888 888 888 .d8888b
|
* Y88b d88P 888 .d88b. 888 888 888 .d8888b
|
||||||
* Y88b d88P 888 d8P Y8b 888 888 888 88K
|
* Y88b d88P 888 d8P Y8b 888 888 888 88K
|
||||||
* Y88o88P 888 88888888 888 888 888 "Y8888b.
|
* Y88o88P 888 88888888 888 888 888 "Y8888b.
|
||||||
* Y888P 888 Y8b. Y88b 888 d88P X88
|
* Y888P 888 Y8b. Y88b 888 d88P X88
|
||||||
* Y8P 888 "Y8888 "Y8888888P" 88888P'
|
* Y8P 888 "Y8888 "Y8888888P" 88888P'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class OCA.WorkflowEngine.TemplateView
|
* @class OCA.WorkflowEngine.TemplateView
|
||||||
*
|
*
|
||||||
* a generic template that handles the Handlebars template compile step
|
* a generic template that handles the Handlebars template compile step
|
||||||
* in a method called "template()"
|
* in a method called "template()"
|
||||||
*/
|
*/
|
||||||
OCA.WorkflowEngine.TemplateView =
|
OCA.WorkflowEngine.TemplateView =
|
||||||
OC.Backbone.View.extend({
|
OC.Backbone.View.extend({
|
||||||
_template: null,
|
_template: null,
|
||||||
template: function(vars) {
|
template: function(vars) {
|
||||||
if (!this._template) {
|
if (!this._template) {
|
||||||
this._template = Handlebars.compile($(this.templateId).html());
|
this._template = Handlebars.compile($(this.templateId).html());
|
||||||
}
|
}
|
||||||
return this._template(vars);
|
return this._template(vars);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class OCA.WorkflowEngine.OperationView
|
* @class OCA.WorkflowEngine.OperationView
|
||||||
*
|
*
|
||||||
* this creates the view for a single operation
|
* this creates the view for a single operation
|
||||||
*/
|
*/
|
||||||
OCA.WorkflowEngine.OperationView =
|
OCA.WorkflowEngine.OperationView =
|
||||||
OCA.WorkflowEngine.TemplateView.extend({
|
OCA.WorkflowEngine.TemplateView.extend({
|
||||||
templateId: '#operation-template',
|
templateId: '#operation-template',
|
||||||
events: {
|
events: {
|
||||||
'change .check-class': 'checkChanged',
|
'change .check-class': 'checkChanged',
|
||||||
'change .check-operator': 'checkChanged',
|
'change .check-operator': 'checkChanged',
|
||||||
'change .check-value': 'checkChanged',
|
'change .check-value': 'checkChanged',
|
||||||
'change .operation-name': 'operationChanged',
|
'change .operation-name': 'operationChanged',
|
||||||
'change .operation-operation': 'operationChanged',
|
'change .operation-operation': 'operationChanged',
|
||||||
'click .button-reset': 'reset',
|
'click .button-reset': 'reset',
|
||||||
'click .button-save': 'save',
|
'click .button-save': 'save',
|
||||||
'click .button-add': 'add',
|
'click .button-add': 'add',
|
||||||
'click .button-delete': 'delete',
|
'click .button-delete': 'delete',
|
||||||
'click .button-delete-check': 'deleteCheck'
|
'click .button-delete-check': 'deleteCheck'
|
||||||
},
|
},
|
||||||
originalModel: null,
|
originalModel: null,
|
||||||
hasChanged: false,
|
hasChanged: false,
|
||||||
message: '',
|
message: '',
|
||||||
errorMessage: '',
|
errorMessage: '',
|
||||||
saving: false,
|
saving: false,
|
||||||
groups: [],
|
groups: [],
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
// this creates a new copy of the object to definitely have a new reference and being able to reset the model
|
// this creates a new copy of the object to definitely have a new reference and being able to reset the model
|
||||||
this.originalModel = JSON.parse(JSON.stringify(this.model));
|
this.originalModel = JSON.parse(JSON.stringify(this.model));
|
||||||
this.model.on('change', function() {
|
this.model.on('change', function() {
|
||||||
console.log('model changed');
|
console.log('model changed');
|
||||||
this.hasChanged = true;
|
this.hasChanged = true;
|
||||||
this.render();
|
this.render();
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
if (this.model.get('id') === undefined) {
|
if (this.model.get('id') === undefined) {
|
||||||
this.hasChanged = true;
|
this.hasChanged = true;
|
||||||
}
|
}
|
||||||
var self = this;
|
var self = this;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: OC.linkToOCS('cloud/groups', 2) + 'details',
|
url: OC.linkToOCS('cloud/groups', 2) + 'details',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
quietMillis: 100,
|
quietMillis: 100,
|
||||||
}).success(function(response) {
|
}).success(function(data) {
|
||||||
if (data.ocs.data.groups && data.ocs.data.groups.length > 0) {
|
if (data.ocs.data.groups && data.ocs.data.groups.length > 0) {
|
||||||
|
|
||||||
data.ocs.data.groups.forEach(function(group) {
|
data.ocs.data.groups.forEach(function(group) {
|
||||||
self.groups.push({ id: group.id, displayname: group.displayname });
|
self.groups.push({ id: group.id, displayname: group.displayname });
|
||||||
})
|
});
|
||||||
self.render();
|
self.render();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
OC.Notification.error(t('workflowengine', 'Group list is empty'), { type: 'error' });
|
OC.Notification.error(t('workflowengine', 'Group list is empty'), { type: 'error' });
|
||||||
console.log(data);
|
console.log(data);
|
||||||
}
|
}
|
||||||
}).error(function(data) {
|
}).error(function(data) {
|
||||||
OC.Notification.error(t('workflowengine', 'Unable to retrieve the group list'), { type: 'error' });
|
OC.Notification.error(t('workflowengine', 'Unable to retrieve the group list'), { type: 'error' });
|
||||||
console.log(data);
|
console.log(data);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
delete: function() {
|
delete: function() {
|
||||||
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
||||||
OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.delete, this));
|
OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.delete, this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.model.destroy();
|
this.model.destroy();
|
||||||
this.remove();
|
this.remove();
|
||||||
},
|
},
|
||||||
reset: function() {
|
reset: function() {
|
||||||
this.hasChanged = false;
|
this.hasChanged = false;
|
||||||
// silent is need to not trigger the change event which resets the hasChanged attribute
|
// silent is need to not trigger the change event which resets the hasChanged attribute
|
||||||
this.model.set(this.originalModel, { silent: true });
|
this.model.set(this.originalModel, { silent: true });
|
||||||
this.render();
|
this.render();
|
||||||
},
|
},
|
||||||
save: function() {
|
save: function() {
|
||||||
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
||||||
OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.save, this));
|
OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.save, this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var success = function(model, response, options) {
|
var success = function(model, response, options) {
|
||||||
this.saving = false;
|
this.saving = false;
|
||||||
this.originalModel = JSON.parse(JSON.stringify(this.model));
|
this.originalModel = JSON.parse(JSON.stringify(this.model));
|
||||||
|
|
||||||
this.message = t('workflowengine', 'Saved');
|
this.message = t('workflowengine', 'Saved');
|
||||||
this.errorMessage = '';
|
this.errorMessage = '';
|
||||||
this.render();
|
this.render();
|
||||||
};
|
};
|
||||||
var error = function(model, response, options) {
|
var error = function(model, response, options) {
|
||||||
this.saving = false;
|
this.saving = false;
|
||||||
this.hasChanged = true;
|
this.hasChanged = true;
|
||||||
|
|
||||||
this.message = t('workflowengine', 'Saving failed:');
|
this.message = t('workflowengine', 'Saving failed:');
|
||||||
this.errorMessage = response.responseText;
|
this.errorMessage = response.responseText;
|
||||||
this.render();
|
this.render();
|
||||||
};
|
};
|
||||||
this.hasChanged = false;
|
this.hasChanged = false;
|
||||||
this.saving = true;
|
this.saving = true;
|
||||||
this.render();
|
this.render();
|
||||||
this.model.save(null, { success: success, error: error, context: this });
|
this.model.save(null, { success: success, error: error, context: this });
|
||||||
},
|
},
|
||||||
add: function() {
|
add: function() {
|
||||||
var checks = _.clone(this.model.get('checks')),
|
var checks = _.clone(this.model.get('checks')),
|
||||||
classname = OCA.WorkflowEngine.availableChecks[0]['class'],
|
classname = OCA.WorkflowEngine.availableChecks[0]['class'],
|
||||||
operators = OCA.WorkflowEngine.availableChecks[0]['operators'];
|
operators = OCA.WorkflowEngine.availableChecks[0]['operators'];
|
||||||
|
|
||||||
checks.push({
|
checks.push({
|
||||||
'class': classname,
|
'class': classname,
|
||||||
'operator': operators[0]['operator'],
|
'operator': operators[0]['operator'],
|
||||||
'value': ''
|
'value': ''
|
||||||
});
|
});
|
||||||
this.model.set({ 'checks': checks });
|
this.model.set({ 'checks': checks });
|
||||||
},
|
},
|
||||||
checkChanged: function(event) {
|
checkChanged: function(event) {
|
||||||
var value = event.target.value,
|
var value = event.target.value,
|
||||||
id = $(event.target.parentElement).data('id'),
|
id = $(event.target.parentElement).data('id'),
|
||||||
// this creates a new copy of the object to definitely have a new reference
|
// this creates a new copy of the object to definitely have a new reference
|
||||||
checks = JSON.parse(JSON.stringify(this.model.get('checks'))),
|
checks = JSON.parse(JSON.stringify(this.model.get('checks'))),
|
||||||
key = null;
|
key = null;
|
||||||
|
|
||||||
for (var i = 0; i < event.target.classList.length; i++) {
|
for (var i = 0; i < event.target.classList.length; i++) {
|
||||||
var className = event.target.classList[i];
|
var className = event.target.classList[i];
|
||||||
if (className.substr(0, 'check-'.length) === 'check-') {
|
if (className.substr(0, 'check-'.length) === 'check-') {
|
||||||
key = className.substr('check-'.length);
|
key = className.substr('check-'.length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === null) {
|
if (key === null) {
|
||||||
console.warn('checkChanged triggered but element doesn\'t have any "check-" class');
|
console.warn('checkChanged triggered but element doesn\'t have any "check-" class');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_.has(checks[id], key)) {
|
if (!_.has(checks[id], key)) {
|
||||||
console.warn('key "' + key + '" is not available in check', check);
|
console.warn('key "' + key + '" is not available in check', check);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
checks[id][key] = value;
|
checks[id][key] = value;
|
||||||
// if the class is changed most likely also the operators have changed
|
// if the class is changed most likely also the operators have changed
|
||||||
// with this we set the operator to the first possible operator
|
// with this we set the operator to the first possible operator
|
||||||
if (key === 'class') {
|
if (key === 'class') {
|
||||||
var check = OCA.WorkflowEngine.getCheckByClass(value);
|
var check = OCA.WorkflowEngine.getCheckByClass(value);
|
||||||
if (!_.isUndefined(check)) {
|
if (!_.isUndefined(check)) {
|
||||||
checks[id]['operator'] = check['operators'][0]['operator'];
|
checks[id]['operator'] = check['operators'][0]['operator'];
|
||||||
}
|
checks[id]['value'] = '';
|
||||||
}
|
}
|
||||||
// model change will trigger render
|
}
|
||||||
this.model.set({ 'checks': checks });
|
// model change will trigger render
|
||||||
},
|
this.model.set({ 'checks': checks });
|
||||||
deleteCheck: function(event) {
|
},
|
||||||
console.log(arguments);
|
deleteCheck: function(event) {
|
||||||
var id = $(event.target.parentElement).data('id'),
|
console.log(arguments);
|
||||||
checks = JSON.parse(JSON.stringify(this.model.get('checks')));
|
var id = $(event.target.parentElement).data('id'),
|
||||||
|
checks = JSON.parse(JSON.stringify(this.model.get('checks')));
|
||||||
|
|
||||||
// splice removes 1 element at index `id`
|
// splice removes 1 element at index `id`
|
||||||
checks.splice(id, 1);
|
checks.splice(id, 1);
|
||||||
// model change will trigger render
|
// model change will trigger render
|
||||||
this.model.set({ 'checks': checks });
|
this.model.set({ 'checks': checks });
|
||||||
},
|
},
|
||||||
operationChanged: function(event) {
|
operationChanged: function(event) {
|
||||||
var value = event.target.value,
|
var value = event.target.value,
|
||||||
key = null;
|
key = null;
|
||||||
|
|
||||||
for (var i = 0; i < event.target.classList.length; i++) {
|
for (var i = 0; i < event.target.classList.length; i++) {
|
||||||
var className = event.target.classList[i];
|
var className = event.target.classList[i];
|
||||||
if (className.substr(0, 'operation-'.length) === 'operation-') {
|
if (className.substr(0, 'operation-'.length) === 'operation-') {
|
||||||
key = className.substr('operation-'.length);
|
key = className.substr('operation-'.length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === null) {
|
if (key === null) {
|
||||||
console.warn('operationChanged triggered but element doesn\'t have any "operation-" class');
|
console.warn('operationChanged triggered but element doesn\'t have any "operation-" class');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key !== 'name' && key !== 'operation') {
|
if (key !== 'name' && key !== 'operation') {
|
||||||
console.warn('key "' + key + '" is no valid attribute');
|
console.warn('key "' + key + '" is no valid attribute');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// model change will trigger render
|
// model change will trigger render
|
||||||
this.model.set(key, value);
|
this.model.set(key, value);
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
this.$el.html(this.template({
|
this.$el.html(this.template({
|
||||||
operation: this.model.toJSON(),
|
operation: this.model.toJSON(),
|
||||||
classes: OCA.WorkflowEngine.availableChecks,
|
classes: OCA.WorkflowEngine.availableChecks,
|
||||||
hasChanged: this.hasChanged,
|
hasChanged: this.hasChanged,
|
||||||
message: this.message,
|
message: this.message,
|
||||||
errorMessage: this.errorMessage,
|
errorMessage: this.errorMessage,
|
||||||
saving: this.saving
|
saving: this.saving
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var checks = this.model.get('checks');
|
var checks = this.model.get('checks');
|
||||||
_.each(this.$el.find('.check'), function(element) {
|
_.each(this.$el.find('.check'), function(element) {
|
||||||
var $element = $(element),
|
var $element = $(element),
|
||||||
id = $element.data('id'),
|
id = $element.data('id'),
|
||||||
check = checks[id],
|
check = checks[id],
|
||||||
valueElement = $element.find('.check-value').first();
|
valueElement = $element.find('.check-value').first();
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
_.each(OCA.WorkflowEngine.availablePlugins, function(plugin) {
|
_.each(OCA.WorkflowEngine.availablePlugins, function(plugin) {
|
||||||
if (_.isFunction(plugin.render)) {
|
if (_.isFunction(plugin.render)) {
|
||||||
plugin.render(valueElement, check, self.groups);
|
plugin.render(valueElement, check, self.groups);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
if (this.message !== '') {
|
if (this.message !== '') {
|
||||||
// hide success messages after some time
|
// hide success messages after some time
|
||||||
_.delay(function(elements) {
|
_.delay(function(elements) {
|
||||||
$(elements).css('opacity', 0);
|
$(elements).css('opacity', 0);
|
||||||
}, 7000, this.$el.find('.msg.success'));
|
}, 7000, this.$el.find('.msg.success'));
|
||||||
this.message = '';
|
this.message = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.$el;
|
return this.$el;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class OCA.WorkflowEngine.OperationsView
|
* @class OCA.WorkflowEngine.OperationsView
|
||||||
*
|
*
|
||||||
* this creates the view for configured operations
|
* this creates the view for configured operations
|
||||||
*/
|
*/
|
||||||
OCA.WorkflowEngine.OperationsView =
|
OCA.WorkflowEngine.OperationsView =
|
||||||
OCA.WorkflowEngine.TemplateView.extend({
|
OCA.WorkflowEngine.TemplateView.extend({
|
||||||
templateId: '#operations-template',
|
templateId: '#operations-template',
|
||||||
collection: null,
|
collection: null,
|
||||||
$el: null,
|
$el: null,
|
||||||
events: {
|
events: {
|
||||||
'click .button-add-operation': 'add'
|
'click .button-add-operation': 'add'
|
||||||
},
|
},
|
||||||
initialize: function(classname) {
|
initialize: function(classname) {
|
||||||
if (!OCA.WorkflowEngine.availablePlugins.length) {
|
if (!OCA.WorkflowEngine.availablePlugins.length) {
|
||||||
OCA.WorkflowEngine.availablePlugins = OC.Plugins.getPlugins('OCA.WorkflowEngine.CheckPlugins');
|
OCA.WorkflowEngine.availablePlugins = OC.Plugins.getPlugins('OCA.WorkflowEngine.CheckPlugins');
|
||||||
_.each(OCA.WorkflowEngine.availablePlugins, function(plugin) {
|
_.each(OCA.WorkflowEngine.availablePlugins, function(plugin) {
|
||||||
if (_.isFunction(plugin.getCheck)) {
|
if (_.isFunction(plugin.getCheck)) {
|
||||||
OCA.WorkflowEngine.availableChecks.push(plugin.getCheck(classname));
|
OCA.WorkflowEngine.availableChecks.push(plugin.getCheck(classname));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.collection.fetch({
|
this.collection.fetch({
|
||||||
data: {
|
data: {
|
||||||
'class': classname
|
'class': classname
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.collection.once('sync', this.render, this);
|
this.collection.once('sync', this.render, this);
|
||||||
},
|
},
|
||||||
add: function() {
|
add: function() {
|
||||||
var operation = this.collection.create();
|
var operation = this.collection.create();
|
||||||
this.renderOperation(operation);
|
this.renderOperation(operation);
|
||||||
},
|
},
|
||||||
renderOperation: function(subView) {
|
renderOperation: function(subView) {
|
||||||
var operationsElement = this.$el.find('.operations');
|
var operationsElement = this.$el.find('.operations');
|
||||||
operationsElement.append(subView.$el);
|
operationsElement.append(subView.$el);
|
||||||
subView.render();
|
subView.render();
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
this.$el.html(this.template());
|
this.$el.html(this.template());
|
||||||
this.collection.each(this.renderOperation, this);
|
this.collection.each(this.renderOperation, this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -63,7 +63,9 @@
|
||||||
},
|
},
|
||||||
formatSelection: function (tagId) {
|
formatSelection: function (tagId) {
|
||||||
var tag = OC.SystemTags.collection.get(tagId);
|
var tag = OC.SystemTags.collection.get(tagId);
|
||||||
return OC.SystemTags.getDescriptiveTag(tag);
|
if (!_.isUndefined(tag)) {
|
||||||
|
return OC.SystemTags.getDescriptiveTag(tag);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
escapeMarkup: function(m) {
|
escapeMarkup: function(m) {
|
||||||
return m;
|
return m;
|
||||||
|
|
Loading…
Reference in New Issue