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.1KB

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