2019-10-02 07:18:17 -04:00
|
|
|
/**
|
2024-05-30 14:13:41 -04:00
|
|
|
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2019-10-02 07:18:17 -04:00
|
|
|
*/
|
|
|
|
|
|
2019-08-29 10:50:33 -04:00
|
|
|
import Vue from 'vue'
|
|
|
|
|
import Vuex from 'vuex'
|
2023-03-23 02:38:34 -04:00
|
|
|
import Settings from './components/Workflow.vue'
|
|
|
|
|
import ShippedChecks from './components/Checks/index.js'
|
|
|
|
|
import store from './store.js'
|
2019-08-30 10:18:19 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A plugin for displaying a custom value field for checks
|
|
|
|
|
*
|
2021-12-02 12:32:57 -05:00
|
|
|
* @typedef {object} CheckPlugin
|
2019-08-30 10:18:19 -04:00
|
|
|
* @property {string} class - The PHP class name of the check
|
|
|
|
|
* @property {Comparison[]} operators - A list of possible comparison operations running on the check
|
2025-03-13 13:44:12 -04:00
|
|
|
* @property {Vue} component - Deprecated: **Use `element` instead**
|
|
|
|
|
*
|
|
|
|
|
* A vue component to handle the rendering of options.
|
2019-12-19 07:22:27 -05:00
|
|
|
* The component should handle the v-model directive properly,
|
|
|
|
|
* so it needs a value property to receive data and emit an input
|
2025-03-13 13:44:12 -04:00
|
|
|
* event once the data has changed.
|
|
|
|
|
*
|
|
|
|
|
* Will be removed in 03/2028.
|
2022-01-10 08:06:28 -05:00
|
|
|
* @property {Function} placeholder - Return a placeholder of no custom component is used
|
|
|
|
|
* @property {Function} validate - validate a check if no custom component is used
|
2025-03-13 13:44:12 -04:00
|
|
|
* @property {string} [element] - A web component id as used in window.customElements.define()`.
|
|
|
|
|
* It is expected that the ID is prefixed with the app namespace, e.g. oca-myapp-flow_do_this_operation
|
|
|
|
|
* It has to emit the `update:model-value` event when a value was changed.
|
|
|
|
|
* The `model-value` property will be set initially with the rule operation value.
|
2021-12-02 12:32:57 -05:00
|
|
|
*/
|
2019-08-30 10:18:19 -04:00
|
|
|
|
|
|
|
|
/**
|
2022-07-28 07:11:38 -04:00
|
|
|
* A plugin for extending the admin page representation of an operator
|
2019-08-30 10:18:19 -04:00
|
|
|
*
|
2021-12-02 12:32:57 -05:00
|
|
|
* @typedef {object} OperatorPlugin
|
2019-08-31 05:53:15 -04:00
|
|
|
* @property {string} id - The PHP class name of the check
|
2019-08-30 10:18:19 -04:00
|
|
|
* @property {string} operation - Default value for the operation field
|
|
|
|
|
* @property {string} color - Custom color code to be applied for the operator selector
|
2025-02-12 15:11:47 -05:00
|
|
|
* @property {object} [options] - Deprecated: **Use `element` instead**
|
|
|
|
|
*
|
|
|
|
|
* A vue component to handle the rendering of options.
|
2019-12-19 07:22:27 -05:00
|
|
|
* The component should handle the v-model directive properly,
|
|
|
|
|
* so it needs a value property to receive data and emit an input
|
2025-02-12 15:11:47 -05:00
|
|
|
* event once the data has changed.
|
|
|
|
|
*
|
|
|
|
|
* Will be removed in 03/2028.
|
|
|
|
|
* @property {string} [element] - A web component id as used in window.customElements.define()`.
|
|
|
|
|
* It is expected that the ID is prefixed with the app namespace, e.g. oca-myapp-flow_do_this_operation
|
|
|
|
|
* It has to emit the `update:model-value` event when a value was changed.
|
|
|
|
|
* The `model-value` property will be set initially with the rule operation value.
|
2019-08-30 10:18:19 -04:00
|
|
|
*/
|
2019-08-06 11:40:30 -04:00
|
|
|
|
2019-08-30 10:18:19 -04:00
|
|
|
/**
|
2021-12-02 12:32:57 -05:00
|
|
|
* @typedef {object} Comparison
|
2019-08-30 10:18:19 -04:00
|
|
|
* @property {string} operator - value the comparison should have, e.g. !less, greater
|
|
|
|
|
* @property {string} name - Translated readable text, e.g. less or equals
|
2021-12-02 12:32:57 -05:00
|
|
|
*/
|
2019-08-30 10:18:19 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Public javascript api for apps to register custom plugins
|
|
|
|
|
*/
|
2019-08-30 08:14:12 -04:00
|
|
|
window.OCA.WorkflowEngine = {
|
|
|
|
|
...OCA.WorkflowEngine, /**
|
2019-08-30 10:18:19 -04:00
|
|
|
*
|
2019-09-25 12:19:42 -04:00
|
|
|
* @param {CheckPlugin} Plugin the plugin to register
|
2019-08-30 10:18:19 -04:00
|
|
|
*/
|
2020-07-31 03:26:43 -04:00
|
|
|
registerCheck(Plugin) {
|
2019-08-30 08:14:12 -04:00
|
|
|
store.commit('addPluginCheck', Plugin)
|
|
|
|
|
},
|
2019-08-30 10:18:19 -04:00
|
|
|
/**
|
|
|
|
|
*
|
2019-09-25 12:19:42 -04:00
|
|
|
* @param {OperatorPlugin} Plugin the plugin to register
|
2019-08-30 10:18:19 -04:00
|
|
|
*/
|
2020-07-31 03:26:43 -04:00
|
|
|
registerOperator(Plugin) {
|
2019-08-30 08:14:12 -04:00
|
|
|
store.commit('addPluginOperator', Plugin)
|
2019-11-13 07:05:10 -05:00
|
|
|
},
|
2019-08-30 08:14:12 -04:00
|
|
|
}
|
|
|
|
|
|
2019-09-06 10:23:45 -04:00
|
|
|
// Register shipped checks
|
|
|
|
|
ShippedChecks.forEach((checkPlugin) => window.OCA.WorkflowEngine.registerCheck(checkPlugin))
|
2019-09-06 07:47:11 -04:00
|
|
|
|
2019-08-30 08:14:12 -04:00
|
|
|
Vue.use(Vuex)
|
2019-08-29 10:50:33 -04:00
|
|
|
Vue.prototype.t = t
|
2019-08-30 08:14:12 -04:00
|
|
|
|
2019-08-06 11:40:30 -04:00
|
|
|
const View = Vue.extend(Settings)
|
2019-10-02 07:18:17 -04:00
|
|
|
const workflowengine = new View({
|
2019-11-13 07:05:10 -05:00
|
|
|
store,
|
2019-10-02 07:18:17 -04:00
|
|
|
})
|
|
|
|
|
workflowengine.$mount('#workflowengine')
|