refactor: simplify property management logic and improve type definitions
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 9s

This commit is contained in:
puriphatt 2025-03-13 14:32:31 +07:00
parent 0da23733ab
commit 0ad05fa960

View file

@ -1,18 +1,10 @@
<script setup lang="ts">
import { ref, watch } from 'vue';
import {
moveItemUp,
moveItemDown,
dialog,
deleteItem,
toCamelCase,
} from 'stores/utils';
import { moveItemUp, moveItemDown, dialog, deleteItem } from 'stores/utils';
import { useI18n } from 'vue-i18n';
import useOptionStore from 'src/stores/options';
import { useWorkflowTemplate } from 'src/stores/workflow-template';
import { useProperty } from 'src/stores/property';
import { Option } from 'stores/options/types';
import {
WorkFlowPayloadStep,
WorkflowTemplate,
@ -22,10 +14,14 @@ import SelectFlow from '../shared/select/SelectFlow.vue';
import NoData from '../NoData.vue';
import DialogForm from '../DialogForm.vue';
interface Option {
value: string;
label: string;
type: string;
}
const { t } = useI18n();
const { getWorkflowTemplate } = useWorkflowTemplate();
const { getPropertyList } = useProperty();
const { locale } = useI18n();
const optionStore = useOptionStore();
const props = defineProps<{
@ -99,8 +95,9 @@ function manageProperties(
) {
if (property === 'all' && propertiesOption.value) {
if (
tempStep.value[stepIndex].attributes.properties.length ===
propertiesOption.value.length
tempStep.value[stepIndex].attributes.properties.filter((p) =>
propertiesOption.value.some((opt: Option) => opt.value === p.fieldName),
).length === propertiesOption.value.length
) {
tempStep.value[stepIndex].attributes.properties = [];
return;
@ -394,8 +391,11 @@ watch(
<div class="full-width flex items-center">
<q-icon
v-if="
tempStep[stepIndex].attributes.properties?.length ===
propertiesOption?.length
tempStep[stepIndex].attributes.properties?.filter((p) =>
propertiesOption.some(
(opt: Option) => opt.value === p.fieldName,
),
).length === propertiesOption.length
"
name="mdi-checkbox-marked"
size="xs"