Workflow engine to ocs api

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-04-25 07:47:16 +02:00
parent d53193fd8e
commit 8c845be11c
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
1 changed files with 341 additions and 337 deletions

View File

@ -20,7 +20,7 @@
(function() {
Handlebars.registerHelper('selectItem', function(currentValue, itemValue) {
if(currentValue === itemValue) {
if (currentValue === itemValue) {
return 'selected="selected"';
}
@ -153,7 +153,7 @@
initialize: function() {
// 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.model.on('change', function(){
this.model.on('change', function() {
console.log('model changed');
this.hasChanged = true;
this.render();
@ -164,21 +164,23 @@
}
var self = this;
$.ajax({
url: OC.generateUrl('settings/users/groups'),
url: OC.linkToOCS('cloud/groups', 2) + 'details',
dataType: 'json',
quietMillis: 100,
}).success(function(response) {
// add admin groups
$.each(response.data.adminGroups, function(id, group) {
self.groups.push({ id: group.id, displayname: group.name });
});
// add groups
$.each(response.data.groups, function(id, group) {
self.groups.push({ id: group.id, displayname: group.name });
});
if (data.ocs.data.groups && data.ocs.data.groups.length > 0) {
data.ocs.data.groups.forEach(function(group) {
self.groups.push({ id: group.id, displayname: group.displayname });
})
self.render();
} else {
OC.Notification.error(t('workflowengine', 'Group list is empty'), { type: 'error' });
console.log(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);
});
},
@ -194,7 +196,7 @@
reset: function() {
this.hasChanged = false;
// 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();
},
save: function() {
@ -222,7 +224,7 @@
this.hasChanged = false;
this.saving = true;
this.render();
this.model.save(null, {success: success, error: error, context: this});
this.model.save(null, { success: success, error: error, context: this });
},
add: function() {
var checks = _.clone(this.model.get('checks')),
@ -234,7 +236,7 @@
'operator': operators[0]['operator'],
'value': ''
});
this.model.set({'checks': checks});
this.model.set({ 'checks': checks });
},
checkChanged: function(event) {
var value = event.target.value,
@ -271,7 +273,7 @@
}
}
// model change will trigger render
this.model.set({'checks': checks});
this.model.set({ 'checks': checks });
},
deleteCheck: function(event) {
console.log(arguments);
@ -281,7 +283,7 @@
// splice removes 1 element at index `id`
checks.splice(id, 1);
// model change will trigger render
this.model.set({'checks': checks});
this.model.set({ 'checks': checks });
},
operationChanged: function(event) {
var value = event.target.value,
@ -319,7 +321,7 @@
}));
var checks = this.model.get('checks');
_.each(this.$el.find('.check'), function(element){
_.each(this.$el.find('.check'), function(element) {
var $element = $(element),
id = $element.data('id'),
check = checks[id],
@ -335,7 +337,7 @@
if (this.message !== '') {
// hide success messages after some time
_.delay(function(elements){
_.delay(function(elements) {
$(elements).css('opacity', 0);
}, 7000, this.$el.find('.msg.success'));
this.message = '';
@ -368,16 +370,18 @@
});
}
this.collection.fetch({data: {
this.collection.fetch({
data: {
'class': classname
}});
}
});
this.collection.once('sync', this.render, this);
},
add: function() {
var operation = this.collection.create();
this.renderOperation(operation);
},
renderOperation: function(subView){
renderOperation: function(subView) {
var operationsElement = this.$el.find('.operations');
operationsElement.append(subView.$el);
subView.render();