You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

workflowengine.js 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /**
  2. * @copyright Copyright (c) 2019 Julius Härtl <jus@bitgrid.net>
  3. *
  4. * @author John Molakvoæ <skjnldsv@protonmail.com>
  5. * @author Julius Härtl <jus@bitgrid.net>
  6. *
  7. * @license AGPL-3.0-or-later
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. import Vue from 'vue'
  24. import Vuex from 'vuex'
  25. import store from './store'
  26. import Settings from './components/Workflow'
  27. import ShippedChecks from './components/Checks'
  28. /**
  29. * A plugin for displaying a custom value field for checks
  30. *
  31. * @typedef {object} CheckPlugin
  32. * @property {string} class - The PHP class name of the check
  33. * @property {Comparison[]} operators - A list of possible comparison operations running on the check
  34. * @property {Vue} component - A vue component to handle the rendering of options
  35. * The component should handle the v-model directive properly,
  36. * so it needs a value property to receive data and emit an input
  37. * event once the data has changed
  38. * @property {Function} placeholder - Return a placeholder of no custom component is used
  39. * @property {Function} validate - validate a check if no custom component is used
  40. */
  41. /**
  42. * A plugin for extending the admin page representation of an operator
  43. *
  44. * @typedef {object} OperatorPlugin
  45. * @property {string} id - The PHP class name of the check
  46. * @property {string} operation - Default value for the operation field
  47. * @property {string} color - Custom color code to be applied for the operator selector
  48. * @property {Vue} component - A vue component to handle the rendering of options
  49. * The component should handle the v-model directive properly,
  50. * so it needs a value property to receive data and emit an input
  51. * event once the data has changed
  52. */
  53. /**
  54. * @typedef {object} Comparison
  55. * @property {string} operator - value the comparison should have, e.g. !less, greater
  56. * @property {string} name - Translated readable text, e.g. less or equals
  57. */
  58. /**
  59. * Public javascript api for apps to register custom plugins
  60. */
  61. window.OCA.WorkflowEngine = Object.assign({}, OCA.WorkflowEngine, {
  62. /**
  63. *
  64. * @param {CheckPlugin} Plugin the plugin to register
  65. */
  66. registerCheck(Plugin) {
  67. store.commit('addPluginCheck', Plugin)
  68. },
  69. /**
  70. *
  71. * @param {OperatorPlugin} Plugin the plugin to register
  72. */
  73. registerOperator(Plugin) {
  74. store.commit('addPluginOperator', Plugin)
  75. },
  76. })
  77. // Register shipped checks
  78. ShippedChecks.forEach((checkPlugin) => window.OCA.WorkflowEngine.registerCheck(checkPlugin))
  79. Vue.use(Vuex)
  80. Vue.prototype.t = t
  81. const View = Vue.extend(Settings)
  82. const workflowengine = new View({
  83. store,
  84. })
  85. workflowengine.$mount('#workflowengine')