Uses mitt for emitting events in event buses and begins implementation of deep watchers for arrays.

This commit is contained in:
mateuswetah 2023-07-18 09:10:58 -03:00
parent d6b74c9964
commit 7362b4fad0
24 changed files with 343 additions and 278 deletions

5
package-lock.json generated
View File

@ -4926,6 +4926,11 @@
"yallist": "^4.0.0" "yallist": "^4.0.0"
} }
}, },
"mitt": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz",
"integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw=="
},
"mkdirp": { "mkdirp": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",

View File

@ -8,6 +8,7 @@
"build-prod": "cross-env NODE_ENV=production webpack --config webpack.prod.js --progress --mode production" "build-prod": "cross-env NODE_ENV=production webpack --config webpack.prod.js --progress --mode production"
}, },
"dependencies": { "dependencies": {
"@vue/compat": "^3.3.4",
"apexcharts": "^3.40.0", "apexcharts": "^3.40.0",
"axios": "^1.4.0", "axios": "^1.4.0",
"blurhash": "^2.0.5", "blurhash": "^2.0.5",
@ -20,6 +21,7 @@
"leaflet": "^1.9.4", "leaflet": "^1.9.4",
"leaflet-active-area": "^1.2.1", "leaflet-active-area": "^1.2.1",
"masonry-layout": "^4.2.2", "masonry-layout": "^4.2.2",
"mitt": "^3.0.1",
"moment": "^2.29.4", "moment": "^2.29.4",
"node-sass": "^7.0.3", "node-sass": "^7.0.3",
"photoswipe": "^5.3.7", "photoswipe": "^5.3.7",
@ -28,7 +30,6 @@
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"swiper": "^8.4.5", "swiper": "^8.4.5",
"vue": "^3.3.4", "vue": "^3.3.4",
"@vue/compat": "^3.3.4",
"vue-apexcharts": "^1.6.2", "vue-apexcharts": "^1.6.2",
"vue-blurhash": "^0.1.4", "vue-blurhash": "^0.1.4",
"vue-countup-v2": "^4.0.0", "vue-countup-v2": "^4.0.0",

View File

@ -950,7 +950,7 @@ export default {
// Obtains current Sequence Group Info // Obtains current Sequence Group Info
this.fetchSequenceGroup({ collectionId: this.collectionId, groupId: this.sequenceId }); this.fetchSequenceGroup({ collectionId: this.collectionId, groupId: this.sequenceId });
}, },
tabs:{ tabs: {
handler() { handler() {
if (this.tabs.length >= 2) { if (this.tabs.length >= 2) {
if (typeof this.swiper.update == 'function') if (typeof this.swiper.update == 'function')
@ -976,7 +976,8 @@ export default {
} }
} }
}, },
immediate: true immediate: true,
deep: true
} }
}, },
created() { created() {
@ -1065,10 +1066,10 @@ export default {
}); });
// Sets feedback variables // Sets feedback variables
eventBusItemMetadata.$on('isUpdatingValue', (status) => { eventBusItemMetadata.$emitter.$on('isUpdatingValue', (status) => {
this.isUpdatingValues = status; this.isUpdatingValues = status;
}); });
eventBusItemMetadata.$on('hasErrorsOnForm', (hasErrors) => { eventBusItemMetadata.$emitter.$on('hasErrorsOnForm', (hasErrors) => {
if (hasErrors) if (hasErrors)
this.formErrorMessage = this.formErrorMessage ? this.formErrorMessage : this.$i18n.get('info_errors_in_form'); this.formErrorMessage = this.formErrorMessage ? this.formErrorMessage : this.$i18n.get('info_errors_in_form');
else else
@ -1077,10 +1078,10 @@ export default {
this.cleanLastUpdated(); this.cleanLastUpdated();
// Updates variables for metadata navigation from compound childs // Updates variables for metadata navigation from compound childs
eventBusItemMetadata.$on('isOnFirstMetadatumOfCompoundNavigation', (isOnFirstMetadatumOfCompoundNavigation) => { eventBusItemMetadata.$emitter.$on('isOnFirstMetadatumOfCompoundNavigation', (isOnFirstMetadatumOfCompoundNavigation) => {
this.isOnFirstMetadatumOfCompoundNavigation = isOnFirstMetadatumOfCompoundNavigation this.isOnFirstMetadatumOfCompoundNavigation = isOnFirstMetadatumOfCompoundNavigation
}); });
eventBusItemMetadata.$on('isOnLastMetadatumOfCompoundNavigation', (isOnLastMetadatumOfCompoundNavigation) => { eventBusItemMetadata.$emitter.$on('isOnLastMetadatumOfCompoundNavigation', (isOnLastMetadatumOfCompoundNavigation) => {
this.isOnLastMetadatumOfCompoundNavigation = isOnLastMetadatumOfCompoundNavigation this.isOnLastMetadatumOfCompoundNavigation = isOnLastMetadatumOfCompoundNavigation
}); });
@ -1093,10 +1094,10 @@ export default {
this.isMobileSubheaderOpen = true; this.isMobileSubheaderOpen = true;
}, },
beforeUnmount () { beforeUnmount () {
eventBusItemMetadata.$off('isUpdatingValue'); eventBusItemMetadata.$emitter.$off('isUpdatingValue');
eventBusItemMetadata.$off('hasErrorsOnForm'); eventBusItemMetadata.$emitter.$off('hasErrorsOnForm');
eventBusItemMetadata.$off('isOnFirstMetadatumOfCompoundNavigation'); eventBusItemMetadata.$emitter.$off('isOnFirstMetadatumOfCompoundNavigation');
eventBusItemMetadata.$off('isOnLastMetadatumOfCompoundNavigation'); eventBusItemMetadata.$emitter.$off('isOnLastMetadatumOfCompoundNavigation');
window.removeEventListener('resize', this.handleWindowResize); window.removeEventListener('resize', this.handleWindowResize);
if (typeof this.swiper.destroy == 'function') if (typeof this.swiper.destroy == 'function')
this.swiper.destroy(); this.swiper.destroy();

View File

@ -206,13 +206,13 @@ export default {
'onDiscard', 'onDiscard',
], ],
mounted() { mounted() {
this.$parent.$on('toggleItemEditionFooterDropdown', () => { this.$parent.$emitter.$on('toggleItemEditionFooterDropdown', () => {
if (this.$refs && this.$refs['item-edition-footer-dropdown']) if (this.$refs && this.$refs['item-edition-footer-dropdown'])
this.$refs['item-edition-footer-dropdown'].toggle(); this.$refs['item-edition-footer-dropdown'].toggle();
}); });
}, },
beforeUnmount() { beforeUnmount() {
this.$parent.$off('toggleItemEditionFooterDropdown'); this.$parent.$emitter.$off('toggleItemEditionFooterDropdown');
}, },
methods: { methods: {
openItemCreationStatusDialog() { openItemCreationStatusDialog() {

View File

@ -83,19 +83,23 @@
} }
}, },
watch: { watch: {
selected(newVal, oldVal) { selected: {
const isEqual = (Array.isArray(newVal) && Array.isArray(oldVal) && (newVal.length == oldVal.length)) && newVal.every((element, index) => { handler(newVal, oldVal) {
return element === oldVal[index]; const isEqual = (Array.isArray(newVal) && Array.isArray(oldVal) && (newVal.length == oldVal.length)) && newVal.every((element, index) => {
}); return element === oldVal[index];
if (!isEqual) });
this.onSelect(); if (!isEqual)
this.onSelect();
},
deep: true
}, },
facetsFromItemSearch: { facetsFromItemSearch: {
handler() { handler() {
if (this.isUsingElasticSearch) if (this.isUsingElasticSearch)
this.loadOptions(); this.loadOptions();
}, },
immediate: true immediate: true,
deep: true
}, },
}, },
mounted() { mounted() {
@ -103,10 +107,10 @@
this.loadOptions(); this.loadOptions();
}, },
created() { created() {
this.$eventBusSearch.$on('hasToReloadFacets', this.reloadOptions); this.$eventBusSearch.$emitter.$on('hasToReloadFacets', this.reloadOptions);
}, },
beforeUnmount() { beforeUnmount() {
this.$eventBusSearch.$off('hasToReloadFacets', this.reloadOptions); this.$eventBusSearch.$emitter.$off('hasToReloadFacets', this.reloadOptions);
}, },
methods: { methods: {
reloadOptions(shouldReload) { reloadOptions(shouldReload) {

View File

@ -46,7 +46,8 @@
if (this.isUsingElasticSearch) if (this.isUsingElasticSearch)
this.loadOptions(); this.loadOptions();
}, },
immediate: true immediate: true,
deep: true
} }
}, },
mounted() { mounted() {
@ -54,10 +55,10 @@
this.loadOptions(); this.loadOptions();
}, },
created() { created() {
this.$eventBusSearch.$on('hasToReloadFacets', this.reloadOptions); this.$eventBusSearch.$emitter.$on('hasToReloadFacets', this.reloadOptions);
}, },
beforeUnmount() { beforeUnmount() {
this.$eventBusSearch.$off('hasToReloadFacets', this.reloadOptions); this.$eventBusSearch.$emitter.$off('hasToReloadFacets', this.reloadOptions);
}, },
methods: { methods: {
reloadOptions(shouldReload) { reloadOptions(shouldReload) {

View File

@ -98,19 +98,23 @@
} }
}, },
watch: { watch: {
selected(newVal, oldVal) { selected: {
const isEqual = (Array.isArray(newVal) && Array.isArray(oldVal) && (newVal.length == oldVal.length)) && newVal.every((element, index) => { handler(newVal, oldVal) {
return element === oldVal[index]; const isEqual = (Array.isArray(newVal) && Array.isArray(oldVal) && (newVal.length == oldVal.length)) && newVal.every((element, index) => {
}); return element === oldVal[index];
if (!isEqual) });
this.onSelect(); if (!isEqual)
this.onSelect();
},
deep: true
}, },
facetsFromItemSearch: { facetsFromItemSearch: {
handler() { handler() {
if (this.isUsingElasticSearch) if (this.isUsingElasticSearch)
this.loadOptions(); this.loadOptions();
}, },
immediate: true immediate: true,
deep:true
}, },
isLoadingItems: { isLoadingItems: {
handler() { handler() {
@ -129,7 +133,7 @@
this.taxonomyId = this.filter.metadatum.metadata_type_object.options.taxonomy_id; this.taxonomyId = this.filter.metadatum.metadata_type_object.options.taxonomy_id;
this.taxonomy = this.filter.metadatum.metadata_type_object.options.taxonomy; this.taxonomy = this.filter.metadatum.metadata_type_object.options.taxonomy;
} }
this.$eventBusSearch.$on('hasToReloadFacets', this.reloadOptions); this.$eventBusSearch.$emitter.$on('hasToReloadFacets', this.reloadOptions);
}, },
mounted(){ mounted(){
if (!this.isUsingElasticSearch) if (!this.isUsingElasticSearch)
@ -141,7 +145,7 @@
if (this.getOptionsValuesCancel != undefined) if (this.getOptionsValuesCancel != undefined)
this.getOptionsValuesCancel.cancel('Facet search Canceled.'); this.getOptionsValuesCancel.cancel('Facet search Canceled.');
this.$eventBusSearch.$off('hasToReloadFacets', this.reloadOptions); this.$eventBusSearch.$emitter.$off('hasToReloadFacets', this.reloadOptions);
}, },
methods: { methods: {
...mapGetters('search', [ ...mapGetters('search', [

View File

@ -2107,21 +2107,24 @@ export default {
}, },
immediate: true immediate: true
}, },
itemsLocations() { itemsLocations: {
setTimeout(() => { handler() {
if ( this.itemsLocations.length && this.$refs['tainacan-admin-view-mode-map'] && this.$refs['tainacan-admin-view-mode-map'].mapObject ) { setTimeout(() => {
if (this.itemsLocations.length == 1) if ( this.itemsLocations.length && this.$refs['tainacan-admin-view-mode-map'] && this.$refs['tainacan-admin-view-mode-map'].mapObject ) {
this.$refs['tainacan-admin-view-mode-map'].mapObject.panInsideBounds(this.itemsLocations.map((anItemLocation) => anItemLocation.location), { animate: true, maxZoom: 16, paddingTopLeft: [48, 48], paddingTopRight: [48, 48] }); if (this.itemsLocations.length == 1)
else this.$refs['tainacan-admin-view-mode-map'].mapObject.panInsideBounds(this.itemsLocations.map((anItemLocation) => anItemLocation.location), { animate: true, maxZoom: 16, paddingTopLeft: [48, 48], paddingTopRight: [48, 48] });
this.$refs['tainacan-admin-view-mode-map'].mapObject.flyToBounds(this.itemsLocations.map((anItemLocation) => anItemLocation.location), { animate: true, maxZoom: 16, paddingTopLeft: [48, 48], paddingTopRight: [48, 48] }); else
} this.$refs['tainacan-admin-view-mode-map'].mapObject.flyToBounds(this.itemsLocations.map((anItemLocation) => anItemLocation.location), { animate: true, maxZoom: 16, paddingTopLeft: [48, 48], paddingTopRight: [48, 48] });
}, 500) }
}, 500);
},
deep: true
}, },
selectedGeocoordinateMetadatum() { selectedGeocoordinateMetadatum() {
this.clearSelectedMarkers(); this.clearSelectedMarkers();
}, },
geocoordinateMetadata: { geocoordinateMetadata: {
handler() { handler() {
// Setting default geocoordinate metadatum for map view mode // Setting default geocoordinate metadatum for map view mode
const prefsGeocoordinateMetadatum = !this.isRepositoryLevel ? 'map_view_mode_selected_geocoordinate_metadatum_' + this.collectionId : 'map_view_mode_selected_geocoordinate_metadatum'; const prefsGeocoordinateMetadatum = !this.isRepositoryLevel ? 'map_view_mode_selected_geocoordinate_metadatum_' + this.collectionId : 'map_view_mode_selected_geocoordinate_metadatum';
const geocoordinateMetadataIds = Object.keys(this.geocoordinateMetadata); const geocoordinateMetadataIds = Object.keys(this.geocoordinateMetadata);
@ -2134,7 +2137,8 @@ export default {
else else
this.selectedGeocoordinateMetadatumId = this.$userPrefs.get(prefsGeocoordinateMetadatum); this.selectedGeocoordinateMetadatumId = this.$userPrefs.get(prefsGeocoordinateMetadatum);
}, },
immediate: true immediate: true,
deep: true
} }
}, },
mounted() { mounted() {

View File

@ -168,27 +168,27 @@
handler() { handler() {
this.createChildMetadataGroups(); this.createChildMetadataGroups();
}, },
immediate: true immediate: true,
deep: true
}, },
isMetadataNavigation() { isMetadataNavigation() {
this.focusedGroupMetadatum = 0; this.focusedGroupMetadatum = 0;
this.focusedChildMetadatum = 0; this.focusedChildMetadatum = 0;
}, },
isFocused() { isFocused() {
if (this.isFocused) { if ( this.isFocused )
this.setMetadatumChildFocus({ groupIndex: this.focusedGroupMetadatum, childIndex: this.focusedChildMetadatum, scrollIntoView: true }); this.setMetadatumChildFocus({ groupIndex: this.focusedGroupMetadatum, childIndex: this.focusedChildMetadatum, scrollIntoView: true });
}
} }
}, },
created() { created() {
eventBusItemMetadata.$on('hasRemovedItemMetadataGroup', this.laterUpdateIsRemovingGroup); eventBusItemMetadata.$emitter.$on('hasRemovedItemMetadataGroup', this.laterUpdateIsRemovingGroup);
eventBusItemMetadata.$on('focusPreviousChildMetadatum', this.focusPreviousChildMetadatum); eventBusItemMetadata.$emitter.$on('focusPreviousChildMetadatum', this.focusPreviousChildMetadatum);
eventBusItemMetadata.$on('focusNextChildMetadatum', this.focusNextChildMetadatum); eventBusItemMetadata.$emitter.$on('focusNextChildMetadatum', this.focusNextChildMetadatum);
}, },
beforeUnmount() { beforeUnmount() {
eventBusItemMetadata.$off('hasRemovedItemMetadataGroup', this.laterUpdateIsRemovingGroup); eventBusItemMetadata.$emitter.$off('hasRemovedItemMetadataGroup', this.laterUpdateIsRemovingGroup);
eventBusItemMetadata.$off('focusPreviousChildMetadatum', this.focusPreviousChildMetadatum); eventBusItemMetadata.$emitter.$off('focusPreviousChildMetadatum', this.focusPreviousChildMetadatum);
eventBusItemMetadata.$off('focusNextChildMetadatum', this.focusNextChildMetadatum); eventBusItemMetadata.$emitter.$off('focusNextChildMetadatum', this.focusNextChildMetadatum);
}, },
methods: { methods: {
createChildMetadataGroups() { createChildMetadataGroups() {

View File

@ -179,16 +179,19 @@
} }
}, },
watch: { watch: {
selectedLatLng() { selectedLatLng: {
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier; handler() {
nextTick(() => { const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
if ( this.$refs[mapComponentRef] && this.$refs[mapComponentRef].mapObject && this.selectedLatLng.length != undefined) { nextTick(() => {
if (this.selectedLatLng.length == 1) if ( this.$refs[mapComponentRef] && this.$refs[mapComponentRef].mapObject && this.selectedLatLng.length != undefined) {
this.$refs[mapComponentRef].mapObject.panInsideBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom }); if (this.selectedLatLng.length == 1)
else this.$refs[mapComponentRef].mapObject.panInsideBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
this.$refs[mapComponentRef].mapObject.flyToBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom }); else
} this.$refs[mapComponentRef].mapObject.flyToBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
}); }
});
},
deep: true
} }
}, },
created() { created() {
@ -199,7 +202,7 @@
// We need to pass mapComponentRef here instead of creating it inside the function // We need to pass mapComponentRef here instead of creating it inside the function
// otherwise the listener would conflict when multiple geo metadata are inserted. // otherwise the listener would conflict when multiple geo metadata are inserted.
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier; const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
eventBusItemMetadata.$on('itemEditionFormResize', () => this.handleWindowResize(mapComponentRef)); eventBusItemMetadata.$emitter.$on('itemEditionFormResize', () => this.handleWindowResize(mapComponentRef));
}, },
mounted() { mounted() {
nextTick(() => { nextTick(() => {
@ -209,7 +212,7 @@
}, },
beforeUnmount() { beforeUnmount() {
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier; const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
eventBusItemMetadata.$off('itemEditionFormResize', () => this.handleWindowResize(mapComponentRef)); eventBusItemMetadata.$emitter.$off('itemEditionFormResize', () => this.handleWindowResize(mapComponentRef));
}, },
methods: { methods: {
onUpdateFromLatitudeInput: _.debounce( function($event) { onUpdateFromLatitudeInput: _.debounce( function($event) {

View File

@ -218,7 +218,7 @@
}, },
created() { created() {
this.setInitialValues(); this.setInitialValues();
eventBusItemMetadata.$on('updateErrorMessageOf#' + (this.itemMetadatum.parent_meta_id ? this.itemMetadatum.metadatum.id + '-' + this.itemMetadatum.parent_meta_id : this.itemMetadatum.metadatum.id), (errors) => { eventBusItemMetadata.$emitter.$on('updateErrorMessageOf#' + (this.itemMetadatum.parent_meta_id ? this.itemMetadatum.metadatum.id + '-' + this.itemMetadatum.parent_meta_id : this.itemMetadatum.metadatum.id), (errors) => {
let updatedErrorMessage = ''; let updatedErrorMessage = '';
if (errors && errors.errors && this.itemMetadatum && this.itemMetadatum.metadatum && (this.itemMetadatum.parent_meta_id ? (this.itemMetadatum.parent_meta_id == errors.parent_meta_id && this.itemMetadatum.metadatum.id == errors.metadatum_id) : this.itemMetadatum.metadatum.id == errors.metadatum_id)) { if (errors && errors.errors && this.itemMetadatum && this.itemMetadatum.metadatum && (this.itemMetadatum.parent_meta_id ? (this.itemMetadatum.parent_meta_id == errors.parent_meta_id && this.itemMetadatum.metadatum.id == errors.metadatum_id) : this.itemMetadatum.metadatum.id == errors.metadatum_id)) {
for (let error of errors.errors) { for (let error of errors.errors) {
@ -231,7 +231,7 @@
}, },
beforeUnmount() { beforeUnmount() {
if (this.itemMetadatum && this.itemMetadatum.metadatum) { if (this.itemMetadatum && this.itemMetadatum.metadatum) {
eventBusItemMetadata.$off('updateErrorMessageOf#' + (this.itemMetadatum.parent_meta_id ? this.itemMetadatum.metadatum.id + '-' + this.itemMetadatum.parent_meta_id : this.itemMetadatum.metadatum.id)); eventBusItemMetadata.$emitter.$off('updateErrorMessageOf#' + (this.itemMetadatum.parent_meta_id ? this.itemMetadatum.metadatum.id + '-' + this.itemMetadatum.parent_meta_id : this.itemMetadatum.metadatum.id));
} }
}, },
mounted () { mounted () {

View File

@ -130,12 +130,12 @@
} }
}, },
created(){ created(){
this.$root.$on('openProcessesPopup', () => { this.$root.$emitter.$on('openProcessesPopup', () => {
this.showProcesses = true; this.showProcesses = true;
}); });
}, },
beforeUnmount() { beforeUnmount() {
this.$root.$off('openProcessesPopup'); this.$root.$emitter.$off('openProcessesPopup');
}, },
methods: { methods: {
updateSearch() { updateSearch() {

View File

@ -81,13 +81,16 @@ export default {
} }
}, },
watch: { watch: {
'$route' (to, from) { '$route': {
if (to.path != from.path) { handler(to, from) {
this.isRepositoryLevel = (to.params.collectionId == undefined); if (to.path != from.path) {
this.isRepositoryLevel = (to.params.collectionId == undefined);
this.activeRoute = to.name; this.activeRoute = to.name;
this.pageTitle = this.$route.meta.title; this.pageTitle = this.$route.meta.title;
} }
},
deep: true
} }
}, },
created() { created() {
@ -96,10 +99,10 @@ export default {
document.title = this.$route.meta.title; document.title = this.$route.meta.title;
this.pageTitle = document.title; this.pageTitle = document.title;
this.$root.$on('onCollectionBreadCrumbUpdate', this.collectionBreadCrumbUpdate); this.$root.$emitter.$on('onCollectionBreadCrumbUpdate', this.collectionBreadCrumbUpdate);
}, },
beforeUnmount() { beforeUnmount() {
this.$root.$on('onCollectionBreadCrumbUpdate', this.collectionBreadCrumbUpdate); this.$root.$emitter.$on('onCollectionBreadCrumbUpdate', this.collectionBreadCrumbUpdate);
}, },
methods: { methods: {
...mapGetters('collection', [ ...mapGetters('collection', [

View File

@ -402,7 +402,7 @@
else else
this.isCheckboxListLoading = true; this.isCheckboxListLoading = true;
this.$parent.$on('updateTaxonomyInputs', ($event) => { this.$parent.$emitter.$on('updateTaxonomyInputs', ($event) => {
if ($event.taxonomyId == this.taxonomy_id && $event.metadatumId == this.metadatumId) { if ($event.taxonomyId == this.taxonomy_id && $event.metadatumId == this.metadatumId) {
this.finderColumns = []; this.finderColumns = [];
this.optionName = ''; this.optionName = '';

View File

@ -385,8 +385,11 @@
} }
}, },
watch: { watch: {
selected() { selected: {
this.$emit('input', this.selected); handler() {
this.$emit('input', this.selected);
},
deep: true
}, },
optionName(newValue, oldValue) { optionName(newValue, oldValue) {
if (newValue != oldValue) { if (newValue != oldValue) {
@ -405,7 +408,7 @@
this.expandResultsSection = this.shouldBeginWithListExpanded; this.expandResultsSection = this.shouldBeginWithListExpanded;
this.$parent.$on('updateTaxonomyInputs', ($event) => { this.$parent.$emitter.$on('updateTaxonomyInputs', ($event) => {
if ($event.taxonomyId == this.taxonomy_id && $event.metadatumId == this.metadatumId) { if ($event.taxonomyId == this.taxonomy_id && $event.metadatumId == this.metadatumId) {
this.finderColumns = []; this.finderColumns = [];
this.optionName = ''; this.optionName = '';

View File

@ -356,43 +356,49 @@
} }
}, },
watch: { watch: {
taxonomyFilters() { taxonomyFilters: {
if ( this.taxonomyFilters != undefined && Object.keys(this.taxonomyFilters).length ) { handler() {
if ( this.taxonomyFilters != undefined && Object.keys(this.taxonomyFilters).length ) {
Object.assign( this.taxonomyFiltersCollectionNames, { 'repository-filters': this.$i18n.get('repository') });
Object.assign( this.taxonomyFiltersCollectionNames, { 'repository-filters': this.$i18n.get('repository') });
// Cancels previous collection name Request
if (this.collectionNameSearchCancel != undefined) // Cancels previous collection name Request
this.collectionNameSearchCancel.cancel('Collection name search Canceled.'); if (this.collectionNameSearchCancel != undefined)
let collectionIds = JSON.parse(JSON.stringify(Object.keys(this.taxonomyFilters))); this.collectionNameSearchCancel.cancel('Collection name search Canceled.');
let collectionIds = JSON.parse(JSON.stringify(Object.keys(this.taxonomyFilters)));
this.fetchAllCollectionNames( collectionIds.filter(aCollectionId => aCollectionId !== 'repository-filters') )
.then((resp) => { this.fetchAllCollectionNames( collectionIds.filter(aCollectionId => aCollectionId !== 'repository-filters') )
resp.request .then((resp) => {
.then((collections) => { resp.request
for (let collection of collections) .then((collections) => {
Object.assign( this.taxonomyFiltersCollectionNames, { [collection.id]: collection.name }); for (let collection of collections)
}); Object.assign( this.taxonomyFiltersCollectionNames, { [collection.id]: collection.name });
// Search Request Token for cancelling });
this.collectionNameSearchCancel = resp.source; // Search Request Token for cancelling
}); this.collectionNameSearchCancel = resp.source;
} });
}
},
deep: true
}, },
repositoryCollectionFilters() { repositoryCollectionFilters: {
if ( this.repositoryCollectionFilters != undefined && Object.keys(this.repositoryCollectionFilters).length ) { handler() {
if ( this.repositoryCollectionFilters != undefined && Object.keys(this.repositoryCollectionFilters).length ) {
Object.assign( this.repositoryCollectionNames, { 'repository-filters': this.$i18n.get('repository') });
Object.assign( this.repositoryCollectionNames, { 'repository-filters': this.$i18n.get('repository') });
for ( let collection of this.getCollections() )
Object.assign( this.repositoryCollectionNames, { [collection.id]: collection.name }); for ( let collection of this.getCollections() )
} Object.assign( this.repositoryCollectionNames, { [collection.id]: collection.name });
}
},
deep: true
} }
}, },
mounted() { mounted() {
this.prepareFilters(); this.prepareFilters();
if (this.isUsingElasticSearch) if (this.isUsingElasticSearch)
this.$eventBusSearch.$on('isLoadingItems', this.updateIsLoadingItems); this.$eventBusSearch.$emitter.$on('isLoadingItems', this.updateIsLoadingItems);
}, },
beforeUnmount() { beforeUnmount() {
// Cancels previous collection name Request // Cancels previous collection name Request
@ -408,7 +414,7 @@
this.filtersSearchCancel.cancel('Filters search Canceled.'); this.filtersSearchCancel.cancel('Filters search Canceled.');
if (this.isUsingElasticSearch) if (this.isUsingElasticSearch)
this.$eventBusSearch.$off('isLoadingItems', this.updateIsLoadingItems); this.$eventBusSearch.$emitter.$off('isLoadingItems', this.updateIsLoadingItems);
}, },
methods: { methods: {

View File

@ -87,6 +87,7 @@ import {
ThumbnailHelperPlugin, ThumbnailHelperPlugin,
OrderByHelperPlugin OrderByHelperPlugin
} from './utilities'; } from './utilities';
import mitt from 'mitt';
export default (element) => { export default (element) => {
@ -104,10 +105,13 @@ export default (element) => {
store, store,
render: h => h(AdminPage) render: h => h(AdminPage)
}); });
app.use(router); app.use(router);
app.use(store); app.use(store);
const emitter = mitt();
app.config.globalProperties.$emitter = emitter;
/* Registers Extra Vue Plugins passed to the window.tainacan_extra_plugins */ /* Registers Extra Vue Plugins passed to the window.tainacan_extra_plugins */
if (typeof window.tainacan_extra_plugins != "undefined") { if (typeof window.tainacan_extra_plugins != "undefined") {
for (let [extraVuePluginName, extraVuePluginObject] of Object.entries(window.tainacan_extra_plugins)) for (let [extraVuePluginName, extraVuePluginObject] of Object.entries(window.tainacan_extra_plugins))

View File

@ -1,5 +1,8 @@
import { createApp } from 'vue'; import { createApp } from 'vue';
import store from './store/store' import store from './store/store'
import mitt from 'mitt';
const emitter = mitt();
export const eventBusItemMetadata = createApp({ export const eventBusItemMetadata = createApp({
store, store,
@ -8,13 +11,16 @@ export const eventBusItemMetadata = createApp({
conditionalSections: {} conditionalSections: {}
}, },
watch: { watch: {
errors() { errors: {
this.$emit('hasErrorsOnForm', this.errors.length > 0 && this.errors[0].errors && this.errors[0].errors.length); handler() {
this.$emit('hasErrorsOnForm', this.errors.length > 0 && this.errors[0].errors && this.errors[0].errors.length);
if (this.errors.length > 0 && this.errors[0].errors && this.errors[0].errors.length) {
for (let error of this.errors) if (this.errors.length > 0 && this.errors[0].errors && this.errors[0].errors.length) {
this.$emit('updateErrorMessageOf#' + (error.metadatum_id + (error.parent_meta_id ? '-' + error.parent_meta_id : '')), error); for (let error of this.errors)
} this.$emit('updateErrorMessageOf#' + (error.metadatum_id + (error.parent_meta_id ? '-' + error.parent_meta_id : '')), error);
}
},
deep: true
} }
}, },
emits: [ emits: [
@ -31,12 +37,12 @@ export const eventBusItemMetadata = createApp({
'isUpdatingValue' 'isUpdatingValue'
], ],
created() { created() {
this.$on('input', this.updateValue); this.$emitter.$on('input', this.updateValue);
this.$on('removeCompoundGroup', this.removeItemMetadataGroup); this.$emitter.$on('removeCompoundGroup', this.removeItemMetadataGroup);
}, },
beforeUpdate() { beforeUpdate() {
this.$off('input', this.updateValue); this.$emitter.$off('input', this.updateValue);
this.$on('removeCompoundGroup', this.removeItemMetadataGroup); this.$emitter.$on('removeCompoundGroup', this.removeItemMetadataGroup);
}, },
methods : { methods : {
updateValue({ itemId, metadatumId, values, parentMetaId, parentId }){ updateValue({ itemId, metadatumId, values, parentMetaId, parentId }){
@ -153,3 +159,4 @@ export const eventBusItemMetadata = createApp({
} }
} }
}); });
eventBusItemMetadata.config.globalProperties.$emitter = emitter;

View File

@ -1,9 +1,12 @@
import { createApp } from 'vue'; import { createApp } from 'vue';
import mitt from 'mitt';
const emitter = mitt();
export default { export default {
install(app, options = {}) { install(app, options = {}) {
app.config.globalProperties.$emitter = emitter;
app.config.globalProperties.$eventBusMetadataList = createApp({ app.config.globalProperties.$eventBusMetadataList = createApp({
emits: [ emits: [
'addMetadatumViaButton', 'addMetadatumViaButton',

View File

@ -1,9 +1,12 @@
import { createApp } from 'vue'; import { createApp } from 'vue';
import mitt from 'mitt';
const emitter = mitt();
export default { export default {
install(app, options = {}) { install(app, options = {}) {
app.config.globalProperties.$emitter = emitter;
app.config.globalProperties.$eventBusSearch = createApp({ app.config.globalProperties.$eventBusSearch = createApp({
router: options.router, router: options.router,
store: options.store, store: options.store,
@ -26,20 +29,20 @@ export default {
'closeAdvancedSearch' 'closeAdvancedSearch'
], ],
created() { created() {
this.$on('input', data => { this.$emitter.$on('input', data => {
if (data.taxonomy) if (data.taxonomy)
this.addTaxquery(data); this.addTaxquery(data);
else else
this.addMetaquery(data); this.addMetaquery(data);
}); });
this.$root.$on('closeAdvancedSearch', () => { this.$root.$emitter.$on('closeAdvancedSearch', () => {
this.$store.dispatch('search/setPage', 1); this.$store.dispatch('search/setPage', 1);
this.performAdvancedSearch({}); this.performAdvancedSearch({});
}); });
this.$root.$on('performAdvancedSearch', advancedSearchQuery => { this.$root.$emitter.$on('performAdvancedSearch', advancedSearchQuery => {
this.$store.dispatch('search/setPage', 1); this.$store.dispatch('search/setPage', 1);
this.performAdvancedSearch(advancedSearchQuery); this.performAdvancedSearch(advancedSearchQuery);
@ -47,148 +50,151 @@ export default {
}); });
}, },
watch: { watch: {
'$route' (to, from) { '$route': {
handler(to, from) {
// Should set Collection ID from URL only when in admin. // Should set Collection ID from URL only when in admin.
if (this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') if (this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage')
this.collectionId = !this.$route.params.collectionId ? this.$route.params.collectionId : parseInt(this.$route.params.collectionId); this.collectionId = !this.$route.params.collectionId ? this.$route.params.collectionId : parseInt(this.$route.params.collectionId);
// Fills the URL with appropriate default values in case a query is not passed // Fills the URL with appropriate default values in case a query is not passed
if (this.$route.name == null || this.$route.name == undefined || this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') { if (this.$route.name == null || this.$route.name == undefined || this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') {
// Items Per Page
if (this.$route.query.perpage == undefined || to.params.collectionId != from.params.collectionId) {
let perPageKey = (this.collectionId != undefined ? 'items_per_page_' + this.collectionId : 'items_per_page');
let perPageValue = this.$userPrefs.get(perPageKey);
if (perPageValue)
this.$route.query.perpage = perPageValue;
else {
this.$route.query.perpage = 12;
this.$userPrefs.set(perPageKey, 12);
}
}
// Page
if (this.$route.query.paged == undefined || to.params.collectionId != from.params.collectionId)
this.$route.query.paged = 1;
// Order (ASC, DESC)
if (this.$route.query.order == undefined || to.params.collectionId != from.params.collectionId) {
let orderKey = (this.collectionId != undefined ? 'order_' + this.collectionId : 'order');
let orderValue = this.$userPrefs.get(orderKey) ? this.$userPrefs.get(orderKey) : this.defaultOrder;
if (orderValue) // Items Per Page
this.$route.query.order = orderValue; if (this.$route.query.perpage == undefined || to.params.collectionId != from.params.collectionId) {
else { let perPageKey = (this.collectionId != undefined ? 'items_per_page_' + this.collectionId : 'items_per_page');
this.$route.query.order = 'DESC'; let perPageValue = this.$userPrefs.get(perPageKey);
this.$userPrefs.set(orderKey, 'DESC');
}
}
// Order By (required extra work to deal with custom metadata ordering)
if (this.$route.query.orderby == undefined || (to.params.collectionId != from.params.collectionId)) {
let orderByKey = (this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by');
let orderBy = this.$userPrefs.get(orderByKey) ? this.$userPrefs.get(orderByKey) : this.defaultOrderBy;
if (orderBy && orderBy != 'name') {
// Previously was stored as a metadata object, now it is a orderby object
if (orderBy.slug || typeof orderBy == 'string')
orderBy = this.$orderByHelper.getOrderByForMetadatum(orderBy);
if (orderBy.orderby) if (perPageValue)
Object.keys(orderBy).forEach((paramKey) => { this.$route.query.perpage = perPageValue;
this.$route.query[paramKey] = orderBy[paramKey]; else {
}); this.$route.query.perpage = 12;
else this.$userPrefs.set(perPageKey, 12);
this.$route.query.orderby = 'date' }
}
// Page
if (this.$route.query.paged == undefined || to.params.collectionId != from.params.collectionId)
this.$route.query.paged = 1;
// Order (ASC, DESC)
if (this.$route.query.order == undefined || to.params.collectionId != from.params.collectionId) {
let orderKey = (this.collectionId != undefined ? 'order_' + this.collectionId : 'order');
let orderValue = this.$userPrefs.get(orderKey) ? this.$userPrefs.get(orderKey) : this.defaultOrder;
} else { if (orderValue)
this.$route.query.orderby = 'date'; this.$route.query.order = orderValue;
this.$userPrefs.set(orderByKey, { else {
slug: 'creation_date', this.$route.query.order = 'DESC';
name: this.$i18n.get('label_creation_date') this.$userPrefs.set(orderKey, 'DESC');
}).catch(() => { }); }
} }
} else if ( this.$route.query.orderby == 'creation_date' ) { // Fixes old usage of creation_date
this.$route.query.orderby = 'date'
}
// Theme View Modes
if ((this.$route.name == null || this.$route.name == undefined ) &&
this.$route.name != 'CollectionItemsPage' && this.$route.name != 'ItemsPage' &&
(this.$route.query.view_mode == undefined || to.params.collectionId != from.params.collectionId)
) {
let viewModeKey = (this.collectionId != undefined ? 'view_mode_' + this.collectionId : 'view_mode'); // Order By (required extra work to deal with custom metadata ordering)
let viewModeValue = this.$userPrefs.get(viewModeKey); if (this.$route.query.orderby == undefined || (to.params.collectionId != from.params.collectionId)) {
let orderByKey = (this.collectionId != undefined ? 'order_by_' + this.collectionId : 'order_by');
let orderBy = this.$userPrefs.get(orderByKey) ? this.$userPrefs.get(orderByKey) : this.defaultOrderBy;
if (orderBy && orderBy != 'name') {
// Previously was stored as a metadata object, now it is a orderby object
if (orderBy.slug || typeof orderBy == 'string')
orderBy = this.$orderByHelper.getOrderByForMetadatum(orderBy);
if (viewModeValue) if (orderBy.orderby)
this.$route.query.view_mode = viewModeValue; Object.keys(orderBy).forEach((paramKey) => {
else { this.$route.query[paramKey] = orderBy[paramKey];
this.$route.query.view_mode = 'table'; });
this.$userPrefs.set(viewModeKey, 'table'); else
this.$route.query.orderby = 'date'
} else {
this.$route.query.orderby = 'date';
this.$userPrefs.set(orderByKey, {
slug: 'creation_date',
name: this.$i18n.get('label_creation_date')
}).catch(() => { });
}
} else if ( this.$route.query.orderby == 'creation_date' ) { // Fixes old usage of creation_date
this.$route.query.orderby = 'date'
} }
}
// Emit slideshow-from to start this view mode from index // Theme View Modes
if (this.$route.query.view_mode != 'slideshow' && this.$route.query['slideshow-from'] !== null && this.$route.query['slideshow-from'] !== undefined && this.$route.query['slideshow-from'] !== false) if ((this.$route.name == null || this.$route.name == undefined ) &&
this.$emit('startSlideshowFromItem', this.$route.query['slideshow-from']); this.$route.name != 'CollectionItemsPage' && this.$route.name != 'ItemsPage' &&
(this.$route.query.view_mode == undefined || to.params.collectionId != from.params.collectionId)
) {
let viewModeKey = (this.collectionId != undefined ? 'view_mode_' + this.collectionId : 'view_mode');
let viewModeValue = this.$userPrefs.get(viewModeKey);
// Admin View Modes if (viewModeValue)
if (this.$route.name != null && this.$route.name != undefined && this.$route.query.view_mode = viewModeValue;
(this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') && else {
(this.$route.query.admin_view_mode == undefined || to.params.collectionId != from.params.collectionId) this.$route.query.view_mode = 'table';
) { this.$userPrefs.set(viewModeKey, 'table');
let adminViewModeKey = (this.collectionId != undefined ? 'admin_view_mode_' + this.collectionId : 'admin_view_mode'); }
let adminViewModeValue = this.$userPrefs.get(adminViewModeKey);
if (adminViewModeValue)
this.$route.query.admin_view_mode = adminViewModeValue;
else {
this.$route.query.admin_view_mode = 'table';
this.$userPrefs.set(adminViewModeKey, 'table');
} }
}
// Advanced Search
if (this.$route.query && this.$route.query.advancedSearch){
this.$store.dispatch('search/set_advanced_query', this.$route.query);
} else {
this.$store.dispatch('search/set_postquery', this.$route.query);
}
// Checks current metaqueries and taxqueries to alert filters that should reload
// For some reason, this process is not working accessing to.query, so we need to check the path string.
const oldQueryString = from.fullPath.replace(from.path + '?', '');
const newQueryString = to.fullPath.replace(from.path + '?', '');
const oldQueryArray = oldQueryString.split('&');
const newQueryArray = newQueryString.split('&');
const oldMetaQueryArray = oldQueryArray.filter(queryItem => queryItem.startsWith('metaquery')); // Emit slideshow-from to start this view mode from index
const newMetaQueryArray = newQueryArray.filter(queryItem => queryItem.startsWith('metaquery')); if (this.$route.query.view_mode != 'slideshow' && this.$route.query['slideshow-from'] !== null && this.$route.query['slideshow-from'] !== undefined && this.$route.query['slideshow-from'] !== false)
const oldTaxQueryArray = oldQueryArray.filter(queryItem => queryItem.startsWith('taxquery')); this.$emit('startSlideshowFromItem', this.$route.query['slideshow-from']);
const newTaxQueryArray = newQueryArray.filter(queryItem => queryItem.startsWith('taxquery'));
const oldStatusArray = oldQueryArray.filter(queryItem => queryItem.startsWith('status'));
const newStatusArray = newQueryArray.filter(queryItem => queryItem.startsWith('status'));
const oldSearchQuery = oldQueryArray.filter(queryItem => queryItem.startsWith('search'));
const newSearchQuery = newQueryArray.filter(queryItem => queryItem.startsWith('search'));
if ( // Admin View Modes
JSON.stringify(oldMetaQueryArray) != JSON.stringify(newMetaQueryArray) || if (this.$route.name != null && this.$route.name != undefined &&
JSON.stringify(oldTaxQueryArray) != JSON.stringify(newTaxQueryArray) || (this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage') &&
JSON.stringify(oldStatusArray) != JSON.stringify(newStatusArray) || (this.$route.query.admin_view_mode == undefined || to.params.collectionId != from.params.collectionId)
JSON.stringify(oldSearchQuery) != JSON.stringify(newSearchQuery) ) {
) { let adminViewModeKey = (this.collectionId != undefined ? 'admin_view_mode_' + this.collectionId : 'admin_view_mode');
this.$emit('hasToReloadFacets', true); let adminViewModeValue = this.$userPrefs.get(adminViewModeKey);
if (adminViewModeValue)
this.$route.query.admin_view_mode = adminViewModeValue;
else {
this.$route.query.admin_view_mode = 'table';
this.$userPrefs.set(adminViewModeKey, 'table');
}
}
// Advanced Search
if (this.$route.query && this.$route.query.advancedSearch){
this.$store.dispatch('search/set_advanced_query', this.$route.query);
} else {
this.$store.dispatch('search/set_postquery', this.$route.query);
}
// Checks current metaqueries and taxqueries to alert filters that should reload
// For some reason, this process is not working accessing to.query, so we need to check the path string.
const oldQueryString = from.fullPath.replace(from.path + '?', '');
const newQueryString = to.fullPath.replace(from.path + '?', '');
const oldQueryArray = oldQueryString.split('&');
const newQueryArray = newQueryString.split('&');
const oldMetaQueryArray = oldQueryArray.filter(queryItem => queryItem.startsWith('metaquery'));
const newMetaQueryArray = newQueryArray.filter(queryItem => queryItem.startsWith('metaquery'));
const oldTaxQueryArray = oldQueryArray.filter(queryItem => queryItem.startsWith('taxquery'));
const newTaxQueryArray = newQueryArray.filter(queryItem => queryItem.startsWith('taxquery'));
const oldStatusArray = oldQueryArray.filter(queryItem => queryItem.startsWith('status'));
const newStatusArray = newQueryArray.filter(queryItem => queryItem.startsWith('status'));
const oldSearchQuery = oldQueryArray.filter(queryItem => queryItem.startsWith('search'));
const newSearchQuery = newQueryArray.filter(queryItem => queryItem.startsWith('search'));
if (
JSON.stringify(oldMetaQueryArray) != JSON.stringify(newMetaQueryArray) ||
JSON.stringify(oldTaxQueryArray) != JSON.stringify(newTaxQueryArray) ||
JSON.stringify(oldStatusArray) != JSON.stringify(newStatusArray) ||
JSON.stringify(oldSearchQuery) != JSON.stringify(newSearchQuery)
) {
this.$emit('hasToReloadFacets', true);
}
// Finally, loads items
if (to.fullPath != from.fullPath)
this.loadItems();
} }
},
// Finally, loads items deep: true
if (to.fullPath != from.fullPath)
this.loadItems();
}
} }
}, },
methods: { methods: {

View File

@ -816,8 +816,11 @@
} }
}, },
watch: { watch: {
displayedMetadata() { displayedMetadata: {
this.localDisplayedMetadata = JSON.parse(JSON.stringify(this.displayedMetadata)); handler() {
this.localDisplayedMetadata = JSON.parse(JSON.stringify(this.displayedMetadata));
},
deep: true
}, },
openAdvancedSearch(newValue) { openAdvancedSearch(newValue) {
if (newValue == false){ if (newValue == false){
@ -848,7 +851,7 @@
this.$eventBusSearch.setCollectionId(this.collectionId); this.$eventBusSearch.setCollectionId(this.collectionId);
this.$eventBusSearch.updateStoreFromURL(); this.$eventBusSearch.updateStoreFromURL();
this.$eventBusSearch.$on('isLoadingItems', isLoadingItems => { this.$eventBusSearch.$emitter.$on('isLoadingItems', isLoadingItems => {
if (isLoadingItems != this.isLoadingItems && this.$refs['items-page-container'] && this.$refs['search-control']) { if (isLoadingItems != this.isLoadingItems && this.$refs['items-page-container'] && this.$refs['search-control']) {
@ -861,7 +864,7 @@
this.isLoadingItems = isLoadingItems; this.isLoadingItems = isLoadingItems;
}); });
this.$eventBusSearch.$on('hasFiltered', hasFiltered => { this.$eventBusSearch.$emitter.$on('hasFiltered', hasFiltered => {
this.hasFiltered = hasFiltered; this.hasFiltered = hasFiltered;
}); });
@ -869,7 +872,7 @@
this.openAdvancedSearch = this.$route.query.advancedSearch; this.openAdvancedSearch = this.$route.query.advancedSearch;
} }
this.$root.$on('openAdvancedSearch', (openAdvancedSearch) => { this.$root.$emitter.$on('openAdvancedSearch', (openAdvancedSearch) => {
this.openAdvancedSearch = openAdvancedSearch; this.openAdvancedSearch = openAdvancedSearch;
}); });
@ -1393,14 +1396,14 @@
}, 750), }, 750),
removeEventListeners() { removeEventListeners() {
// Component // Component
this.$off(); this.$emitter.$off();
// Window // Window
window.removeEventListener('resize', this.hideFiltersOnMobile); window.removeEventListener('resize', this.hideFiltersOnMobile);
// $root // $root
this.$root.$off('openAdvancedSearch'); this.$root.$emitter.$off('openAdvancedSearch');
// $eventBusSearch // $eventBusSearch
this.$eventBusSearch.$off('isLoadingItems'); this.$eventBusSearch.$emitter.$off('isLoadingItems');
this.$eventBusSearch.$off('hasFiltered'); this.$eventBusSearch.$emitter.$off('hasFiltered');
} }
} }
} }

View File

@ -830,8 +830,11 @@
} }
}, },
watch: { watch: {
displayedMetadata() { displayedMetadata: {
this.localDisplayedMetadata = JSON.parse(JSON.stringify(this.displayedMetadata)); handler() {
this.localDisplayedMetadata = JSON.parse(JSON.stringify(this.displayedMetadata));
},
deep: true
}, },
openAdvancedSearch(newValue){ openAdvancedSearch(newValue){
if (newValue == false){ if (newValue == false){
@ -898,7 +901,7 @@
} }
} }
this.$eventBusSearch.$on('isLoadingItems', isLoadingItems => { this.$eventBusSearch.$emitter.$on('isLoadingItems', isLoadingItems => {
this.isLoadingItems = isLoadingItems; this.isLoadingItems = isLoadingItems;
@ -912,7 +915,7 @@
})); }));
}); });
this.$eventBusSearch.$on('hasFiltered', hasFiltered => { this.$eventBusSearch.$emitter.$on('hasFiltered', hasFiltered => {
this.hasFiltered = hasFiltered; this.hasFiltered = hasFiltered;
}); });
@ -922,12 +925,12 @@
this.openAdvancedSearch = this.$route.query.advancedSearch; this.openAdvancedSearch = this.$route.query.advancedSearch;
} }
this.$root.$on('openAdvancedSearch', (openAdvancedSearch) => { this.$root.$emitter.$on('openAdvancedSearch', (openAdvancedSearch) => {
this.openAdvancedSearch = openAdvancedSearch; this.openAdvancedSearch = openAdvancedSearch;
}); });
} }
this.$eventBusSearch.$on('startSlideshowFromItem', (index) => { this.$eventBusSearch.$emitter.$on('startSlideshowFromItem', (index) => {
let currentQuery = this.$route.query; let currentQuery = this.$route.query;
delete currentQuery['slideshow-from']; delete currentQuery['slideshow-from'];
this.$router.replace({ query: currentQuery }).catch((error) => this.$console.log(error)); this.$router.replace({ query: currentQuery }).catch((error) => this.$console.log(error));
@ -1453,16 +1456,16 @@
}, 500), }, 500),
removeEventListeners() { removeEventListeners() {
// Component // Component
this.$off(); this.$emitter.$off();
// Window // Window
if (!this.hideFilters) if (!this.hideFilters)
window.removeEventListener('resize', this.hideFiltersOnMobile); window.removeEventListener('resize', this.hideFiltersOnMobile);
// $root // $root
if (!this.hideAdvancedSearch) if (!this.hideAdvancedSearch)
this.$root.$off('openAdvancedSearch'); this.$root.$emitter.$off('openAdvancedSearch');
// $eventBusSearch // $eventBusSearch
this.$eventBusSearch.$off('isLoadingItems'); this.$eventBusSearch.$emitter.$off('isLoadingItems');
this.$eventBusSearch.$off('hasFiltered'); this.$eventBusSearch.$emitter.$off('hasFiltered');
}, },
} }

View File

@ -44,6 +44,7 @@ import {
ThumbnailHelperPlugin, ThumbnailHelperPlugin,
OrderByHelperPlugin OrderByHelperPlugin
} from '../../../admin/js/utilities'; } from '../../../admin/js/utilities';
import mitt from 'mitt';
export default (element) => { export default (element) => {
@ -279,6 +280,9 @@ export default (element) => {
.catch(error => console.log(error)); .catch(error => console.log(error));
}); });
const emitter = mitt();
VueItemsList.config.globalProperties.$emitter = emitter;
VueItemsList.use(eventBusSearch, { store: store, router: routerTheme }); VueItemsList.use(eventBusSearch, { store: store, router: routerTheme });
VueItemsList.mount(); VueItemsList.mount();

View File

@ -908,7 +908,7 @@ export default {
// CREATING NEW ITEM SUBMISSION // CREATING NEW ITEM SUBMISSION
this.createNewItem(); this.createNewItem();
eventBusItemMetadata.$on('hasErrorsOnForm', (hasErrors) => { eventBusItemMetadata.$emitter.$on('hasErrorsOnForm', (hasErrors) => {
if (hasErrors) { if (hasErrors) {
if (Array.isArray(this.formErrors)) { if (Array.isArray(this.formErrors)) {
for (let i = 0; i < this.metadataSectionCollapses.length; i++) for (let i = 0; i < this.metadataSectionCollapses.length; i++)
@ -968,7 +968,7 @@ export default {
this.form.document_type = 'url'; this.form.document_type = 'url';
}, },
beforeUnmount () { beforeUnmount () {
eventBusItemMetadata.$off('hasErrorsOnForm'); eventBusItemMetadata.$emitter.$off('hasErrorsOnForm');
}, },
methods: { methods: {
...mapActions('item', [ ...mapActions('item', [