0
0
Fork 0

Merge branch 'dev' into 7129-finishRouteMigration

This commit is contained in:
Pablo Natek 2024-06-13 13:48:44 +02:00
commit d6f085dc3d
119 changed files with 4268 additions and 1260 deletions

View File

@ -1,3 +1,100 @@
# Version 24.24 - 2024-06-11
### Added 🆕
- feat: 6942 hashtag in key : value summary by:jgallego
- feat: #6957: Rename FetchedTags instance tag by:Javier Segarra
- feat: refactor template by:Javier Segarra
- feat: refs #6600 Add option to add comment for photo motivation by:jorgep
- feat: refs #6942 test e2e tobook & toUnbook by:jorgep
- feat: refs #6942 to book summary button & reactive value by:jorgep
- feat: refs #6942 to unbook by:jorgep
- feat: refs #6942 url update by:jorgep
- feat: refs #6942 use correct currency in InvoiceIn components by:jorgep
- feat: refs #6942 vat rate total by:jorgep
- feat: refs #7494 new icons (7494-icons) by:alexm
- feat: refs #7494 new icons by:alexm
- feat: refs #7542 drop space by:jorgep
- feat: refs #7542 empty by:jorgep
- fix: refs #6942 changes and new features by:jorgep
- fix: style by:Javier Segarra
- style: color transparent when is fetive by:Javier Segarra
- style: fix color when is empty by:Javier Segarra
- style: reset poc style (6957_refactorFetechedTags) by:Javier Segarra
- style: reset poc style by:Javier Segarra
- style updates by:Javier Segarra
### Changed 📦
- feat: refactor template by:Javier Segarra
- perf: 6957 add color as new shared variable by:Javier Segarra
- perf: 6957 change fetchedTags color by:Javier Segarra
- perf: remove local tree variable by:Javier Segarra
- refactor: add flat by:alexm
- refactor: refs #6600 replace QInput to VnInput by:jorgep
- refactor: refs #6652 improved defaulter section by:Jon
- refactor: refs #6942 Fix getTotalAmount function to correctly calculate the total amount in InvoiceInDueDay.vue by:jorgep
- refactor: refs #6942 new summary layout by:jorgep
- refactor: refs #6942 store key & actions by:jorgep
- refactor: refs #6942 summary by:jorgep
- refactor: refs #6942 use router hook by:jorgep
- refactor: refs #6942 WIP summary layout by:jorgep
### Fixed 🛠️
- fix: 9-12 by:Javier Segarra
- fix: defaulter icon by:alexm
- fix: refs #5186 validation by:jorgep
- fix: refs #6095 add reFfk null on search by:pablone
- fix: refs #6942 cardDescriptor use store if its popup or different source data by:jorgep
- fix: refs #6942 changes and new features by:jorgep
- fix: refs #6942 drop comments by:jorgep
- fix: refs #6942 drop console by:jorgep
- fix: refs #6942 drop console.log by:jorgep
- fix: refs #6942 e2e test (origin/6942-warmfix-fixFormModel) by:jorgep
- fix: refs #6942 e2e tests by:jorgep
- fix: refs #6942 e2e tests by:jorgep
- fix: refs #6942 fix emit on data saved by:jorgep
- fix: refs #6942 fix emit on reset by:jorgep
- fix: refs #6942 fix vncard by:jorgep
- fix: refs #6942 formModel & CardDescriptor by:jorgep
- fix: refs #6942 formModel watch changes & invoiceInCreate by:jorgep
- fix: refs #6942 import by:jorgep
- fix: refs #6942 reloading by:jorgep
- fix: refs #6942 rollback by:jorgep
- fix: refs #6942 selectable expense by:jorgep
- fix: refs #6942 skip e2e tests by:jorgep
- fix: refs #6942 table bottom highlight & drop isBooked field by:jorgep
- fix: refs #6942 tests e2e by:jorgep
- fix: refs #6942 tests & summary table spacing by:jorgep
- fix: refs #6942 unit tests by:jorgep
- fix: refs #6942 vnLocation by:jorgep
- fix: refs #6942 wip: formModel by:jorgep
- fix: refs #7542 use right panel by:jorgep
- fix: searchbar redirect by:alexm
- fix: style by:Javier Segarra
- fix: WorkerCalendarItem by:Javier Segarra
- mini fix by:wbuezas
- refs #6111 clean code fix changes by:carlossa
- refs #6111 fix merge, fix column by:carlossa
- refs #6111 fix qtable, actions, scroll by:carlossa
- refs #6111 fix routeList by:carlossa
- refs #6111 fix sticky by:carlossa
- refs #6111 fix trad remove logs by:carlossa
- refs #6111 fix visibleColumns by:carlossa
- refs #6111 routeList fix by:carlossa
- refs #6332 fix calendar by:carlossa
- refs #6332 fix colors by:carlossa
- refs #6332 fix festive by:carlossa
- refs #6820 fix BasicData Tickets by:carlossa
- refs #6820 fix error front by:carlossa
- refs #6820 fix traduction by:carlossa
- refs #7391 fix textarea by:carlossa
- refs #7396 fix summary by:carlossa
- Search childs fix by:wbuezas
- small fix by:wbuezas
- style: fix color when is empty by:Javier Segarra
# Changelog # Changelog
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
@ -10,6 +107,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
- (Item) => Se añade la opción de añadir un comentario del motivo de hacer una foto - (Item) => Se añade la opción de añadir un comentario del motivo de hacer una foto
- (Worker) => Se añade la opción de crear un trabajador ajeno a la empresa
- (Route) => Ahora se muestran todos los cmrs
## [2418.01] ## [2418.01]

4
Jenkinsfile vendored
View File

@ -94,7 +94,7 @@ pipeline {
sh 'quasar build' sh 'quasar build'
script { script {
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
} }
dockerBuild() dockerBuild()
} }
@ -106,7 +106,7 @@ pipeline {
steps { steps {
script { script {
def packageJson = readJSON file: 'package.json' def packageJson = readJSON file: 'package.json'
env.VERSION = packageJson.version env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
} }
withKubeConfig([ withKubeConfig([
serverUrl: "$KUBERNETES_API", serverUrl: "$KUBERNETES_API",

34
changelog.sh Normal file
View File

@ -0,0 +1,34 @@
features_types=(chore feat style)
changes_types=(refactor perf)
fix_types=(fix revert)
file="CHANGELOG.md"
file_tmp="temp_log.txt"
file_current_tmp="temp_current_log.txt"
setType(){
echo "### $1" >> $file_tmp
arr=("$@")
echo "" > $file_current_tmp
for i in "${arr[@]}"
do
git log --grep="$i" --oneline --no-merges --format="- %s %d by:%an" master..test >> $file_current_tmp
done
# remove duplicates
sort -o $file_current_tmp -u $file_current_tmp
cat $file_current_tmp >> $file_tmp
echo "" >> $file_tmp
# remove tmp current file
[ -e $file_current_tmp ] && rm $file_current_tmp
}
echo "# Version XX.XX - XXXX-XX-XX" >> $file_tmp
echo "" >> $file_tmp
setType "Added 🆕" "${features_types[@]}"
setType "Changed 📦" "${changes_types[@]}"
setType "Fixed 🛠️" "${fix_types[@]}"
cat $file >> $file_tmp
mv $file_tmp $file

View File

@ -1,6 +1,6 @@
{ {
"name": "salix-front", "name": "salix-front",
"version": "24.26.0", "version": "24.26.2",
"description": "Salix frontend", "description": "Salix frontend",
"productName": "Salix", "productName": "Salix",
"author": "Verdnatura", "author": "Verdnatura",
@ -56,4 +56,4 @@
"vite": "^5.1.4", "vite": "^5.1.4",
"vitest": "^0.31.1" "vitest": "^0.31.1"
} }
} }

View File

@ -1,21 +1,48 @@
import { getCurrentInstance } from 'vue'; import { getCurrentInstance } from 'vue';
const filterAvailableInput = element => element.classList.contains('q-field__native') && !element.disabled const filterAvailableInput = (element) => {
const filterAvailableText = element => element.__vueParentComponent.type.name === 'QInput' && element.__vueParentComponent?.attrs?.class !== 'vn-input-date'; return element.classList.contains('q-field__native') && !element.disabled;
};
const filterAvailableText = (element) => {
return (
element.__vueParentComponent.type.name === 'QInput' &&
element.__vueParentComponent?.attrs?.class !== 'vn-input-date'
);
};
export default { export default {
mounted: function () { mounted: function () {
const vm = getCurrentInstance(); const vm = getCurrentInstance();
if (vm.type.name === 'QForm') if (vm.type.name === 'QForm') {
if (!['searchbarForm','filterPanelForm'].includes(this.$el?.id)) { if (!['searchbarForm', 'filterPanelForm'].includes(this.$el?.id)) {
// AUTOFOCUS // AUTOFOCUS
const elementsArray = Array.from(this.$el.elements); const elementsArray = Array.from(this.$el.elements);
const firstInputElement = elementsArray.filter(filterAvailableInput).find(filterAvailableText); const availableInputs = elementsArray.filter(filterAvailableInput);
const firstInputElement = availableInputs.find(filterAvailableText);
if (firstInputElement) { if (firstInputElement) {
firstInputElement.focus(); firstInputElement.focus();
} }
const that = this;
this.$el.addEventListener('keyup', function (evt) {
if (evt.key === 'Enter') {
const input = evt.target;
console.log('input', input);
if (input.type == 'textarea' && evt.shiftKey) {
evt.preventDefault();
let { selectionStart, selectionEnd } = input;
input.value =
input.value.substring(0, selectionStart) +
'\n' +
input.value.substring(selectionEnd);
selectionStart = selectionEnd = selectionStart + 1;
return;
}
evt.preventDefault();
that.onSubmit();
}
});
} }
}
}, },
}; };

View File

@ -155,7 +155,7 @@ const rotateRight = () => {
editor.value.rotate(-90); editor.value.rotate(-90);
}; };
const onUploadAccept = () => { const onSubmit = () => {
try { try {
if (!newPhoto.files && !newPhoto.url) { if (!newPhoto.files && !newPhoto.url) {
notify(t('Select an image'), 'negative'); notify(t('Select an image'), 'negative');
@ -206,7 +206,7 @@ const makeRequest = async () => {
@on-fetch="(data) => (allowedContentTypes = data.join(', '))" @on-fetch="(data) => (allowedContentTypes = data.join(', '))"
auto-load auto-load
/> />
<QForm @submit="onUploadAccept()" class="all-pointer-events"> <QForm @submit="onSubmit()" class="all-pointer-events">
<QCard class="q-pa-lg"> <QCard class="q-pa-lg">
<span ref="closeButton" class="close-icon" v-close-popup> <span ref="closeButton" class="close-icon" v-close-popup>
<QIcon name="close" size="sm" /> <QIcon name="close" size="sm" />

View File

@ -50,7 +50,7 @@ const onDataSaved = () => {
closeForm(); closeForm();
}; };
const submitData = async () => { const onSubmit = async () => {
try { try {
isLoading.value = true; isLoading.value = true;
const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk })); const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk }));
@ -74,7 +74,7 @@ const closeForm = () => {
</script> </script>
<template> <template>
<QForm @submit="submitData()" class="all-pointer-events"> <QForm @submit="onSubmit()" class="all-pointer-events">
<QCard class="q-pa-lg"> <QCard class="q-pa-lg">
<span ref="closeButton" class="close-icon" v-close-popup> <span ref="closeButton" class="close-icon" v-close-popup>
<QIcon name="close" size="sm" /> <QIcon name="close" size="sm" />

View File

@ -83,7 +83,7 @@ const tableColumns = computed(() => [
}, },
]); ]);
const fetchResults = async () => { const onSubmit = async () => {
try { try {
let filter = itemFilter; let filter = itemFilter;
const params = itemFilterParams; const params = itemFilterParams;
@ -145,7 +145,7 @@ const selectItem = ({ id }) => {
@on-fetch="(data) => (InksOptions = data)" @on-fetch="(data) => (InksOptions = data)"
auto-load auto-load
/> />
<QForm @submit="fetchResults()" class="all-pointer-events"> <QForm @submit="onSubmit()" class="all-pointer-events">
<QCard class="column" style="padding: 32px; z-index: 100"> <QCard class="column" style="padding: 32px; z-index: 100">
<span ref="closeButton" class="close-icon" v-close-popup> <span ref="closeButton" class="close-icon" v-close-popup>
<QIcon name="close" size="sm" /> <QIcon name="close" size="sm" />

View File

@ -85,7 +85,7 @@ const tableColumns = computed(() => [
}, },
]); ]);
const fetchResults = async () => { const onSubmit = async () => {
try { try {
let filter = travelFilter; let filter = travelFilter;
const params = travelFilterParams; const params = travelFilterParams;
@ -138,7 +138,7 @@ const selectTravel = ({ id }) => {
@on-fetch="(data) => (warehousesOptions = data)" @on-fetch="(data) => (warehousesOptions = data)"
auto-load auto-load
/> />
<QForm @submit="fetchResults()" class="all-pointer-events"> <QForm @submit="onSubmit()" class="all-pointer-events">
<QCard class="column" style="padding: 32px; z-index: 100"> <QCard class="column" style="padding: 32px; z-index: 100">
<span ref="closeButton" class="close-icon" v-close-popup> <span ref="closeButton" class="close-icon" v-close-popup>
<QIcon name="close" size="sm" /> <QIcon name="close" size="sm" />

View File

@ -12,6 +12,7 @@ import SkeletonForm from 'components/ui/SkeletonForm.vue';
import VnConfirm from './ui/VnConfirm.vue'; import VnConfirm from './ui/VnConfirm.vue';
import { tMobile } from 'src/composables/tMobile'; import { tMobile } from 'src/composables/tMobile';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import { useRoute } from 'vue-router';
const { push } = useRouter(); const { push } = useRouter();
const quasar = useQuasar(); const quasar = useQuasar();
@ -20,6 +21,7 @@ const stateStore = useStateStore();
const { t } = useI18n(); const { t } = useI18n();
const { validate } = useValidator(); const { validate } = useValidator();
const { notify } = useNotify(); const { notify } = useNotify();
const route = useRoute();
const $props = defineProps({ const $props = defineProps({
url: { url: {
@ -28,7 +30,7 @@ const $props = defineProps({
}, },
model: { model: {
type: String, type: String,
default: '', default: null,
}, },
filter: { filter: {
type: Object, type: Object,
@ -82,17 +84,18 @@ const $props = defineProps({
description: 'It is used for redirect on click "save and continue"', description: 'It is used for redirect on click "save and continue"',
}, },
}); });
const emit = defineEmits(['onFetch', 'onDataSaved']); const emit = defineEmits(['onFetch', 'onDataSaved']);
const modelValue = computed(
() => $props.model ?? `formModel_${route?.meta?.title ?? route.name}`
);
const componentIsRendered = ref(false); const componentIsRendered = ref(false);
const arrayData = useArrayData($props.model); const arrayData = useArrayData(modelValue);
const isLoading = ref(false); const isLoading = ref(false);
// Si elegimos observar los cambios del form significa que inicialmente las actions estaran deshabilitadas // Si elegimos observar los cambios del form significa que inicialmente las actions estaran deshabilitadas
const isResetting = ref(false); const isResetting = ref(false);
const hasChanges = ref(!$props.observeFormChanges); const hasChanges = ref(!$props.observeFormChanges);
const originalData = ref({}); const originalData = ref({});
const formData = computed(() => state.get($props.model)); const formData = computed(() => state.get(modelValue));
const formUrl = computed(() => $props.url); const formUrl = computed(() => $props.url);
const defaultButtons = computed(() => ({ const defaultButtons = computed(() => ({
save: { save: {
@ -114,7 +117,7 @@ onMounted(async () => {
nextTick(() => (componentIsRendered.value = true)); nextTick(() => (componentIsRendered.value = true));
// Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla // Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla
state.set($props.model, $props.formInitialData); state.set(modelValue, $props.formInitialData);
if ($props.autoLoad && !$props.formInitialData && $props.url) await fetch(); if ($props.autoLoad && !$props.formInitialData && $props.url) await fetch();
else if (arrayData.store.data) updateAndEmit('onFetch', arrayData.store.data); else if (arrayData.store.data) updateAndEmit('onFetch', arrayData.store.data);
@ -161,8 +164,8 @@ onBeforeRouteLeave((to, from, next) => {
onUnmounted(() => { onUnmounted(() => {
// Restauramos los datos originales en el store si se realizaron cambios en el formulario pero no se guardaron, evitando modificaciones erróneas. // Restauramos los datos originales en el store si se realizaron cambios en el formulario pero no se guardaron, evitando modificaciones erróneas.
if (hasChanges.value) return state.set($props.model, originalData.value); if (hasChanges.value) return state.set(modelValue, originalData.value);
if ($props.clearStoreOnUnmount) state.unset($props.model); if ($props.clearStoreOnUnmount) state.unset(modelValue);
}); });
async function fetch() { async function fetch() {
@ -174,7 +177,7 @@ async function fetch() {
updateAndEmit('onFetch', data); updateAndEmit('onFetch', data);
} catch (e) { } catch (e) {
state.set($props.model, {}); state.set(modelValue, {});
originalData.value = {}; originalData.value = {};
} }
} }
@ -235,11 +238,11 @@ function filter(value, update, filterOptions) {
} }
function updateAndEmit(evt, val, res) { function updateAndEmit(evt, val, res) {
state.set($props.model, val); state.set(modelValue, val);
originalData.value = val && JSON.parse(JSON.stringify(val)); originalData.value = val && JSON.parse(JSON.stringify(val));
if (!$props.url) arrayData.store.data = val; if (!$props.url) arrayData.store.data = val;
emit(evt, state.get($props.model), res); emit(evt, state.get(modelValue), res);
} }
defineExpose({ save, isLoading, hasChanges }); defineExpose({ save, isLoading, hasChanges });

View File

@ -4,7 +4,7 @@ import { useI18n } from 'vue-i18n';
import FormModel from 'components/FormModel.vue'; import FormModel from 'components/FormModel.vue';
const emit = defineEmits(['onDataSaved']); const emit = defineEmits(['onDataSaved', 'onDataCanceled']);
defineProps({ defineProps({
title: { title: {
@ -15,26 +15,6 @@ defineProps({
type: String, type: String,
default: '', default: '',
}, },
url: {
type: String,
default: '',
},
model: {
type: String,
default: '',
},
filter: {
type: Object,
default: null,
},
urlCreate: {
type: String,
default: null,
},
formInitialData: {
type: Object,
default: () => {},
},
}); });
const { t } = useI18n(); const { t } = useI18n();
@ -43,8 +23,8 @@ const formModelRef = ref(null);
const closeButton = ref(null); const closeButton = ref(null);
const onDataSaved = (formData, requestResponse) => { const onDataSaved = (formData, requestResponse) => {
emit('onDataSaved', formData, requestResponse);
closeForm(); closeForm();
emit('onDataSaved', formData, requestResponse);
}; };
const isLoading = computed(() => formModelRef.value?.isLoading); const isLoading = computed(() => formModelRef.value?.isLoading);
@ -61,11 +41,9 @@ defineExpose({
<template> <template>
<FormModel <FormModel
ref="formModelRef" ref="formModelRef"
:form-initial-data="formInitialData"
:observe-form-changes="false" :observe-form-changes="false"
:default-actions="false" :default-actions="false"
:url-create="urlCreate" v-bind="$attrs"
:model="model"
@on-data-saved="onDataSaved" @on-data-saved="onDataSaved"
> >
<template #form="{ data, validate }"> <template #form="{ data, validate }">
@ -84,6 +62,7 @@ defineExpose({
flat flat
:disabled="isLoading" :disabled="isLoading"
:loading="isLoading" :loading="isLoading"
@click="emit('onDataCanceled')"
v-close-popup v-close-popup
/> />
<QBtn <QBtn

View File

@ -74,7 +74,7 @@ const closeForm = () => {
:disabled="isLoading" :disabled="isLoading"
:loading="isLoading" :loading="isLoading"
/> />
<slot name="customButtons" /> <slot name="custom-buttons" />
</div> </div>
</QCard> </QCard>
</QForm> </QForm>

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { onMounted, computed } from 'vue'; import { onMounted, computed, ref } from 'vue';
import { Dark, Quasar } from 'quasar'; import { Dark, Quasar } from 'quasar';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
@ -10,13 +10,12 @@ import { localeEquivalence } from 'src/i18n/index';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import { useClipboard } from 'src/composables/useClipboard';
const state = useState(); const state = useState();
const session = useSession(); const session = useSession();
const router = useRouter(); const router = useRouter();
const { t, locale } = useI18n(); const { t, locale } = useI18n();
import { useClipboard } from 'src/composables/useClipboard';
import { ref } from 'vue';
const { copyText } = useClipboard(); const { copyText } = useClipboard();
const userLocale = computed({ const userLocale = computed({
get() { get() {
@ -91,6 +90,15 @@ function logout() {
function copyUserToken() { function copyUserToken() {
copyText(session.getToken(), { label: 'components.userPanel.copyToken' }); copyText(session.getToken(), { label: 'components.userPanel.copyToken' });
} }
function localUserData() {
state.setUser(user.value);
}
function saveUserData(param, value) {
axios.post('UserConfigs/setUserConfig', { [param]: value });
localUserData();
}
</script> </script>
<template> <template>
@ -180,6 +188,7 @@ function copyUserToken() {
option-value="id" option-value="id"
input-debounce="0" input-debounce="0"
hide-selected hide-selected
@update:model-value="localUserData"
/> />
<VnSelect <VnSelect
:label="t('components.userPanel.localBank')" :label="t('components.userPanel.localBank')"
@ -189,6 +198,7 @@ function copyUserToken() {
option-value="id" option-value="id"
input-debounce="0" input-debounce="0"
hide-selected hide-selected
@update:model-value="localUserData"
> >
<template #option="{ itemProps, opt }"> <template #option="{ itemProps, opt }">
<QItem v-bind="itemProps"> <QItem v-bind="itemProps">
@ -210,6 +220,7 @@ function copyUserToken() {
option-label="code" option-label="code"
option-value="id" option-value="id"
input-debounce="0" input-debounce="0"
@update:model-value="localUserData"
/> />
<VnSelect <VnSelect
:label="t('components.userPanel.userWarehouse')" :label="t('components.userPanel.userWarehouse')"
@ -219,6 +230,7 @@ function copyUserToken() {
option-label="name" option-label="name"
option-value="id" option-value="id"
input-debounce="0" input-debounce="0"
@update:model-value="(v) => saveUserData('warehouseFk', v)"
/> />
</VnRow> </VnRow>
<VnRow> <VnRow>
@ -232,6 +244,7 @@ function copyUserToken() {
style="flex: 0" style="flex: 0"
dense dense
input-debounce="0" input-debounce="0"
@update:model-value="(v) => saveUserData('companyFk', v)"
/> />
</VnRow> </VnRow>
</div> </div>

View File

@ -22,6 +22,7 @@ const props = defineProps({
searchbarInfo: { type: String, default: '' }, searchbarInfo: { type: String, default: '' },
searchCustomRouteRedirect: { type: String, default: undefined }, searchCustomRouteRedirect: { type: String, default: undefined },
searchRedirect: { type: Boolean, default: true }, searchRedirect: { type: Boolean, default: true },
searchMakeFetch: { type: Boolean, default: true },
}); });
const stateStore = useStateStore(); const stateStore = useStateStore();

View File

@ -13,6 +13,10 @@ const $props = defineProps({
type: Boolean, type: Boolean,
default: false, default: false,
}, },
info: {
type: String,
default: '',
},
}); });
const { t } = useI18n(); const { t } = useI18n();
@ -83,6 +87,11 @@ const inputRules = [
v-if="hover && value && !$attrs.disabled" v-if="hover && value && !$attrs.disabled"
@click="value = null" @click="value = null"
></QIcon> ></QIcon>
<QIcon v-if="info" name="info">
<QTooltip max-width="350px">
{{ info }}
</QTooltip>
</QIcon>
</template> </template>
</QInput> </QInput>
</div> </div>

View File

@ -2,7 +2,6 @@
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import isValidDate from 'filters/isValidDate'; import isValidDate from 'filters/isValidDate';
import VnInput from 'components/common/VnInput.vue';
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {

View File

@ -622,145 +622,140 @@ setLogTree();
</QList> </QList>
</div> </div>
</div> </div>
<QDrawer v-model="stateStore.rightDrawer" show-if-above side="right" :width="300"> <Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()">
<QScrollArea class="fit text-grey-8"> <QList dense>
<QList dense> <QSeparator />
<QSeparator /> <QItem class="q-mt-sm">
<QItem class="q-mt-sm"> <QInput
<QInput :label="t('globals.search')"
:label="t('globals.search')" v-model="searchInput"
v-model="searchInput" class="full-width"
class="full-width" clearable
clearable clear-icon="close"
clear-icon="close" @keyup.enter="() => selectFilter('search')"
@keyup.enter="() => selectFilter('search')" @focusout="() => selectFilter('search')"
@focusout="() => selectFilter('search')" @clear="() => selectFilter('search')"
@clear="() => selectFilter('search')" >
> <template #append>
<template #append> <QIcon name="info" class="cursor-pointer">
<QIcon name="info" class="cursor-pointer"> <QTooltip>{{ t('tooltips.search') }}</QTooltip>
<QTooltip>{{ t('tooltips.search') }}</QTooltip> </QIcon>
</QIcon> </template>
</template> </QInput>
</QInput> </QItem>
</QItem> <QItem>
<QItem> <VnSelect
class="full-width"
:label="t('globals.entity')"
v-model="selectedFilters.changedModel"
option-label="locale"
option-value="value"
:options="actions"
@update:model-value="selectFilter('action')"
hide-selected
/>
</QItem>
<QItem class="q-mt-sm">
<QOptionGroup
size="sm"
v-model="userRadio"
:options="userTypes"
color="primary"
@update:model-value="selectFilter('userRadio')"
right-label
>
<template #label="{ label }">
{{ t(`Users.${label}`) }}
</template>
</QOptionGroup>
</QItem>
<QItem class="q-mt-sm">
<QItemSection v-if="!workers">
<QSkeleton type="QInput" class="full-width" />
</QItemSection>
<QItemSection v-if="workers && userRadio !== null">
<VnSelect <VnSelect
class="full-width" class="full-width"
:label="t('globals.entity')" :label="t('globals.user')"
v-model="selectedFilters.changedModel" v-model="userSelect"
option-label="locale" option-label="name"
option-value="value" option-value="id"
:options="actions" :options="workers"
@update:model-value="selectFilter('action')" @update:model-value="selectFilter('userSelect')"
hide-selected hide-selected
/>
</QItem>
<QItem class="q-mt-sm">
<QOptionGroup
size="sm"
v-model="userRadio"
:options="userTypes"
color="primary"
@update:model-value="selectFilter('userRadio')"
right-label
> >
<template #label="{ label }"> <template #option="{ opt, itemProps }">
{{ t(`Users.${label}`) }} <QItem v-bind="itemProps" class="q-pa-xs row items-center">
<QItemSection class="col-3 items-center">
<VnAvatar :worker-id="opt.id" />
</QItemSection>
<QItemSection class="col-9 justify-center">
<span>{{ opt.name }}</span>
<span class="text-grey">{{ opt.nickname }}</span>
</QItemSection>
</QItem>
</template> </template>
</QOptionGroup> </VnSelect>
</QItem> </QItemSection>
<QItem class="q-mt-sm"> </QItem>
<QItemSection v-if="!workers"> <QItem class="q-mt-sm">
<QSkeleton type="QInput" class="full-width" /> <QInput
</QItemSection> :label="t('globals.changes')"
<QItemSection v-if="workers && userRadio !== null"> v-model="changeInput"
<VnSelect class="full-width"
class="full-width" clearable
:label="t('globals.user')" clear-icon="close"
v-model="userSelect" @keyup.enter="selectFilter('change')"
option-label="name" @focusout="selectFilter('change')"
option-value="id" @clear="selectFilter('change')"
:options="workers"
@update:model-value="selectFilter('userSelect')"
hide-selected
>
<template #option="{ opt, itemProps }">
<QItem
v-bind="itemProps"
class="q-pa-xs row items-center"
>
<QItemSection class="col-3 items-center">
<VnAvatar :worker-id="opt.id" />
</QItemSection>
<QItemSection class="col-9 justify-center">
<span>{{ opt.name }}</span>
<span class="text-grey">{{ opt.nickname }}</span>
</QItemSection>
</QItem>
</template>
</VnSelect>
</QItemSection>
</QItem>
<QItem class="q-mt-sm">
<QInput
:label="t('globals.changes')"
v-model="changeInput"
class="full-width"
clearable
clear-icon="close"
@keyup.enter="selectFilter('change')"
@focusout="selectFilter('change')"
@clear="selectFilter('change')"
>
<template #append>
<QIcon name="info" class="cursor-pointer">
<QTooltip max-width="250px">{{
t('tooltips.changes')
}}</QTooltip>
</QIcon>
</template>
</QInput>
</QItem>
<QItem
:class="index == 'create' ? 'q-mt-md' : 'q-mt-xs'"
v-for="(checkboxOption, index) in checkboxOptions"
:key="index"
> >
<QCheckbox <template #append>
size="sm" <QIcon name="info" class="cursor-pointer">
v-model="checkboxOption.selected" <QTooltip max-width="250px">{{
:label="t(`actions.${checkboxOption.label}`)" t('tooltips.changes')
@update:model-value="selectFilter" }}</QTooltip>
/> </QIcon>
</QItem> </template>
<QItem class="q-mt-sm"> </QInput>
<QInput </QItem>
class="full-width" <QItem
:label="t('globals.date')" :class="index == 'create' ? 'q-mt-md' : 'q-mt-xs'"
@click="dateFromDialog = true" v-for="(checkboxOption, index) in checkboxOptions"
@focus="(evt) => evt.target.blur()" :key="index"
@clear="selectFilter('date', 'to')" >
v-model="dateFrom" <QCheckbox
clearable size="sm"
clear-icon="close" v-model="checkboxOption.selected"
/> :label="t(`actions.${checkboxOption.label}`)"
</QItem> @update:model-value="selectFilter"
<QItem class="q-mt-sm"> />
<QInput </QItem>
class="full-width" <QItem class="q-mt-sm">
:label="t('to')" <QInput
@click="dateToDialog = true" class="full-width"
@focus="(evt) => evt.target.blur()" :label="t('globals.date')"
@clear="selectFilter('date', 'from')" @click="dateFromDialog = true"
v-model="dateTo" @focus="(evt) => evt.target.blur()"
clearable @clear="selectFilter('date', 'to')"
clear-icon="close" v-model="dateFrom"
/> clearable
</QItem> clear-icon="close"
</QList> />
</QScrollArea> </QItem>
</QDrawer> <QItem class="q-mt-sm">
<QInput
class="full-width"
:label="t('to')"
@click="dateToDialog = true"
@focus="(evt) => evt.target.blur()"
@clear="selectFilter('date', 'from')"
v-model="dateTo"
clearable
clear-icon="close"
/>
</QItem>
</QList>
</Teleport>
<QDialog v-model="dateFromDialog"> <QDialog v-model="dateFromDialog">
<QDate <QDate
:years-in-month-view="false" :years-in-month-view="false"

View File

@ -0,0 +1,6 @@
<script setup>
const model = defineModel({ type: Boolean, required: true });
</script>
<template>
<QRadio v-model="model" v-bind="$attrs" dense :dark="true" class="q-mr-sm" />
</template>

View File

@ -0,0 +1,37 @@
<script setup>
import { computed } from 'vue';
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
const props = defineProps({
wdays: {
type: Array,
default: () => [],
},
});
const emit = defineEmits(['update:wdays']);
const weekdayStore = useWeekdayStore();
const selectedWDays = computed({
get: () => props.wdays,
set: (value) => emit('update:wdays', value),
});
const toggleDay = (index) => (selectedWDays.value[index] = !selectedWDays.value[index]);
</script>
<template>
<div class="q-gutter-x-sm" style="width: max-content">
<QBtn
v-for="(weekday, index) in weekdayStore.getLocalesMap"
:key="index"
:label="weekday.localeChar"
rounded
style="max-width: 36px"
:color="selectedWDays[weekday.index] ? 'primary' : ''"
@click="toggleDay(weekday.index)"
/>
</div>
</template>

View File

@ -28,7 +28,7 @@ const toggleCardCheck = (item) => {
<div class="title text-primary text-weight-bold text-h5"> <div class="title text-primary text-weight-bold text-h5">
{{ $props.title }} {{ $props.title }}
</div> </div>
<QChip class="q-chip-color" outline size="sm"> <QChip v-if="$props.id" class="q-chip-color" outline size="sm">
{{ t('ID') }}: {{ $props.id }} {{ t('ID') }}: {{ $props.id }}
</QChip> </QChip>
</div> </div>

View File

@ -147,7 +147,7 @@ const containerClasses = computed(() => {
.q-calendar-month__head--workweek, .q-calendar-month__head--workweek,
.q-calendar-month__head--weekday.q-calendar__center.q-calendar__ellipsis { .q-calendar-month__head--weekday.q-calendar__center.q-calendar__ellipsis {
text-transform: capitalize; text-transform: capitalize;
color: var(---color-font-secondary); color: $color-font-secondary;
font-weight: bold; font-weight: bold;
font-size: 0.8rem; font-size: 0.8rem;
text-align: center; text-align: center;

View File

@ -20,7 +20,12 @@ const state = useState();
const currentUser = ref(state.getUser()); const currentUser = ref(state.getUser());
const newNote = ref(''); const newNote = ref('');
const vnPaginateRef = ref(); const vnPaginateRef = ref();
function handleKeyUp(event) {
if (event.key === 'Enter') {
event.preventDefault();
if (!event.shiftKey) insert();
}
}
async function insert() { async function insert() {
const body = $props.body; const body = $props.body;
Object.assign(body, { text: newNote.value }); Object.assign(body, { text: newNote.value });
@ -48,12 +53,12 @@ async function insert() {
size="lg" size="lg"
autogrow autogrow
autofocus autofocus
@keyup.ctrl.enter.stop="insert" @keyup="handleKeyUp"
clearable clearable
> >
<template #append <template #append>
><QBtn <QBtn
:title="t('Save (ctrl + Enter)')" :title="t('Save (Enter)')"
icon="save" icon="save"
color="primary" color="primary"
flat flat
@ -130,6 +135,6 @@ async function insert() {
es: es:
Add note here...: Añadir nota aquí... Add note here...: Añadir nota aquí...
New note: Nueva nota New note: Nueva nota
Save (ctrl + Enter): Guardar (Ctrl + Intro) Save (Enter): Guardar (Intro)
</i18n> </i18n>

View File

@ -67,6 +67,10 @@ const props = defineProps({
type: String, type: String,
default: '', default: '',
}, },
makeFetch: {
type: Boolean,
default: true,
},
}); });
let arrayData = useArrayData(props.dataKey, { ...props }); let arrayData = useArrayData(props.dataKey, { ...props });
@ -94,12 +98,14 @@ async function search() {
([key, value]) => value && (props.staticParams || []).includes(key) ([key, value]) => value && (props.staticParams || []).includes(key)
); );
store.skip = 0; store.skip = 0;
await arrayData.applyFilter({
params: { if (props.makeFetch)
...Object.fromEntries(staticParams), await arrayData.applyFilter({
search: searchText.value, params: {
}, ...Object.fromEntries(staticParams),
}); search: searchText.value,
},
});
if (!props.redirect) return; if (!props.redirect) return;

View File

@ -18,7 +18,7 @@ onMounted(() => {
const observer = new MutationObserver( const observer = new MutationObserver(
() => () =>
(hasContent.value = (hasContent.value =
actions.value.childNodes.length + data.value.childNodes.length) actions.value?.childNodes?.length + data.value?.childNodes?.length)
); );
if (actions.value) observer.observe(actions.value, opts); if (actions.value) observer.observe(actions.value, opts);
if (data.value) observer.observe(data.value, opts); if (data.value) observer.observe(data.value, opts);

33
src/composables/useAcl.js Normal file
View File

@ -0,0 +1,33 @@
import axios from 'axios';
import { useState } from './useState';
export function useAcl() {
const state = useState();
async function fetch() {
const { data } = await axios.get('VnUsers/acls');
const acls = {};
data.forEach((acl) => {
acls[acl.model] = acls[acl.model] || {};
acls[acl.model][acl.property] = acls[acl.model][acl.property] || {};
acls[acl.model][acl.property][acl.accessType] = true;
});
state.setAcls(acls);
}
function hasAny(model, prop, accessType) {
const acls = state.getAcls().value[model];
if (acls)
return ['*', prop].some((key) => {
const acl = acls[key];
return acl && (acl['*'] || acl[accessType]);
});
}
return {
fetch,
hasAny,
state,
};
}

View File

@ -6,7 +6,7 @@ import { buildFilter } from 'filters/filterPanel';
const arrayDataStore = useArrayDataStore(); const arrayDataStore = useArrayDataStore();
export function useArrayData(key, userOptions) { export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
if (!key) throw new Error('ArrayData: A key is required to use this composable'); if (!key) throw new Error('ArrayData: A key is required to use this composable');
if (!arrayDataStore.get(key)) arrayDataStore.set(key); if (!arrayDataStore.get(key)) arrayDataStore.set(key);

View File

@ -1,5 +1,6 @@
import { useState } from './useState'; import { useState } from './useState';
import { useRole } from './useRole'; import { useRole } from './useRole';
import { useAcl } from './useAcl';
import { useUserConfig } from './useUserConfig'; import { useUserConfig } from './useUserConfig';
import axios from 'axios'; import axios from 'axios';
import useNotify from './useNotify'; import useNotify from './useNotify';
@ -88,6 +89,7 @@ export function useSession() {
setSession(data); setSession(data);
await useRole().fetch(); await useRole().fetch();
await useAcl().fetch();
await useUserConfig().fetch(); await useUserConfig().fetch();
await useTokenConfig().fetch(); await useTokenConfig().fetch();

View File

@ -11,8 +11,11 @@ const user = ref({
companyFk: null, companyFk: null,
warehouseFk: null, warehouseFk: null,
}); });
if (sessionStorage.getItem('user'))
user.value = JSON.parse(sessionStorage.getItem('user'));
const roles = ref([]); const roles = ref([]);
const acls = ref([]);
const tokenConfig = ref({}); const tokenConfig = ref({});
const drawer = ref(true); const drawer = ref(true);
const headerMounted = ref(false); const headerMounted = ref(false);
@ -25,7 +28,10 @@ export function useState() {
} }
function setUser(data) { function setUser(data) {
user.value = data; const currentUser = { ...JSON.parse(sessionStorage.getItem('user')), ...data };
sessionStorage.setItem('user', JSON.stringify(currentUser));
user.value = currentUser;
return currentUser;
} }
function getRoles() { function getRoles() {
@ -37,6 +43,14 @@ export function useState() {
function setRoles(data) { function setRoles(data) {
roles.value = data; roles.value = data;
} }
function getAcls() {
return computed(() => acls.value);
}
function setAcls(data) {
acls.value = data;
}
function getTokenConfig() { function getTokenConfig() {
return computed(() => { return computed(() => {
return tokenConfig.value; return tokenConfig.value;
@ -64,6 +78,8 @@ export function useState() {
setUser, setUser,
getRoles, getRoles,
setRoles, setRoles,
getAcls,
setAcls,
getTokenConfig, getTokenConfig,
setTokenConfig, setTokenConfig,
set, set,

View File

@ -0,0 +1,6 @@
import toCurrency from './toCurrency';
export default function (value) {
if (value == null || value === '') return () => '-';
return () => toCurrency(value);
}

View File

@ -10,6 +10,7 @@ import toLowerCamel from './toLowerCamel';
import dashIfEmpty from './dashIfEmpty'; import dashIfEmpty from './dashIfEmpty';
import dateRange from './dateRange'; import dateRange from './dateRange';
import toHour from './toHour'; import toHour from './toHour';
import dashOrCurrency from './dashOrCurrency';
export { export {
toLowerCase, toLowerCase,
@ -17,6 +18,7 @@ export {
toDate, toDate,
toHour, toHour,
toDateString, toDateString,
dashOrCurrency,
toDateHourMin, toDateHourMin,
toDateHourMinSec, toDateHourMinSec,
toRelativeDate, toRelativeDate,

View File

@ -103,6 +103,8 @@ globals:
deliveryList: Delivery days deliveryList: Delivery days
upcomingList: Upcoming deliveries upcomingList: Upcoming deliveries
role: Role role: Role
alias: Alias
aliasUsers: Users
subRoles: Subroles subRoles: Subroles
inheritedRoles: Inherited Roles inheritedRoles: Inherited Roles
created: Created created: Created
@ -394,6 +396,7 @@ entry:
type: Type type: Type
color: Color color: Color
id: ID id: ID
printedStickers: Printed stickers
notes: notes:
observationType: Observation type observationType: Observation type
descriptor: descriptor:
@ -470,6 +473,7 @@ ticket:
agency: Agency agency: Agency
zone: Zone zone: Zone
warehouse: Warehouse warehouse: Warehouse
collection: Collection
route: Route route: Route
invoice: Invoice invoice: Invoice
shipped: Shipped shipped: Shipped
@ -579,6 +583,9 @@ claim:
created: Created created: Created
state: State state: State
pickup: Pick up pickup: Pick up
null: No
agency: Agency
delivery: Delivery
photo: photo:
fileDescription: 'Claim id {claimId} from client {clientName} id {clientId}' fileDescription: 'Claim id {claimId} from client {clientName} id {clientId}'
noData: 'There are no images/videos, click here or drag and drop the file' noData: 'There are no images/videos, click here or drag and drop the file'
@ -960,7 +967,7 @@ roadmap:
route: route:
pageTitles: pageTitles:
routes: Routes routes: Routes
cmrsList: External CMRs list cmrsList: CMRs list
RouteList: List RouteList: List
routeCreate: New route routeCreate: New route
basicData: Basic Data basicData: Basic Data
@ -1187,6 +1194,7 @@ item:
available: Available available: Available
warehouseText: 'Calculated on the warehouse of { warehouseName }' warehouseText: 'Calculated on the warehouse of { warehouseName }'
itemDiary: Item diary itemDiary: Item diary
producer: Producer
list: list:
id: Identifier id: Identifier
grouping: Grouping grouping: Grouping

View File

@ -103,6 +103,8 @@ globals:
deliveryList: Días de entrega deliveryList: Días de entrega
upcomingList: Próximos repartos upcomingList: Próximos repartos
role: Role role: Role
alias: Alias
aliasUsers: Usuarios
subRoles: Subroles subRoles: Subroles
inheritedRoles: Roles heredados inheritedRoles: Roles heredados
workers: Trabajadores workers: Trabajadores
@ -393,6 +395,7 @@ entry:
type: Tipo type: Tipo
color: Color color: Color
id: ID id: ID
printedStickers: Etiquetas impresas
notes: notes:
observationType: Tipo de observación observationType: Tipo de observación
descriptor: descriptor:
@ -469,6 +472,7 @@ ticket:
agency: Agencia agency: Agencia
zone: Zona zone: Zona
warehouse: Almacén warehouse: Almacén
collection: Colección
route: Ruta route: Ruta
invoice: Factura invoice: Factura
shipped: Enviado shipped: Enviado
@ -949,7 +953,7 @@ roadmap:
route: route:
pageTitles: pageTitles:
routes: Rutas routes: Rutas
cmrsList: Listado de CMRs externos cmrsList: Listado de CMRs
RouteList: Listado RouteList: Listado
routeCreate: Nueva ruta routeCreate: Nueva ruta
basicData: Datos básicos basicData: Datos básicos
@ -1177,6 +1181,7 @@ item:
available: Disponible available: Disponible
warehouseText: 'Calculado sobre el almacén de { warehouseName }' warehouseText: 'Calculado sobre el almacén de { warehouseName }'
itemDiary: Registro de compra-venta itemDiary: Registro de compra-venta
producer: Productor
list: list:
id: Identificador id: Identificador
grouping: Grouping grouping: Grouping

View File

@ -0,0 +1,104 @@
<script setup>
import { useI18n } from 'vue-i18n';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnInput from 'src/components/common/VnInput.vue';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
const { t } = useI18n();
const { notify } = useNotify();
const onSynchronizeAll = async () => {
try {
notify(t('Synchronizing in the background'), 'positive');
await axios.patch(`Accounts/syncAll`);
} catch (error) {
console.error('Error synchronizing all accounts', error);
}
};
const onSynchronizeRoles = async () => {
try {
await axios.patch(`RoleInherits/sync`);
notify(t('Roles synchronized!'), 'positive');
} catch (error) {
console.error('Error synchronizing roles', error);
}
};
</script>
<template>
<QPage>
<VnSubToolbar />
<FormModel
:url="`AccountConfigs/${1}`"
:url-update="`AccountConfigs/${1}`"
model="AccountAccounts"
auto-load
>
<template #moreActions>
<QBtn
class="q-ml-none"
color="primary"
:label="t('accounts.syncAll')"
@click="onSynchronizeAll()"
/>
<QBtn
color="primary"
:label="t('accounts.syncRoles')"
@click="onSynchronizeRoles()"
/>
</template>
<template #form="{ data }">
<div class="q-gutter-y-sm">
<VnInput :label="t('accounts.homedir')" v-model="data.homedir" />
<VnInput :label="t('accounts.shell')" v-model="data.shell" />
<VnInput
:label="t('accounts.idBase')"
v-model="data.idBase"
type="number"
min="0"
/>
<VnRow>
<VnInput
:label="t('accounts.min')"
v-model="data.min"
type="number"
min="0"
/>
<VnInput
:label="t('accounts.max')"
v-model="data.max"
type="number"
min="0"
/>
</VnRow>
<VnRow>
<VnInput
:label="t('accounts.warn')"
v-model="data.warn"
type="number"
min="0"
/>
<VnInput
:label="t('accounts.inact')"
v-model="data.inact"
type="number"
min="0"
/>
</VnRow>
</div>
</template>
</FormModel>
</QPage>
</template>
<i18n>
es:
Roles synchronized!: ¡Roles sincronizados!
Synchronizing in the background: Sincronizando en segundo plano
</i18n>

View File

@ -0,0 +1,151 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { ref } from 'vue';
import FetchData from 'components/FetchData.vue';
import VnPaginate from 'components/ui/VnPaginate.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
import CardList from 'src/components/ui/CardList.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import AclFilter from './Acls/AclFilter.vue';
import AclFormView from './Acls/AclFormView.vue';
import { useVnConfirm } from 'composables/useVnConfirm';
import { useStateStore } from 'stores/useStateStore';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
defineProps({
id: {
type: Number,
default: 0,
},
});
const { notify } = useNotify();
const { t } = useI18n();
const stateStore = useStateStore();
const { openConfirmationModal } = useVnConfirm();
const paginateRef = ref();
const formDialog = ref(false);
const rolesOptions = ref([]);
const exprBuilder = (param, value) => {
switch (param) {
case 'search':
return { model: { like: `%${value}%` } };
default:
return { [param]: value };
}
};
const deleteAcl = async (id) => {
try {
await axios.delete(`ACLs/${id}`);
paginateRef.value.fetch();
notify('ACL removed', 'positive');
} catch (error) {
console.error('Error deleting Acl: ', error);
}
};
function showFormDialog(data) {
formDialog.value = {
show: true,
formInitialData: { ...data },
};
}
</script>
<template>
<FetchData
url="VnRoles"
:filter="{ fields: ['name'], order: 'name ASC' }"
@on-fetch="(data) => (rolesOptions = data)"
auto-load
/>
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#searchbar">
<VnSearchbar
data-key="AccountAcls"
url="ACLs"
:expr-builder="exprBuilder"
:label="t('acls.search')"
:info="t('acls.searchInfo')"
/>
</Teleport>
</template>
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
<QScrollArea class="fit text-grey-8">
<AclFilter data-key="AccountAcls" />
</QScrollArea>
</QDrawer>
<QPage class="flex justify-center q-pa-md">
<div class="vn-card-list">
<VnPaginate
ref="paginateRef"
data-key="AccountAcls"
url="ACLs"
:expr-builder="exprBuilder"
>
<template #body="{ rows }">
<CardList
v-for="row of rows"
:id="row.id"
:key="row.id"
:title="`${row.model}.${row.property}`"
@click="showFormDialog(row)"
>
<template #list-items>
<VnLv :label="t('acls.role')" :value="row.principalId" />
<VnLv :label="t('acls.accessType')" :value="row.accessType" />
<VnLv
:label="t('acls.permissions')"
:value="row.permission"
/>
</template>
<template #actions>
<QBtn
:label="t('globals.delete')"
@click.stop="
openConfirmationModal(
t('ACL will be removed'),
t('Are you sure you want to continue?'),
() => deleteAcl(row.id)
)
"
color="primary"
style="margin-top: 15px"
/>
</template>
</CardList>
</template>
</VnPaginate>
</div>
<QDialog
v-model="formDialog.show"
transition-show="scale"
transition-hide="scale"
>
<AclFormView
:form-initial-data="formDialog.formInitialData"
@on-data-change="paginateRef.fetch()"
:roles-options="rolesOptions"
/>
</QDialog>
<QPageSticky position="bottom-right" :offset="[18, 18]">
<QBtn fab icon="add" color="primary" @click="showFormDialog()">
<QTooltip class="text-no-wrap">{{ t('New ACL') }}</QTooltip>
</QBtn>
</QPageSticky>
</QPage>
</template>
<i18n>
es:
New ACL: Nuevo ACL
ACL removed: ACL eliminado
ACL will be removed: El ACL será eliminado
Are you sure you want to continue?: ¿Seguro que quieres continuar?
</i18n>

View File

@ -0,0 +1,105 @@
<script setup>
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { ref } from 'vue';
import VnPaginate from 'components/ui/VnPaginate.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
import CardList from 'src/components/ui/CardList.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import AliasSummary from './Alias/Card/AliasSummary.vue';
import AliasCreateForm from './Alias/AliasCreateForm.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import { useStateStore } from 'stores/useStateStore';
defineProps({
id: {
type: Number,
default: 0,
},
});
const { t } = useI18n();
const { viewSummary } = useSummaryDialog();
const router = useRouter();
const stateStore = useStateStore();
const aliasCreateDialogRef = ref(null);
const exprBuilder = (param, value) => {
switch (param) {
case 'search':
return /^\d+$/.test(value)
? { id: value }
: { alias: { like: `%${value}%` } };
}
};
const navigate = (id) => router.push({ name: 'AliasSummary', params: { id } });
const openCreateModal = () => aliasCreateDialogRef.value.show();
</script>
<template>
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#searchbar">
<VnSearchbar
data-key="AccountAliasList"
url="MailAliases"
:expr-builder="exprBuilder"
:label="t('mailAlias.search')"
:info="t('mailAlias.searchInfo')"
/>
</Teleport>
</template>
<QPage class="flex justify-center q-pa-md">
<div class="vn-card-list">
<VnPaginate
ref="paginateRef"
data-key="AccountAliasList"
url="MailAliases"
:expr-builder="exprBuilder"
>
<template #body="{ rows }">
<CardList
v-for="row of rows"
:id="row.id"
:key="row.id"
:title="row.alias"
@click="navigate(row.id)"
>
<template #list-items>
<VnLv :label="t('mailAlias.alias')" :value="row.alias">
</VnLv>
<VnLv
:label="t('mailAlias.description')"
:value="row.description"
>
</VnLv>
</template>
<template #actions>
<QBtn
:label="t('components.smartCard.openSummary')"
@click.stop="viewSummary(row.id, AliasSummary)"
color="primary"
style="margin-top: 15px"
/>
</template>
</CardList>
</template>
</VnPaginate>
</div>
<QDialog
ref="aliasCreateDialogRef"
transition-show="scale"
transition-hide="scale"
>
<AliasCreateForm />
</QDialog>
<QPageSticky position="bottom-right" :offset="[18, 18]">
<QBtn fab icon="add" color="primary" @click="openCreateModal()">
<QTooltip class="text-no-wrap">{{ t('mailAlias.newAlias') }}</QTooltip>
</QBtn>
</QPageSticky>
</QPage>
</template>

View File

@ -0,0 +1,112 @@
<script setup>
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import VnPaginate from 'components/ui/VnPaginate.vue';
import CardList from 'src/components/ui/CardList.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import { toDateTimeFormat } from 'src/filters/date.js';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
import { useVnConfirm } from 'composables/useVnConfirm';
const { t } = useI18n();
const router = useRouter();
const { notify } = useNotify();
const { openConfirmationModal } = useVnConfirm();
const paginateRef = ref(null);
const filter = {
fields: ['id', 'created', 'userId'],
include: {
relation: 'user',
scope: {
fields: ['username'],
},
},
order: 'created DESC',
};
const urlPath = 'AccessTokens';
const refresh = () => paginateRef.value.fetch();
const navigate = (id) => router.push({ name: 'AccountSummary', params: { id } });
const killSession = async (id) => {
try {
await axios.delete(`${urlPath}/${id}`);
paginateRef.value.fetch();
notify(t('Session killed'), 'positive');
} catch (error) {
console.error('Error killing session', error);
}
};
</script>
<template>
<QPage class="column items-center q-pa-md">
<div class="vn-card-list">
<VnPaginate
:data-key="urlPath"
ref="paginateRef"
:filter="filter"
:url="urlPath"
order="created DESC"
auto-load
>
<template #body="{ rows }">
<CardList
:key="row.id"
:title="row.user?.username"
@click="navigate(row.userId)"
v-for="row of rows"
>
<template #list-items>
<div style="flex-direction: column; width: 100%">
<VnLv
:label="t('connections.username')"
:value="row.user?.username"
>
</VnLv>
<VnLv
:label="t('connections.created')"
:value="toDateTimeFormat(row.created)"
>
</VnLv>
</div>
</template>
<template #actions>
<QBtn
class="q-mt-xs"
:label="t('connections.killSession')"
@click.stop="
openConfirmationModal(
t('Session will be killed'),
t('Are you sure you want to continue?'),
() => killSession(row.id)
)
"
outline
/>
</template>
</CardList>
</template>
</VnPaginate>
</div>
<QPageSticky position="bottom-right" :offset="[18, 18]">
<QBtn fab icon="refresh" color="primary" @click="refresh()">
<QTooltip>{{ t('connections.refresh') }}</QTooltip>
</QBtn>
</QPageSticky>
</QPage>
</template>
<i18n>
es:
Session killed: Sesión matada
Session will be killed: Se va a matar la sesión
Are you sure you want to continue?: ¿Seguro que quieres continuar?
</i18n>

View File

@ -0,0 +1,171 @@
<script setup>
import { ref, onMounted, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import { useArrayData } from 'src/composables/useArrayData';
import useNotify from 'src/composables/useNotify.js';
import axios from 'axios';
const { t } = useI18n();
const { notify } = useNotify();
const arrayData = useArrayData('AccountLdap');
const URL_UPDATE = `LdapConfigs/${1}`;
const URL_CREATE = `LdapConfigs`;
const DEFAULT_DATA = {
id: 1,
hasData: false,
groupDn: null,
password: null,
rdn: null,
server: null,
userDn: null,
};
const initialData = ref({
...DEFAULT_DATA,
});
const hasData = computed({
get: () => initialData.value.hasData,
set: (val) => {
initialData.value.hasData = val;
if (!val) formCustomFn.value = deleteMailForward;
else formCustomFn.value = null;
},
});
const initialDataLoaded = ref(false);
const formUrlCreate = ref(null);
const formUrlUpdate = ref(null);
const formCustomFn = ref(null);
const onTestConection = async () => {
try {
await axios.get(`LdapConfigs/test`);
notify(t('LDAP connection established!'), 'positive');
} catch (error) {
console.error('Error testing connection', error);
}
};
const getInitialLdapConfig = async () => {
try {
initialDataLoaded.value = false;
const { data } = await axios.get(URL_UPDATE);
initialData.value = data;
hasData.value = true;
return data;
} catch (error) {
hasData.value = false;
arrayData.destroy();
console.error('Error fetching initial LDAP config', error);
return null;
} finally {
// Si asignamos un valor a urlUpdate, debemos asignar null a urlCreate y viceversa, ya puede causar problemas en formModel
if (hasData.value) {
formUrlUpdate.value = URL_UPDATE;
formUrlCreate.value = null;
} else {
formUrlUpdate.value = null;
formUrlCreate.value = URL_CREATE;
}
initialDataLoaded.value = true;
}
};
const deleteMailForward = async () => {
try {
await axios.delete(URL_UPDATE);
initialData.value = { ...DEFAULT_DATA };
hasData.value = false;
notify(t('globals.dataSaved'), 'positive');
} catch (err) {
console.error('Error deleting mail forward', err);
}
};
onMounted(async () => await getInitialLdapConfig());
</script>
<template>
<QPage>
<VnSubToolbar />
<FormModel
:key="initialDataLoaded"
model="AccountLdap"
:form-initial-data="initialData"
:url-create="formUrlCreate"
:url-update="formUrlUpdate"
:save-fn="formCustomFn"
auto-load
@on-data-saved="getInitialLdapConfig()"
>
<template #moreActions>
<QBtn
class="q-ml-none"
color="primary"
:label="t('ldap.testConnection')"
@click="onTestConection()"
>
<QTooltip>
{{ t('ldap.testConnection') }}
</QTooltip>
</QBtn>
</template>
<template #form="{ data, validate }">
<VnRow class="row q-gutter-md">
<div class="col">
<QCheckbox
:label="t('ldap.enableSync')"
v-model="data.hasData"
@update:model-value="($event) => (hasData = $event)"
:toggle-indeterminate="false"
/>
</div>
</VnRow>
<template v-if="hasData">
<VnInput
:label="t('ldap.server')"
clearable
v-model="data.server"
:required="true"
:rules="validate('LdapConfig.server')"
/>
<VnInput
:label="t('ldap.rdn')"
clearable
v-model="data.rdn"
:required="true"
:rules="validate('LdapConfig.rdn')"
/>
<VnInput
:label="t('ldap.password')"
clearable
type="password"
v-model="data.password"
:required="true"
:rules="validate('LdapConfig.password')"
/>
<VnInput :label="t('ldap.userDN')" clearable v-model="data.userDn" />
<VnInput
:label="t('ldap.groupDN')"
clearable
v-model="data.groupDn"
/>
</template>
</template>
</FormModel>
</QPage>
</template>
<i18n>
es:
LDAP connection established!: ¡Conexión con LDAP establecida!
</i18n>

View File

@ -1 +1 @@
<template>account list view</template> <template>Account list</template>

View File

@ -0,0 +1,187 @@
<script setup>
import { ref, onMounted, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import { useArrayData } from 'src/composables/useArrayData';
import useNotify from 'src/composables/useNotify.js';
import axios from 'axios';
const { t } = useI18n();
const { notify } = useNotify();
const arrayData = useArrayData('AccountSamba');
const formModel = ref(null);
const URL_UPDATE = `SambaConfigs/${1}`;
const URL_CREATE = `SambaConfigs`;
const DEFAULT_DATA = {
id: 1,
hasData: false,
adDomain: null,
adController: null,
adUser: null,
adPassword: null,
userDn: null,
verifyCert: false,
};
const initialData = ref({
...DEFAULT_DATA,
});
const hasData = computed({
get: () => initialData.value.hasData,
set: (val) => {
initialData.value.hasData = val;
if (!val) formCustomFn.value = deleteMailForward;
else formCustomFn.value = null;
},
});
const initialDataLoaded = ref(false);
const formUrlCreate = ref(null);
const formUrlUpdate = ref(null);
const formCustomFn = ref(null);
const onTestConection = async () => {
try {
await axios.get(`SambaConfigs/test`);
notify(t('Samba connection established!'), 'positive');
} catch (error) {
console.error('Error testing connection', error);
}
};
const getInitialSambaConfig = async () => {
try {
initialDataLoaded.value = false;
const { data } = await axios.get(URL_UPDATE);
initialData.value = data;
hasData.value = true;
return data;
} catch (error) {
hasData.value = false;
arrayData.destroy();
console.error('Error fetching initial Samba config', error);
return null;
} finally {
if (hasData.value) {
formUrlUpdate.value = URL_UPDATE;
formUrlCreate.value = null;
} else {
formUrlUpdate.value = null;
formUrlCreate.value = URL_CREATE;
}
initialDataLoaded.value = true;
}
};
const deleteMailForward = async () => {
try {
await axios.delete(URL_UPDATE);
initialData.value = { ...DEFAULT_DATA };
hasData.value = false;
notify(t('globals.dataSaved'), 'positive');
} catch (err) {
console.error('Error deleting mail forward', err);
}
};
onMounted(async () => await getInitialSambaConfig());
</script>
<template>
<QPage>
<VnSubToolbar />
<FormModel
ref="formModel"
:key="initialDataLoaded"
model="AccountSamba"
:form-initial-data="initialData"
:url-create="formUrlCreate"
:url-update="formUrlUpdate"
:save-fn="formCustomFn"
auto-load
@on-data-saved="getInitialSambaConfig()"
>
<template #moreActions>
<QBtn
class="q-ml-none"
color="primary"
:label="t('samba.testConnection')"
:disable="formModel.hasChanges"
@click="onTestConection()"
>
<QTooltip>
{{ t('samba.testConnection') }}
</QTooltip>
</QBtn>
</template>
<template #form="{ data, validate }">
<VnRow class="row q-gutter-md">
<div class="col">
<QCheckbox
:label="t('samba.enableSync')"
v-model="data.hasData"
@update:model-value="($event) => (hasData = $event)"
:toggle-indeterminate="false"
/>
</div>
</VnRow>
<template v-if="hasData">
<VnInput
:label="t('samba.domainAD')"
clearable
v-model="data.adDomain"
:required="true"
:rules="validate('SambaConfigs.server')"
/>
<VnInput
:label="t('samba.domainController')"
clearable
v-model="data.adController"
:required="true"
:rules="validate('SambaConfigs.adController')"
/>
<VnInput
:label="t('samba.userAD')"
clearable
v-model="data.adUser"
:rules="validate('SambaConfigs.adUser')"
/>
<VnInput
:label="t('samba.passwordAD')"
clearable
type="password"
v-model="data.adPassword"
/>
<VnInput
:label="t('samba.domainPart')"
clearable
v-model="data.userDn"
:required="true"
:rules="validate('SambaConfigs.userDn')"
/>
<QCheckbox
:label="t('samba.verifyCertificate')"
v-model="data.verifyCert"
:rules="validate('SambaConfigs.groupDn')"
:toggle-indeterminate="false"
/>
</template>
</template>
</FormModel>
</QPage>
</template>
<i18n>
es:
Samba connection established!: ¡Conexión con LDAP establecida!
</i18n>

View File

@ -0,0 +1,128 @@
<script setup>
import { ref, onBeforeMount } from 'vue';
import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue';
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import VnSelect from 'components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue';
import { useValidator } from 'src/composables/useValidator';
const props = defineProps({
dataKey: {
type: String,
required: true,
},
});
const { t } = useI18n();
const validationsStore = useValidator();
const { models } = validationsStore;
const validations = ref([]);
const accessTypes = [{ name: '*' }, { name: 'READ' }, { name: 'WRITE' }];
const permissions = [{ name: 'ALLOW' }, { name: 'DENY' }];
const rolesOptions = ref([]);
onBeforeMount(() => {
for (let model in models) validations.value.push({ name: model });
});
</script>
<template>
<FetchData
url="VnRoles"
:filter="{ fields: ['name'], order: 'name ASC' }"
@on-fetch="(data) => (rolesOptions = data)"
auto-load
/>
<VnFilterPanel
:data-key="props.dataKey"
:search-button="true"
:hidden-tags="['search']"
>
<template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs">
<strong>{{ t(`acls.aclFilter.${tag.label}`) }}: </strong>
<span>{{ formatFn(tag.value) }}</span>
</div>
</template>
<template #body="{ params, searchFn }">
<QItem class="q-mb-sm">
<QItemSection>
<VnSelect
:label="t('acls.aclFilter.principalId')"
v-model="params.principalId"
@update:model-value="searchFn()"
:options="rolesOptions"
option-value="name"
option-label="name"
use-input
dense
outlined
rounded
/>
</QItemSection>
</QItem>
<QItem class="q-mb-sm">
<QItemSection>
<VnSelect
:label="t('acls.aclFilter.model')"
v-model="params.model"
@update:model-value="searchFn()"
:options="validations"
option-value="name"
option-label="name"
use-input
dense
outlined
rounded
/>
</QItemSection>
</QItem>
<QItem class="q-mb-sm">
<QItemSection>
<VnInput
:label="t('acls.aclFilter.property')"
v-model="params.property"
lazy-rules
is-outlined
/>
</QItemSection>
</QItem>
<QItem class="q-mb-sm">
<QItemSection>
<VnSelect
:label="t('acls.aclFilter.accessType')"
v-model="params.accessType"
@update:model-value="searchFn()"
:options="accessTypes"
option-value="name"
option-label="name"
use-input
dense
outlined
rounded
/>
</QItemSection>
</QItem>
<QItem class="q-mb-sm">
<QItemSection>
<VnSelect
:label="t('acls.aclFilter.permission')"
v-model="params.permission"
@update:model-value="searchFn()"
:options="permissions"
option-value="name"
option-label="name"
use-input
dense
outlined
rounded
/>
</QItemSection>
</QItem>
</template>
</VnFilterPanel>
</template>

View File

@ -0,0 +1,126 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { ref, onBeforeMount, onMounted } from 'vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FormModelPopup from 'components/FormModelPopup.vue';
import { useValidator } from 'src/composables/useValidator';
import { useArrayData } from 'src/composables/useArrayData';
const emit = defineEmits(['onDataChange']);
const { t } = useI18n();
const validationsStore = useValidator();
const { models } = validationsStore;
const arrayData = useArrayData('aclCreate');
const { store } = arrayData;
const accessTypes = [{ name: '*' }, { name: 'READ' }, { name: 'WRITE' }];
const permissions = [{ name: 'ALLOW' }, { name: 'DENY' }];
const validations = ref([]);
const url = ref();
const urlCreate = ref('ACLs');
const urlUpdate = ref();
const action = ref('New');
const $props = defineProps({
formInitialData: {
type: Object,
default: () => {
return {
property: '*',
principalType: 'ROLE',
accessType: 'READ',
permission: 'ALLOW',
};
},
},
rolesOptions: {
type: Array,
required: true,
},
});
onBeforeMount(() => {
for (let model in models) validations.value.push({ name: model });
});
onMounted(() => {
store.data = $props.formInitialData;
if ($props.formInitialData.id) {
urlCreate.value = null;
urlUpdate.value = 'ACLs';
action.value = 'Edit';
}
});
</script>
<template>
<FormModelPopup
v-if="urlCreate || urlUpdate"
:title="t(`${action} ACL`)"
:url="url"
:url-update="urlUpdate"
:url-create="urlCreate"
:form-initial-data="formInitialData"
auto-load
model="aclCreate"
@on-data-saved="emit('onDataChange')"
@on-data-canceled="emit('onDataChange')"
>
<template #form-inputs="{ data }">
<div class="column q-gutter-y-md">
<VnSelect
:label="t('acls.aclFilter.principalId')"
v-model="data.principalId"
:options="$props.rolesOptions"
option-value="name"
option-label="name"
use-input
rounded
/>
<VnSelect
:label="t('acls.aclFilter.model')"
v-model="data.model"
:options="validations"
option-value="name"
option-label="name"
use-input
rounded
/>
<VnInput
:label="t('acls.aclFilter.property')"
v-model="data.property"
lazy-rules
>
<template #append>
<QIcon name="info" class="cursor-pointer">
<QTooltip>{{ t('acls.tooltip') }}</QTooltip>
</QIcon>
</template></VnInput
>
<VnSelect
:label="t('acls.aclFilter.accessType')"
v-model="data.accessType"
:options="accessTypes"
option-value="name"
option-label="name"
use-input
rounded
/>
<VnSelect
:label="t('acls.aclFilter.permission')"
v-model="data.permission"
:options="permissions"
option-value="name"
option-label="name"
use-input
rounded
/>
</div>
</template>
</FormModelPopup>
</template>

View File

@ -0,0 +1,57 @@
<script setup>
import { useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import FormModelPopup from 'components/FormModelPopup.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import { useArrayData } from 'src/composables/useArrayData';
const router = useRouter();
const { t } = useI18n();
const arrayData = useArrayData('AliasCreate');
const { store } = arrayData;
const defaultInitialData = {
alias: null,
description: null,
};
const onDataSaved = ({ id }) => {
router.push({ name: 'AliasBasicData', params: { id } });
store.data = null;
};
</script>
<template>
<FormModelPopup
:title="t('Create alias')"
ref="formModelPopupRef"
url-create="MailAliases"
model="AliasCreate"
:form-initial-data="defaultInitialData"
@on-data-saved="onDataSaved"
>
<template #form-inputs="{ data }">
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<VnInput v-model="data.alias" :label="t('mailAlias.name')" />
</div>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<VnInput
v-model="data.description"
:label="t('mailAlias.description')"
/>
</div>
</VnRow>
</template>
</FormModelPopup>
</template>
<i18n>
es:
Create alias: Crear alias
</i18n>

View File

@ -0,0 +1,20 @@
<script setup>
import { useI18n } from 'vue-i18n';
import FormModel from 'components/FormModel.vue';
import VnInput from 'src/components/common/VnInput.vue';
const { t } = useI18n();
</script>
<template>
<FormModel model="Alias">
<template #form="{ data }">
<div class="column q-gutter-y-md">
<VnInput v-model="data.alias" :label="t('mailAlias.name')" />
<VnInput v-model="data.description" :label="t('mailAlias.description')" />
<QCheckbox :label="t('mailAlias.isPublic')" v-model="data.isPublic" />
</div>
</template>
</FormModel>
</template>

View File

@ -0,0 +1,33 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { computed } from 'vue';
import VnCard from 'components/common/VnCard.vue';
import AliasDescriptor from './AliasDescriptor.vue';
const { t } = useI18n();
const route = useRoute();
const routeName = computed(() => route.name);
const customRouteRedirectName = computed(() => {
return routeName.value;
});
const searchBarDataKeys = {
AliasBasicData: 'AliasBasicData',
AliasUsers: 'AliasUsers',
};
</script>
<template>
<VnCard
data-key="Alias"
base-url="MailAliases"
:descriptor="AliasDescriptor"
:search-data-key="searchBarDataKeys[routeName]"
:search-custom-route-redirect="customRouteRedirectName"
:search-redirect="!!customRouteRedirectName"
:searchbar-label="t('mailAlias.search')"
:searchbar-info="t('mailAlias.searchInfo')"
/>
</template>

View File

@ -0,0 +1,88 @@
<script setup>
import { ref, computed } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import CardDescriptor from 'components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import useCardDescription from 'src/composables/useCardDescription';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
const $props = defineProps({
id: {
type: Number,
required: false,
default: null,
},
});
const { t } = useI18n();
const route = useRoute();
const quasar = useQuasar();
const router = useRouter();
const { notify } = useNotify();
const entityId = computed(() => {
return $props.id || route.params.id;
});
const data = ref(useCardDescription());
const setData = (entity) => (data.value = useCardDescription(entity.alias, entity.id));
const removeAlias = () => {
quasar
.dialog({
title: t('Alias will be removed'),
message: t('Are you sure you want to continue?'),
ok: {
push: true,
color: 'primary',
},
cancel: true,
})
.onOk(async () => {
try {
await axios.delete(`MailAliases/${entityId.value}`);
notify(t('Alias removed'), 'positive');
router.push({ name: 'AccountAlias' });
} catch (err) {
console.error('Error removing alias');
}
});
};
</script>
<template>
<CardDescriptor
ref="descriptor"
:url="`MailAliases/${entityId}`"
module="Alias"
@on-fetch="setData"
data-key="aliasData"
:title="data.title"
:subtitle="data.subtitle"
>
<template #menu>
<QItem v-ripple clickable @click="removeAlias()">
<QItemSection>{{ t('Delete') }}</QItemSection>
</QItem>
</template>
<template #body="{ entity }">
<VnLv :label="t('mailAlias.description')" :value="entity.description" />
</template>
</CardDescriptor>
</template>
<i18n>
en:
accountRate: Claming rate
es:
accountRate: Ratio de reclamación
Delete: Eliminar
Alias will be removed: El alias será eliminado
Are you sure you want to continue?: ¿Seguro que quieres continuar?
Alias removed: Alias eliminado
</i18n>

View File

@ -0,0 +1,49 @@
<script setup>
import { ref, computed } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import CardSummary from 'components/ui/CardSummary.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import { useArrayData } from 'src/composables/useArrayData';
const route = useRoute();
const { t } = useI18n();
const $props = defineProps({
id: {
type: Number,
default: 0,
},
});
const { store } = useArrayData('Alias');
const alias = ref(store.data);
const entityId = computed(() => $props.id || route.params.id);
</script>
<template>
<CardSummary
ref="summary"
:url="`MailAliases/${entityId}`"
@on-fetch="(data) => (alias = data)"
>
<template #header> {{ alias.id }} - {{ alias.alias }} </template>
<template #body>
<QCard class="vn-one">
<QCardSection class="q-pa-none">
<router-link
:to="{ name: 'AliasBasicData', params: { id: entityId } }"
class="header header-link"
>
{{ t('globals.summary.basicData') }}
<QIcon name="open_in_new" />
</router-link>
</QCardSection>
<VnLv :label="t('mailAlias.id')" :value="alias.id" />
<VnLv :label="t('mailAlias.description')" :value="alias.description" />
</QCard>
</template>
</CardSummary>
</template>

View File

@ -0,0 +1,122 @@
<script setup>
import { useRoute } from 'vue-router';
import { computed, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import VnPaginate from 'components/ui/VnPaginate.vue';
import { useVnConfirm } from 'composables/useVnConfirm';
import { useArrayData } from 'composables/useArrayData';
import useNotify from 'src/composables/useNotify.js';
import axios from 'axios';
const { t } = useI18n();
const { notify } = useNotify();
const route = useRoute();
const { openConfirmationModal } = useVnConfirm();
const paginateRef = ref(null);
const arrayData = useArrayData('AliasUsers');
const { store } = arrayData;
const data = computed(() => {
const dataCopy = JSON.parse(JSON.stringify(store.data));
return dataCopy.sort((a, b) => a.user?.name.localeCompare(b.user?.name));
});
const filter = {
include: {
relation: 'user',
scope: {
fields: ['id', 'name'],
},
},
};
const urlPath = computed(() => `MailAliases/${route.params.id}/accounts`);
const columns = computed(() => [
{
name: 'alias',
},
{
name: 'action',
},
]);
const deleteAlias = async (row) => {
try {
await axios.delete(`${urlPath.value}/${row.id}`);
notify(t('User removed'), 'positive');
fetchAliases();
} catch (error) {
console.error(error);
}
};
watch(
() => route.params.id,
() => {
store.url = urlPath.value;
store.filter = filter;
fetchAliases();
}
);
const fetchAliases = () => paginateRef.value.fetch();
</script>
<template>
<QPage class="column items-center q-pa-md">
<div class="full-width" style="max-width: 400px">
<VnPaginate
ref="paginateRef"
data-key="AliasUsers"
:filter="filter"
:url="urlPath"
:limit="0"
auto-load
>
<template #body>
<QTable :rows="data" :columns="columns" hide-header>
<template #body="{ row }">
<QTr>
<QTd>
<span>{{ row.user?.name }}</span>
</QTd>
<QTd style="width: 50px !important">
<QIcon
name="delete"
size="sm"
class="cursor-pointer"
color="primary"
@click="
openConfirmationModal(
t('User will be removed from alias'),
t('Are you sure you want to continue?'),
() => deleteAlias(row)
)
"
>
<QTooltip>
{{ t('Delete') }}
</QTooltip>
</QIcon>
</QTd>
</QTr>
</template>
</QTable>
</template>
</VnPaginate>
</div>
</QPage>
</template>
<i18n>
es:
User will be removed from alias: El usuario será borrado del alias
Are you sure you want to continue?: ¿Seguro que quieres continuar?
User removed: Usuario borrado
Delete: Eliminar
</i18n>

View File

@ -1,256 +0,0 @@
<script setup>
import { ref, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import CrudModel from 'components/CrudModel.vue';
import FetchData from 'components/FetchData.vue';
import VnSelect from 'components/common/VnSelect.vue';
import { tMobile } from 'composables/tMobile';
const route = useRoute();
const { t } = useI18n();
const accountDevelopmentForm = ref();
const accountReasons = ref([]);
const accountResults = ref([]);
const accountResponsibles = ref([]);
const accountRedeliveries = ref([]);
const workers = ref([]);
const selected = ref([]);
const saveButtonRef = ref();
const developmentsFilter = {
fields: [
'id',
'accountFk',
'accountReasonFk',
'accountResultFk',
'accountResponsibleFk',
'workerFk',
'accountRedeliveryFk',
],
where: {
accountFk: route.params.id,
},
};
const columns = computed(() => [
{
name: 'accountReason',
label: t('Reason'),
field: (row) => row.accountReasonFk,
sortable: true,
options: accountReasons.value,
required: true,
model: 'accountReasonFk',
optionValue: 'id',
optionLabel: 'description',
tabIndex: 1,
align: 'left',
},
{
name: 'accountResult',
label: t('Result'),
field: (row) => row.accountResultFk,
sortable: true,
options: accountResults.value,
required: true,
model: 'accountResultFk',
optionValue: 'id',
optionLabel: 'description',
tabIndex: 2,
align: 'left',
},
{
name: 'accountResponsible',
label: t('Responsible'),
field: (row) => row.accountResponsibleFk,
sortable: true,
options: accountResponsibles.value,
required: true,
model: 'accountResponsibleFk',
optionValue: 'id',
optionLabel: 'description',
tabIndex: 3,
align: 'left',
},
{
name: 'worker',
label: t('Worker'),
field: (row) => row.workerFk,
sortable: true,
options: workers.value,
model: 'workerFk',
optionValue: 'id',
optionLabel: 'nickname',
tabIndex: 4,
align: 'left',
},
{
name: 'accountRedelivery',
label: t('Redelivery'),
field: (row) => row.accountRedeliveryFk,
sortable: true,
options: accountRedeliveries.value,
required: true,
model: 'accountRedeliveryFk',
optionValue: 'id',
optionLabel: 'description',
tabIndex: 5,
align: 'left',
},
]);
</script>
<template>
<FetchData
url="AccountReasons"
order="description"
@on-fetch="(data) => (accountReasons = data)"
auto-load
/>
<FetchData
url="AccountResults"
order="description"
@on-fetch="(data) => (accountResults = data)"
auto-load
/>
<FetchData
url="AccountResponsibles"
order="description"
@on-fetch="(data) => (accountResponsibles = data)"
auto-load
/>
<FetchData
url="AccountRedeliveries"
order="description"
@on-fetch="(data) => (accountRedeliveries = data)"
auto-load
/>
<FetchData
url="Workers/search"
:where="{ active: 1 }"
order="name ASC"
@on-fetch="(data) => (workers = data)"
auto-load
/>
<CrudModel
data-key="AccountDevelopments"
url="AccountDevelopments"
model="accountDevelopment"
:filter="developmentsFilter"
ref="accountDevelopmentForm"
:data-required="{ accountFk: route.params.id }"
v-model:selected="selected"
auto-load
@save-changes="$router.push(`/account/${route.params.id}/action`)"
:default-save="false"
>
<template #body="{ rows }">
<QTable
:columns="columns"
:rows="rows"
row-key="$index"
selection="multiple"
v-model:selected="selected"
:grid="$q.screen.lt.md"
table-header-class="text-left"
>
<template #body-cell="{ row, col }">
<QTd
auto-width
@keyup.ctrl.enter.stop="accountDevelopmentForm.saveChanges()"
>
<VnSelect
v-model="row[col.model]"
:options="col.options"
:option-value="col.optionValue"
:option-label="col.optionLabel"
:autofocus="col.tabIndex == 1"
input-debounce="0"
hide-selected
>
<template #option="scope" v-if="col.name == 'worker'">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
<QItemLabel caption>
{{ scope.opt?.nickname }}
{{ scope.opt?.code }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
</QTd>
</template>
<template #item="props">
<div class="q-pa-xs col-xs-12 col-sm-6 grid-style-transition">
<QCard
bordered
flat
@keyup.ctrl.enter.stop="accountDevelopmentForm?.saveChanges()"
>
<QCardSection>
<QCheckbox v-model="props.selected" dense />
</QCardSection>
<QSeparator />
<QList dense>
<QItem v-for="col in props.cols" :key="col.name">
<QItemSection>
<VnSelect
:label="col.label"
v-model="props.row[col.model]"
:options="col.options"
:option-value="col.optionValue"
:option-label="col.optionLabel"
dense
input-debounce="0"
:autofocus="col.tabIndex == 1"
hide-selected
/>
</QItemSection>
</QItem>
</QList>
</QCard>
</div>
</template>
</QTable>
</template>
<template #moreAfterActions>
<QBtn
:label="tMobile('globals.save')"
ref="saveButtonRef"
color="primary"
icon="save"
:disable="!accountDevelopmentForm?.hasChanges"
@click="accountDevelopmentForm?.onSubmit"
:title="t('globals.save')"
/>
</template>
</CrudModel>
<QPageSticky position="bottom-right" :offset="[25, 25]">
<QBtn
fab
color="primary"
icon="add"
@keydown.tab.prevent="saveButtonRef.$el.focus()"
@click="accountDevelopmentForm.insert()"
/>
</QPageSticky>
</template>
<style lang="scss" scoped>
.grid-style-transition {
transition: transform 0.28s, background-color 0.28s;
}
</style>
<i18n>
es:
Reason: Motivo
Result: Consecuencia
Responsible: Responsable
Worker: Trabajador
Redelivery: Devolución
</i18n>

View File

@ -4,7 +4,6 @@ import { useI18n } from 'vue-i18n';
import FormModel from 'components/FormModel.vue'; import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnInputDate from 'components/common/VnInputDate.vue';
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
</script> </script>
@ -24,6 +23,11 @@ const { t } = useI18n();
/> />
</div> </div>
</VnRow> </VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<div class="col">
<QCheckbox :label="t('mailAlias.isPublic')" v-model="data.isPublic" />
</div>
</VnRow>
</template> </template>
</FormModel> </FormModel>
</template> </template>

View File

@ -2,7 +2,6 @@
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useState } from 'src/composables/useState';
import CardDescriptor from 'components/ui/CardDescriptor.vue'; import CardDescriptor from 'components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import useCardDescription from 'src/composables/useCardDescription'; import useCardDescription from 'src/composables/useCardDescription';
@ -64,7 +63,7 @@ const removeRole = () => {
ref="descriptor" ref="descriptor"
:url="`VnRoles`" :url="`VnRoles`"
:filter="filter" :filter="filter"
module="Account" module="Role"
@on-fetch="setData" @on-fetch="setData"
data-key="accountData" data-key="accountData"
:title="data.title" :title="data.title"

View File

@ -15,6 +15,7 @@ account:
privileges: Privileges privileges: Privileges
mailAlias: Mail Alias mailAlias: Mail Alias
mailForwarding: Mail Forwarding mailForwarding: Mail Forwarding
aliasUsers: Users
card: card:
name: Name name: Name
nickname: User nickname: User
@ -45,6 +46,18 @@ role:
searchInfo: Search role by id or name searchInfo: Search role by id or name
name: Name name: Name
description: Description description: Description
id: Id
mailAlias:
pageTitles:
aliasUsers: Users
search: Search mail alias
searchInfo: Search alias by id or name
alias: Alias
description: Description
id: Id
newAlias: New alias
name: Name
isPublic: Public
ldap: ldap:
enableSync: Enable synchronization enableSync: Enable synchronization
server: Server server: Server
@ -54,6 +67,7 @@ ldap:
groupDN: Group DN groupDN: Group DN
testConnection: Test connection testConnection: Test connection
success: LDAP connection established! success: LDAP connection established!
password: Password
samba: samba:
enableSync: Enable synchronization enableSync: Enable synchronization
domainController: Domain controller domainController: Domain controller
@ -65,3 +79,31 @@ samba:
verifyCertificate: Verify certificate verifyCertificate: Verify certificate
testConnection: Test connection testConnection: Test connection
success: Samba connection established! success: Samba connection established!
accounts:
homedir: Homedir base
shell: Shell
idBase: User and role base id
min: Min
max: Max
warn: Warn
inact: Inact
syncAll: Synchronize all
syncRoles: Synchronize roles
connections:
refresh: Refresh
username: Username
created: Created
killSession: Kill session
acls:
role: Role
accessType: Access type
permissions: Permission
search: Search acls
searchInfo: Search acls by model name
tooltip: Use * to match all properties
aclFilter:
principalId: Role
model: Model
property: Property
accessType: Access type
permission: Permission

View File

@ -15,6 +15,7 @@ account:
privileges: Privilegios privileges: Privilegios
mailAlias: Alias de correo mailAlias: Alias de correo
mailForwarding: Reenvío de correo mailForwarding: Reenvío de correo
aliasUsers: Usuarios
card: card:
nickname: Usuario nickname: Usuario
name: Nombre name: Nombre
@ -56,7 +57,20 @@ role:
searchInfo: Buscar rol por id o nombre searchInfo: Buscar rol por id o nombre
name: Nombre name: Nombre
description: Descripción description: Descripción
id: Id
mailAlias:
pageTitles:
aliasUsers: Usuarios
search: Buscar alias de correo
searchInfo: Buscar alias por id o nombre
alias: Alias
description: Descripción
id: Id
newAlias: Nuevo alias
name: Nombre
isPublic: Público
ldap: ldap:
password: Contraseña
enableSync: Habilitar sincronización enableSync: Habilitar sincronización
server: Servidor server: Servidor
rdn: RDN rdn: RDN
@ -73,6 +87,34 @@ samba:
userAD: Usuario AD userAD: Usuario AD
passwordAD: Contraseña AD passwordAD: Contraseña AD
domainPart: DN usuarios (sin la parte del dominio) domainPart: DN usuarios (sin la parte del dominio)
Verify certificate: Verificar certificado verifyCertificate: Verificar certificado
testConnection: Probar conexión testConnection: Probar conexión
success: ¡Conexión con Samba establecida! success: ¡Conexión con Samba establecida!
accounts:
homedir: Directorio base para carpetas de usuario
shell: Intérprete de línea de comandos
idBase: Id base usuarios y roles
min: Min
max: Max
warn: Warn
inact: Inact
syncAll: Sincronizar todo
syncRoles: Sincronizar roles
connections:
refresh: Actualizar
username: Nombre de usuario
created: Creado
killSession: Matar sesión
acls:
role: Rol
accessType: Tipo de acceso
permissions: Permiso
search: Buscar acls
searchInfo: Buscar acls por nombre
tooltip: Usa * para marcar todas las propiedades
aclFilter:
principalId: Rol
model: Modelo
property: Propiedad
accessType: Tipo de acceso
permission: Permiso

View File

@ -158,8 +158,7 @@ const statesFilter = {
map-options map-options
use-input use-input
:input-debounce="0" :input-debounce="0"
> />
</QSelect>
</VnRow> </VnRow>
</template> </template>
</FormModel> </FormModel>

View File

@ -1,7 +1,6 @@
<script setup> <script setup>
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { useStateStore } from 'stores/useStateStore';
import { toDate } from 'filters/index'; import { toDate } from 'filters/index';
import VnPaginate from 'src/components/ui/VnPaginate.vue'; import VnPaginate from 'src/components/ui/VnPaginate.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnSearchbar from 'components/ui/VnSearchbar.vue';
@ -14,7 +13,6 @@ import ClaimSummary from './Card/ClaimSummary.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import RightMenu from 'src/components/common/RightMenu.vue'; import RightMenu from 'src/components/common/RightMenu.vue';
const stateStore = useStateStore();
const router = useRouter(); const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();

View File

@ -234,7 +234,7 @@ const showBalancePdf = (balance) => {
<template #body-cell-employee="{ row }"> <template #body-cell-employee="{ row }">
<QTd auto-width @click.stop> <QTd auto-width @click.stop>
<QBtn color="blue" flat no-caps>{{ row.userName }}</QBtn> <QBtn color="blue" flat no-caps>{{ row.userName }}</QBtn>
<WorkerDescriptorProxy :id="row.clientFk" /> <WorkerDescriptorProxy :id="row.workerFk" />
</QTd> </QTd>
</template> </template>

View File

@ -2,7 +2,6 @@
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import { useVnConfirm } from 'composables/useVnConfirm'; import { useVnConfirm } from 'composables/useVnConfirm';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import CardDescriptor from 'src/components/ui/CardDescriptor.vue'; import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
@ -23,7 +22,6 @@ const $props = defineProps({
}, },
}); });
const quasar = useQuasar();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();

View File

@ -82,6 +82,16 @@ const tableColumnComponents = computed(() => ({
}, },
event: getInputEvents, event: getInputEvents,
}, },
printedStickers: {
component: VnInput,
props: {
type: 'number',
min: 0,
class: 'input-number',
dense: true,
},
event: getInputEvents,
},
weight: { weight: {
component: VnInput, component: VnInput,
props: { props: {
@ -147,7 +157,7 @@ const entriesTableColumns = computed(() => {
return [ return [
{ {
label: t('entry.summary.item'), label: t('entry.summary.item'),
field: 'id', field: 'itemFk',
name: 'item', name: 'item',
align: 'left', align: 'left',
}, },
@ -169,6 +179,12 @@ const entriesTableColumns = computed(() => {
name: 'stickers', name: 'stickers',
align: 'left', align: 'left',
}, },
{
label: t('entry.buys.printedStickers'),
field: 'printedStickers',
name: 'printedStickers',
align: 'left',
},
{ {
label: t('entry.summary.weight'), label: t('entry.summary.weight'),
field: 'weight', field: 'weight',
@ -216,7 +232,6 @@ const entriesTableColumns = computed(() => {
}); });
const copyOriginalRowsData = (rows) => { const copyOriginalRowsData = (rows) => {
// el objetivo de esto es guardar los valores iniciales de todas las rows para evitar guardar cambios si la data no cambió al disparar los eventos
originalRowDataCopy.value = JSON.parse(JSON.stringify(rows)); originalRowDataCopy.value = JSON.parse(JSON.stringify(rows));
}; };
@ -386,19 +401,16 @@ const lockIconType = (groupingMode, mode) => {
</template> </template>
<ItemDescriptorProxy <ItemDescriptorProxy
v-if="col.name === 'item'" v-if="col.name === 'item'"
:id="props.row.id" :id="props.row.item.id"
/> />
</component> </component>
</QTd> </QTd>
</QTr> </QTr>
<QTr no-hover> <QTr no-hover class="full-width infoRow" style="column-span: all">
<QTd /> <QTd />
<QTd> <QTd cols>
<span>{{ props.row.item.itemType.code }}</span> <span>{{ props.row.item.itemType.code }}</span>
</QTd> </QTd>
<QTd>
<span>{{ props.row.item.id }}</span>
</QTd>
<QTd> <QTd>
<span>{{ props.row.item.size }}</span> <span>{{ props.row.item.size }}</span>
</QTd> </QTd>
@ -413,10 +425,6 @@ const lockIconType = (groupingMode, mode) => {
<FetchedTags :item="props.row.item" :max-length="5" /> <FetchedTags :item="props.row.item" :max-length="5" />
</QTd> </QTd>
</QTr> </QTr>
<!-- Esta última row es utilizada para agregar un espaciado y así marcar una diferencia visual entre los diferentes buys -->
<QTr v-if="props.rowIndex !== rows.length - 1" class="separation-row">
<QTd colspan="12" class="vn-table-separation-row" />
</QTr>
</template> </template>
<template #item="props"> <template #item="props">
<div class="q-pa-xs col-xs-12 col-sm-6 grid-style-transition"> <div class="q-pa-xs col-xs-12 col-sm-6 grid-style-transition">
@ -466,11 +474,13 @@ const lockIconType = (groupingMode, mode) => {
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.separation-row { .q-table--horizontal-separator tbody tr:nth-child(odd) > td {
background-color: var(--vn-section-color) !important; border-bottom-width: 0px;
border-top-width: 2px;
border-color: var(--vn-text-color);
} }
.grid-style-transition { .infoRow > td {
transition: transform 0.28s, background-color 0.28s; color: var(--vn-label-color);
} }
</style> </style>

View File

@ -174,7 +174,7 @@ const redirectToBuysView = () => {
@on-fetch="(data) => (packagingsOptions = data)" @on-fetch="(data) => (packagingsOptions = data)"
auto-load auto-load
/> />
<QForm> <QForm @submit="onSubmit()">
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown()"> <Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown()">
<div> <div>
<QBtnGroup push class="q-gutter-x-sm"> <QBtnGroup push class="q-gutter-x-sm">
@ -222,7 +222,7 @@ const redirectToBuysView = () => {
<VnRow class="row q-gutter-md q-mb-md"> <VnRow class="row q-gutter-md q-mb-md">
<VnInput <VnInput
:label="t('entry.buys.reference')" :label="t('entry.buys.reference')"
v-model="importData.ref" v-model="importData.ref"
/> />
</VnRow> </VnRow>
<VnRow class="row q-gutter-md q-mb-md"> <VnRow class="row q-gutter-md q-mb-md">

View File

@ -34,7 +34,7 @@ const entryFilter = {
{ {
relation: 'travel', relation: 'travel',
scope: { scope: {
fields: ['id', 'landed', 'agencyModeFk', 'warehouseOutFk'], fields: ['id', 'landed', 'shipped', 'agencyModeFk', 'warehouseOutFk'],
include: [ include: [
{ {
relation: 'agency', relation: 'agency',
@ -125,10 +125,8 @@ watch;
:label="t('entry.descriptor.agency')" :label="t('entry.descriptor.agency')"
:value="entity.travel?.agency?.name" :value="entity.travel?.agency?.name"
/> />
<VnLv <VnLv :label="t('shipped')" :value="toDate(entity.travel?.shipped)" />
:label="t('entry.descriptor.landed')" <VnLv :label="t('landed')" :value="toDate(entity.travel?.landed)" />
:value="toDate(entity.travel?.landed)"
/>
<VnLv <VnLv
:label="t('entry.descriptor.warehouseOut')" :label="t('entry.descriptor.warehouseOut')"
:value="entity.travel?.warehouseOut?.name" :value="entity.travel?.warehouseOut?.name"

View File

@ -221,10 +221,7 @@ const fetchEntryBuys = async () => {
:value="entry.travel.agency.name" :value="entry.travel.agency.name"
/> />
<VnLv <VnLv :label="t('shipped')" :value="toDate(entry.travel.shipped)" />
:label="t('entry.summary.travelShipped')"
:value="toDate(entry.travel.shipped)"
/>
<VnLv <VnLv
:label="t('entry.summary.travelWarehouseOut')" :label="t('entry.summary.travelWarehouseOut')"
@ -236,10 +233,7 @@ const fetchEntryBuys = async () => {
v-model="entry.travel.isDelivered" v-model="entry.travel.isDelivered"
:disable="true" :disable="true"
/> />
<VnLv <VnLv :label="t('landed')" :value="toDate(entry.travel.landed)" />
:label="t('entry.summary.travelLanded')"
:value="toDate(entry.travel.landed)"
/>
<VnLv <VnLv
:label="t('entry.summary.travelWarehouseIn')" :label="t('entry.summary.travelWarehouseIn')"

View File

@ -78,10 +78,7 @@ onMounted(async () => {
</QIcon> </QIcon>
</template> </template>
<template #list-items> <template #list-items>
<VnLv <VnLv :label="t('landed')" :value="toDate(row.landed)" />
:label="t('entry.list.landed')"
:value="toDate(row.landed)"
/>
<VnLv <VnLv
:label="t('entry.list.booked')" :label="t('entry.list.booked')"
:value="!!row.isBooked" :value="!!row.isBooked"

View File

@ -6,3 +6,5 @@ entryFilter:
filter: filter:
search: General search search: General search
reference: Reference reference: Reference
landed: Landed
shipped: Shipped

View File

@ -8,3 +8,6 @@ entryFilter:
filter: filter:
search: Búsqueda general search: Búsqueda general
reference: Referencia reference: Referencia
landed: F. llegada
shipped: F. salida

View File

@ -19,7 +19,8 @@ const { t } = useI18n();
const dms = ref({}); const dms = ref({});
const route = useRoute(); const route = useRoute();
const editDownloadDisabled = ref(false); const editDownloadDisabled = ref(false);
const invoiceIn = computed(() => useArrayData(route.meta.moduleName).store.data); const arrayData = useArrayData();
const invoiceIn = computed(() => arrayData.store.data);
const userConfig = ref(null); const userConfig = ref(null);
const invoiceId = computed(() => +route.params.id); const invoiceId = computed(() => +route.params.id);
@ -81,7 +82,7 @@ async function setCreateDms() {
createDmsRef.value.show(); createDmsRef.value.show();
} }
async function upsert() { async function onSubmit() {
try { try {
const isEdit = !!dms.value.id; const isEdit = !!dms.value.id;
const errors = { const errors = {
@ -318,224 +319,236 @@ async function upsert() {
</template> </template>
</FormModel> </FormModel>
<QDialog ref="editDmsRef"> <QDialog ref="editDmsRef">
<QCard> <QForm @submit="onSubmit()" class="all-pointer-events">
<QCardSection class="q-pb-none"> <QCard class="q-pa-sm">
<QItem class="q-px-none"> <QCardSection class="row items-center q-pb-none">
<span class="text-primary text-h6 full-width"> <span class="text-primary text-h6">
<QIcon name="edit" class="q-mr-xs" /> <QIcon name="edit" class="q-mr-xs" />
{{ t('Edit document') }} {{ t('Edit document') }}
</span> </span>
<QSpace />
<QBtn icon="close" flat round dense v-close-popup /> <QBtn icon="close" flat round dense v-close-popup />
</QItem> </QCardSection>
</QCardSection> <QCardSection class="q-py-none">
<QCardSection class="q-py-none"> <QItem>
<QItem> <VnInput
<VnInput class="full-width q-pa-xs"
class="full-width q-pa-xs" :label="t('Reference')"
:label="t('Reference')" v-model="dms.reference"
v-model="dms.reference" clearable
clearable clear-icon="close"
clear-icon="close" />
<VnSelect
class="full-width q-pa-xs"
:label="t('Company')"
v-model="dms.companyId"
:options="companies"
option-value="id"
option-label="code"
:required="true"
/>
</QItem>
<QItem>
<VnSelect
class="full-width q-pa-xs"
:label="t('Warehouse')"
v-model="dms.warehouseId"
:options="warehouses"
option-value="id"
option-label="name"
:required="true"
/>
<VnSelect
class="full-width q-pa-xs"
:label="t('Type')"
v-model="dms.dmsTypeId"
:options="dmsTypes"
option-value="id"
option-label="name"
:required="true"
/>
</QItem>
<QItem>
<VnInput
:label="t('Description')"
v-model="dms.description"
:required="true"
type="textarea"
class="full-width q-pa-xs"
size="lg"
autogrow
clearable
clear-icon="close"
/>
</QItem>
<QItem>
<QFile
ref="inputFileRef"
class="full-width q-pa-xs"
:label="t('File')"
v-model="dms.files"
multiple
:accept="allowedContentTypes.join(',')"
clearable
clear-icon="close"
>
<template #append>
<QBtn
icon="attach_file_add"
flat
round
padding="xs"
@click="inputFileRef.pickFiles()"
>
<QTooltip>
{{ t('globals.selectFile') }}
</QTooltip>
</QBtn>
<QBtn icon="info" flat round padding="xs">
<QTooltip max-width="30rem">
{{
`${t(
'Allowed content types'
)}: ${allowedContentTypes.join(', ')}`
}}
</QTooltip>
</QBtn>
</template>
</QFile>
</QItem>
<QItem>
<QCheckbox
:label="t('Generate identifier for original file')"
v-model="dms.hasFile"
/>
</QItem>
</QCardSection>
<QCardActions class="justify-end">
<QBtn
flat
:label="t('globals.close')"
color="primary"
v-close-popup
/> />
<VnSelect <QBtn :label="t('globals.save')" color="primary" @click="onSubmit" />
class="full-width q-pa-xs" </QCardActions>
:label="t('Company')" </QCard>
v-model="dms.companyId" </QForm>
:options="companies"
option-value="id"
option-label="code"
:required="true"
/>
</QItem>
<QItem>
<VnSelect
class="full-width q-pa-xs"
:label="t('Warehouse')"
v-model="dms.warehouseId"
:options="warehouses"
option-value="id"
option-label="name"
:required="true"
/>
<VnSelect
class="full-width q-pa-xs"
:label="t('Type')"
v-model="dms.dmsTypeId"
:options="dmsTypes"
option-value="id"
option-label="name"
:required="true"
/>
</QItem>
<QItem>
<VnInput
:label="t('Description')"
v-model="dms.description"
:required="true"
type="textarea"
class="full-width q-pa-xs"
size="lg"
autogrow
clearable
clear-icon="close"
/>
</QItem>
<QItem>
<QFile
ref="inputFileRef"
class="full-width q-pa-xs"
:label="t('File')"
v-model="dms.files"
multiple
:accept="allowedContentTypes.join(',')"
clearable
clear-icon="close"
>
<template #append>
<QBtn
icon="attach_file_add"
flat
round
padding="xs"
@click="inputFileRef.pickFiles()"
>
<QTooltip>
{{ t('globals.selectFile') }}
</QTooltip>
</QBtn>
<QBtn icon="info" flat round padding="xs">
<QTooltip max-width="30rem">
{{
`${t(
'Allowed content types'
)}: ${allowedContentTypes.join(', ')}`
}}
</QTooltip>
</QBtn>
</template>
</QFile>
</QItem>
<QItem>
<QCheckbox
:label="t('Generate identifier for original file')"
v-model="dms.hasFile"
/>
</QItem>
</QCardSection>
<QCardActions class="justify-end">
<QBtn flat :label="t('globals.close')" color="primary" v-close-popup />
<QBtn :label="t('globals.save')" color="primary" @click="upsert" />
</QCardActions>
</QCard>
</QDialog> </QDialog>
<QDialog ref="createDmsRef"> <QDialog ref="createDmsRef">
<QCard> <QForm @submit="onSubmit()" class="all-pointer-events">
<QCardSection class="q-pb-none"> <QCard class="q-pa-sm">
<QItem> <QCardSection class="row items-center q-pb-none">
<span class="text-primary text-h6 full-width"> <span class="text-primary text-h6">
<QIcon name="edit" class="q-mr-xs" /> <QIcon name="edit" class="q-mr-xs" />
{{ t('Create document') }} {{ t('Create document') }}
</span> </span>
<QBtn icon="close" flat round dense v-close-popup align="right" /> <QSpace />
</QItem> <QBtn icon="close" flat round dense v-close-popup />
</QCardSection> </QCardSection>
<QCardSection class="q-pb-none"> <QCardSection class="q-pb-none">
<QItem> <QItem>
<VnInput <VnInput
class="full-width q-pa-xs" class="full-width q-pa-xs"
:label="t('Reference')" :label="t('Reference')"
v-model="dms.reference" v-model="dms.reference"
/>
<VnSelect
class="full-width q-pa-xs"
:label="`${t('Company')}*`"
v-model="dms.companyId"
:options="companies"
option-value="id"
option-label="code"
:required="true"
/>
</QItem>
<QItem>
<VnSelect
class="full-width q-pa-xs"
:label="`${t('Warehouse')}*`"
v-model="dms.warehouseId"
:options="warehouses"
option-value="id"
option-label="name"
:required="true"
/>
<VnSelect
class="full-width q-pa-xs"
:label="`${t('Type')}*`"
v-model="dms.dmsTypeId"
:options="dmsTypes"
option-value="id"
option-label="name"
:required="true"
/>
</QItem>
<QItem>
<VnInput
class="full-width q-pa-xs"
type="textarea"
size="lg"
autogrow
:label="`${t('Description')}*`"
v-model="dms.description"
clearable
clear-icon="close"
:rules="[(val) => val.length || t('Required field')]"
/>
</QItem>
<QItem>
<QFile
ref="inputFileRef"
class="full-width q-pa-xs"
:label="t('File')"
v-model="dms.files"
multiple
:accept="allowedContentTypes.join(',')"
clearable
clear-icon="close"
>
<template #append>
<QBtn
icon="attach_file_add"
flat
round
padding="xs"
@click="inputFileRef.pickFiles()"
>
<QTooltip>
{{ t('globals.selectFile') }}
</QTooltip>
</QBtn>
<QBtn icon="info" flat round padding="xs">
<QTooltip max-width="30rem">
{{
`${t(
'Allowed content types'
)}: ${allowedContentTypes.join(', ')}`
}}
</QTooltip>
</QBtn>
</template>
</QFile>
</QItem>
<QItem>
<QCheckbox
:label="t('Generate identifier for original file')"
v-model="dms.hasFile"
/>
</QItem>
</QCardSection>
<QCardActions align="right">
<QBtn
flat
:label="t('globals.close')"
color="primary"
v-close-popup
/> />
<VnSelect <QBtn :label="t('globals.save')" color="primary" @click="onSubmit" />
class="full-width q-pa-xs" </QCardActions>
:label="`${t('Company')}*`" </QCard>
v-model="dms.companyId" </QForm>
:options="companies"
option-value="id"
option-label="code"
:required="true"
/>
</QItem>
<QItem>
<VnSelect
class="full-width q-pa-xs"
:label="`${t('Warehouse')}*`"
v-model="dms.warehouseId"
:options="warehouses"
option-value="id"
option-label="name"
:required="true"
/>
<VnSelect
class="full-width q-pa-xs"
:label="`${t('Type')}*`"
v-model="dms.dmsTypeId"
:options="dmsTypes"
option-value="id"
option-label="name"
:required="true"
/>
</QItem>
<QItem>
<VnInput
class="full-width q-pa-xs"
type="textarea"
size="lg"
autogrow
:label="`${t('Description')}*`"
v-model="dms.description"
clearable
clear-icon="close"
:rules="[(val) => val.length || t('Required field')]"
/>
</QItem>
<QItem>
<QFile
ref="inputFileRef"
class="full-width q-pa-xs"
:label="t('File')"
v-model="dms.files"
multiple
:accept="allowedContentTypes.join(',')"
clearable
clear-icon="close"
>
<template #append>
<QBtn
icon="attach_file_add"
flat
round
padding="xs"
@click="inputFileRef.pickFiles()"
>
<QTooltip>
{{ t('globals.selectFile') }}
</QTooltip>
</QBtn>
<QBtn icon="info" flat round padding="xs">
<QTooltip max-width="30rem">
{{
`${t(
'Allowed content types'
)}: ${allowedContentTypes.join(', ')}`
}}
</QTooltip>
</QBtn>
</template>
</QFile>
</QItem>
<QItem>
<QCheckbox
:label="t('Generate identifier for original file')"
v-model="dms.hasFile"
/>
</QItem>
</QCardSection>
<QCardActions align="right">
<QBtn flat :label="t('globals.close')" color="primary" v-close-popup />
<QBtn :label="t('globals.save')" color="primary" @click="upsert" />
</QCardActions>
</QCard>
</QDialog> </QDialog>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -12,7 +12,7 @@ const { push, currentRoute } = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const invoiceId = +currentRoute.value.params.id; const invoiceId = +currentRoute.value.params.id;
const arrayData = useArrayData(currentRoute.value.meta.moduleName); const arrayData = useArrayData();
const invoiceIn = computed(() => arrayData.store.data); const invoiceIn = computed(() => arrayData.store.data);
const invoiceInCorrectionRef = ref(); const invoiceInCorrectionRef = ref();
const filter = { const filter = {

View File

@ -27,9 +27,9 @@ const quasar = useQuasar();
const { hasAny } = useRole(); const { hasAny } = useRole();
const { t } = useI18n(); const { t } = useI18n();
const { openReport, sendEmail } = usePrintService(); const { openReport, sendEmail } = usePrintService();
const { store } = useArrayData(currentRoute.value.meta.moduleName); const arrayData = useArrayData();
const invoiceIn = computed(() => store.data); const invoiceIn = computed(() => arrayData.store.data);
const cardDescriptorRef = ref(); const cardDescriptorRef = ref();
const correctionDialogRef = ref(); const correctionDialogRef = ref();
const entityId = computed(() => $props.id || +currentRoute.value.params.id); const entityId = computed(() => $props.id || +currentRoute.value.params.id);
@ -184,7 +184,7 @@ async function toUnbook() {
: t('isNotLinked', { bookEntry }); : t('isNotLinked', { bookEntry });
quasar.notify({ type, message }); quasar.notify({ type, message });
if (!isLinked) store.data.isBooked = false; if (!isLinked) arrayData.store.data.isBooked = false;
} }
async function deleteInvoice() { async function deleteInvoice() {
@ -487,9 +487,6 @@ const createInvoiceInCorrection = async () => {
.q-dialog { .q-dialog {
.q-card { .q-card {
max-width: 45em; max-width: 45em;
.q-item__section > .q-input {
padding-bottom: 1.4em;
}
} }
} }

View File

@ -13,7 +13,7 @@ import { toCurrency } from 'src/filters';
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const arrayData = useArrayData(route.meta.moduleName); const arrayData = useArrayData();
const invoiceIn = computed(() => arrayData.store.data); const invoiceIn = computed(() => arrayData.store.data);
const rowsSelected = ref([]); const rowsSelected = ref([]);

View File

@ -11,9 +11,8 @@ import { useArrayData } from 'src/composables/useArrayData';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const currency = computed( const arrayData = useArrayData();
() => useArrayData(route.meta.moduleName).store.data?.currency?.code const currency = computed(() => arrayData.store.data?.currency?.code);
);
const invoceInIntrastat = ref([]); const invoceInIntrastat = ref([]);
const rowsSelected = ref([]); const rowsSelected = ref([]);
const countries = ref([]); const countries = ref([]);

View File

@ -14,9 +14,10 @@ import VnTitle from 'src/components/common/VnTitle.vue';
const props = defineProps({ id: { type: [Number, String], default: 0 } }); const props = defineProps({ id: { type: [Number, String], default: 0 } });
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const arrayData = useArrayData();
const entityId = computed(() => props.id || +route.params.id); const entityId = computed(() => props.id || +route.params.id);
const invoiceIn = computed(() => useArrayData(route.meta.moduleName).store.data); const invoiceIn = computed(() => arrayData.store.data);
const currency = computed(() => invoiceIn.value?.currency?.code); const currency = computed(() => invoiceIn.value?.currency?.code);
const invoiceInUrl = ref(); const invoiceInUrl = ref();
const amountsNotMatch = ref(null); const amountsNotMatch = ref(null);

View File

@ -11,13 +11,12 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import CrudModel from 'src/components/CrudModel.vue'; import CrudModel from 'src/components/CrudModel.vue';
import VnCurrency from 'src/components/common/VnCurrency.vue'; import VnCurrency from 'src/components/common/VnCurrency.vue';
const router = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const quasar = useQuasar(); const quasar = useQuasar();
const arrayData = useArrayData(router.meta.moduleName); const arrayData = useArrayData();
const invoiceIn = computed(() => arrayData.store.data); const invoiceIn = computed(() => arrayData.store.data);
const invoiceId = +router.params.id; const invoiceId = +useRoute().params.id;
const currency = computed(() => invoiceIn.value?.currency?.code); const currency = computed(() => invoiceIn.value?.currency?.code);
const expenses = ref([]); const expenses = ref([]);
const sageTaxTypes = ref([]); const sageTaxTypes = ref([]);

View File

@ -1,5 +1,4 @@
<script setup> <script setup>
import { useRoute } from 'vue-router';
import axios from 'axios'; import axios from 'axios';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
@ -10,7 +9,7 @@ const { t } = useI18n();
defineExpose({ checkToBook }); defineExpose({ checkToBook });
const { store } = useArrayData(useRoute().meta.moduleName); const { store } = useArrayData();
async function checkToBook(id) { async function checkToBook(id) {
let directBooking = true; let directBooking = true;

View File

@ -16,6 +16,7 @@ import useCardDescription from 'src/composables/useCardDescription';
import { useSession } from 'src/composables/useSession'; import { useSession } from 'src/composables/useSession';
import { getUrl } from 'src/composables/getUrl'; import { getUrl } from 'src/composables/getUrl';
import axios from 'axios'; import axios from 'axios';
import { dashIfEmpty } from 'src/filters';
const $props = defineProps({ const $props = defineProps({
id: { id: {
@ -182,6 +183,10 @@ const openCloneDialog = async () => {
</span> </span>
</template> </template>
</VnLv> </VnLv>
<VnLv
:label="t('item.descriptor.producer')"
:value="dashIfEmpty(entity.subName)"
/>
<VnLv <VnLv
v-if="entity.value5" v-if="entity.value5"
:label="t('item.descriptor.color')" :label="t('item.descriptor.color')"

View File

@ -56,7 +56,7 @@ const params = reactive({});
const arrayData = useArrayData('ItemFixedPrices', { const arrayData = useArrayData('ItemFixedPrices', {
url: 'FixedPrices/filter', url: 'FixedPrices/filter',
userParams: params, userParams: params,
order: ['itemFk'], order: ['name ASC', 'itemFk'],
exprBuilder: exprBuilder, exprBuilder: exprBuilder,
}); });
const store = arrayData.store; const store = arrayData.store;

View File

@ -33,7 +33,7 @@ const addToOrder = async () => {
<template> <template>
<div class="container order-catalog-item q-pb-md"> <div class="container order-catalog-item q-pb-md">
<QForm @submit.prevent="addToOrder"> <QForm @submit="addToOrder">
<QMarkupTable class="shadow-0"> <QMarkupTable class="shadow-0">
<tbody> <tbody>
<tr v-for="item in fields" :key="item.warehouse"> <tr v-for="item in fields" :key="item.warehouse">

View File

@ -11,13 +11,10 @@ import VnInputDate from 'components/common/VnInputDate.vue';
import VnInput from 'components/common/VnInput.vue'; import VnInput from 'components/common/VnInput.vue';
import axios from 'axios'; import axios from 'axios';
import VnInputTime from 'components/common/VnInputTime.vue'; import VnInputTime from 'components/common/VnInputTime.vue';
import RouteSearchbar from 'pages/Route/Card/RouteSearchbar.vue';
import { useStateStore } from 'stores/useStateStore';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const stateStore = useStateStore();
const shelvingId = ref(route.params?.id || null); const shelvingId = ref(route.params?.id || null);
const isNew = Boolean(!shelvingId.value); const isNew = Boolean(!shelvingId.value);
const defaultInitialData = { const defaultInitialData = {

View File

@ -1,11 +1,11 @@
<script setup> <script setup>
import { ref } from 'vue'; import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue'; import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import VnInputDate from 'components/common/VnInputDate.vue'; import VnInputDate from 'components/common/VnInputDate.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
const { t } = useI18n(); const { t } = useI18n();
const props = defineProps({ const props = defineProps({
@ -16,10 +16,11 @@ const props = defineProps({
}); });
const countries = ref(); const countries = ref();
const warehouses = ref();
</script> </script>
<template> <template>
<FetchData url="Countries" @on-fetch="(data) => (countries = data)" auto-load /> <FetchData url="Countries" @on-fetch="(data) => (countries = data)" auto-load />
<FetchData url="Warehouses" @on-fetch="(data) => (warehouses = data)" auto-load />
<VnFilterPanel :data-key="props.dataKey" :search-button="true"> <VnFilterPanel :data-key="props.dataKey" :search-button="true">
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
@ -93,13 +94,13 @@ const countries = ref();
<QItemSection v-if="!countries"> <QItemSection v-if="!countries">
<QSkeleton type="QInput" class="full-width" /> <QSkeleton type="QInput" class="full-width" />
</QItemSection> </QItemSection>
<QItemSection v-if="countries" class="q-mb-sm"> <QItemSection v-if="countries">
<QSelect <VnSelect
:label="t('route.cmr.list.country')" :label="t('route.cmr.list.country')"
v-model="params.country" v-model="params.country"
:options="countries" :options="countries"
option-value="country" option-label="name"
option-label="country" option-value="id"
transition-show="jump-down" transition-show="jump-down"
transition-hide="jump-up" transition-hide="jump-up"
emit-value emit-value
@ -111,9 +112,23 @@ const countries = ref();
<template #prepend> <template #prepend>
<QIcon name="flag" size="sm"></QIcon> <QIcon name="flag" size="sm"></QIcon>
</template> </template>
</QSelect> </VnSelect>
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem>
<VnSelect
:label="t('globals.warehouse')"
:options="warehouses"
hide-selected
option-label="name"
option-value="id"
v-model="params.warehouseFk"
rounded
dense
outlined
>
</VnSelect>
</QItem>
<QItem> <QItem>
<QItemSection> <QItemSection>
<VnInputDate <VnInputDate
@ -126,7 +141,6 @@ const countries = ref();
</template> </template>
</VnFilterPanel> </VnFilterPanel>
</template> </template>
<i18n> <i18n>
en: en:
params: params:

View File

@ -14,6 +14,7 @@ const { t } = useI18n();
const { getTokenMultimedia } = useSession(); const { getTokenMultimedia } = useSession();
const token = getTokenMultimedia(); const token = getTokenMultimedia();
const selected = ref([]); const selected = ref([]);
const warehouses = ref([]);
const columns = computed(() => [ const columns = computed(() => [
{ {
@ -63,6 +64,13 @@ const columns = computed(() => [
sortable: true, sortable: true,
headerStyle: 'padding-left: 33px', headerStyle: 'padding-left: 33px',
}, },
{
name: 'warehouseFk',
label: t('globals.warehouse'),
field: ({ warehouseFk }) => warehouseFk,
align: 'center',
sortable: true,
},
{ {
name: 'icons', name: 'icons',
align: 'center', align: 'center',
@ -99,7 +107,7 @@ function downloadPdfs() {
<div class="list"> <div class="list">
<VnPaginate <VnPaginate
data-key="CmrList" data-key="CmrList"
:url="`Routes/getExternalCmrs`" :url="`Routes/cmrs`"
order="cmrFk DESC" order="cmrFk DESC"
limit="null" limit="null"
auto-load auto-load
@ -147,6 +155,11 @@ function downloadPdfs() {
<CustomerDescriptorProxy :id="value" /> <CustomerDescriptorProxy :id="value" />
</QTd> </QTd>
</template> </template>
<template #body-cell-warehouseFk="{ value }">
<QTd align="center">
{{ warehouses.find(({ id }) => id === value)?.name }}
</QTd>
</template>
<template #body-cell-icons="{ value }"> <template #body-cell-icons="{ value }">
<QTd align="center"> <QTd align="center">
<a :href="getCmrUrl(value)" target="_blank"> <a :href="getCmrUrl(value)" target="_blank">

View File

@ -34,7 +34,7 @@ const updateDefaultStop = (data) => {
const onSave = async () => { const onSave = async () => {
isLoading.value = true; isLoading.value = true;
try { try {
await axios.post('ExpeditionTrucks', { ...roadmapStopForm }); await axios.post('RoadmapStops', { ...roadmapStopForm });
emit('ok'); emit('ok');
} finally { } finally {
isLoading.value = false; isLoading.value = false;

View File

@ -23,28 +23,43 @@ const props = defineProps({
}); });
const { t } = useI18n(); const { t } = useI18n();
const warehouseList = ref([]); const addressList = ref([]);
const form = computed(() => props.formData); const form = computed(() => props.formData);
const isDialog = computed(() => props.layout === 'dialog'); const isDialog = computed(() => props.layout === 'dialog');
const onFetch = (data) => {
addressList.value = data.map((roadmap) => ({
id: roadmap.addressFk,
nickname: roadmap.address ? roadmap.address.nickname : '',
}));
};
</script> </script>
<template> <template>
<FetchData <FetchData
url="Warehouses" url="RoadmapAddresses"
auto-load auto-load
:filter="{ fields: ['id', 'name'] }" :filter="{
sort-by="name" include: [
{
relation: 'address',
scope: {
fields: ['nickname'],
},
},
],
}"
limit="30" limit="30"
@on-fetch="(data) => (warehouseList = data)" @on-fetch="onFetch"
/> />
<div :class="[isDialog ? 'column' : 'form-gap', 'full-width flex']"> <div :class="[isDialog ? 'column' : 'form-gap', 'full-width flex']">
<QCardSection class="flex-grow q-px-none flex-1"> <QCardSection class="flex-grow q-px-none flex-1">
<VnSelect <VnSelect
v-model.number="form.warehouseFk" v-model.number="form.addressFk"
class="full-width" class="full-width"
:label="t('Warehouse')" :label="t('Address')"
:options="warehouseList" :options="addressList"
option-value="id" option-value="id"
option-label="name" option-label="nickname"
emit-value emit-value
map-options map-options
use-input use-input
@ -80,6 +95,7 @@ const isDialog = computed(() => props.layout === 'dialog');
</QCardSection> </QCardSection>
</div> </div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
.form-gap { .form-gap {
gap: 16px; gap: 16px;
@ -93,9 +109,10 @@ const isDialog = computed(() => props.layout === 'dialog');
flex: 2; flex: 2;
} }
</style> </style>
<i18n> <i18n>
es: es:
Warehouse: Almacén Address: Dirección
ETA date: Fecha ETA ETA date: Fecha ETA
ETA hour: Hora ETA ETA hour: Hora ETA
Description: Descripción Description: Descripción

View File

@ -3,7 +3,6 @@ import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import FormModel from 'components/FormModel.vue'; import FormModel from 'components/FormModel.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnInputDate from 'components/common/VnInputDate.vue'; import VnInputDate from 'components/common/VnInputDate.vue';
import VnInput from 'components/common/VnInput.vue'; import VnInput from 'components/common/VnInput.vue';
import VnInputTime from 'components/common/VnInputTime.vue'; import VnInputTime from 'components/common/VnInputTime.vue';
@ -22,7 +21,6 @@ const onSave = (data, response) => {
}; };
</script> </script>
<template> <template>
<VnSubToolbar />
<FetchData <FetchData
url="Suppliers" url="Suppliers"
auto-load auto-load

View File

@ -1,21 +1,17 @@
<script setup> <script setup>
import { useStateStore } from 'stores/useStateStore'; import VnCard from 'components/common/VnCard.vue';
import LeftMenu from 'components/LeftMenu.vue'; import RoadmapDescriptor from 'pages/Route/Roadmap/RoadmapDescriptor.vue';
import RoadmapDescriptor from "pages/Route/Roadmap/RoadmapDescriptor.vue"; import RoadmapFilter from 'pages/Route/Roadmap/RoadmapFilter.vue';
const stateStore = useStateStore();
</script> </script>
<template> <template>
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256"> <VnCard
<QScrollArea class="fit"> data-key="Roadmap"
<RoadmapDescriptor /> base-url="Roadmaps"
<QSeparator /> :descriptor="RoadmapDescriptor"
<LeftMenu source="card" /> :filter-panel="RoadmapFilter"
</QScrollArea> search-data-key="RoadmapList"
</QDrawer> search-url="Roadmaps"
<QPageContainer> searchbar-label="Search roadmap"
<QPage> searchbar-info="You can search by roadmap id or customer name"
<RouterView></RouterView> />
</QPage>
</QPageContainer>
</template> </template>

View File

@ -1,7 +1,6 @@
<script setup> <script setup>
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import { ref } from 'vue'; import { ref } from 'vue';
import CrudModel from 'components/CrudModel.vue'; import CrudModel from 'components/CrudModel.vue';
@ -23,7 +22,6 @@ const updateDefaultStop = (data) => {
}; };
</script> </script>
<template> <template>
<VnSubToolbar />
<FetchData <FetchData
:url="`Roadmaps/${route.params?.id}`" :url="`Roadmaps/${route.params?.id}`"
auto-load auto-load
@ -33,9 +31,9 @@ const updateDefaultStop = (data) => {
<div class="q-pa-lg"> <div class="q-pa-lg">
<CrudModel <CrudModel
ref="roadmapStopsCrudRef" ref="roadmapStopsCrudRef"
data-key="ExpeditionTrucks" data-key="RoadmapStops"
url="ExpeditionTrucks" url="RoadmapStops"
model="ExpeditionTrucks" model="RoadmapStops"
:filter="{ where: { roadmapFk: route.params?.id } }" :filter="{ where: { roadmapFk: route.params?.id } }"
:default-remove="false" :default-remove="false"
:data-required="defaultStop" :data-required="defaultStop"
@ -86,7 +84,7 @@ const updateDefaultStop = (data) => {
</template> </template>
<i18n> <i18n>
es: es:
Warehouse: Almacén Address: Consignatario
ETA date: Fecha ETA ETA date: Fecha ETA
ETA hour: Hora ETA ETA hour: Hora ETA
Description: Descripción Description: Descripción

View File

@ -35,9 +35,9 @@ onUnmounted(hideRightDrawer);
const columns = ref([ const columns = ref([
{ {
name: 'warehouse', name: 'address',
label: t('Warehouse'), label: t('Address'),
field: (row) => dashIfEmpty(row?.warehouse?.name), field: (row) => dashIfEmpty(row?.address?.nickname),
sortable: true, sortable: true,
align: 'left', align: 'left',
}, },
@ -54,8 +54,17 @@ const filter = {
{ relation: 'supplier' }, { relation: 'supplier' },
{ relation: 'worker' }, { relation: 'worker' },
{ {
relation: 'expeditionTruck', relation: 'roadmapStop',
scope: { include: [{ relation: 'warehouse' }] }, scope: {
include: [
{
relation: 'address',
scope: {
fields: ['nickname'],
},
},
],
},
}, },
], ],
}; };
@ -151,11 +160,9 @@ const openAddStopDialog = () => {
</div> </div>
<QTable <QTable
:columns="columns" :columns="columns"
:rows="entity?.expeditionTruck" :rows="entity?.roadmapStop"
:rows-per-page-options="[0]" :rows-per-page-options="[0]"
row-key="id" row-key="id"
flat
hide-pagination
/> />
</QCard> </QCard>
</template> </template>
@ -171,7 +178,7 @@ es:
Worker: Trabajador Worker: Trabajador
Observations: Observaciones Observations: Observaciones
Stops: Paradas Stops: Paradas
Warehouse: Almacén Address: Dirección
Go to stops: Ir a paradas Go to stops: Ir a paradas
Add stop: Añadir parada Add stop: Añadir parada
</i18n> </i18n>

View File

@ -266,9 +266,9 @@ function navigateToRoadmapSummary(event, row) {
<i18n> <i18n>
es: es:
Search roadmaps: Buscar troncales Search roadmaps: Buscar troncales
You can search by roadmap reference: Puedes buscar por referencia de la troncal You can search by roadmap reference: Puedes buscar por referencia del troncal
Delete roadmap(s): Eliminar troncal(es) Delete roadmap(s): Eliminar troncal(es)
Selected roadmaps will be removed: Las troncales seleccionadas serán eliminadas Selected roadmaps will be removed: Los troncales seleccionadas serán eliminados
Are you sure you want to continue?: ¿Seguro que quieres continuar? Are you sure you want to continue?: ¿Seguro que quieres continuar?
The date can't be empty: La fecha no puede estar vacía The date can't be empty: La fecha no puede estar vacía
Clone Selected Routes: Clonar rutas seleccionadas Clone Selected Routes: Clonar rutas seleccionadas

View File

@ -35,6 +35,7 @@ const ticket = ref();
const salesLines = ref(null); const salesLines = ref(null);
const editableStates = ref([]); const editableStates = ref([]);
const ticketUrl = ref(); const ticketUrl = ref();
const grafanaUrl = 'https://grafana.verdnatura.es';
onMounted(async () => { onMounted(async () => {
ticketUrl.value = (await getUrl('ticket/')) + entityId.value + '/'; ticketUrl.value = (await getUrl('ticket/')) + entityId.value + '/';
@ -159,6 +160,20 @@ async function changeState(value) {
:label="t('ticket.summary.warehouse')" :label="t('ticket.summary.warehouse')"
:value="ticket.warehouse?.name" :value="ticket.warehouse?.name"
/> />
<VnLv
:label="t('ticket.summary.collection')"
:value="ticket.ticketCollections[0]?.collectionFk"
>
<template #value>
<a
:href="`${grafanaUrl}/d/d552ab74-85b4-4e7f-a279-fab7cd9c6124/control-de-expediciones?orgId=1&var-collectionFk=${ticket.ticketCollections[0]?.collectionFk}`"
target="_blank"
class="grafana"
>
{{ ticket.ticketCollections[0]?.collectionFk }}
</a>
</template>
</VnLv>
<VnLv :label="t('ticket.summary.route')" :value="ticket.routeFk" /> <VnLv :label="t('ticket.summary.route')" :value="ticket.routeFk" />
<VnLv :label="t('ticket.summary.invoice')"> <VnLv :label="t('ticket.summary.invoice')">
<template #value> <template #value>
@ -487,4 +502,7 @@ async function changeState(value) {
.fetched-tags { .fetched-tags {
max-width: 70%; max-width: 70%;
} }
.grafana {
color: $primary-light;
}
</style> </style>

View File

@ -136,13 +136,6 @@ const getEventByTimestamp = ({ year, month, day }) => {
return props.events[stamp] || null; return props.events[stamp] || null;
}; };
const isFestive = (timestamp) => {
const event = getEventByTimestamp(timestamp);
if (!event) return false;
const { isFestive } = event;
return isFestive;
};
const getEventAttrs = (timestamp) => { const getEventAttrs = (timestamp) => {
const event = getEventByTimestamp(timestamp); const event = getEventByTimestamp(timestamp);
if (!event) return {}; if (!event) return {};

View File

@ -0,0 +1,99 @@
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import VnRow from 'components/ui/VnRow.vue';
import FormPopup from 'src/components/FormPopup.vue';
import VnInput from 'src/components/common/VnInput.vue';
import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
const $props = defineProps({
id: {
type: Object,
default: () => {},
},
});
const emit = defineEmits(['onSubmit']);
const { t } = useI18n();
const { notify } = useNotify();
const formData = reactive({
newPassword: null,
repeatPassword: null,
});
const passRequirements = ref([]);
const setPassword = async () => {
try {
if (!formData.newPassword) {
notify(t('You must enter a new password'), 'negative');
return;
}
if (formData.newPassword != formData.repeatPassword) {
notify(t(`Passwords don't match`), 'negative');
return;
}
await axios.patch(`Workers/${$props.id}/setPassword`, {
newPass: formData.newPassword,
});
notify(t('Password changed!'), 'positive');
emit('onSubmit');
} catch (err) {
console.error('Error setting password', err);
}
};
const getPassRequirements = async () => {
const { data } = await axios.get('UserPasswords/findOne');
passRequirements.value = data;
};
onMounted(async () => await getPassRequirements());
</script>
<template>
<FormPopup :title="t('Reset password')" @on-submit="setPassword()">
<template #form-inputs>
<VnRow class="row q-gutter-md q-mb-md">
<VnInput
:label="t('New password')"
v-model="formData.newPassword"
type="password"
:required="true"
:info="
t('passwordRequirements', {
length: passRequirements.length,
nAlpha: passRequirements.nAlpha,
nUpper: passRequirements.nUpper,
nDigits: passRequirements.nDigits,
nPunct: passRequirements.nPunct,
})
"
/>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<VnInput
:label="t('Repeat password')"
v-model="formData.repeatPassword"
type="password"
/>
</VnRow>
</template>
</FormPopup>
</template>
<i18n>
es:
Reset password: Restablecer contraseña
New password: Nueva contraseña
Repeat password: Repetir contraseña
You must enter a new password: Debes introducir la nueva contraseña
Passwords don't match: Las contraseñas no coinciden
</i18n>

View File

@ -6,8 +6,10 @@ import { useSession } from 'src/composables/useSession';
import CardDescriptor from 'src/components/ui/CardDescriptor.vue'; import CardDescriptor from 'src/components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue'; import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue';
import WorkerChangePasswordForm from 'src/pages/Worker/Card/WorkerChangePasswordForm.vue';
import useCardDescription from 'src/composables/useCardDescription'; import useCardDescription from 'src/composables/useCardDescription';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import axios from 'axios';
const $props = defineProps({ const $props = defineProps({
id: { id: {
@ -25,12 +27,16 @@ const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const { getTokenMultimedia } = useSession(); const { getTokenMultimedia } = useSession();
const state = useState(); const state = useState();
const user = state.getUser();
const changePasswordFormDialog = ref(null);
const cardDescriptorRef = ref(null);
const entityId = computed(() => { const entityId = computed(() => {
return $props.id || route.params.id; return $props.id || route.params.id;
}); });
const worker = ref(); const worker = ref();
const workerExcluded = ref(false);
const filter = { const filter = {
include: [ include: [
{ {
@ -71,14 +77,44 @@ function getWorkerAvatar() {
const token = getTokenMultimedia(); const token = getTokenMultimedia();
return `/api/Images/user/160x160/${entityId.value}/download?access_token=${token}`; return `/api/Images/user/160x160/${entityId.value}/download?access_token=${token}`;
} }
const data = ref(useCardDescription()); const data = ref(useCardDescription());
const setData = (entity) => { const setData = (entity) => {
if (!entity) return; if (!entity) return;
data.value = useCardDescription(entity.user.nickname, entity.id); data.value = useCardDescription(entity.user.nickname, entity.id);
}; };
const openChangePasswordForm = () => changePasswordFormDialog.value.show();
const getIsExcluded = async () => {
try {
const { data } = await axios.get(
`WorkerDisableExcludeds/${entityId.value}/exists`
);
if (!data) return;
workerExcluded.value = data.exists;
} catch (err) {
console.error('Error getting worker excluded: ', err);
}
};
const handleExcluded = async () => {
if (workerExcluded.value)
await axios.delete(`WorkerDisableExcludeds/${entityId.value}`);
else
await axios.post(`WorkerDisableExcludeds`, {
workerFk: entityId.value,
dated: new Date(),
});
workerExcluded.value = !workerExcluded.value;
};
const refetch = async () => await cardDescriptorRef.value.getData();
</script> </script>
<template> <template>
<CardDescriptor <CardDescriptor
ref="cardDescriptorRef"
module="Worker" module="Worker"
data-key="workerData" data-key="workerData"
:url="`Workers/${entityId}`" :url="`Workers/${entityId}`"
@ -90,9 +126,34 @@ const setData = (entity) => {
(data) => { (data) => {
worker = data; worker = data;
setData(data); setData(data);
getIsExcluded();
} }
" "
> >
<template #menu="{}">
<QItem v-ripple clickable @click="handleExcluded()">
<QItemSection>
{{
workerExcluded
? t('Click to allow the user to be disabled')
: t('Click to exclude the user from getting disabled')
}}
</QItemSection>
</QItem>
<QItem
v-if="!worker.user.emailVerified && user.id != worker.id"
v-ripple
clickable
@click="openChangePasswordForm()"
>
<QItemSection>
{{ t('Change password') }}
<QDialog ref="changePasswordFormDialog">
<WorkerChangePasswordForm @on-submit="refetch()" :id="entityId" />
</QDialog>
</QItemSection>
</QItem>
</template>
<template #before> <template #before>
<QImg :src="getWorkerAvatar()" class="photo"> <QImg :src="getWorkerAvatar()" class="photo">
<template #error> <template #error>
@ -139,3 +200,10 @@ const setData = (entity) => {
height: 256px; height: 256px;
} }
</style> </style>
<i18n>
es:
Click to allow the user to be disabled: Marcar para deshabilitar
Click to exclude the user from getting disabled: Marcar para no deshabilitar
Change password: Cambiar contraseña
</i18n>

View File

@ -460,7 +460,7 @@ onMounted(async () => {
style="margin-left: 1px" style="margin-left: 1px"
/> />
</QBtnGroup> </QBtnGroup>
<QBtnGroup push class="q-gutter-x-sm" flat style="margin-left: 0px"> <QBtnGroup push class="q-gutter-x-sm q-ml-none" flat>
<QBtn <QBtn
v-if="reason && state && (isHimSelf || isHr)" v-if="reason && state && (isHimSelf || isHr)"
:label="t('Reason')" :label="t('Reason')"

View File

@ -1,59 +1,29 @@
<script setup> <script setup>
import { onMounted, ref } from 'vue'; import { onBeforeMount, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios';
import FetchData from 'components/FetchData.vue'; import { useUserConfig } from 'src/composables/useUserConfig';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnInputDate from 'components/common/VnInputDate.vue'; import VnInputDate from 'components/common/VnInputDate.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
import VnLocation from 'src/components/common/VnLocation.vue'; import VnLocation from 'src/components/common/VnLocation.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import FetchData from 'components/FetchData.vue';
import { useUserConfig } from 'src/composables/useUserConfig'; import FormModel from 'components/FormModel.vue';
import CreateBankEntityForm from 'src/components/CreateBankEntityForm.vue';
import VnRadio from 'src/components/common/VnRadio.vue';
const { t } = useI18n(); const { t } = useI18n();
const workerConfigFilter = {
field: ['payMethodFk'],
};
const newWorkerForm = ref({
companyFk: null,
payMethodFk: null,
firstName: null,
lastNames: null,
birth: null,
fi: null,
code: null,
phone: null,
postcode: null,
provinceFk: null,
city: null,
street: null,
name: null,
email: null,
bossFk: null,
iban: null,
bankEntityFk: null,
});
const companiesOptions = ref([]); const companiesOptions = ref([]);
const workersOptions = ref([]); const workersOptions = ref([]);
const payMethodsOptions = ref([]); const payMethodsOptions = ref([]);
const bankEntitiesOptions = ref([]); const bankEntitiesOptions = ref([]);
const postcodesOptions = ref([]); const postcodesOptions = ref([]);
const formData = ref({ isFreelance: false });
const onFetchWorkerConfig = (workerConfig) => { const defaultPayMethod = ref(0);
newWorkerForm.value.payMethodFk = workerConfig.payMethodFk;
};
const onBankEntityCreated = (data) => {
bankEntitiesOptions.value.push(data);
};
function handleLocation(data, location) { function handleLocation(data, location) {
const { town, code, provinceFk, countryFk } = location ?? {}; const { town, code, provinceFk, countryFk } = location ?? {};
@ -63,20 +33,18 @@ function handleLocation(data, location) {
data.countryFk = countryFk; data.countryFk = countryFk;
} }
onMounted(async () => { onBeforeMount(async () => {
const userInfo = await useUserConfig().fetch(); const userInfo = await useUserConfig().fetch();
newWorkerForm.value = { companyFk: userInfo.companyFk }; formData.value.companyFk = userInfo.companyFk;
const { data } = await axios.get('WorkerConfigs/findOne', {
params: { field: ['payMethodFk'] },
});
defaultPayMethod.value = data.payMethodFk;
formData.value.payMethodFk = defaultPayMethod.value;
}); });
</script> </script>
<template> <template>
<FetchData
url="WorkerConfigs/findOne"
@on-fetch="(data) => onFetchWorkerConfig(data)"
:filter="workerConfigFilter"
auto-load
/>
<FetchData <FetchData
url="Companies" url="Companies"
@on-fetch="(data) => (companiesOptions = data)" @on-fetch="(data) => (companiesOptions = data)"
@ -97,16 +65,31 @@ onMounted(async () => {
@on-fetch="(data) => (bankEntitiesOptions = data)" @on-fetch="(data) => (bankEntitiesOptions = data)"
auto-load auto-load
/> />
<QPage> <QPage>
<VnSubToolbar /> <VnSubToolbar>
<template #st-data>
<VnRadio
v-model="formData.isFreelance"
:val="false"
:label="`${t('Internal')}`"
@update:model-value="formData.payMethodFk = defaultPayMethod"
/>
<VnRadio
v-model="formData.isFreelance"
:val="true"
:label="`${t('External')}`"
@update:model-value="delete formData.payMethodFk"
/>
</template>
</VnSubToolbar>
<FormModel <FormModel
url-create="Workers/new" url-create="Workers/new"
model="worker" model="worker"
:form-initial-data="newWorkerForm" :form-initial-data="formData"
@on-data-saved="(__, { id }) => $router.push({ path: `/worker/${id}` })"
> >
<template #form="{ data, validate }"> <template #form="{ data, validate }">
<VnRow class="row q-gutter-md q-mb-md"> <VnRow>
<VnInput <VnInput
v-model="data.firstName" v-model="data.firstName"
:label="t('worker.create.name')" :label="t('worker.create.name')"
@ -117,47 +100,13 @@ onMounted(async () => {
:label="t('worker.create.lastName')" :label="t('worker.create.lastName')"
:rules="validate('Worker.lastNames')" :rules="validate('Worker.lastNames')"
/> />
<VnInputDate
v-model="data.birth"
:label="t('worker.create.birth')"
:rules="validate('Worker.birth')"
/>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<VnInput
v-model="data.fi"
:label="t('worker.create.fi')"
:rules="validate('Worker.fi')"
/>
<VnInput <VnInput
v-model="data.code" v-model="data.code"
:label="t('worker.create.code')" :label="t('worker.create.code')"
:rules="validate('Worker.code')" :rules="validate('Worker.code')"
/> />
<VnInput
v-model="data.phone"
:label="t('worker.create.phone')"
:rules="validate('Worker.phone')"
/>
</VnRow> </VnRow>
<VnRow class="row q-gutter-md q-mb-md"> <VnRow>
<VnLocation
:rules="validate('Worker.postcode')"
:roles-allowed-to-create="['deliveryAssistant']"
:options="postcodesOptions"
v-model="data.location"
@update:model-value="(location) => handleLocation(data, location)"
>
</VnLocation>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<VnInput
:label="t('worker.create.street')"
v-model="data.street"
:rules="validate('Worker.street')"
/>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<VnInput <VnInput
v-model="data.name" v-model="data.name"
:label="t('worker.create.webUser')" :label="t('worker.create.webUser')"
@ -169,7 +118,7 @@ onMounted(async () => {
:rules="validate('Worker.email')" :rules="validate('Worker.email')"
/> />
</VnRow> </VnRow>
<VnRow class="row q-gutter-md q-mb-md"> <VnRow>
<VnSelect <VnSelect
:label="t('worker.create.company')" :label="t('worker.create.company')"
v-model="data.companyFk" v-model="data.companyFk"
@ -201,7 +150,45 @@ onMounted(async () => {
</template> </template>
</VnSelect> </VnSelect>
</VnRow> </VnRow>
<VnRow class="row q-gutter-md q-mb-md"> <VnRow>
<VnInput
v-model="data.fi"
:label="t('worker.create.fi')"
:rules="validate('Worker.fi')"
/>
<VnInputDate
v-model="data.birth"
:label="t('worker.create.birth')"
:rules="validate('Worker.birth')"
:disable="formData.isFreelance"
/>
<VnInput
v-model="data.phone"
:label="t('worker.create.phone')"
:rules="validate('Worker.phone')"
:disable="formData.isFreelance"
/>
</VnRow>
<VnRow>
<VnLocation
:rules="validate('Worker.postcode')"
:roles-allowed-to-create="['deliveryAssistant']"
:options="postcodesOptions"
v-model="data.location"
@update:model-value="(location) => handleLocation(data, location)"
:disable="formData.isFreelance"
>
</VnLocation>
</VnRow>
<VnRow>
<VnInput
:label="t('worker.create.street')"
v-model="data.street"
:rules="validate('Worker.street')"
:disable="formData.isFreelance"
/>
</VnRow>
<VnRow>
<VnSelect <VnSelect
:label="t('worker.create.payMethods')" :label="t('worker.create.payMethods')"
v-model="data.payMethodFk" v-model="data.payMethodFk"
@ -211,11 +198,14 @@ onMounted(async () => {
map-options map-options
hide-selected hide-selected
:rules="validate('Worker.payMethodFk')" :rules="validate('Worker.payMethodFk')"
:disable="formData.isFreelance"
@update:model-value="(val) => !val && delete formData.payMethodFk"
/> />
<VnInput <VnInput
v-model="data.iban" v-model="data.iban"
:label="t('worker.create.iban')" :label="t('worker.create.iban')"
:rules="validate('Worker.iban')" :rules="validate('Worker.iban')"
:disable="formData.isFreelance"
> >
<template #append> <template #append>
<QIcon name="info" class="cursor-info"> <QIcon name="info" class="cursor-info">
@ -232,10 +222,11 @@ onMounted(async () => {
hide-selected hide-selected
:roles-allowed-to-create="['salesAssistant', 'hr']" :roles-allowed-to-create="['salesAssistant', 'hr']"
:rules="validate('Worker.bankEntity')" :rules="validate('Worker.bankEntity')"
:disable="formData.isFreelance"
> >
<template #form> <template #form>
<CreateBankEntityForm <CreateBankEntityForm
@on-data-saved="onBankEntityCreated($event)" @on-data-saved="(data) => bankEntitiesOptions.push(data)"
/> />
</template> </template>
<template #option="scope"> <template #option="scope">

View File

@ -0,0 +1 @@
passwordRequirements: 'The password must have at least { length } length characters, {nAlpha} alphabetic characters, {nUpper} capital letters, {nDigits} digits and {nPunct} symbols (Ex: $%&.)\n'

View File

@ -1,3 +1,6 @@
Search worker: Buscar trabajador Search worker: Buscar trabajador
You can search by worker id or name: Puedes buscar por id o nombre del trabajador You can search by worker id or name: Puedes buscar por id o nombre del trabajador
Locker: Taquilla Locker: Taquilla
Internal: Interno
External: Externo
passwordRequirements: 'La contraseña debe tener al menos { length } caracteres de longitud, {nAlpha} caracteres alfabéticos, {nUpper} letras mayúsculas, {nDigits} dígitos y {nPunct} símbolos (Ej: $%&.)'

View File

@ -14,10 +14,12 @@ const customRouteRedirectName = computed(() => {
if (routeName.value === 'ZoneLocations') return null; if (routeName.value === 'ZoneLocations') return null;
return routeName.value; return routeName.value;
}); });
const searchbarMakeFetch = computed(() => routeName.value !== 'ZoneEvents');
const searchBarDataKeys = { const searchBarDataKeys = {
ZoneWarehouses: 'ZoneWarehouses', ZoneWarehouses: 'ZoneWarehouses',
ZoneSummary: 'ZoneSummary', ZoneSummary: 'ZoneSummary',
ZoneLocations: 'ZoneLocations', ZoneLocations: 'ZoneLocations',
ZoneEvents: 'ZoneEvents',
}; };
</script> </script>
<template> <template>
@ -27,6 +29,7 @@ const searchBarDataKeys = {
:search-data-key="searchBarDataKeys[routeName]" :search-data-key="searchBarDataKeys[routeName]"
:search-custom-route-redirect="customRouteRedirectName" :search-custom-route-redirect="customRouteRedirectName"
:search-redirect="!!customRouteRedirectName" :search-redirect="!!customRouteRedirectName"
:search-make-fetch="searchbarMakeFetch"
:searchbar-label="t('list.searchZone')" :searchbar-label="t('list.searchZone')"
:searchbar-info="t('list.searchInfo')" :searchbar-info="t('list.searchInfo')"
/> />

View File

@ -0,0 +1,207 @@
<script setup>
import { ref, computed, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import VnRow from 'components/ui/VnRow.vue';
import FormPopup from 'components/FormPopup.vue';
import ZoneLocationsTree from './ZoneLocationsTree.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import { useArrayData } from 'src/composables/useArrayData';
import { useVnConfirm } from 'composables/useVnConfirm';
import axios from 'axios';
const props = defineProps({
date: {
type: Date,
required: true,
default: null,
},
event: {
type: Object,
default: null,
},
isNewMode: {
type: Boolean,
default: true,
},
eventType: {
type: String,
default: '',
},
geoIds: {
type: Array,
default: () => [],
},
});
const emit = defineEmits(['onSubmit', 'closeForm']);
const route = useRoute();
const { t } = useI18n();
const { openConfirmationModal } = useVnConfirm();
const isNew = computed(() => props.isNewMode);
const dated = ref(null);
const tickedNodes = ref();
const _excludeType = ref('all');
const excludeType = computed({
get: () => _excludeType.value,
set: (val) => {
_excludeType.value = val;
},
});
const arrayData = useArrayData('ZoneEvents');
const exclusionGeoCreate = async () => {
try {
if (isNew.value) {
const params = {
zoneFk: parseInt(route.params.id),
date: dated.value,
geoIds: tickedNodes.value,
};
await axios.post('Zones/exclusionGeo', params);
} else {
const params = {
zoneExclusionFk: props.event?.zoneExclusionFk,
geoIds: tickedNodes.value,
};
await axios.post('Zones/updateExclusionGeo', params);
}
await refetchEvents();
} catch (err) {
console.error('Error creating exclusion geo: ', err);
}
};
const exclusionCreate = async () => {
try {
if (isNew.value)
await axios.post(`Zones/${route.params.id}/exclusions`, [
{ dated: dated.value },
]);
else
await axios.put(`Zones/${route.params.id}/exclusions/${props.event?.id}`, {
dated: dated.value,
});
await refetchEvents();
} catch (err) {
console.error('Error creating exclusion: ', err);
}
};
const onSubmit = async () => {
if (excludeType.value === 'all') exclusionCreate();
else exclusionGeoCreate();
};
const deleteEvent = async () => {
try {
if (!props.event) return;
const exclusionId = props.event?.zoneExclusionFk || props.event?.id;
await axios.delete(`Zones/${route.params.id}/exclusions/${exclusionId}`);
await refetchEvents();
} catch (err) {
console.error('Error deleting event: ', err);
}
};
const closeForm = () => emit('closeForm');
const refetchEvents = async () => {
await arrayData.refresh({ append: false });
closeForm();
};
onMounted(() => {
if (props.event) {
dated.value = props.event?.dated;
excludeType.value =
props.eventType === 'geoExclusion' ? 'specificLocations' : 'all';
tickedNodes.value = props.geoIds || [];
} else if (props.date) dated.value = props.date;
});
</script>
<template>
<FormPopup
:title="
isNew
? t('eventsExclusionForm.addExclusion')
: t('eventsExclusionForm.editExclusion')
"
@on-submit="onSubmit()"
:default-cancel-button="false"
:default-submit-button="false"
>
<template #form-inputs>
<VnRow class="row q-gutter-md q-mb-lg">
<VnInputDate :label="t('eventsInclusionForm.day')" v-model="dated" />
</VnRow>
<div class="column q-gutter-y-sm q-mb-md">
<QRadio
v-model="excludeType"
dense
val="all"
:label="t('eventsExclusionForm.all')"
/>
<QRadio
v-model="excludeType"
dense
val="specificLocations"
:label="t('eventsExclusionForm.specificLocations')"
/>
</div>
<div
v-if="excludeType === 'specificLocations'"
style="min-height: 60vh; overflow-y: scroll"
>
<ZoneLocationsTree
:root-label="t('eventsExclusionForm.rootTreeLabel')"
v-model:tickedNodes="tickedNodes"
show-search-bar
show-default-checkboxes
>
<template #content="{ node }">
<span>{{ node.name }}</span>
</template>
</ZoneLocationsTree>
</div>
</template>
<template #custom-buttons>
<QBtn
:label="t('globals.cancel')"
color="primary"
flat
class="q-mr-sm"
v-close-popup
/>
<QBtn
v-if="
!isNew && (eventType === 'exclusion' || eventType === 'geoExclusion')
"
:label="t('globals.delete')"
color="primary"
flat
class="q-mr-sm"
@click="
openConfirmationModal(
t('eventsPanel.deleteTitle'),
t('eventsPanel.deleteSubtitle'),
() => deleteEvent()
)
"
/>
<QBtn
:label="isNew ? t('globals.add') : t('globals.save')"
type="submit"
color="primary"
/>
</template>
</FormPopup>
</template>

View File

@ -0,0 +1,240 @@
<script setup>
import { ref, computed, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import VnRow from 'components/ui/VnRow.vue';
import FormPopup from 'components/FormPopup.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnWeekdayPicker from 'src/components/common/VnWeekdayPicker.vue';
import VnInputTime from 'components/common/VnInputTime.vue';
import VnInput from 'src/components/common/VnInput.vue';
import { useArrayData } from 'src/composables/useArrayData';
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
import { useVnConfirm } from 'composables/useVnConfirm';
import axios from 'axios';
const props = defineProps({
date: {
type: Date,
required: true,
default: null,
},
event: {
type: Object,
default: null,
},
isNewMode: {
type: Boolean,
default: true,
},
eventType: {
type: Boolean,
default: true,
},
});
const emit = defineEmits(['onSubmit', 'closeForm']);
const route = useRoute();
const { t } = useI18n();
const weekdayStore = useWeekdayStore();
const { openConfirmationModal } = useVnConfirm();
const isNew = computed(() => props.isNewMode);
const eventInclusionFormData = ref({ wdays: [] });
const _inclusionType = ref('indefinitely');
const inclusionType = computed({
get: () => _inclusionType.value,
set: (val) => {
_inclusionType.value = val;
eventInclusionFormData.value.type = val;
},
});
const arrayData = useArrayData('ZoneEvents');
const createEvent = async () => {
try {
eventInclusionFormData.value.weekDays = weekdayStore.toSet(
eventInclusionFormData.value.wdays
);
if (inclusionType.value == 'day') eventInclusionFormData.value.weekDays = '';
else eventInclusionFormData.value.dated = null;
if (inclusionType.value != 'range') {
eventInclusionFormData.value.started = null;
eventInclusionFormData.value.ended = null;
}
if (isNew.value)
await axios.post(
`Zones/${route.params.id}/events`,
eventInclusionFormData.value
);
else
await axios.put(
`Zones/${route.params.id}/events/${props.event?.id}`,
eventInclusionFormData.value
);
await refetchEvents();
emit('onSubmit');
} catch (err) {
console.error('Error creating event', err);
}
};
const deleteEvent = async () => {
try {
if (!props.event) return;
await axios.delete(`Zones/${route.params.id}/events/${props.event?.id}`);
await refetchEvents();
} catch (err) {
console.error('Error deleting event: ', err);
}
};
const closeForm = () => {
emit('closeForm');
};
const refetchEvents = async () => {
await arrayData.refresh({ append: false });
closeForm();
};
onMounted(() => {
if (props.event) {
eventInclusionFormData.value = { ...props.event };
inclusionType.value = props.event?.type || 'day';
} else if (props.date) {
eventInclusionFormData.value.dated = props.date;
inclusionType.value = 'day';
} else inclusionType.value = 'indefinitely';
});
</script>
<template>
<FormPopup
:title="
isNew ? t('eventsInclusionForm.addEvent') : t('eventsInclusionForm.editEvent')
"
@on-submit="createEvent()"
:default-cancel-button="false"
:default-submit-button="false"
>
<template #form-inputs>
<div class="column q-gutter-y-sm q-mb-md">
<QRadio
v-model="inclusionType"
dense
val="day"
:label="t('eventsInclusionForm.oneDay')"
/>
<QRadio
v-model="inclusionType"
dense
val="indefinitely"
:label="t('eventsInclusionForm.indefinitely')"
/>
<QRadio
v-model="inclusionType"
dense
val="range"
:label="t('eventsInclusionForm.rangeOfDates')"
class="q-mb-sm"
/>
</div>
<VnRow class="row q-gutter-md q-mb-md">
<div class="col flex justify-center">
<VnInputDate
v-if="inclusionType === 'day'"
:label="t('eventsInclusionForm.day')"
v-model="eventInclusionFormData.dated"
class="full-width"
/>
<VnWeekdayPicker
v-else
v-model:wdays="eventInclusionFormData.wdays"
/>
</div>
</VnRow>
<VnRow v-if="inclusionType === 'range'" class="row q-gutter-md q-mb-md">
<VnInputDate
:label="t('eventsInclusionForm.from')"
v-model="eventInclusionFormData.started"
/>
<VnInputDate
:label="t('eventsInclusionForm.to')"
v-model="eventInclusionFormData.ended"
/>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<VnInputTime
v-model="eventInclusionFormData.hour"
:label="t('eventsInclusionForm.closing')"
/>
<VnInput
v-model="eventInclusionFormData.travelingDays"
:label="t('eventsInclusionForm.travelingDays')"
type="number"
min="0"
/>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<VnInput
v-model="eventInclusionFormData.price"
:label="t('eventsInclusionForm.price')"
type="number"
min="0"
/>
<VnInput
v-model="eventInclusionFormData.bonus"
:label="t('eventsInclusionForm.bonus')"
type="number"
min="0"
/>
</VnRow>
<VnRow class="row q-gutter-md q-mb-md">
<VnInput
v-model="eventInclusionFormData.m3Max"
:label="t('eventsInclusionForm.m3Max')"
type="number"
min="0"
/>
</VnRow>
</template>
<template #custom-buttons>
<QBtn
:label="t('globals.cancel')"
color="primary"
flat
class="q-mr-sm"
v-close-popup
/>
<QBtn
v-if="!isNew && eventType === 'event'"
:label="t('globals.delete')"
color="primary"
flat
class="q-mr-sm"
@click="
openConfirmationModal(
t('eventsPanel.deleteTitle'),
t('eventsPanel.deleteSubtitle'),
() => deleteEvent()
)
"
/>
<QBtn
:label="isNew ? t('globals.save') : t('globals.add')"
type="submit"
color="primary"
/>
</template>
</FormPopup>
</template>

View File

@ -0,0 +1,111 @@
<script setup>
import { ref, onUnmounted } from 'vue';
import { useI18n } from 'vue-i18n';
import ZoneEventsPanel from './ZoneEventsPanel.vue';
import ZoneCalendarGrid from '../ZoneCalendarGrid.vue';
import ZoneEventInclusionForm from './ZoneEventInclusionForm.vue';
import ZoneEventExclusionForm from './ZoneEventExclusionForm.vue';
import { useStateStore } from 'stores/useStateStore';
import { reactive } from 'vue';
const { t } = useI18n();
const stateStore = useStateStore();
const firstDay = ref(null);
const lastDay = ref(null);
const events = ref([]);
const formModeName = ref('include');
const showZoneEventForm = ref(false);
const zoneEventsFormProps = reactive({
isNewMode: true,
date: null,
});
const openForm = (data) => {
const { date = null, isNewMode, event, eventType, geoIds = [] } = data;
zoneEventsFormProps.date = date;
zoneEventsFormProps.isNewMode = isNewMode;
zoneEventsFormProps.event = event;
zoneEventsFormProps.eventType = eventType;
if (geoIds.length) zoneEventsFormProps.geoIds = geoIds;
showZoneEventForm.value = true;
};
const onZoneEventFormClose = () => {
showZoneEventForm.value = false;
zoneEventsFormProps.value = {};
};
onUnmounted(() => (stateStore.rightDrawer = false));
</script>
<template>
<template v-if="stateStore.isHeaderMounted()">
<Teleport to="#actions-append">
<div class="row q-gutter-x-sm">
<QBtn
flat
@click="stateStore.toggleRightDrawer()"
round
dense
icon="menu"
>
<QTooltip bottom anchor="bottom right">
{{ t('globals.collapseMenu') }}
</QTooltip>
</QBtn>
</div>
</Teleport>
</template>
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
<QScrollArea class="fit text-grey-8">
<ZoneEventsPanel
:first-day="firstDay"
:last-day="lastDay"
:events="events"
v-model:formModeName="formModeName"
@open-zone-form="openForm"
/>
</QScrollArea>
</QDrawer>
<QPage class="q-pa-md flex justify-center">
<ZoneCalendarGrid
v-model:events="events"
v-model:firstDay="firstDay"
v-model:lastDay="lastDay"
data-key="ZoneEvents"
@on-date-selected="openForm"
/>
<QDialog v-model="showZoneEventForm" @hide="onZoneEventFormClose()">
<ZoneEventInclusionForm
v-if="formModeName === 'include'"
v-bind="zoneEventsFormProps"
@close-form="onZoneEventFormClose()"
/>
<ZoneEventExclusionForm
v-else
v-bind="zoneEventsFormProps"
@close-form="onZoneEventFormClose()"
/>
</QDialog>
<QPageSticky :offset="[20, 20]">
<QBtn
@click="
openForm({
isNewMode: true,
})
"
color="primary"
fab
icon="add"
/>
<QTooltip class="text-no-wrap">
{{ t('eventsInclusionForm.addEvent') }}
</QTooltip>
</QPageSticky>
</QPage>
</template>

View File

@ -0,0 +1,221 @@
<script setup>
import { onMounted, watch, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { useArrayData } from 'src/composables/useArrayData';
import axios from 'axios';
import { toDateFormat, toTimeFormat } from 'src/filters/date.js';
import { dashOrCurrency } from 'filters/index';
import { dashIfEmpty } from 'src/filters';
import { useWeekdayStore } from 'src/stores/useWeekdayStore';
import { useVnConfirm } from 'composables/useVnConfirm';
const props = defineProps({
firstDay: {
type: Date,
required: true,
default: null,
},
lastDay: {
type: Date,
required: true,
default: null,
},
events: {
type: Array,
required: true,
default: () => [],
},
formModeName: {
type: String,
required: true,
default: 'include',
},
});
const emit = defineEmits(['openZoneForm', 'update:formModeName']);
const { t } = useI18n();
const route = useRoute();
const weekdayStore = useWeekdayStore();
const { openConfirmationModal } = useVnConfirm();
const formName = computed({
get: () => props.formModeName,
set: (value) => emit('update:formModeName', value),
});
const params = computed(() => ({
zoneFk: route.params.id,
started: props.firstDay,
ended: props.lastDay,
}));
const arrayData = useArrayData('ZoneEvents', {
params: params,
url: `Zones/getEventsFiltered`,
});
const fetchData = async () => {
try {
if (!params.value.zoneFk || !params.value.started || !params.value.ended) return;
await arrayData.applyFilter({
params: params.value,
});
} catch (err) {
console.error('Error fetching events: ', err);
}
};
watch(
params,
async () => {
await fetchData();
},
{ immediate: true, deep: true }
);
const formatWdays = (event) => {
if (!event.weekDays) return;
let abrWdays = event.weekDays
.split(',')
.map((wday) => weekdayStore.getLocalesMap[wday].localeAbr);
return abrWdays.length < 7 ? abrWdays.join(', ') : t('eventsPanel.everyday');
};
const deleteEvent = async (id) => {
try {
if (!id) return;
await axios.delete(`Zones/${route.params.id}/events/${id}`);
await fetchData();
} catch (err) {
console.error('Error deleting event: ', err);
}
};
const openInclusionForm = (event) => {
formName.value = 'include';
emit('openZoneForm', {
date: event.dated,
event,
isNewMode: false,
eventType: 'event',
});
};
onMounted(async () => {
weekdayStore.initStore();
});
</script>
<template>
<QForm @submit="onSubmit()">
<div class="column q-pa-md q-gutter-y-sm">
<span class="color-vn-label text-subtitle1">{{
t('eventsPanel.editMode')
}}</span>
<QRadio
v-model="formName"
dense
val="include"
:label="t('eventsPanel.include')"
/>
<QRadio
v-model="formName"
dense
val="exclude"
:label="t('eventsPanel.exclude')"
class="q-mb-sm"
/>
</div>
<span class="color-vn-label text-subtitle1 q-px-md">{{
t('eventsPanel.events')
}}</span>
<QList>
<QItem v-for="(event, index) in events" :key="index" class="event-card">
<QItemSection left @click="openInclusionForm(event)">
<div v-if="event.type == 'day'" class="q-mb-xs">
{{ toDateFormat(event.dated) }}
</div>
<div v-if="event.type != 'day'" class="q-mb-xs">
<span v-if="event.weekDays">
{{ formatWdays(event) }}
</span>
<span v-if="event.type == 'range'">
({{ toDateFormat(event.started) }} -
{{ toDateFormat(event.ended) }})
</span>
</div>
<span class="color-vn-label">
{{ t('eventsPanel.closing') }}:
<span class="color-vn-text q-ml-xs">
{{ dashIfEmpty(toTimeFormat(event.hour)) }}
</span>
</span>
<span class="color-vn-label">
{{ t('eventsPanel.travelingDays') }}:
<span class="color-vn-text">
{{ dashIfEmpty(event.travelingDays) }}
</span>
</span>
<span class="color-vn-label">
{{ t('eventsPanel.price') }}:
<span class="color-vn-text">
{{ dashOrCurrency(event.price)() }}</span
>
</span>
<span class="color-vn-label">
{{ t('eventsPanel.bonus') }}:
<span class="color-vn-text">
{{ dashOrCurrency(event.bonus)() }}</span
>
</span>
<span class="color-vn-label">
{{ t('eventsPanel.m3Max') }}:
<span class="color-vn-text"> {{ dashIfEmpty(event.m3Max) }}</span>
</span>
</QItemSection>
<QItemSection side @click="openInclusionForm(event)">
<QBtn
icon="delete"
flat
dense
size="md"
color="primary"
@click.stop="
openConfirmationModal(
t('eventsPanel.deleteTitle'),
t('eventsPanel.deleteSubtitle'),
() => deleteEvent(event.id)
)
"
>
<QTooltip>{{ t('eventsPanel.delete') }}</QTooltip>
</QBtn>
</QItemSection>
</QItem>
<span
v-if="!events.length"
class="flex justify-center text-h5 color-vn-label"
>
{{ t('globals.noResults') }}
</span>
</QList>
</QForm>
</template>
<style scoped lang="scss">
.event-card {
display: flex;
border-bottom: $border-thin-light;
margin: 0;
&:hover {
background-color: var(--vn-accent-color);
cursor: pointer;
}
}
</style>

View File

@ -24,7 +24,8 @@ const onSelected = async (val, node) => {
<QPage class="column items-center q-pa-md"> <QPage class="column items-center q-pa-md">
<QCard class="full-width q-pa-md" style="max-width: 800px"> <QCard class="full-width q-pa-md" style="max-width: 800px">
<ZoneLocationsTree :root-label="t('zoneLocations.locations')"> <ZoneLocationsTree :root-label="t('zoneLocations.locations')">
<template #checkbox="{ node }"> <template #content="{ node }">
<span v-if="!node.id">{{ node.name }}</span>
<QCheckbox <QCheckbox
v-if="node.id" v-if="node.id"
v-model="node.selected" v-model="node.selected"

View File

@ -1,12 +1,34 @@
<script setup> <script setup>
import { onMounted, ref, computed, watch } from 'vue'; import { onMounted, ref, computed, watch, onUnmounted } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import VnInput from 'src/components/common/VnInput.vue';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import axios from 'axios'; import axios from 'axios';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
import { onUnmounted } from 'vue';
const props = defineProps({
rootLabel: {
type: String,
default: 'Locations',
},
tickedNodes: {
type: Array,
default: () => [],
},
showSearchBar: {
type: Boolean,
default: false,
},
showDefaultCheckboxes: {
type: Boolean,
default: false,
},
});
const emit = defineEmits(['update:tickedNodes']);
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
@ -22,9 +44,21 @@ const { store } = arrayData;
const storeData = computed(() => store.data); const storeData = computed(() => store.data);
const nodes = ref([ const nodes = ref([
{ id: null, name: t('zoneLocations.locations'), sons: true, childs: [{}] }, {
id: null,
name: props.rootLabel,
sons: true,
tickable: false,
noTick: true,
children: [{}],
},
]); ]);
const _tickedNodes = computed({
get: () => props.tickedNodes,
set: (value) => emit('update:tickedNodes', value),
});
const previousExpandedNodes = ref(new Set()); const previousExpandedNodes = ref(new Set());
const onNodeExpanded = async (nodeKeysArray) => { const onNodeExpanded = async (nodeKeysArray) => {
@ -107,17 +141,19 @@ watch(storeData, async (val) => {
formatNodeSelected(n); formatNodeSelected(n);
}); });
} else { } else {
for (let n of state.get('Tree')) { for (let n of state.get('Tree')) await fetchNodeLeaves(n);
await fetchNodeLeaves(n);
}
expanded.value = [null, ...fetchedNodeKeys]; expanded.value = [null, ...fetchedNodeKeys];
} }
previousExpandedNodes.value = new Set(expanded.value); previousExpandedNodes.value = new Set(expanded.value);
}); });
const reFetch = async () => {
await arrayData.fetch({ append: false });
};
onMounted(async () => { onMounted(async () => {
if (store.userParams?.search) { if (store.userParams?.search && !props.showSearchBar) {
await arrayData.fetch({ append: false }); await reFetch();
return; return;
} }
const stateTree = state.get('Tree'); const stateTree = state.get('Tree');
@ -140,6 +176,7 @@ onMounted(async () => {
} }
}, 1000); }, 1000);
expanded.value.unshift(null);
previousExpandedNodes.value = new Set(expanded.value); previousExpandedNodes.value = new Set(expanded.value);
}); });
@ -149,14 +186,26 @@ onUnmounted(() => {
</script> </script>
<template> <template>
<VnInput
v-if="showSearchBar"
v-model="store.userParams.search"
:placeholder="t('globals.search')"
@keydown.enter.prevent="reFetch()"
>
<template #prepend>
<QIcon class="cursor-pointer" name="search" />
</template>
</VnInput>
<QTree <QTree
ref="treeRef" ref="treeRef"
:nodes="nodes" :nodes="nodes"
node-key="id" node-key="id"
label-key="name" label-key="name"
children-key="childs" children-key="childs"
:tick-strategy="props.showDefaultCheckboxes ? 'strict' : 'none'"
v-model:expanded="expanded" v-model:expanded="expanded"
@update:expanded="onNodeExpanded($event)" @update:expanded="onNodeExpanded($event)"
v-model:ticked="_tickedNodes"
:default-expand-all="true" :default-expand-all="true"
> >
<template #default-header="{ node }"> <template #default-header="{ node }">
@ -164,8 +213,7 @@ onUnmounted(() => {
:id="node.id" :id="node.id"
class="qtr row justify-between full-width q-pr-md cursor-pointer" class="qtr row justify-between full-width q-pr-md cursor-pointer"
> >
<span v-if="!node.id">{{ node.name }}</span> <slot name="content" :node="node" />
<slot name="checkbox" :node="node" />
</div> </div>
</template> </template>
</QTree> </QTree>

View File

@ -2,6 +2,7 @@
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { date } from 'quasar'; import { date } from 'quasar';
import { useRoute } from 'vue-router';
import ZoneClosingTable from './ZoneClosingTable.vue'; import ZoneClosingTable from './ZoneClosingTable.vue';
import QCalendarMonthWrapper from 'src/components/ui/QCalendarMonthWrapper.vue'; import QCalendarMonthWrapper from 'src/components/ui/QCalendarMonthWrapper.vue';
@ -38,7 +39,10 @@ const props = defineProps({
}, },
}); });
const emit = defineEmits(['onDateSelected']);
const { locale } = useI18n(); const { locale } = useI18n();
const route = useRoute();
const calendarRef = ref(null); const calendarRef = ref(null);
const weekdayStore = useWeekdayStore(); const weekdayStore = useWeekdayStore();
@ -52,7 +56,11 @@ const todayTimestamp = computed(() => {
}); });
const _monthDate = computed(() => date.formatDate(props.monthDate, 'YYYY-MM-DD')); const _monthDate = computed(() => date.formatDate(props.monthDate, 'YYYY-MM-DD'));
const isZoneDeliveryView = computed(() => route.name === 'ZoneDeliveryDays');
const onEventSelection = async ({ year, month, day }) => { const onEventSelection = async ({ year, month, day }) => {
if (!isZoneDeliveryView.value) return;
const date = new Date(year, month - 1, day); const date = new Date(year, month - 1, day);
const stamp = date.getTime(); const stamp = date.getTime();
const events = props.daysMap[stamp]; const events = props.daysMap[stamp];
@ -81,6 +89,13 @@ const getEventByTimestamp = ({ year, month, day }) => {
); );
}; };
const getEventType = ({ year, month, day }) => {
const stamp = new Date(year, month - 1, day).getTime();
if (props.exclusions[stamp]) return 'exclusion';
if (props.geoExclusions[stamp]) return 'geoExclusion';
return 'event';
};
const getEventAttrs = ({ year, month, day }) => { const getEventAttrs = ({ year, month, day }) => {
const stamp = new Date(year, month - 1, day).getTime(); const stamp = new Date(year, month - 1, day).getTime();
@ -104,6 +119,28 @@ const isToday = (timestamp) => {
const calendarHeaderTitle = computed(() => { const calendarHeaderTitle = computed(() => {
return `${weekdayStore.getLocaleMonths[props.month - 1].locale} ${props.year}`; return `${weekdayStore.getLocaleMonths[props.month - 1].locale} ${props.year}`;
}); });
const handleDateClick = (timestamp) => {
if (isZoneDeliveryView.value) return;
const event = getEventByTimestamp(timestamp);
const { year, month, day } = timestamp;
const date = new Date(year, month - 1, day);
const stamp = date.getTime();
const eventType = getEventType(timestamp);
let geoIds = [];
if (eventType === 'geoExclusion')
geoIds = props.geoExclusions[stamp].map((geoExclusion) => geoExclusion.geoFk);
emit('onDateSelected', {
date,
isNewMode: !event,
event: event && event.length > 0 ? event[0] : null,
eventType,
geoIds,
});
};
</script> </script>
<template> <template>
@ -128,6 +165,7 @@ const calendarHeaderTitle = computed(() => {
short-weekday-label short-weekday-label
:locale="locale" :locale="locale"
:now="today" :now="today"
@click-date="handleDateClick($event.scope.timestamp)"
mini-mode mini-mode
> >
<template #day="{ scope: { timestamp } }"> <template #day="{ scope: { timestamp } }">
@ -135,7 +173,11 @@ const calendarHeaderTitle = computed(() => {
<QBtn <QBtn
v-if="getEventByTimestamp(timestamp)" v-if="getEventByTimestamp(timestamp)"
v-bind="{ ...getEventAttrs(timestamp) }" v-bind="{ ...getEventAttrs(timestamp) }"
@click="onEventSelection(timestamp)" @click="
isZoneDeliveryView
? onEventSelection(timestamp)
: handleDateClick(timestamp)
"
rounded rounded
dense dense
flat flat
@ -144,7 +186,7 @@ const calendarHeaderTitle = computed(() => {
'--today': isToday(timestamp), '--today': isToday(timestamp),
}" }"
> >
<QPopupProxy> <QPopupProxy v-if="isZoneDeliveryView">
<ZoneClosingTable <ZoneClosingTable
v-if="zoneClosingData && zoneClosingData.length" v-if="zoneClosingData && zoneClosingData.length"
:rows="zoneClosingData" :rows="zoneClosingData"

Some files were not shown because too many files have changed in this diff Show More