seitime-frappe/frappe/public/js/workflow_builder/components/Properties.vue
Ayush Chaudhari 761751f269
feat: App-Defined Workflow Tasks and Server Scripts on Transition (#33255)
* feat: add workflow task doctypes

* chore: add Workflow Task to Script Type of Server Scripts

* chore: add description for Workflow Tasks

* feat: fetch dotted paths and corresponding names from hooks

* fix: use Select field instead of Autocomplete

* feat: execute tasks in the background on state transition

* fix: throw error when task not found

* fix: naming for transition task set by user

* fix: child table views

* feat: support for server scripts

* chore: comments and description

* fix: change the casing of docevent options

* fix: change test casing

* feat: Add Workflow Transition field to webhooks

* fix: temporarily remove filter

* feat: add webhooks as workflow actions

* test: test execution of synchronous app-defined methods and server scripts

* chore: shorten the description and change the fieldname of the field 'execute_asynchronously' to 'asynchronous'

* test: server script executipn

* fix: add field to UI

* test: change customer to domain

* test: change Customer to Domain

* fix: patch for change in webhook fields

* chore: fetch only used fields in get_all

* fix: don't run test logic in application code 🙂

* test: separate tests for workflow tasks

* Revert "fix: patch for change in webhook fields"

This reverts commit 2e9c51c43ca2b3698991fbe75cc4032368ab174c.

* chore: break into smaller functions

* test: webhooks with workflow tasks

isolate mock responses to test_sync_tasks

* Revert "fix: change test casing"

This reverts commit e2bad96ed01dea0a26d002ea44a1e0175525ed31.

* Revert "fix: change the casing of docevent options"

This reverts commit ddfc81bf775fad74225f25815b8e3e7b255dc9eb.

* fix: webhook casing

* fix: type hint for doc
2025-07-29 11:01:44 +05:30

99 lines
2.6 KiB
Vue

<script setup>
import { ref, computed, nextTick } from "vue";
import { useStore } from "../store";
let store = useStore();
let title = ref("Workflow Details");
let doc = computed(() => {
return store.workflow.selected ? store.workflow.selected.data : store.workflow_doc;
});
let properties = computed(() => {
nextTick(() => {
let field = $(".field input[data-fieldname!='document_type']").first();
if (field.val() === "") field.focus();
});
if (store.workflow.selected && "action" in store.workflow.selected.data) {
title.value = __("Transition Properties");
return store.transitionfields.filter((df) =>
["action", "allowed", "allow_self_approval", "condition", "transition_tasks"].includes(
df.fieldname
)
);
} else if (store.workflow.selected && "state" in store.workflow.selected.data) {
title.value = __("State Properties");
let allow_edit = store.statefields.find((df) => df.fieldname == "allow_edit");
store.statefields = store.statefields.filter(
(df) => !["allow_edit", "workflow_builder_id"].includes(df.fieldname)
);
store.statefields.splice(2, 0, allow_edit);
return store.statefields.filter((df) => {
if (df.fieldname == "doc_status") {
df.options = ["Draft", "Submitted", "Cancelled"];
df.description = "";
}
if (df.fieldname == "update_field") {
df.options = store.workflow_doc_fields;
}
return true;
});
}
title.value = __("Workflow Details");
return store.workflowfields.filter(
(df) => !["states", "transitions", "workflow_data", "workflow_name"].includes(df.fieldname)
);
});
</script>
<template>
<div class="title">{{ __(title) }}</div>
<div class="properties">
<div class="control-data">
<div v-if="doc">
<div class="field" v-for="df in properties" :key="df.name">
<component
:is="df.fieldtype.replaceAll(' ', '') + 'Control'"
:df="df"
:value="doc[df.fieldname]"
v-model="doc[df.fieldname]"
:data-fieldname="df.fieldname"
:data-fieldtype="df.fieldtype"
/>
</div>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.title {
font-size: var(--text-lg);
font-weight: 600;
padding: var(--padding-sm) var(--padding-md);
border-bottom: 1px solid var(--border-color);
}
.control-data {
height: calc(100vh - 250px);
overflow-y: auto;
padding: 8px;
.field {
margin: 5px;
margin-top: 0;
margin-bottom: 1rem;
:deep(.form-control:disabled) {
color: var(--disabled-text-color);
background-color: var(--disabled-control-bg);
cursor: default;
}
:deep(.description) {
font-size: var(--text-sm);
color: var(--text-muted);
}
}
}
</style>