0
0
Fork 0

feat: replace stickyButtons by subtoolbar

This commit is contained in:
Javier Segarra 2024-07-12 15:22:29 +02:00
parent 4cbca1ca64
commit fceeaea1f5
2 changed files with 24 additions and 49 deletions

View File

@ -392,22 +392,6 @@ function highlightNewRow(index) {
const openEditTableCellDialog = () => { const openEditTableCellDialog = () => {
editTableCellDialogRef.value.show(); editTableCellDialogRef.value.show();
}; };
async function showBadDates() {
try {
if (!checked.value) fixedPrices.value = fixedPricesOriginalData.value;
else {
rowsSelected.value = [];
const { data } = await axios.get('FixedPrices/filter', {
params: {
showBadDates: checked.value,
},
});
fixedPrices.value = data;
}
} catch (error) {
console.error(error);
}
}
const onEditCellDataSaved = async () => { const onEditCellDataSaved = async () => {
rowsSelected.value = []; rowsSelected.value = [];
await fetchFixedPrices(); await fetchFixedPrices();
@ -480,13 +464,16 @@ onUnmounted(() => (stateStore.rightDrawer = false));
</RightMenu> </RightMenu>
<VnSubToolbar> <VnSubToolbar>
<template #st-data> <template #st-data>
<QCheckbox <QBtn
size="sm" v-if="rowsSelected.length"
v-model="checked" @click="openEditTableCellDialog()"
:label="t(`Show future items`)" color="primary"
@update:model-value="showBadDates" icon="edit"
> >
</QCheckbox> <QTooltip>
{{ t('Edit fixed price(s)') }}
</QTooltip>
</QBtn>
</template> </template>
</VnSubToolbar> </VnSubToolbar>
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md">
@ -700,32 +687,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
{{ t('Add') }} {{ t('Add') }}
</QTooltip> </QTooltip>
</QPageSticky> </QPageSticky>
<QPageSticky v-if="rowsSelected.length" :offset="[20, 60]">
<QBtn @click="openEditTableCellDialog()" color="primary" fab icon="edit" />
<QTooltip>
{{ t('Edit fixed price(s)') }}
</QTooltip>
</QPageSticky>
<QPageSticky
:offset="[20, 120]"
v-if="tableRef?.rows?.length > 0 && checked && rowsSelected.length > 0"
>
<QBtn
color="primary"
fab
icon="delete"
@click.stop="
openConfirmationModal(
t('This row will be removed'),
t('Do you want to clone this item?'),
() => removeFuturePrice()
)
"
/>
<QTooltip>
{{ t('Add') }}
</QTooltip>
</QPageSticky>
<QDialog ref="editTableCellDialogRef"> <QDialog ref="editTableCellDialogRef">
<EditTableCellValueForm <EditTableCellValueForm
edit-url="FixedPrices/editFixedPrice" edit-url="FixedPrices/editFixedPrice"

View File

@ -30,7 +30,9 @@ const sanitizeParam = (param) => {
}; };
const $params = ref({}); const $params = ref({});
onMounted(() => { onMounted(() => {
['mine', 'hasMinPrice'].forEach((tag) => ($params.value[tag] = sanitizeParam(tag))); ['mine', 'hasMinPrice', 'showBadDates'].forEach(
(tag) => ($params.value[tag] = sanitizeParam(tag))
);
}); });
const pushParam = (param) => ({ const pushParam = (param) => ({
param: { [param]: $params.value[param] }, param: { [param]: $params.value[param] },
@ -109,6 +111,17 @@ const pushParam = (param) => ({
@update:model-value="searchFn(pushParam('mine'))" @update:model-value="searchFn(pushParam('mine'))"
/> />
</QItemSection> </QItemSection>
<QItemSection>
<QCheckbox
size="sm"
v-model="checked"
:label="t(`Show future items`)"
:true-value="'true'"
:false-value="'false'"
@update:model-value="searchFn(pushParam('showBadDates'))"
>
</QCheckbox>
</QItemSection>
<QItemSection> <QItemSection>
<QCheckbox <QCheckbox
:label="t('components.itemsFilterPanel.hasMinPrice')" :label="t('components.itemsFilterPanel.hasMinPrice')"