diff --git a/src/modules/qbe/qbeDialogs/qbeFilterDialog/QBEFilterCard.vue b/src/modules/qbe/qbeDialogs/qbeFilterDialog/QBEFilterCard.vue index d0f70fbf6..fd51d0c00 100644 --- a/src/modules/qbe/qbeDialogs/qbeFilterDialog/QBEFilterCard.vue +++ b/src/modules/qbe/qbeDialogs/qbeFilterDialog/QBEFilterCard.vue @@ -123,7 +123,6 @@ import Dropdown from 'primevue/dropdown' import QBEFilterDialogDescriptor from './QBEFilterDialogDescriptor.json' import QBEFilterValuesTable from './QBEFilterValuesTable.vue' import moment from 'moment' -import { getLocale, localeDate } from '@/helpers/commons/localeHelper' export default defineComponent({ name: 'qbe-filter-card', @@ -310,23 +309,9 @@ export default defineComponent({ }, onManualValueChange() { if (this.filter) { - const isDateOrTimestamp = ['DATE', 'TIMESTAMP'].includes(this.field?.id?.type) - if (isDateOrTimestamp) this.formatManualDate() this.filter.rightOperandValue = [this.filter.rightOperandDescription] } }, - formatManualDate() { - if (!this.filter) return - - const serverFormat = 'DD/MM/YYYY hh:mm' - const format = localeDate().replace(/yyyy/g, 'YYYY').replace(/dd/g, 'DD').replace(/d/g, 'D').replace(/MM/g, 'MM').replace(/M/g, 'M').replace(/hh/g, 'HH').replace(/mm/g, 'mm').replace(/ss/g, 'ss').replace(/SSS/g, 'SSS') - const momentDate = moment(this.filter.rightOperandDescription, format, true) - - if (momentDate.isValid()) { - const formattedDate = momentDate.format(serverFormat) - this.filter.rightOperandDescription = formattedDate - } - }, onManualBetweenChange() { if (this.filter) { this.filter.rightOperandValue = [this.firstOperand, this.secondOperand] diff --git a/src/modules/qbe/qbeDialogs/qbeFilterDialog/QBEFilterDialog.vue b/src/modules/qbe/qbeDialogs/qbeFilterDialog/QBEFilterDialog.vue index 959eab209..106826cfa 100644 --- a/src/modules/qbe/qbeDialogs/qbeFilterDialog/QBEFilterDialog.vue +++ b/src/modules/qbe/qbeDialogs/qbeFilterDialog/QBEFilterDialog.vue @@ -36,6 +36,7 @@ import { defineComponent, PropType } from 'vue' import { AxiosResponse } from 'axios' import { iField, iQuery, iFilter } from '../../QBE' import { removeInPlace } from '../qbeAdvancedFilterDialog/treeService' +import { localeDate } from '@/helpers/commons/localeHelper' import Dialog from 'primevue/dialog' import KnFabButton from '@/components/UI/KnFabButton.vue' import Message from 'primevue/message' @@ -47,6 +48,7 @@ import mainStore from '../../../../App.store' import cryptoRandomString from 'crypto-random-string' import deepcopy from 'deepcopy' import UserFunctionalitiesConstants from '@/UserFunctionalitiesConstants.json' +import moment from 'moment' export default defineComponent({ name: 'qbe-filter-dialog', @@ -269,6 +271,23 @@ export default defineComponent({ this.parameterTableVisible = false } }, + formatManualDatesFiltersForSave() { + this.filters?.forEach((filter: iFilter) => { + const field = this.filterDialogData?.field as any + const isDateOrTimestamp = ['DATE', 'TIMESTAMP'].includes(field?.id?.type) + if (isDateOrTimestamp) this.formatManualDate(filter) + }) + }, + formatManualDate(filter: iFilter) { + const serverFormat = 'DD/MM/YYYY hh:mm' + const format = localeDate().replace(/yyyy/g, 'YYYY').replace(/dd/g, 'DD').replace(/d/g, 'D').replace(/MM/g, 'MM').replace(/M/g, 'M').replace(/hh/g, 'HH').replace(/mm/g, 'mm').replace(/ss/g, 'ss').replace(/SSS/g, 'SSS') + const momentDate = moment(filter.rightOperandDescription, format, true) + + if (momentDate.isValid()) { + const formattedDate = momentDate.format(serverFormat) + filter.rightOperandDescription = formattedDate + } + }, onParametersUpdated(updatedParameters: any[]) { this.updatedParameters = updatedParameters },