refactor: refs #8684 improve slot usage and clean up ItemTags and ItemListFilter components
gitea/salix-front/pipeline/pr-dev This commit is unstable Details

This commit is contained in:
Pablo Natek 2025-04-24 13:57:36 +02:00
parent 9c13cd921e
commit 21c7b2088b
3 changed files with 13 additions and 71 deletions

View File

@ -106,7 +106,7 @@ function checkIsMain() {
<slot <slot
name="moreFilterPanel" name="moreFilterPanel"
v-bind="{ params, orders, searchFn }" v-bind="{ params, orders, searchFn }"
></slot> />
</template> </template>
</VnTableFilter> </VnTableFilter>
</slot> </slot>

View File

@ -17,7 +17,7 @@ const itemTagsRef = ref();
const tagOptions = ref([]); const tagOptions = ref([]);
const valueOptionsMap = ref(new Map()); const valueOptionsMap = ref(new Map());
const getSelectedTagValues = async (tag) => { const getSelectedTagValues = async (tag) => {
if (!tag.tagFk && tag.tag.isFree) return; if (!tag.tagFk && tag.tag?.isFree) return;
const filter = { const filter = {
fields: ['value'], fields: ['value'],
order: 'value ASC', order: 'value ASC',
@ -25,6 +25,7 @@ const getSelectedTagValues = async (tag) => {
}; };
const params = { filter: JSON.stringify(filter) }; const params = { filter: JSON.stringify(filter) };
if (!tag.tagFk) return;
const { data } = await axios.get(`Tags/${tag.tagFk}/filterValue`, { const { data } = await axios.get(`Tags/${tag.tagFk}/filterValue`, {
params, params,
}); });
@ -143,7 +144,6 @@ const insertTag = (rows) => {
v-model="row.priority" v-model="row.priority"
:required="true" :required="true"
:rules="validate('itemTag.priority')" :rules="validate('itemTag.priority')"
style="max-width: 60%"
/> />
<div class="row justify-center" style="flex: 0"> <div class="row justify-center" style="flex: 0">
<QIcon <QIcon

View File

@ -227,6 +227,16 @@ onMounted(async () => {
/> />
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem>
<QItemSection>
<QCheckbox
:label="t('params.isFloramondo')"
v-model="params.isFloramondo"
toggle-indeterminate
@update:model-value="searchFn()"
/>
</QItemSection>
</QItem>
<!-- Tags filter --> <!-- Tags filter -->
<QItemLabel header> <QItemLabel header>
{{ t('params.tags') }} {{ t('params.tags') }}
@ -293,74 +303,6 @@ onMounted(async () => {
@click="removeTag(index, params, searchFn)" @click="removeTag(index, params, searchFn)"
/> />
</QItem> </QItem>
<!-- Filter fields -->
<QItemLabel header
>{{ t('More fields') }}
<QIcon
name="add_circle"
class="fill-icon-on-hover q-ml-md"
size="sm"
color="primary"
@click="fieldFiltersValues.push({})"
/></QItemLabel>
<QItem v-for="(fieldFilter, index) in fieldFiltersValues" :key="index">
<QItemSection class="col">
<VnSelect
class="full-width"
:label="t('params.tag')"
:model-value="fieldFilter.selectedField"
:options="moreFields"
option-label="label"
option-value="label"
dense
filled
:emit-value="false"
use-input
:is-clearable="false"
@update:model-value="
($event) => {
fieldFilter.name = $event.name;
fieldFilter.value = null;
fieldFilter.selectedField = $event;
}
"
/>
</QItemSection>
<QItemSection class="col">
<VnCheckbox
v-if="fieldFilter.selectedField?.type === 'boolean'"
v-model="fieldFilter.value"
:label="t('params.value')"
@update:model-value="applyFieldFilters(params, searchFn)"
/>
<VnInput
v-else
v-model="fieldFilter.value"
:label="t('params.value')"
:disable="!fieldFilter.selectedField"
filled
@keydown.enter="applyFieldFilters(params, searchFn)"
/>
</QItemSection>
<QItemSection side
><QIcon
name="delete"
class="fill-icon-on-hover q-ml-xs"
size="sm"
color="primary"
@click="removeFieldFilter(index, params, searchFn)"
/></QItemSection>
</QItem>
<QItem>
<QItemSection>
<QCheckbox
:label="t('params.isFloramondo')"
v-model="params.isFloramondo"
toggle-indeterminate
@update:model-value="searchFn()"
/>
</QItemSection>
</QItem>
</template> </template>
</VnFilterPanel> </VnFilterPanel>
</template> </template>