Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/workflowengine/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
['name' => 'flowOperations#addOperation', 'url' => '/operations', 'verb' => 'POST'],
['name' => 'flowOperations#updateOperation', 'url' => '/operations/{id}', 'verb' => 'PUT'],
['name' => 'flowOperations#deleteOperation', 'url' => '/operations/{id}', 'verb' => 'DELETE'],
['name' => 'requestTime#getTimezones', 'url' => '/timezones', 'verb' => 'GET'],
]
];
4 changes: 4 additions & 0 deletions apps/workflowengine/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@
margin-right: 5px;
}

.workflowengine .invalid-input {
border-color: #aa0000;
}

41 changes: 16 additions & 25 deletions apps/workflowengine/js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,6 @@
}
});

/**
* @class OCA.WorkflowEngine.AvailableCheck
*/
OCA.WorkflowEngine.AvailableCheck =
OC.Backbone.Model.extend({});

/**
* .d8888b. 888 888 888 d8b
* d88P Y88b 888 888 888 Y8P
Expand Down Expand Up @@ -143,6 +137,7 @@
'change .check-operator': 'checkChanged',
'change .check-value': 'checkChanged',
'change .operation-name': 'operationChanged',
'change .operation-operation': 'operationChanged',
'click .button-reset': 'reset',
'click .button-save': 'save',
'click .button-add': 'add',
Expand Down Expand Up @@ -248,7 +243,7 @@
// model change will trigger render
this.model.set({'checks': checks});
},
deleteCheck: function() {
deleteCheck: function(event) {
console.log(arguments);
var id = $(event.target.parentElement).data('id'),
checks = JSON.parse(JSON.stringify(this.model.get('checks')));
Expand All @@ -275,7 +270,7 @@
return;
}

if (key !== 'name') {
if (key !== 'name' && key !== 'operation') {
console.warn('key "' + key + '" is no valid attribute');
return;
}
Expand All @@ -302,7 +297,7 @@

_.each(OCA.WorkflowEngine.availablePlugins, function(plugin) {
if (_.isFunction(plugin.render)) {
plugin.render(valueElement, check['class'], check['value']);
plugin.render(valueElement, check);
}
});
}, this);
Expand All @@ -315,6 +310,7 @@
this.message = '';
}

return this.$el;
}
});

Expand All @@ -331,16 +327,15 @@
events: {
'click .button-add-operation': 'add'
},
initialize: function() {
this._initialize('OCA\\WorkflowEngine\\Operation');
},
_initialize: function(classname) {
OCA.WorkflowEngine.availablePlugins = OC.Plugins.getPlugins('OCA.WorkflowEngine.CheckPlugins');
_.each(OCA.WorkflowEngine.availablePlugins, function(plugin) {
if (_.isFunction(plugin.getCheck)) {
OCA.WorkflowEngine.availableChecks.push(plugin.getCheck());
}
});
initialize: function(classname) {
if (!OCA.WorkflowEngine.availablePlugins.length) {
OCA.WorkflowEngine.availablePlugins = OC.Plugins.getPlugins('OCA.WorkflowEngine.CheckPlugins');
_.each(OCA.WorkflowEngine.availablePlugins, function(plugin) {
if (_.isFunction(plugin.getCheck)) {
OCA.WorkflowEngine.availableChecks.push(plugin.getCheck(classname));
}
});
}

this.collection.fetch({data: {
'class': classname
Expand All @@ -351,12 +346,8 @@
var operation = this.collection.create();
this.renderOperation(operation);
},
renderOperation: function(operation){
console.log(operation);
var subView = new OCA.WorkflowEngine.OperationView({
model: operation
}),
operationsElement = this.$el.find('.operations');
renderOperation: function(subView){
var operationsElement = this.$el.find('.operations');
operationsElement.append(subView.$el);
subView.render();
},
Expand Down
72 changes: 72 additions & 0 deletions apps/workflowengine/js/filemimetypeplugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/**
* @copyright Copyright (c) 2016 Joas Schilling <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

(function() {

OCA.WorkflowEngine = OCA.WorkflowEngine || {};
OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {};

OCA.WorkflowEngine.Plugins.FileMimeTypePlugin = {
getCheck: function() {
return {
'class': 'OCA\\WorkflowEngine\\Check\\FileMimeType',
'name': t('workflowengine', 'File mime type (upload)'),
'operators': [
{'operator': 'is', 'name': t('workflowengine', 'is')},
{'operator': '!is', 'name': t('workflowengine', 'is not')},
{'operator': 'matches', 'name': t('workflowengine', 'matches')},
{'operator': '!matches', 'name': t('workflowengine', 'does not match')}
]
};
},
render: function(element, check) {
if (check['class'] !== 'OCA\\WorkflowEngine\\Check\\FileMimeType') {
return;
}

var placeholder = t('workflowengine', 'text/plain');
if (check['operator'] === 'matches' || check['operator'] === '!matches') {
placeholder = t('workflowengine', '/^text\\/(plain|html)$/i');

if (this._validateRegex(check['value'])) {
$(element).removeClass('invalid-input');
} else {
$(element).addClass('invalid-input');
}
}

$(element).css('width', '250px')
.attr('placeholder', placeholder)
.attr('title', t('workflowengine', 'Example: {placeholder}', {placeholder: placeholder}))
.addClass('has-tooltip')
.tooltip({
placement: 'bottom'
});
},

_validateRegex: function(string) {
var regexRegex = /^\/(.*)\/([gui]{0,3})$/,
result = regexRegex.exec(string);
return result !== null;
}
};
})();

OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileMimeTypePlugin);
56 changes: 56 additions & 0 deletions apps/workflowengine/js/filesizeplugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* @copyright Copyright (c) 2016 Joas Schilling <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

(function() {

OCA.WorkflowEngine = OCA.WorkflowEngine || {};
OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {};

OCA.WorkflowEngine.Plugins.FileSizePlugin = {
getCheck: function() {
return {
'class': 'OCA\\WorkflowEngine\\Check\\FileSize',
'name': t('workflowengine', 'File size (upload)'),
'operators': [
{'operator': 'less', 'name': t('workflowengine', 'less')},
{'operator': '!greater', 'name': t('workflowengine', 'less or equals')},
{'operator': '!less', 'name': t('workflowengine', 'greater or equals')},
{'operator': 'greater', 'name': t('workflowengine', 'greater')}
]
};
},
render: function(element, check) {
if (check['class'] !== 'OCA\\WorkflowEngine\\Check\\FileSize') {
return;
}

var placeholder = '12 MB'; // Do not translate!!!
$(element).css('width', '250px')
.attr('placeholder', placeholder)
.attr('title', t('workflowengine', 'Example: {placeholder}', {placeholder: placeholder}))
.addClass('has-tooltip')
.tooltip({
placement: 'bottom'
});
}
};
})();

OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileSizePlugin);
76 changes: 76 additions & 0 deletions apps/workflowengine/js/filesystemtagsplugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/**
* @copyright Copyright (c) 2016 Joas Schilling <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

(function() {

OCA.WorkflowEngine = OCA.WorkflowEngine || {};
OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {};

OCA.WorkflowEngine.Plugins.FileSystemTagsPlugin = {
getCheck: function() {
this.collection = OC.SystemTags.collection;

return {
'class': 'OCA\\WorkflowEngine\\Check\\FileSystemTags',
'name': t('workflowengine', 'File system tag'),
'operators': [
{'operator': 'is', 'name': t('workflowengine', 'is tagged with')},
{'operator': '!is', 'name': t('workflowengine', 'is not tagged with')}
]
};
},
render: function(element, check) {
if (check['class'] !== 'OCA\\WorkflowEngine\\Check\\FileSystemTags') {
return;
}

$(element).css('width', '400px');

$(element).select2({
allowClear: false,
multiple: false,
placeholder: t('workflowengine', 'Select tag…'),
query: _.debounce(function(query) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice 👍

query.callback({
results: OC.SystemTags.collection.filterByName(query.term)
});
}, 100, true),
id: function(element) {
return element.get('id');
},
initSelection: function(element, callback) {
callback($(element).val());
},
formatResult: function (tag) {
return OC.SystemTags.getDescriptiveTag(tag);
},
formatSelection: function (tagId) {
var tag = OC.SystemTags.collection.get(tagId);
return OC.SystemTags.getDescriptiveTag(tag);
},
escapeMarkup: function(m) {
return m;
}
});
}
};
})();

OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileSystemTagsPlugin);
Loading