From bd281daa47152dc09c0f6c2bbc9e5a308d1748bd Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Thu, 29 Aug 2019 16:50:33 +0200 Subject: Move to vuex store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/workflowengine/src/admin.js | 385 --------------------- apps/workflowengine/src/components/Check.vue | 134 ++++--- apps/workflowengine/src/components/Event.vue | 105 +++--- apps/workflowengine/src/components/Operation.vue | 39 +-- .../src/components/Operations/ConvertToPdf.vue | 59 ++-- .../src/components/Operations/Tag.vue | 28 +- apps/workflowengine/src/components/Rule.vue | 216 ++++++------ .../src/components/Values/FileMimeType.vue | 56 +-- .../src/components/Values/SizeValue.vue | 37 +- apps/workflowengine/src/components/Workflow.vue | 116 +++---- apps/workflowengine/src/filemimetypeplugin.js | 77 ----- apps/workflowengine/src/filenameplugin.js | 78 ----- apps/workflowengine/src/filesizeplugin.js | 59 ---- apps/workflowengine/src/filesystemtagsplugin.js | 78 ----- .../workflowengine/src/hbs_helpers/getOperators.js | 7 - apps/workflowengine/src/hbs_helpers/selectItem.js | 7 - .../src/legacy/filemimetypeplugin.js | 77 +++++ apps/workflowengine/src/legacy/filenameplugin.js | 78 +++++ apps/workflowengine/src/legacy/filesizeplugin.js | 59 ++++ .../src/legacy/filesystemtagsplugin.js | 78 +++++ .../src/legacy/requestremoteaddressplugin.js | 83 +++++ .../workflowengine/src/legacy/requesttimeplugin.js | 196 +++++++++++ apps/workflowengine/src/legacy/requesturlplugin.js | 116 +++++++ .../src/legacy/requestuseragentplugin.js | 119 +++++++ .../src/legacy/usergroupmembershipplugin.js | 75 ++++ .../src/requestremoteaddressplugin.js | 83 ----- apps/workflowengine/src/requesttimeplugin.js | 196 ----------- apps/workflowengine/src/requesturlplugin.js | 117 ------- apps/workflowengine/src/requestuseragentplugin.js | 119 ------- apps/workflowengine/src/services/Operation.js | 134 ++----- .../src/templates/operation.handlebars | 45 --- .../src/templates/operations.handlebars | 2 - .../src/usergroupmembershipplugin.js | 75 ---- apps/workflowengine/src/workflowengine.js | 34 +- 34 files changed, 1309 insertions(+), 1858 deletions(-) delete mode 100644 apps/workflowengine/src/admin.js delete mode 100644 apps/workflowengine/src/filemimetypeplugin.js delete mode 100644 apps/workflowengine/src/filenameplugin.js delete mode 100644 apps/workflowengine/src/filesizeplugin.js delete mode 100644 apps/workflowengine/src/filesystemtagsplugin.js delete mode 100644 apps/workflowengine/src/hbs_helpers/getOperators.js delete mode 100644 apps/workflowengine/src/hbs_helpers/selectItem.js create mode 100644 apps/workflowengine/src/legacy/filemimetypeplugin.js create mode 100644 apps/workflowengine/src/legacy/filenameplugin.js create mode 100644 apps/workflowengine/src/legacy/filesizeplugin.js create mode 100644 apps/workflowengine/src/legacy/filesystemtagsplugin.js create mode 100644 apps/workflowengine/src/legacy/requestremoteaddressplugin.js create mode 100644 apps/workflowengine/src/legacy/requesttimeplugin.js create mode 100644 apps/workflowengine/src/legacy/requesturlplugin.js create mode 100644 apps/workflowengine/src/legacy/requestuseragentplugin.js create mode 100644 apps/workflowengine/src/legacy/usergroupmembershipplugin.js delete mode 100644 apps/workflowengine/src/requestremoteaddressplugin.js delete mode 100644 apps/workflowengine/src/requesttimeplugin.js delete mode 100644 apps/workflowengine/src/requesturlplugin.js delete mode 100644 apps/workflowengine/src/requestuseragentplugin.js delete mode 100644 apps/workflowengine/src/templates/operation.handlebars delete mode 100644 apps/workflowengine/src/templates/operations.handlebars delete mode 100644 apps/workflowengine/src/usergroupmembershipplugin.js (limited to 'apps/workflowengine/src') diff --git a/apps/workflowengine/src/admin.js b/apps/workflowengine/src/admin.js deleted file mode 100644 index fb2af941436..00000000000 --- a/apps/workflowengine/src/admin.js +++ /dev/null @@ -1,385 +0,0 @@ -/** - * @copyright Copyright (c) 2016 Morris Jobke - * - * @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 . - * - */ - -import OperationTemplate from './templates/operation.handlebars'; -import OperationsTemplate from './templates/operations.handlebars'; - -(function() { - OCA.WorkflowEngine = _.extend(OCA.WorkflowEngine || {}, { - availablePlugins: [], - availableChecks: [], - - getCheckByClass: function(className) { - var length = OCA.WorkflowEngine.availableChecks.length; - for (var i = 0; i < length; i++) { - if (OCA.WorkflowEngine.availableChecks[i]['class'] === className) { - return OCA.WorkflowEngine.availableChecks[i]; - } - } - return undefined; - } - }); - - /** - * 888b d888 888 888 - * 8888b d8888 888 888 - * 88888b.d88888 888 888 - * 888Y88888P888 .d88b. .d88888 .d88b. 888 .d8888b - * 888 Y888P 888 d88""88b d88" 888 d8P Y8b 888 88K - * 888 Y8P 888 888 888 888 888 88888888 888 "Y8888b. - * 888 " 888 Y88..88P Y88b 888 Y8b. 888 X88 - * 888 888 "Y88P" "Y88888 "Y8888 888 88888P' - */ - - /** - * @class OCA.WorkflowEngine.Operation - */ - OCA.WorkflowEngine.Operation = - OC.Backbone.Model.extend({ - defaults: { - 'class': 'OCA\\WorkflowEngine\\Operation', - 'name': '', - 'checks': [], - 'operation': '' - } - }); - - /** - * .d8888b. 888 888 888 d8b - * d88P Y88b 888 888 888 Y8P - * 888 888 888 888 888 - * 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 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 - * "Y8888P" "Y88P" 888 888 "Y8888 "Y8888P "Y888 888 "Y88P" 888 888 88888P' - */ - - /** - * @class OCA.WorkflowEngine.OperationsCollection - * - * collection for all configurated operations - */ - OCA.WorkflowEngine.OperationsCollection = - OC.Backbone.Collection.extend({ - model: OCA.WorkflowEngine.Operation, - url: OC.generateUrl('apps/workflowengine/operations') - }); - - /** - * 888 888 d8b - * 888 888 Y8P - * 888 888 - * Y88b d88P 888 .d88b. 888 888 888 .d8888b - * Y88b d88P 888 d8P Y8b 888 888 888 88K - * Y88o88P 888 88888888 888 888 888 "Y8888b. - * Y888P 888 Y8b. Y88b 888 d88P X88 - * Y8P 888 "Y8888 "Y8888888P" 88888P' - */ - - /** - * @class OCA.WorkflowEngine.OperationView - * - * this creates the view for a single operation - */ - OCA.WorkflowEngine.OperationView = - OC.Backbone.View.extend({ - templateId: '#operation-template', - events: { - 'change .check-class': 'checkChanged', - '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', - 'click .button-delete': 'delete', - 'click .button-delete-check': 'deleteCheck' - }, - originalModel: null, - hasChanged: false, - message: '', - errorMessage: '', - saving: false, - groups: [], - template: function(vars) { - return OperationTemplate(_.extend( - { - shortRuleDescTXT: t('workflowengine', 'Short rule description'), - addRuleTXT: t('workflowengine', 'Add rule'), - resetTXT: t('workflowengine', 'Reset'), - saveTXT: t('workflowengine', 'Save'), - savingTXT: t('workflowengine', 'Saving…') - }, - vars - )); - }, - 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() { - console.log('model changed'); - this.hasChanged = true; - this.render(); - }, this); - - if (this.model.get('id') === undefined) { - this.hasChanged = true; - } - var self = this; - $.ajax({ - url: OC.linkToOCS('cloud/groups', 2) + 'details', - dataType: 'json', - quietMillis: 100, - }).success(function(data) { - 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' }); - console.log(data); - }); - }, - delete: function() { - if (OC.PasswordConfirmation.requiresPasswordConfirmation()) { - OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.delete, this)); - return; - } - - this.model.destroy(); - this.remove(); - }, - 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.render(); - }, - save: function() { - if (OC.PasswordConfirmation.requiresPasswordConfirmation()) { - OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.save, this)); - return; - } - - var success = function(model, response, options) { - this.saving = false; - this.originalModel = JSON.parse(JSON.stringify(this.model)); - - this.message = t('workflowengine', 'Saved'); - this.errorMessage = ''; - this.render(); - }; - var error = function(model, response, options) { - this.saving = false; - this.hasChanged = true; - - this.message = t('workflowengine', 'Saving failed:'); - this.errorMessage = response.responseText; - this.render(); - }; - this.hasChanged = false; - this.saving = true; - this.render(); - this.model.save(null, { success: success, error: error, context: this }); - }, - add: function() { - var checks = _.clone(this.model.get('checks')), - classname = OCA.WorkflowEngine.availableChecks[0]['class'], - operators = OCA.WorkflowEngine.availableChecks[0]['operators']; - - checks.push({ - 'class': classname, - 'operator': operators[0]['operator'], - 'value': '' - }); - this.model.set({ 'checks': checks }); - }, - checkChanged: function(event) { - var value = event.target.value, - id = $(event.target.parentElement).data('id'), - // this creates a new copy of the object to definitely have a new reference - checks = JSON.parse(JSON.stringify(this.model.get('checks'))), - key = null; - - for (var i = 0; i < event.target.classList.length; i++) { - var className = event.target.classList[i]; - if (className.substr(0, 'check-'.length) === 'check-') { - key = className.substr('check-'.length); - break; - } - } - - if (key === null) { - console.warn('checkChanged triggered but element doesn\'t have any "check-" class'); - return; - } - - if (!_.has(checks[id], key)) { - console.warn('key "' + key + '" is not available in check', check); - return; - } - - checks[id][key] = value; - // if the class is changed most likely also the operators have changed - // with this we set the operator to the first possible operator - if (key === 'class') { - var check = OCA.WorkflowEngine.getCheckByClass(value); - if (!_.isUndefined(check)) { - checks[id]['operator'] = check['operators'][0]['operator']; - checks[id]['value'] = ''; - } - } - // model change will trigger render - this.model.set({ 'checks': checks }); - }, - deleteCheck: function(event) { - console.log(arguments); - var id = $(event.target.parentElement).data('id'), - checks = JSON.parse(JSON.stringify(this.model.get('checks'))); - - // splice removes 1 element at index `id` - checks.splice(id, 1); - // model change will trigger render - this.model.set({ 'checks': checks }); - }, - operationChanged: function(event) { - var value = event.target.value, - key = null; - - for (var i = 0; i < event.target.classList.length; i++) { - var className = event.target.classList[i]; - if (className.substr(0, 'operation-'.length) === 'operation-') { - key = className.substr('operation-'.length); - break; - } - } - - if (key === null) { - console.warn('operationChanged triggered but element doesn\'t have any "operation-" class'); - return; - } - - if (key !== 'name' && key !== 'operation') { - console.warn('key "' + key + '" is no valid attribute'); - return; - } - - // model change will trigger render - this.model.set(key, value); - }, - render: function() { - this.$el.html(this.template({ - operation: this.model.toJSON(), - classes: OCA.WorkflowEngine.availableChecks, - hasChanged: this.hasChanged, - message: this.message, - errorMessage: this.errorMessage, - saving: this.saving - })); - - var checks = this.model.get('checks'); - _.each(this.$el.find('.check'), function(element) { - var $element = $(element), - id = $element.data('id'), - check = checks[id], - valueElement = $element.find('.check-value').first(); - var self = this; - - _.each(OCA.WorkflowEngine.availablePlugins, function(plugin) { - if (_.isFunction(plugin.render)) { - plugin.render(valueElement, check, self.groups); - } - }); - }, this); - - if (this.message !== '') { - // hide success messages after some time - _.delay(function(elements) { - $(elements).css('opacity', 0); - }, 7000, this.$el.find('.msg.success')); - this.message = ''; - } - - return this.$el; - } - }); - - /** - * @class OCA.WorkflowEngine.OperationsView - * - * this creates the view for configured operations - */ - OCA.WorkflowEngine.OperationsView = - OC.Backbone.View.extend({ - templateId: '#operations-template', - collection: null, - $el: null, - events: { - 'click .button-add-operation': 'add' - }, - template: function(vars) { - return OperationsTemplate(_.extend( - { - addRuleGroupTXT: t('workflowengine', 'Add rule group') - }, - vars - )); - }, - 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 - } - }); - this.collection.once('sync', this.render, this); - }, - add: function() { - var operation = this.collection.create(); - this.renderOperation(operation); - }, - renderOperation: function(subView) { - var operationsElement = this.$el.find('.operations'); - operationsElement.append(subView.$el); - subView.render(); - }, - render: function() { - this.$el.html(this.template()); - this.collection.each(this.renderOperation, this); - } - }); -})(); \ No newline at end of file diff --git a/apps/workflowengine/src/components/Check.vue b/apps/workflowengine/src/components/Check.vue index 86005dae268..b2e8e13c29b 100644 --- a/apps/workflowengine/src/components/Check.vue +++ b/apps/workflowengine/src/components/Check.vue @@ -1,86 +1,82 @@ \ No newline at end of file + diff --git a/apps/workflowengine/src/components/Operations/Tag.vue b/apps/workflowengine/src/components/Operations/Tag.vue index 74e4e4f977b..7a27e2b572d 100644 --- a/apps/workflowengine/src/components/Operations/Tag.vue +++ b/apps/workflowengine/src/components/Operations/Tag.vue @@ -1,22 +1,24 @@ \ No newline at end of file + diff --git a/apps/workflowengine/src/components/Rule.vue b/apps/workflowengine/src/components/Rule.vue index d1f5a088f51..8a446dd7ae9 100644 --- a/apps/workflowengine/src/components/Rule.vue +++ b/apps/workflowengine/src/components/Rule.vue @@ -4,143 +4,144 @@

{{ t('workflowengine', 'When') }} - +

{{ t('workflowengine', 'and') }} - +

- - + +

- Cancel rule creation - Remove rule + + Cancel rule creation + + + Remove rule + - +
- - + +
\ No newline at end of file + diff --git a/apps/workflowengine/src/components/Values/SizeValue.vue b/apps/workflowengine/src/components/Values/SizeValue.vue index bc4378702e1..03b28f18947 100644 --- a/apps/workflowengine/src/components/Values/SizeValue.vue +++ b/apps/workflowengine/src/components/Values/SizeValue.vue @@ -1,28 +1,29 @@ \ No newline at end of file + diff --git a/apps/workflowengine/src/components/Workflow.vue b/apps/workflowengine/src/components/Workflow.vue index 0525722666e..986b6f5197c 100644 --- a/apps/workflowengine/src/components/Workflow.vue +++ b/apps/workflowengine/src/components/Workflow.vue @@ -4,93 +4,68 @@

{{ t('workflowengine', 'Workflows') }}

- + -
+
- - + + -