Solves date insertion on filter that was setting a day before the selected. Update moment js and handle null values for date format.

This commit is contained in:
mateuswetah 2020-05-15 10:42:21 -03:00
parent c259cee660
commit fed11ca1ad
8 changed files with 2492 additions and 1900 deletions

4299
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,48 +7,48 @@
"build": "cross-env NODE_ENV=development webpack --display-error-details --mode development --progress --hide-modules"
},
"dependencies": {
"axios": "^0.19.0",
"buefy": "^0.8.16",
"axios": "^0.19.2",
"buefy": "^0.8.18",
"bulma": "^0.7.5",
"css-vars-ponyfill": "^2.1.2",
"css-vars-ponyfill": "^2.3.1",
"mdi": "^2.2.43",
"moment": "^2.22.2",
"node-sass": "^4.13.1",
"qs": "^6.5.2",
"react": "^16.8.3",
"react-dom": "^16.8.3",
"moment": "^2.25.3",
"node-sass": "^4.14.1",
"qs": "^6.9.4",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"t": "^0.5.1",
"v-tooltip": "^2.0.2",
"v-tooltip": "^2.0.3",
"vue": "^2.6.11",
"vue-awesome-swiper": "^3.1.3",
"vue-masonry-css": "^1.0.3",
"vue-router": "^3.0.1",
"vue-router": "^3.1.6",
"vue-the-mask": "^0.11.1",
"vuedraggable": "^2.23.2",
"vuex": "^3.0.1"
"vuex": "^3.4.0"
},
"devDependencies": {
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"@babel/core": "^7.9.6",
"@babel/preset-env": "^7.9.6",
"@babel/preset-react": "^7.9.4",
"acorn": "^6.0.0",
"autoprefixer": "^9.2.1",
"babel-loader": "^8.0.4",
"cross-env": "^5.2.0",
"css-loader": "^1.0.0",
"autoprefixer": "^9.7.6",
"babel-loader": "^8.1.0",
"cross-env": "^5.2.1",
"css-loader": "^1.0.1",
"eslint": "^5.16.0",
"eslint-loader": "^2.1.1",
"eslint-loader": "^2.2.1",
"eslint-plugin-vue": "^5.2.3",
"file-loader": "^2.0.0",
"postcss-loader": "^3.0.0",
"sass-loader": "^7.1.0",
"sass-loader": "^7.3.1",
"style-loader": "^0.23.1",
"terser-webpack-plugin": "^2.3.2",
"vue-loader": "^15.4.2",
"terser-webpack-plugin": "^2.3.6",
"vue-loader": "^15.9.2",
"vue-template-compiler": "^2.6.11",
"webpack": "^4.43.0",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.1.2",
"webpack-dev-server": ">=3.10.3"
"webpack-bundle-analyzer": "^3.7.0",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.11.0"
}
}

View File

@ -125,9 +125,11 @@
if (index >= 0) {
let metadata = this.query.metaquery[ index ];
if (metadata.value && metadata.value.length > 0){
this.dateInit = new Date(metadata.value[0]);
this.dateEnd = new Date(metadata.value[1]);
if (metadata.value && metadata.value.length > 0) {
const dateValueInit = new Date(metadata.value[0].replace(/-/g, '/'));
this.dateInit = moment(dateValueInit, moment.ISO_8601).toDate();
const dateValueEnd = new Date(metadata.value[1].replace(/-/g, '/'));
this.dateEnd = moment(dateValueEnd, moment.ISO_8601).toDate();
}
if (metadata.value[0] != undefined && metadata.value[1] != undefined)
@ -179,4 +181,7 @@
.field {
margin-bottom: 0.125em !important;
}
.dropdown-trigger input {
font-size: 0.75em;
}
</style>

View File

@ -72,7 +72,7 @@
:aria-labelledby="'filter-label-id-' + filter.id"
:placeholder="$i18n.get('instruction_select_a_date')"
v-model="value"
@input="($event) => { resetPage(); emit($event) }"
@input="($event) => { resetPage(); emit($event); }"
editable
:trap-focus="false"
:date-formatter="(date) => dateFormatter(date)"
@ -170,10 +170,11 @@
while (textValue.split('-')[0].length < 4)
textValue = '0' + textValue;
this.value = new Date(textValue);
const dateValue = new Date(textValue.replace(/-/g, '/'));
this.value = moment(dateValue, moment.ISO_8601).toDate();
this.$emit('sendValuesToTags', {
label: this.comparator + ' ' + moment(this.value, moment.ISO_8601).format(this.dateFormat),
label: this.comparator + ' ' + this.parseDateToNavigatorLanguage(textValue),
value: textValue
});
}
@ -182,7 +183,7 @@
this.value = null;
}
},
dateFormatter(dateObject) {
dateFormatter(dateObject) {
return moment(dateObject, moment.ISO_8601).format(this.dateFormat);
},
dateParser(dateString) {
@ -208,7 +209,7 @@
while (valueQuery.split('-')[0].length < 4)
valueQuery = '0' + valueQuery;
this.$emit('input', {
filter: 'date',
type: 'DATE',
@ -221,7 +222,6 @@
label: this.comparator + ' ' + moment(this.value, moment.ISO_8601).format(this.dateFormat),
value: valueQuery
});
},
onChangeComparator(newComparator) {
this.comparator = newComparator;

View File

@ -206,7 +206,9 @@
right: 0;
}
@media screen and (min-width: 768px) {
.dropdown-trigger input {
font-size: 0.75em !important;
}
.datepicker-header {
.dropdown-menu {

View File

@ -33,7 +33,7 @@ export const dateInter = {
moment.locale(locale);
let localeData = moment.localeData();
this.dateFormat = localeData.longDateFormat('L');
this.dateFormat = localeData.longDateFormat('L') ? localeData.longDateFormat('L') : (localeData._abbr == 'pt_BR' ? 'DD/MM/YYYY' : 'YYYY-MM-DD');
this.dateMask = this.dateFormat.replace(/[\w]/g, '#');
},
data() {

View File

@ -193,6 +193,10 @@
}
.dropdown-trigger {
input {
font-size: 0.875em;
height: auto;
}
span.icon>i.mdi-calendar-today::before{
display: inline-block;
font: "TainacanIcons" normal normal normal 20px/1;

View File

@ -475,10 +475,10 @@ return apply_filters( 'tainacan-admin-i18n', [
'instruction_click_to_select_a_filter_type' => __( 'Click to select a filter type:', 'tainacan' ),
'instruction_select_a_parent_term' => __( 'Select a parent term:', 'tainacan' ),
'instruction_select_a_metadatum' => __( 'Select a metadatum', 'tainacan' ),
'instruction_cover_page' => __( 'Type to search a Page to choose.', 'tainacan' ),
'instruction_type_search_users' => __( 'Type to search users...', 'tainacan' ),
'instruction_type_search_users_filter' => __( 'Type to search users to filter...', 'tainacan' ),
'instruction_type_search_roles_filter' => __( 'Type to search roles to filter...', 'tainacan' ),
'instruction_cover_page' => __( 'Search a Page to choose.', 'tainacan' ),
'instruction_type_search_users' => __( 'Search users...', 'tainacan' ),
'instruction_type_search_users_filter' => __( 'Search users to filter...', 'tainacan' ),
'instruction_type_search_roles_filter' => __( 'Search roles to filter...', 'tainacan' ),
'instruction_select_a_parent_collection' => __( 'Select a parent collection.', 'tainacan' ),
'instruction_select_collection_thumbnail' => __( 'Select a thumbnail image for collection', 'tainacan' ),
'instruction_select_item_thumbnail' => __( 'Select a thumbnail image for item', 'tainacan' ),