EditExecuteWorkflow.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div>
  3. <ui-select
  4. :model-value="data.workflowId"
  5. :placeholder="t('workflow.blocks.execute-workflow.select')"
  6. class="w-full mb-4"
  7. @change="updateData({ workflowId: $event })"
  8. >
  9. <option
  10. v-for="workflow in workflows"
  11. :key="workflow.id"
  12. :value="workflow.id"
  13. >
  14. {{ workflow.name }}
  15. </option>
  16. </ui-select>
  17. <p>{{ t('common.globalData') }}</p>
  18. <prism-editor
  19. v-if="!state.showGlobalData"
  20. :model-value="data.globalData"
  21. :highlight="highlighter('json')"
  22. readonly
  23. class="p-4 max-h-80"
  24. @click="state.showGlobalData = true"
  25. />
  26. <ui-modal
  27. v-model="state.showGlobalData"
  28. title="Global data"
  29. content-class="max-w-xl"
  30. >
  31. <p>{{ t('workflow.blocks.execute-workflow.overwriteNote') }}</p>
  32. <prism-editor
  33. :model-value="state.globalData"
  34. :highlight="highlighter('json')"
  35. class="w-full scroll"
  36. style="height: calc(100vh - 10rem)"
  37. @input="updateGlobalData"
  38. />
  39. </ui-modal>
  40. </div>
  41. </template>
  42. <script setup>
  43. import { computed, shallowReactive } from 'vue';
  44. import { useI18n } from 'vue-i18n';
  45. import { useRoute } from 'vue-router';
  46. import { PrismEditor } from 'vue-prism-editor';
  47. import { highlighter } from '@/lib/prism';
  48. import Workflow from '@/models/workflow';
  49. const props = defineProps({
  50. data: {
  51. type: Object,
  52. default: () => ({}),
  53. },
  54. hideBase: {
  55. type: Boolean,
  56. default: false,
  57. },
  58. });
  59. const emit = defineEmits(['update:data']);
  60. const { t } = useI18n();
  61. const route = useRoute();
  62. const state = shallowReactive({
  63. showGlobalData: false,
  64. globalData: `${props.data.globalData}`,
  65. });
  66. const workflows = computed(() =>
  67. Workflow.query()
  68. .where(
  69. ({ id, drawflow }) =>
  70. id !== route.params.id && !drawflow.includes(route.params.id)
  71. )
  72. .orderBy('name', 'asc')
  73. .get()
  74. );
  75. function updateData(value) {
  76. emit('update:data', { ...props.data, ...value });
  77. }
  78. function updateGlobalData(event) {
  79. const { value } = event.target;
  80. state.globalData = value;
  81. updateData({ globalData: value });
  82. }
  83. </script>