From ce4148855b141a729f5c8f4e23811b27a3197061 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Mon, 6 Aug 2018 11:37:15 -0300 Subject: [PATCH 1/2] Fixes weird rotation of triangle on selects loading. --- src/admin/pages/lists/items-page.vue | 10 -------- src/admin/scss/_selects.scss | 7 ++++-- .../filter-types/tainacan-filter-item.vue | 23 +------------------ 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/src/admin/pages/lists/items-page.vue b/src/admin/pages/lists/items-page.vue index 970b23a07..fadce091f 100644 --- a/src/admin/pages/lists/items-page.vue +++ b/src/admin/pages/lists/items-page.vue @@ -774,16 +774,6 @@ this.isFilterModalActive = false; } }, - onSwipeFiltersMenuRight() { - let screenWidth = window.screen.width; - - if (!this.isFilterModalActive && screenWidth <= 768) - this.isFilterModalActive = true; - }, - onSwipeFiltersMenuLeft() { - if (this.isFilterModalActive) - this.isFilterModalActive = false; - }, onOpenImportersModal() { this.$modal.open({ parent: this, diff --git a/src/admin/scss/_selects.scss b/src/admin/scss/_selects.scss index 31be52c19..3adec9125 100644 --- a/src/admin/scss/_selects.scss +++ b/src/admin/scss/_selects.scss @@ -21,7 +21,7 @@ background-color: white !important; } } - &:not(.is-multiple)::after { + &:not(.is-loading)::after { content: "\F35D" !important; font: normal normal normal 24px/1 "Material Design Icons" !important; border: none !important; @@ -31,5 +31,8 @@ color: $secondary !important; display: flex !important; align-items: initial; - } + } + &.is-loading.is-small::after { + font-size: 0.875rem; + } } \ No newline at end of file diff --git a/src/classes/filter-types/tainacan-filter-item.vue b/src/classes/filter-types/tainacan-filter-item.vue index 1950ff6e6..6b7764b3b 100644 --- a/src/classes/filter-types/tainacan-filter-item.vue +++ b/src/classes/filter-types/tainacan-filter-item.vue @@ -179,27 +179,6 @@ padding: 0.75rem 1px 0.75rem 0 !important; } - .select { - padding-top: 0px !important; - select { - font-size: 14px; - border-radius: 1px !important; - font-weight: normal; - height: 30px !important; - padding: 2px 25px 2px 15px !important; - margin-top: 0px !important; - margin-bottom: 0px !important; - } - &:not(.is-multiple)::after { - content: "\F35D" !important; - font: normal normal normal 24px/1 "Material Design Icons" !important; - transform: none; - margin-top: -0.6em; - right: 0.95em; - color: $turquoise3; - } - } - .collapse { .label { display: inline-flex; @@ -213,7 +192,7 @@ width: 100%; } - .input, .textarea, .taginput-container { + .taginput-container { font-size: 14px; border-radius: 1px !important; box-shadow: none !important; From d6122f2911b86b82d8fcffe61b6a7f78c6b01348 Mon Sep 17 00:00:00 2001 From: Mateus Machado Luna Date: Mon, 6 Aug 2018 13:40:38 -0300 Subject: [PATCH 2/2] Fixes bug where sequential disabling/enabling metadada or filters would affect only the most recent clicks, due to assynchronous manipulation of collection filters_order and metadata_order. --- src/admin/components/lists/filters-list.vue | 16 ++++++++++++---- src/admin/components/lists/metadata-list.vue | 14 +++++++++++--- src/js/store/modules/filter/actions.js | 4 ++-- src/js/store/modules/filter/mutations.js | 8 ++++++++ src/js/store/modules/metadata/actions.js | 5 +++-- src/js/store/modules/metadata/mutations.js | 8 ++++++++ 6 files changed, 44 insertions(+), 11 deletions(-) diff --git a/src/admin/components/lists/filters-list.vue b/src/admin/components/lists/filters-list.vue index adcc21bc4..557943672 100644 --- a/src/admin/components/lists/filters-list.vue +++ b/src/admin/components/lists/filters-list.vue @@ -35,7 +35,7 @@
- @@ -203,6 +204,7 @@ export default { isLoadingFilters: false, isLoadingFilterTypes: false, isLoadingFilter: false, + iisUpdatingFiltersOrder: false, openedFilterId: '', formWithErrors: '', editForms: {}, @@ -288,7 +290,10 @@ export default { for (let filter of this.activeFilterList) { filtersOrder.push({'id': filter.id, 'enabled': filter.enabled}); } - this.updateCollectionFiltersOrder({ collectionId: this.collectionId, filtersOrder: filtersOrder }); + this.isUpdatingFiltersOrder = true; + this.updateCollectionFiltersOrder({ collectionId: this.collectionId, filtersOrder: filtersOrder }) + .then(() => this.isUpdatingFiltersOrder = false) + .catch(() => this.isUpdatingFiltersOrder = false); }, updateListOfMetadata() { @@ -311,7 +316,10 @@ export default { filtersOrder.push({'id': filter.id, 'enabled': filter.enabled}); } filtersOrder[index].enabled = $event; - this.updateCollectionFiltersOrder({ collectionId: this.collectionId, filtersOrder: filtersOrder }); + this.isUpdatingFiltersOrder = true; + this.updateCollectionFiltersOrder({ collectionId: this.collectionId, filtersOrder: filtersOrder }) + .then(() => this.isUpdatingFiltersOrder = false) + .catch(() => this.isUpdatingFiltersOrder = false); }, addMetadatumViaButton(metadatumType, metadatumIndex) { this.availableMetadatumList.splice(metadatumIndex, 1); diff --git a/src/admin/components/lists/metadata-list.vue b/src/admin/components/lists/metadata-list.vue index 377c5c7f5..564a6504a 100644 --- a/src/admin/components/lists/metadata-list.vue +++ b/src/admin/components/lists/metadata-list.vue @@ -39,7 +39,7 @@
@@ -351,6 +352,7 @@ export default { isLoadingMetadatumTypes: true, isLoadingMetadata: false, isLoadingMetadatum: false, + isUpdatingMetadataOrder: false, openedMetadatumId: '', formWithErrors: '', hightlightedMetadatum: '', @@ -449,7 +451,10 @@ export default { for (let metadatum of this.activeMetadatumList) { metadataOrder.push({'id': metadatum.id, 'enabled': metadatum.enabled}); } - this.updateCollectionMetadataOrder({ collectionId: this.collectionId, metadataOrder: metadataOrder }); + this.isUpdatingMetadataOrder = true; + this.updateCollectionMetadataOrder({ collectionId: this.collectionId, metadataOrder: metadataOrder }) + .then(() => this.isUpdatingMetadataOrder = false) + .catch(() => this.isUpdatingMetadataOrder = false); }, onChangeEnable($event, index) { let metadataOrder = []; @@ -457,7 +462,10 @@ export default { metadataOrder.push({'id': metadatum.id, 'enabled': metadatum.enabled}); } metadataOrder[index].enabled = $event; - this.updateCollectionMetadataOrder({ collectionId: this.collectionId, metadataOrder: metadataOrder }); + this.isUpdatingMetadataOrder = true; + this.updateCollectionMetadataOrder({ collectionId: this.collectionId, metadataOrder: metadataOrder }) + .then(() => this.isUpdatingMetadataOrder = false) + .catch(() => this.isUpdatingMetadataOrder = false); }, addMetadatumViaButton(metadatumType) { let lastIndex = this.activeMetadatumList.length; diff --git a/src/js/store/modules/filter/actions.js b/src/js/store/modules/filter/actions.js index 896133697..2d394947c 100644 --- a/src/js/store/modules/filter/actions.js +++ b/src/js/store/modules/filter/actions.js @@ -89,8 +89,7 @@ export const deleteFilter = ({ commit }, filterId ) => { .then( res => { commit('deleteFilter', res.data ); resolve( res.data ); - }).catch((error) => { - console.log(error); + }).catch((error) => { reject( error ); }); @@ -111,6 +110,7 @@ export const updateCollectionFiltersOrder = ({ commit }, { collectionId, filters filters_order: filtersOrder }).then( res => { commit('collection/setCollection', res.data, { root: true }); + commit('updateFiltersOrderFromCollection', res.data.filters_order); resolve( res.data ); }).catch( error => { reject( error.response ); diff --git a/src/js/store/modules/filter/mutations.js b/src/js/store/modules/filter/mutations.js index 709ee7585..99a96a543 100644 --- a/src/js/store/modules/filter/mutations.js +++ b/src/js/store/modules/filter/mutations.js @@ -24,6 +24,14 @@ export const setFilters = (state, filters) => { state.filters = filters; } +export const updateFiltersOrderFromCollection = (state, filtersOrder) => { + for (let i = 0; i < state.filters.length; i++) { + let updatedFilterIndex = filtersOrder.findIndex(aFilter => aFilter.id == state.filters[i].id); + if (updatedFilterIndex >= 0) + state.filters[i].enabled = filtersOrder[updatedFilterIndex].enabled; + } +} + export const setFilterTypes = (state, filterTypes) => { state.filterTypes = filterTypes; } \ No newline at end of file diff --git a/src/js/store/modules/metadata/actions.js b/src/js/store/modules/metadata/actions.js index 8061d6ede..a83f7a0fb 100644 --- a/src/js/store/modules/metadata/actions.js +++ b/src/js/store/modules/metadata/actions.js @@ -122,12 +122,13 @@ export const deleteMetadatum = ({commit}, {collectionId, metadatumId, isReposito }); }; -export const updateCollectionMetadataOrder = ({ dispatch }, {collectionId, metadataOrder}) => { +export const updateCollectionMetadataOrder = ({ commit }, {collectionId, metadataOrder}) => { return new Promise((resolve, reject) => { axios.tainacan.patch('/collections/' + collectionId, { metadata_order: metadataOrder }).then(res => { - //dispatch('collection/setCollection', res.data, {root: true}); + commit('collection/setCollection', res.data, { root: true }); + commit('updateMetadataOrderFromCollection', res.data.metadata_order); resolve(res.data); }).catch(error => { reject(error.response); diff --git a/src/js/store/modules/metadata/mutations.js b/src/js/store/modules/metadata/mutations.js index 316e971bf..f97d70f94 100644 --- a/src/js/store/modules/metadata/mutations.js +++ b/src/js/store/modules/metadata/mutations.js @@ -15,6 +15,14 @@ export const setMetadata = (state, metadata) => { state.metadata = metadata; } +export const updateMetadataOrderFromCollection = (state, metadataOrder) => { + for (let i = 0; i < state.metadata.length; i++) { + let updatedMetadatumIndex = metadataOrder.findIndex(aMetadatum => aMetadatum.id == state.metadata[i].id); + if (updatedMetadatumIndex >= 0) + state.metadata[i].enabled = metadataOrder[updatedMetadatumIndex].enabled; + } +} + export const setMetadatumTypes = (state, metadatumTypes) => { state.metadatumTypes = metadatumTypes; }