@@ -136,6 +122,7 @@ onMounted(() => {
:label="t('eventsInclusionForm.day')"
v-model="dated"
:model-value="props.date"
+ :required="true"
/>
@@ -196,6 +183,7 @@ onMounted(() => {
:label="isNew ? t('globals.add') : t('globals.save')"
type="submit"
color="primary"
+ @click="onSubmit()"
/>
diff --git a/src/pages/Zone/Card/ZoneLocationsTree.vue b/src/pages/Zone/Card/ZoneLocationsTree.vue
index 23a37ef7c..d0d4b18b8 100644
--- a/src/pages/Zone/Card/ZoneLocationsTree.vue
+++ b/src/pages/Zone/Card/ZoneLocationsTree.vue
@@ -38,6 +38,7 @@ const datakey = 'ZoneLocations';
const url = computed(() => `Zones/${route.params.id}/getLeaves`);
const arrayData = useArrayData(datakey, {
url: url.value,
+ limit: null,
});
const store = arrayData.store;
@@ -90,21 +91,16 @@ const onNodeExpanded = async (nodeKeysArray) => {
previousExpandedNodes.value = nodeKeysSet;
};
-const formatNodeSelected = (node) => {
- if (node.selected === 1) node.selected = true;
- else if (node.selected === 0) node.selected = false;
-
- if (node.sons > 0 && !node.childs) node.childs = [{}];
-};
-
const fetchNodeLeaves = async (nodeKey) => {
if (!treeRef.value) return;
const node = treeRef.value?.getNodeByKey(nodeKey);
- if (node.selected === 1) node.selected = true;
- else if (node.selected === 0) node.selected = false;
+ if (typeof node.selected === 'number') node.selected = !!node.selected;
+ if (node.sons > 0 && !node.childs) {
+ node.childs = [{}];
+ const index = expanded.value.indexOf(node.id);
+ expanded.value.splice(index, 1);
+ }
if (!node || node.sons === 0) return;
-
- state.set('Tree', node);
};
function getNodeIds(node) {
@@ -128,18 +124,9 @@ watch(
nodes.value[0].childs = [...val];
const fetchedNodeKeys = val.flatMap(getNodeIds);
state.set('Tree', [...fetchedNodeKeys]);
-
- if (!store.userParams?.search) {
- val.forEach((n) => {
- formatNodeSelected(n);
- });
- store.data = null;
- expanded.value = [null];
- } else {
- for (let n of state.get('Tree')) {
- await fetchNodeLeaves(n);
- }
- expanded.value = [null, ...fetchedNodeKeys];
+ expanded.value = [null, ...fetchedNodeKeys];
+ for (let n of state.get('Tree')) {
+ await fetchNodeLeaves(n);
}
previousExpandedNodes.value = new Set(expanded.value);
},
@@ -147,13 +134,11 @@ watch(
);
const reFetch = async () => {
- const { data } = await arrayData.fetch({ append: false });
- nodes.value = data;
- expanded.value = [null];
+ await arrayData.fetch({});
};
onMounted(async () => {
- if (store.userParams?.search) await arrayData.fetch({});
+ await reFetch();
});
onUnmounted(() => {
@@ -167,13 +152,13 @@ onUnmounted(() => {
v-if="showSearchBar"
v-model="store.userParams.search"
:placeholder="$t('globals.search')"
- @update:model-value="reFetch()"
+ @keyup.enter="reFetch"
>
-
+