Uses mitt for emitting events in event buses and begins implementation of deep watchers for arrays.
This commit is contained in:
parent
d6b74c9964
commit
7362b4fad0
|
@ -4926,6 +4926,11 @@
|
|||
"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": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"build-prod": "cross-env NODE_ENV=production webpack --config webpack.prod.js --progress --mode production"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vue/compat": "^3.3.4",
|
||||
"apexcharts": "^3.40.0",
|
||||
"axios": "^1.4.0",
|
||||
"blurhash": "^2.0.5",
|
||||
|
@ -20,6 +21,7 @@
|
|||
"leaflet": "^1.9.4",
|
||||
"leaflet-active-area": "^1.2.1",
|
||||
"masonry-layout": "^4.2.2",
|
||||
"mitt": "^3.0.1",
|
||||
"moment": "^2.29.4",
|
||||
"node-sass": "^7.0.3",
|
||||
"photoswipe": "^5.3.7",
|
||||
|
@ -28,7 +30,6 @@
|
|||
"react-dom": "^17.0.2",
|
||||
"swiper": "^8.4.5",
|
||||
"vue": "^3.3.4",
|
||||
"@vue/compat": "^3.3.4",
|
||||
"vue-apexcharts": "^1.6.2",
|
||||
"vue-blurhash": "^0.1.4",
|
||||
"vue-countup-v2": "^4.0.0",
|
||||
|
|
|
@ -976,7 +976,8 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -1065,10 +1066,10 @@ export default {
|
|||
});
|
||||
|
||||
// Sets feedback variables
|
||||
eventBusItemMetadata.$on('isUpdatingValue', (status) => {
|
||||
eventBusItemMetadata.$emitter.$on('isUpdatingValue', (status) => {
|
||||
this.isUpdatingValues = status;
|
||||
});
|
||||
eventBusItemMetadata.$on('hasErrorsOnForm', (hasErrors) => {
|
||||
eventBusItemMetadata.$emitter.$on('hasErrorsOnForm', (hasErrors) => {
|
||||
if (hasErrors)
|
||||
this.formErrorMessage = this.formErrorMessage ? this.formErrorMessage : this.$i18n.get('info_errors_in_form');
|
||||
else
|
||||
|
@ -1077,10 +1078,10 @@ export default {
|
|||
this.cleanLastUpdated();
|
||||
|
||||
// Updates variables for metadata navigation from compound childs
|
||||
eventBusItemMetadata.$on('isOnFirstMetadatumOfCompoundNavigation', (isOnFirstMetadatumOfCompoundNavigation) => {
|
||||
eventBusItemMetadata.$emitter.$on('isOnFirstMetadatumOfCompoundNavigation', (isOnFirstMetadatumOfCompoundNavigation) => {
|
||||
this.isOnFirstMetadatumOfCompoundNavigation = isOnFirstMetadatumOfCompoundNavigation
|
||||
});
|
||||
eventBusItemMetadata.$on('isOnLastMetadatumOfCompoundNavigation', (isOnLastMetadatumOfCompoundNavigation) => {
|
||||
eventBusItemMetadata.$emitter.$on('isOnLastMetadatumOfCompoundNavigation', (isOnLastMetadatumOfCompoundNavigation) => {
|
||||
this.isOnLastMetadatumOfCompoundNavigation = isOnLastMetadatumOfCompoundNavigation
|
||||
});
|
||||
|
||||
|
@ -1093,10 +1094,10 @@ export default {
|
|||
this.isMobileSubheaderOpen = true;
|
||||
},
|
||||
beforeUnmount () {
|
||||
eventBusItemMetadata.$off('isUpdatingValue');
|
||||
eventBusItemMetadata.$off('hasErrorsOnForm');
|
||||
eventBusItemMetadata.$off('isOnFirstMetadatumOfCompoundNavigation');
|
||||
eventBusItemMetadata.$off('isOnLastMetadatumOfCompoundNavigation');
|
||||
eventBusItemMetadata.$emitter.$off('isUpdatingValue');
|
||||
eventBusItemMetadata.$emitter.$off('hasErrorsOnForm');
|
||||
eventBusItemMetadata.$emitter.$off('isOnFirstMetadatumOfCompoundNavigation');
|
||||
eventBusItemMetadata.$emitter.$off('isOnLastMetadatumOfCompoundNavigation');
|
||||
window.removeEventListener('resize', this.handleWindowResize);
|
||||
if (typeof this.swiper.destroy == 'function')
|
||||
this.swiper.destroy();
|
||||
|
|
|
@ -206,13 +206,13 @@ export default {
|
|||
'onDiscard',
|
||||
],
|
||||
mounted() {
|
||||
this.$parent.$on('toggleItemEditionFooterDropdown', () => {
|
||||
this.$parent.$emitter.$on('toggleItemEditionFooterDropdown', () => {
|
||||
if (this.$refs && this.$refs['item-edition-footer-dropdown'])
|
||||
this.$refs['item-edition-footer-dropdown'].toggle();
|
||||
});
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.$parent.$off('toggleItemEditionFooterDropdown');
|
||||
this.$parent.$emitter.$off('toggleItemEditionFooterDropdown');
|
||||
},
|
||||
methods: {
|
||||
openItemCreationStatusDialog() {
|
||||
|
|
|
@ -83,19 +83,23 @@
|
|||
}
|
||||
},
|
||||
watch: {
|
||||
selected(newVal, oldVal) {
|
||||
selected: {
|
||||
handler(newVal, oldVal) {
|
||||
const isEqual = (Array.isArray(newVal) && Array.isArray(oldVal) && (newVal.length == oldVal.length)) && newVal.every((element, index) => {
|
||||
return element === oldVal[index];
|
||||
});
|
||||
if (!isEqual)
|
||||
this.onSelect();
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
facetsFromItemSearch: {
|
||||
handler() {
|
||||
if (this.isUsingElasticSearch)
|
||||
this.loadOptions();
|
||||
},
|
||||
immediate: true
|
||||
immediate: true,
|
||||
deep: true
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
|
@ -103,10 +107,10 @@
|
|||
this.loadOptions();
|
||||
},
|
||||
created() {
|
||||
this.$eventBusSearch.$on('hasToReloadFacets', this.reloadOptions);
|
||||
this.$eventBusSearch.$emitter.$on('hasToReloadFacets', this.reloadOptions);
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.$eventBusSearch.$off('hasToReloadFacets', this.reloadOptions);
|
||||
this.$eventBusSearch.$emitter.$off('hasToReloadFacets', this.reloadOptions);
|
||||
},
|
||||
methods: {
|
||||
reloadOptions(shouldReload) {
|
||||
|
|
|
@ -46,7 +46,8 @@
|
|||
if (this.isUsingElasticSearch)
|
||||
this.loadOptions();
|
||||
},
|
||||
immediate: true
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
@ -54,10 +55,10 @@
|
|||
this.loadOptions();
|
||||
},
|
||||
created() {
|
||||
this.$eventBusSearch.$on('hasToReloadFacets', this.reloadOptions);
|
||||
this.$eventBusSearch.$emitter.$on('hasToReloadFacets', this.reloadOptions);
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.$eventBusSearch.$off('hasToReloadFacets', this.reloadOptions);
|
||||
this.$eventBusSearch.$emitter.$off('hasToReloadFacets', this.reloadOptions);
|
||||
},
|
||||
methods: {
|
||||
reloadOptions(shouldReload) {
|
||||
|
|
|
@ -98,19 +98,23 @@
|
|||
}
|
||||
},
|
||||
watch: {
|
||||
selected(newVal, oldVal) {
|
||||
selected: {
|
||||
handler(newVal, oldVal) {
|
||||
const isEqual = (Array.isArray(newVal) && Array.isArray(oldVal) && (newVal.length == oldVal.length)) && newVal.every((element, index) => {
|
||||
return element === oldVal[index];
|
||||
});
|
||||
if (!isEqual)
|
||||
this.onSelect();
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
facetsFromItemSearch: {
|
||||
handler() {
|
||||
if (this.isUsingElasticSearch)
|
||||
this.loadOptions();
|
||||
},
|
||||
immediate: true
|
||||
immediate: true,
|
||||
deep:true
|
||||
},
|
||||
isLoadingItems: {
|
||||
handler() {
|
||||
|
@ -129,7 +133,7 @@
|
|||
this.taxonomyId = this.filter.metadatum.metadata_type_object.options.taxonomy_id;
|
||||
this.taxonomy = this.filter.metadatum.metadata_type_object.options.taxonomy;
|
||||
}
|
||||
this.$eventBusSearch.$on('hasToReloadFacets', this.reloadOptions);
|
||||
this.$eventBusSearch.$emitter.$on('hasToReloadFacets', this.reloadOptions);
|
||||
},
|
||||
mounted(){
|
||||
if (!this.isUsingElasticSearch)
|
||||
|
@ -141,7 +145,7 @@
|
|||
if (this.getOptionsValuesCancel != undefined)
|
||||
this.getOptionsValuesCancel.cancel('Facet search Canceled.');
|
||||
|
||||
this.$eventBusSearch.$off('hasToReloadFacets', this.reloadOptions);
|
||||
this.$eventBusSearch.$emitter.$off('hasToReloadFacets', this.reloadOptions);
|
||||
},
|
||||
methods: {
|
||||
...mapGetters('search', [
|
||||
|
|
|
@ -2107,7 +2107,8 @@ export default {
|
|||
},
|
||||
immediate: true
|
||||
},
|
||||
itemsLocations() {
|
||||
itemsLocations: {
|
||||
handler() {
|
||||
setTimeout(() => {
|
||||
if ( this.itemsLocations.length && this.$refs['tainacan-admin-view-mode-map'] && this.$refs['tainacan-admin-view-mode-map'].mapObject ) {
|
||||
if (this.itemsLocations.length == 1)
|
||||
|
@ -2115,7 +2116,9 @@ export default {
|
|||
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() {
|
||||
this.clearSelectedMarkers();
|
||||
|
@ -2134,7 +2137,8 @@ export default {
|
|||
else
|
||||
this.selectedGeocoordinateMetadatumId = this.$userPrefs.get(prefsGeocoordinateMetadatum);
|
||||
},
|
||||
immediate: true
|
||||
immediate: true,
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
|
|
@ -168,27 +168,27 @@
|
|||
handler() {
|
||||
this.createChildMetadataGroups();
|
||||
},
|
||||
immediate: true
|
||||
immediate: true,
|
||||
deep: true
|
||||
},
|
||||
isMetadataNavigation() {
|
||||
this.focusedGroupMetadatum = 0;
|
||||
this.focusedChildMetadatum = 0;
|
||||
},
|
||||
isFocused() {
|
||||
if (this.isFocused) {
|
||||
if ( this.isFocused )
|
||||
this.setMetadatumChildFocus({ groupIndex: this.focusedGroupMetadatum, childIndex: this.focusedChildMetadatum, scrollIntoView: true });
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
eventBusItemMetadata.$on('hasRemovedItemMetadataGroup', this.laterUpdateIsRemovingGroup);
|
||||
eventBusItemMetadata.$on('focusPreviousChildMetadatum', this.focusPreviousChildMetadatum);
|
||||
eventBusItemMetadata.$on('focusNextChildMetadatum', this.focusNextChildMetadatum);
|
||||
eventBusItemMetadata.$emitter.$on('hasRemovedItemMetadataGroup', this.laterUpdateIsRemovingGroup);
|
||||
eventBusItemMetadata.$emitter.$on('focusPreviousChildMetadatum', this.focusPreviousChildMetadatum);
|
||||
eventBusItemMetadata.$emitter.$on('focusNextChildMetadatum', this.focusNextChildMetadatum);
|
||||
},
|
||||
beforeUnmount() {
|
||||
eventBusItemMetadata.$off('hasRemovedItemMetadataGroup', this.laterUpdateIsRemovingGroup);
|
||||
eventBusItemMetadata.$off('focusPreviousChildMetadatum', this.focusPreviousChildMetadatum);
|
||||
eventBusItemMetadata.$off('focusNextChildMetadatum', this.focusNextChildMetadatum);
|
||||
eventBusItemMetadata.$emitter.$off('hasRemovedItemMetadataGroup', this.laterUpdateIsRemovingGroup);
|
||||
eventBusItemMetadata.$emitter.$off('focusPreviousChildMetadatum', this.focusPreviousChildMetadatum);
|
||||
eventBusItemMetadata.$emitter.$off('focusNextChildMetadatum', this.focusNextChildMetadatum);
|
||||
},
|
||||
methods: {
|
||||
createChildMetadataGroups() {
|
||||
|
|
|
@ -179,7 +179,8 @@
|
|||
}
|
||||
},
|
||||
watch: {
|
||||
selectedLatLng() {
|
||||
selectedLatLng: {
|
||||
handler() {
|
||||
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
|
||||
nextTick(() => {
|
||||
if ( this.$refs[mapComponentRef] && this.$refs[mapComponentRef].mapObject && this.selectedLatLng.length != undefined) {
|
||||
|
@ -189,6 +190,8 @@
|
|||
this.$refs[mapComponentRef].mapObject.flyToBounds(this.selectedLatLng, { animate: true, maxZoom: this.maxZoom });
|
||||
}
|
||||
});
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -199,7 +202,7 @@
|
|||
// We need to pass mapComponentRef here instead of creating it inside the function
|
||||
// otherwise the listener would conflict when multiple geo metadata are inserted.
|
||||
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
|
||||
eventBusItemMetadata.$on('itemEditionFormResize', () => this.handleWindowResize(mapComponentRef));
|
||||
eventBusItemMetadata.$emitter.$on('itemEditionFormResize', () => this.handleWindowResize(mapComponentRef));
|
||||
},
|
||||
mounted() {
|
||||
nextTick(() => {
|
||||
|
@ -209,7 +212,7 @@
|
|||
},
|
||||
beforeUnmount() {
|
||||
const mapComponentRef = 'map--' + this.itemMetadatumIdentifier;
|
||||
eventBusItemMetadata.$off('itemEditionFormResize', () => this.handleWindowResize(mapComponentRef));
|
||||
eventBusItemMetadata.$emitter.$off('itemEditionFormResize', () => this.handleWindowResize(mapComponentRef));
|
||||
},
|
||||
methods: {
|
||||
onUpdateFromLatitudeInput: _.debounce( function($event) {
|
||||
|
|
|
@ -218,7 +218,7 @@
|
|||
},
|
||||
created() {
|
||||
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 = '';
|
||||
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) {
|
||||
|
@ -231,7 +231,7 @@
|
|||
},
|
||||
beforeUnmount() {
|
||||
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 () {
|
||||
|
|
|
@ -130,12 +130,12 @@
|
|||
}
|
||||
},
|
||||
created(){
|
||||
this.$root.$on('openProcessesPopup', () => {
|
||||
this.$root.$emitter.$on('openProcessesPopup', () => {
|
||||
this.showProcesses = true;
|
||||
});
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.$root.$off('openProcessesPopup');
|
||||
this.$root.$emitter.$off('openProcessesPopup');
|
||||
},
|
||||
methods: {
|
||||
updateSearch() {
|
||||
|
|
|
@ -81,13 +81,16 @@ export default {
|
|||
}
|
||||
},
|
||||
watch: {
|
||||
'$route' (to, from) {
|
||||
'$route': {
|
||||
handler(to, from) {
|
||||
if (to.path != from.path) {
|
||||
this.isRepositoryLevel = (to.params.collectionId == undefined);
|
||||
|
||||
this.activeRoute = to.name;
|
||||
this.pageTitle = this.$route.meta.title;
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
created() {
|
||||
|
@ -96,10 +99,10 @@ export default {
|
|||
document.title = this.$route.meta.title;
|
||||
this.pageTitle = document.title;
|
||||
|
||||
this.$root.$on('onCollectionBreadCrumbUpdate', this.collectionBreadCrumbUpdate);
|
||||
this.$root.$emitter.$on('onCollectionBreadCrumbUpdate', this.collectionBreadCrumbUpdate);
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.$root.$on('onCollectionBreadCrumbUpdate', this.collectionBreadCrumbUpdate);
|
||||
this.$root.$emitter.$on('onCollectionBreadCrumbUpdate', this.collectionBreadCrumbUpdate);
|
||||
},
|
||||
methods: {
|
||||
...mapGetters('collection', [
|
||||
|
|
|
@ -402,7 +402,7 @@
|
|||
else
|
||||
this.isCheckboxListLoading = true;
|
||||
|
||||
this.$parent.$on('updateTaxonomyInputs', ($event) => {
|
||||
this.$parent.$emitter.$on('updateTaxonomyInputs', ($event) => {
|
||||
if ($event.taxonomyId == this.taxonomy_id && $event.metadatumId == this.metadatumId) {
|
||||
this.finderColumns = [];
|
||||
this.optionName = '';
|
||||
|
|
|
@ -385,9 +385,12 @@
|
|||
}
|
||||
},
|
||||
watch: {
|
||||
selected() {
|
||||
selected: {
|
||||
handler() {
|
||||
this.$emit('input', this.selected);
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
optionName(newValue, oldValue) {
|
||||
if (newValue != oldValue) {
|
||||
this.noMoreSearchPage = false;
|
||||
|
@ -405,7 +408,7 @@
|
|||
|
||||
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) {
|
||||
this.finderColumns = [];
|
||||
this.optionName = '';
|
||||
|
|
|
@ -356,7 +356,8 @@
|
|||
}
|
||||
},
|
||||
watch: {
|
||||
taxonomyFilters() {
|
||||
taxonomyFilters: {
|
||||
handler() {
|
||||
if ( this.taxonomyFilters != undefined && Object.keys(this.taxonomyFilters).length ) {
|
||||
|
||||
Object.assign( this.taxonomyFiltersCollectionNames, { 'repository-filters': this.$i18n.get('repository') });
|
||||
|
@ -378,7 +379,10 @@
|
|||
});
|
||||
}
|
||||
},
|
||||
repositoryCollectionFilters() {
|
||||
deep: true
|
||||
},
|
||||
repositoryCollectionFilters: {
|
||||
handler() {
|
||||
if ( this.repositoryCollectionFilters != undefined && Object.keys(this.repositoryCollectionFilters).length ) {
|
||||
|
||||
Object.assign( this.repositoryCollectionNames, { 'repository-filters': this.$i18n.get('repository') });
|
||||
|
@ -386,13 +390,15 @@
|
|||
for ( let collection of this.getCollections() )
|
||||
Object.assign( this.repositoryCollectionNames, { [collection.id]: collection.name });
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.prepareFilters();
|
||||
|
||||
if (this.isUsingElasticSearch)
|
||||
this.$eventBusSearch.$on('isLoadingItems', this.updateIsLoadingItems);
|
||||
this.$eventBusSearch.$emitter.$on('isLoadingItems', this.updateIsLoadingItems);
|
||||
},
|
||||
beforeUnmount() {
|
||||
// Cancels previous collection name Request
|
||||
|
@ -408,7 +414,7 @@
|
|||
this.filtersSearchCancel.cancel('Filters search Canceled.');
|
||||
|
||||
if (this.isUsingElasticSearch)
|
||||
this.$eventBusSearch.$off('isLoadingItems', this.updateIsLoadingItems);
|
||||
this.$eventBusSearch.$emitter.$off('isLoadingItems', this.updateIsLoadingItems);
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
|
|
@ -87,6 +87,7 @@ import {
|
|||
ThumbnailHelperPlugin,
|
||||
OrderByHelperPlugin
|
||||
} from './utilities';
|
||||
import mitt from 'mitt';
|
||||
|
||||
export default (element) => {
|
||||
|
||||
|
@ -108,6 +109,9 @@ export default (element) => {
|
|||
app.use(router);
|
||||
app.use(store);
|
||||
|
||||
const emitter = mitt();
|
||||
app.config.globalProperties.$emitter = emitter;
|
||||
|
||||
/* Registers Extra Vue Plugins passed to the window.tainacan_extra_plugins */
|
||||
if (typeof window.tainacan_extra_plugins != "undefined") {
|
||||
for (let [extraVuePluginName, extraVuePluginObject] of Object.entries(window.tainacan_extra_plugins))
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import { createApp } from 'vue';
|
||||
import store from './store/store'
|
||||
import mitt from 'mitt';
|
||||
|
||||
const emitter = mitt();
|
||||
|
||||
export const eventBusItemMetadata = createApp({
|
||||
store,
|
||||
|
@ -8,13 +11,16 @@ export const eventBusItemMetadata = createApp({
|
|||
conditionalSections: {}
|
||||
},
|
||||
watch: {
|
||||
errors() {
|
||||
errors: {
|
||||
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)
|
||||
this.$emit('updateErrorMessageOf#' + (error.metadatum_id + (error.parent_meta_id ? '-' + error.parent_meta_id : '')), error);
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
emits: [
|
||||
|
@ -31,12 +37,12 @@ export const eventBusItemMetadata = createApp({
|
|||
'isUpdatingValue'
|
||||
],
|
||||
created() {
|
||||
this.$on('input', this.updateValue);
|
||||
this.$on('removeCompoundGroup', this.removeItemMetadataGroup);
|
||||
this.$emitter.$on('input', this.updateValue);
|
||||
this.$emitter.$on('removeCompoundGroup', this.removeItemMetadataGroup);
|
||||
},
|
||||
beforeUpdate() {
|
||||
this.$off('input', this.updateValue);
|
||||
this.$on('removeCompoundGroup', this.removeItemMetadataGroup);
|
||||
this.$emitter.$off('input', this.updateValue);
|
||||
this.$emitter.$on('removeCompoundGroup', this.removeItemMetadataGroup);
|
||||
},
|
||||
methods : {
|
||||
updateValue({ itemId, metadatumId, values, parentMetaId, parentId }){
|
||||
|
@ -153,3 +159,4 @@ export const eventBusItemMetadata = createApp({
|
|||
}
|
||||
}
|
||||
});
|
||||
eventBusItemMetadata.config.globalProperties.$emitter = emitter;
|
|
@ -1,9 +1,12 @@
|
|||
import { createApp } from 'vue';
|
||||
import mitt from 'mitt';
|
||||
|
||||
const emitter = mitt();
|
||||
|
||||
export default {
|
||||
|
||||
install(app, options = {}) {
|
||||
|
||||
app.config.globalProperties.$emitter = emitter;
|
||||
app.config.globalProperties.$eventBusMetadataList = createApp({
|
||||
emits: [
|
||||
'addMetadatumViaButton',
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import { createApp } from 'vue';
|
||||
import mitt from 'mitt';
|
||||
|
||||
const emitter = mitt();
|
||||
|
||||
export default {
|
||||
|
||||
install(app, options = {}) {
|
||||
|
||||
app.config.globalProperties.$emitter = emitter;
|
||||
app.config.globalProperties.$eventBusSearch = createApp({
|
||||
router: options.router,
|
||||
store: options.store,
|
||||
|
@ -26,20 +29,20 @@ export default {
|
|||
'closeAdvancedSearch'
|
||||
],
|
||||
created() {
|
||||
this.$on('input', data => {
|
||||
this.$emitter.$on('input', data => {
|
||||
if (data.taxonomy)
|
||||
this.addTaxquery(data);
|
||||
else
|
||||
this.addMetaquery(data);
|
||||
});
|
||||
|
||||
this.$root.$on('closeAdvancedSearch', () => {
|
||||
this.$root.$emitter.$on('closeAdvancedSearch', () => {
|
||||
this.$store.dispatch('search/setPage', 1);
|
||||
|
||||
this.performAdvancedSearch({});
|
||||
});
|
||||
|
||||
this.$root.$on('performAdvancedSearch', advancedSearchQuery => {
|
||||
this.$root.$emitter.$on('performAdvancedSearch', advancedSearchQuery => {
|
||||
this.$store.dispatch('search/setPage', 1);
|
||||
this.performAdvancedSearch(advancedSearchQuery);
|
||||
|
||||
|
@ -47,7 +50,8 @@ export default {
|
|||
});
|
||||
},
|
||||
watch: {
|
||||
'$route' (to, from) {
|
||||
'$route': {
|
||||
handler(to, from) {
|
||||
|
||||
// Should set Collection ID from URL only when in admin.
|
||||
if (this.$route.name == 'CollectionItemsPage' || this.$route.name == 'ItemsPage')
|
||||
|
@ -189,6 +193,8 @@ export default {
|
|||
if (to.fullPath != from.fullPath)
|
||||
this.loadItems();
|
||||
}
|
||||
},
|
||||
deep: true
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
|
@ -816,9 +816,12 @@
|
|||
}
|
||||
},
|
||||
watch: {
|
||||
displayedMetadata() {
|
||||
displayedMetadata: {
|
||||
handler() {
|
||||
this.localDisplayedMetadata = JSON.parse(JSON.stringify(this.displayedMetadata));
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
openAdvancedSearch(newValue) {
|
||||
if (newValue == false){
|
||||
this.$eventBusSearch.$emit('closeAdvancedSearch');
|
||||
|
@ -848,7 +851,7 @@
|
|||
this.$eventBusSearch.setCollectionId(this.collectionId);
|
||||
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']) {
|
||||
|
||||
|
@ -861,7 +864,7 @@
|
|||
this.isLoadingItems = isLoadingItems;
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$on('hasFiltered', hasFiltered => {
|
||||
this.$eventBusSearch.$emitter.$on('hasFiltered', hasFiltered => {
|
||||
this.hasFiltered = hasFiltered;
|
||||
});
|
||||
|
||||
|
@ -869,7 +872,7 @@
|
|||
this.openAdvancedSearch = this.$route.query.advancedSearch;
|
||||
}
|
||||
|
||||
this.$root.$on('openAdvancedSearch', (openAdvancedSearch) => {
|
||||
this.$root.$emitter.$on('openAdvancedSearch', (openAdvancedSearch) => {
|
||||
this.openAdvancedSearch = openAdvancedSearch;
|
||||
});
|
||||
|
||||
|
@ -1393,14 +1396,14 @@
|
|||
}, 750),
|
||||
removeEventListeners() {
|
||||
// Component
|
||||
this.$off();
|
||||
this.$emitter.$off();
|
||||
// Window
|
||||
window.removeEventListener('resize', this.hideFiltersOnMobile);
|
||||
// $root
|
||||
this.$root.$off('openAdvancedSearch');
|
||||
this.$root.$emitter.$off('openAdvancedSearch');
|
||||
// $eventBusSearch
|
||||
this.$eventBusSearch.$off('isLoadingItems');
|
||||
this.$eventBusSearch.$off('hasFiltered');
|
||||
this.$eventBusSearch.$emitter.$off('isLoadingItems');
|
||||
this.$eventBusSearch.$emitter.$off('hasFiltered');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -830,9 +830,12 @@
|
|||
}
|
||||
},
|
||||
watch: {
|
||||
displayedMetadata() {
|
||||
displayedMetadata: {
|
||||
handler() {
|
||||
this.localDisplayedMetadata = JSON.parse(JSON.stringify(this.displayedMetadata));
|
||||
},
|
||||
deep: true
|
||||
},
|
||||
openAdvancedSearch(newValue){
|
||||
if (newValue == false){
|
||||
this.$eventBusSearch.$emit('closeAdvancedSearch');
|
||||
|
@ -898,7 +901,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
this.$eventBusSearch.$on('isLoadingItems', isLoadingItems => {
|
||||
this.$eventBusSearch.$emitter.$on('isLoadingItems', isLoadingItems => {
|
||||
|
||||
this.isLoadingItems = isLoadingItems;
|
||||
|
||||
|
@ -912,7 +915,7 @@
|
|||
}));
|
||||
});
|
||||
|
||||
this.$eventBusSearch.$on('hasFiltered', hasFiltered => {
|
||||
this.$eventBusSearch.$emitter.$on('hasFiltered', hasFiltered => {
|
||||
this.hasFiltered = hasFiltered;
|
||||
});
|
||||
|
||||
|
@ -922,12 +925,12 @@
|
|||
this.openAdvancedSearch = this.$route.query.advancedSearch;
|
||||
}
|
||||
|
||||
this.$root.$on('openAdvancedSearch', (openAdvancedSearch) => {
|
||||
this.$root.$emitter.$on('openAdvancedSearch', (openAdvancedSearch) => {
|
||||
this.openAdvancedSearch = openAdvancedSearch;
|
||||
});
|
||||
}
|
||||
|
||||
this.$eventBusSearch.$on('startSlideshowFromItem', (index) => {
|
||||
this.$eventBusSearch.$emitter.$on('startSlideshowFromItem', (index) => {
|
||||
let currentQuery = this.$route.query;
|
||||
delete currentQuery['slideshow-from'];
|
||||
this.$router.replace({ query: currentQuery }).catch((error) => this.$console.log(error));
|
||||
|
@ -1453,16 +1456,16 @@
|
|||
}, 500),
|
||||
removeEventListeners() {
|
||||
// Component
|
||||
this.$off();
|
||||
this.$emitter.$off();
|
||||
// Window
|
||||
if (!this.hideFilters)
|
||||
window.removeEventListener('resize', this.hideFiltersOnMobile);
|
||||
// $root
|
||||
if (!this.hideAdvancedSearch)
|
||||
this.$root.$off('openAdvancedSearch');
|
||||
this.$root.$emitter.$off('openAdvancedSearch');
|
||||
// $eventBusSearch
|
||||
this.$eventBusSearch.$off('isLoadingItems');
|
||||
this.$eventBusSearch.$off('hasFiltered');
|
||||
this.$eventBusSearch.$emitter.$off('isLoadingItems');
|
||||
this.$eventBusSearch.$emitter.$off('hasFiltered');
|
||||
|
||||
},
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import {
|
|||
ThumbnailHelperPlugin,
|
||||
OrderByHelperPlugin
|
||||
} from '../../../admin/js/utilities';
|
||||
import mitt from 'mitt';
|
||||
|
||||
export default (element) => {
|
||||
|
||||
|
@ -279,6 +280,9 @@ export default (element) => {
|
|||
.catch(error => console.log(error));
|
||||
});
|
||||
|
||||
const emitter = mitt();
|
||||
VueItemsList.config.globalProperties.$emitter = emitter;
|
||||
|
||||
VueItemsList.use(eventBusSearch, { store: store, router: routerTheme });
|
||||
|
||||
VueItemsList.mount();
|
||||
|
|
|
@ -908,7 +908,7 @@ export default {
|
|||
// CREATING NEW ITEM SUBMISSION
|
||||
this.createNewItem();
|
||||
|
||||
eventBusItemMetadata.$on('hasErrorsOnForm', (hasErrors) => {
|
||||
eventBusItemMetadata.$emitter.$on('hasErrorsOnForm', (hasErrors) => {
|
||||
if (hasErrors) {
|
||||
if (Array.isArray(this.formErrors)) {
|
||||
for (let i = 0; i < this.metadataSectionCollapses.length; i++)
|
||||
|
@ -968,7 +968,7 @@ export default {
|
|||
this.form.document_type = 'url';
|
||||
},
|
||||
beforeUnmount () {
|
||||
eventBusItemMetadata.$off('hasErrorsOnForm');
|
||||
eventBusItemMetadata.$emitter.$off('hasErrorsOnForm');
|
||||
},
|
||||
methods: {
|
||||
...mapActions('item', [
|
||||
|
|
Loading…
Reference in New Issue