Continues implementation of deep watchers for arrays and objects. #794.

This commit is contained in:
mateuswetah 2023-07-18 09:11:21 -03:00
parent 7362b4fad0
commit f02907a480
36 changed files with 249 additions and 155 deletions

View File

@ -96,10 +96,13 @@
} }
}, },
watch: { watch: {
'$route' (to) { '$route': {
this.isMenuCompressed = (to.params.collectionId != undefined); handler(to) {
this.activeRoute = to.name; this.isMenuCompressed = (to.params.collectionId != undefined);
this.isRepositoryLevel = this.$route.params.collectionId == undefined; this.activeRoute = to.name;
this.isRepositoryLevel = this.$route.params.collectionId == undefined;
},
deep: true
} }
}, },
created() { created() {

View File

@ -65,8 +65,11 @@
} }
}, },
watch: { watch: {
'query'() { 'query': {
this.updateSelectedValues(); handler() {
this.updateSelectedValues();
},
deep: true
} }
}, },
mounted() { mounted() {

View File

@ -79,8 +79,11 @@
if ( val && this.dateEnd === null) if ( val && this.dateEnd === null)
this.dateEnd = new Date(); this.dateEnd = new Date();
}, },
'query'() { 'query': {
this.updateSelectedValues(); handler() {
this.updateSelectedValues();
},
deep: true
} }
}, },
mounted() { mounted() {

View File

@ -149,8 +149,11 @@
} }
}, },
watch: { watch: {
'query'() { 'query': {
this.updateSelectedValues(); handler() {
this.updateSelectedValues();
},
deep: true,
}, },
}, },
mounted() { mounted() {

View File

@ -40,9 +40,12 @@
} }
}, },
watch: { watch: {
'query'() { 'query': {
this.updateSelectedValues(); handler() {
}, this.updateSelectedValues();
},
deep: true
}
}, },
mounted() { mounted() {
this.updateSelectedValues(); this.updateSelectedValues();

View File

@ -33,8 +33,11 @@
} }
}, },
watch: { watch: {
'query'() { 'query': {
this.updateSelectedValues(); handler() {
this.updateSelectedValues();
},
deep: true
} }
}, },
mounted() { mounted() {

View File

@ -102,8 +102,11 @@
} }
}, },
watch: { watch: {
'query'() { 'query': {
this.updateSelectedValues(); handler() {
this.updateSelectedValues();
},
deep: true
} }
}, },
mounted() { mounted() {

View File

@ -76,8 +76,11 @@
} }
}, },
watch: { watch: {
'query'() { 'query': {
this.updateSelectedValues(); handler() {
this.updateSelectedValues();
},
deep: true
} }
}, },
created() { created() {

View File

@ -67,8 +67,11 @@
}, },
immediate: true immediate: true
}, },
'query'() { 'query': {
this.updateSelectedValues(); handler() {
this.updateSelectedValues();
},
deep: true
} }
}, },
created() { created() {

View File

@ -569,7 +569,8 @@ export default {
this.editMetadataSection(newQuery.sectionEdit); this.editMetadataSection(newQuery.sectionEdit);
} }
}, },
immediate: true immediate: true,
deep: true
}, },
collapseAll(isCollapsed) { collapseAll(isCollapsed) {
this.activeMetadataSectionsList.forEach((metadataSection) => { this.activeMetadataSectionsList.forEach((metadataSection) => {
@ -581,8 +582,8 @@ export default {
mounted() { mounted() {
this.cleanMetadataSections(); this.cleanMetadataSections();
this.$eventBusMetadataList.$on('addMetadatumViaButton', this.addMetadatumViaButton); this.$eventBusMetadataList.$emitter.$on('addMetadatumViaButton', this.addMetadatumViaButton);
this.$eventBusMetadataList.$on('addMetadataSectionViaButton', this.addMetadataSectionViaButton); this.$eventBusMetadataList.$emitter.$on('addMetadataSectionViaButton', this.addMetadataSectionViaButton);
this.collectionId = this.$route.params.collectionId; this.collectionId = this.$route.params.collectionId;
this.isLoadingMetadataSections = true; this.isLoadingMetadataSections = true;
@ -600,8 +601,8 @@ export default {
if (this.metadataSearchCancel != undefined) if (this.metadataSearchCancel != undefined)
this.metadataSearchCancel.cancel('Metadata search Canceled.'); this.metadataSearchCancel.cancel('Metadata search Canceled.');
this.$eventBusMetadataList.$off('addMetadatumViaButton', this.addMetadatumViaButton); this.$eventBusMetadataList.$emitter.$off('addMetadatumViaButton', this.addMetadatumViaButton);
this.$eventBusMetadataList.$off('addMetadataSectionViaButton', this.addMetadataSectionViaButton); this.$eventBusMetadataList.$emitter.$off('addMetadataSectionViaButton', this.addMetadataSectionViaButton);
}, },
methods: { methods: {
...mapActions('metadata', [ ...mapActions('metadata', [

View File

@ -392,23 +392,29 @@ export default {
} }
}, },
watch: { watch: {
collections() { collections: {
this.selectedCollections = []; handler() {
for (let i = 0; i < this.collections.length; i++) this.selectedCollections = [];
this.selectedCollections.push(false); for (let i = 0; i < this.collections.length; i++)
this.selectedCollections.push(false);
},
deep: true
}, },
selectedCollections() { selectedCollections: {
let allSelected = true; handler() {
let isSelecting = false; let allSelected = true;
for (let i = 0; i < this.selectedCollections.length; i++) { let isSelecting = false;
if (this.selectedCollections[i] == false) { for (let i = 0; i < this.selectedCollections.length; i++) {
allSelected = false; if (this.selectedCollections[i] == false) {
} else { allSelected = false;
isSelecting = true; } else {
isSelecting = true;
}
} }
} this.allCollectionsOnPageSelected = allSelected;
this.allCollectionsOnPageSelected = allSelected; this.isSelectingCollections = isSelecting;
this.isSelectingCollections = isSelecting; },
deep: true
} }
}, },
methods: { methods: {

View File

@ -358,27 +358,33 @@
} }
}, },
watch: { watch: {
processes() { processes: {
this.selected = []; handler() {
for (let i = 0; i < this.processes.length; i++) this.selected = [];
this.selected.push(false); for (let i = 0; i < this.processes.length; i++)
this.selected.push(false);
this.collapses = [];
for (let i = 0; i < this.processes.length; i++) this.collapses = [];
this.collapses.push(false); for (let i = 0; i < this.processes.length; i++)
this.collapses.push(false);
},
deep: true
}, },
selected() { selected: {
let allSelected = true; handler() {
let isSelecting = false; let allSelected = true;
for (let i = 0; i < this.selected.length; i++) { let isSelecting = false;
if (this.selected[i] == false) { for (let i = 0; i < this.selected.length; i++) {
allSelected = false; if (this.selected[i] == false) {
} else { allSelected = false;
isSelecting = true; } else {
isSelecting = true;
}
} }
} this.allOnPageSelected = allSelected;
this.allOnPageSelected = allSelected; this.isSelecting = isSelecting;
this.isSelecting = isSelecting; },
deep: true
} }
}, },
mounted() { mounted() {

View File

@ -329,7 +329,8 @@ export default {
this.editMetadatum(this.activeMetadatumList[existingMetadataIndex]) this.editMetadatum(this.activeMetadatumList[existingMetadataIndex])
} }
}, },
immediate: true immediate: true,
deep: true
}, },
collapseAll(isCollapsed) { collapseAll(isCollapsed) {
this.activeMetadatumList.forEach((metadatum) => Object.assign(this.collapses, { [metadatum.id]: isCollapsed })); this.activeMetadatumList.forEach((metadatum) => Object.assign(this.collapses, { [metadatum.id]: isCollapsed }));
@ -338,7 +339,7 @@ export default {
mounted() { mounted() {
this.cleanMetadata(); this.cleanMetadata();
this.loadMetadata(); this.loadMetadata();
this.$eventBusMetadataList.$on('addMetadatumViaButton', this.addMetadatumViaButton); this.$eventBusMetadataList.$emitter.$on('addMetadatumViaButton', this.addMetadatumViaButton);
}, },
beforeUnmount() { beforeUnmount() {
// Cancels previous Request // Cancels previous Request

View File

@ -275,23 +275,28 @@
} }
}, },
watch: { watch: {
taxonomies() { taxonomies: {
this.selected = []; handler() {
for (let i = 0; i < this.taxonomies.length; i++) this.selected = [];
this.selected.push(false); for (let i = 0; i < this.taxonomies.length; i++)
this.selected.push(false);
}
}, },
selected() { selected: {
let allSelected = true; handler() {
let isSelecting = false; let allSelected = true;
for (let i = 0; i < this.selected.length; i++) { let isSelecting = false;
if (this.selected[i] == false) { for (let i = 0; i < this.selected.length; i++) {
allSelected = false; if (this.selected[i] == false) {
} else { allSelected = false;
isSelecting = true; } else {
isSelecting = true;
}
} }
} this.allOnPageSelected = allSelected;
this.allOnPageSelected = allSelected; this.isSelecting = isSelecting;
this.isSelecting = isSelecting; },
deep: true
} }
}, },
methods: { methods: {

View File

@ -321,12 +321,12 @@ export default {
}, },
created() { created() {
this.fetchTerms(); this.fetchTerms();
this.$parent.$on('deleteSelectedTerms', this.deleteSelectedTerms); this.$parent.$emitter.$on('deleteSelectedTerms', this.deleteSelectedTerms);
this.$parent.$on('updateSelectedTermsParent', this.updateSelectedTermsParent); this.$parent.$emitter.$on('updateSelectedTermsParent', this.updateSelectedTermsParent);
}, },
beforeUnmount() { beforeUnmount() {
this.$parent.$off('deleteSelectedTerms', this.deleteSelectedTerms); this.$parent.$emitter.$off('deleteSelectedTerms', this.deleteSelectedTerms);
this.$parent.$off('updateSelectedTermsParent', this.updateSelectedTermsParent); this.$parent.$emitter.$off('updateSelectedTermsParent', this.updateSelectedTermsParent);
}, },
methods: { methods: {
...mapActions('taxonomy', [ ...mapActions('taxonomy', [

View File

@ -279,7 +279,8 @@
this.editMetadatum(this.childrenMetadata[existingMetadataIndex]) this.editMetadatum(this.childrenMetadata[existingMetadataIndex])
} }
}, },
immediate: true immediate: true,
deep: true
}, },
'parent.metadata_type_options.children_objects': { 'parent.metadata_type_options.children_objects': {
handler(childrenObjects) { handler(childrenObjects) {
@ -288,7 +289,8 @@
else else
this.childrenMetadata = []; this.childrenMetadata = [];
}, },
immediate: true immediate: true,
deep: true
}, },
collapseAll(isCollapsed) { collapseAll(isCollapsed) {
this.childrenMetadata.forEach((metadatum) => Object.assign( this.collapses, { [metadatum.id]: isCollapsed })); this.childrenMetadata.forEach((metadatum) => Object.assign( this.collapses, { [metadatum.id]: isCollapsed }));

View File

@ -163,7 +163,7 @@
} }
}, },
watch:{ watch:{
collection( value ){ collection( value ) {
this.collection = value; this.collection = value;
if( value && value !== '' ) { if( value && value !== '' ) {
this.fetchMetadataFromCollection(value); this.fetchMetadataFromCollection(value);

View File

@ -157,8 +157,11 @@
} }
}, },
watch: { watch: {
valueComponent( val ) { valueComponent: {
this.$emit('input', val); handler( val ) {
this.$emit('input', val);
},
deep: true
} }
}, },
created() { created() {

View File

@ -76,11 +76,14 @@
} }
}, },
watch: { watch: {
selected() { selected: {
if (this.allowSelectToCreate && this.selected[0]) { hanlder() {
this.selected[0].label.includes(`(${this.$i18n.get('select_to_create')})`); if (this.allowSelectToCreate && this.selected[0]) {
this.selected[0].label = this.selected[0].label.split('(')[0]; this.selected[0].label.includes(`(${this.$i18n.get('select_to_create')})`);
} this.selected[0].label = this.selected[0].label.split('(')[0];
}
},
deep: true
} }
}, },
created() { created() {

View File

@ -667,9 +667,12 @@
} }
}, },
watch: { watch: {
'$route' (to, from) { '$route': {
if (to !== from) hanlder(to, from) {
this.$parent.close(); if (to !== from)
this.$parent.close();
},
deep: true
} }
}, },
created() { created() {

View File

@ -146,11 +146,14 @@ export default {
} }
}, },
watch: { watch: {
'$route' (to, from) { '$route': {
if (to.path != from.path) { handler(to, from) {
this.activeRoute = to.name; if (to.path != from.path) {
this.pageTitle = this.$route.meta.title; this.activeRoute = to.name;
} this.pageTitle = this.$route.meta.title;
}
},
deep: true
} }
}, },
created() { created() {

View File

@ -169,17 +169,23 @@ export default {
} }
}, },
watch: { watch: {
updatedProcesses() { updatedProcesses: {
if (this.updatedProcesses.length !== 0) { handler() {
for (let updatedProcess of this.updatedProcesses) { if (this.updatedProcesses.length !== 0) {
let updatedProcessIndex = this.bgProcesses.findIndex((aProcess) => aProcess.ID == updatedProcess.ID); for (let updatedProcess of this.updatedProcesses) {
if (updatedProcessIndex >= 0) let updatedProcessIndex = this.bgProcesses.findIndex((aProcess) => aProcess.ID == updatedProcess.ID);
Object.assign(this.bgProcesses, { [updatedProcessIndex]: updatedProcess }); if (updatedProcessIndex >= 0)
Object.assign(this.bgProcesses, { [updatedProcessIndex]: updatedProcess });
}
} }
} },
deep: true
}, },
bgProcesses(newBG) { bgProcesses: {
this.hasAnyProcessExecuting = newBG.some((element) => element.done <= 0); hanlder(newBG) {
this.hasAnyProcessExecuting = newBG.some((element) => element.done <= 0);
},
deep: true
} }
}, },
created() { created() {

View File

@ -134,9 +134,12 @@
} }
}, },
watch: { watch: {
filterTags() { filterTags: {
if (typeof this.swiper.update == 'function') handler() {
this.swiper.update(); if (typeof this.swiper.update == 'function')
this.swiper.update();
},
deep: true
} }
}, },
mounted() { mounted() {

View File

@ -535,7 +535,8 @@ export default {
this.editFilter(this.activeFiltersList[existingFilterIndex]) this.editFilter(this.activeFiltersList[existingFilterIndex])
} }
}, },
immediate: true immediate: true,
deep: true
} }
}, },
created() { created() {

View File

@ -37,24 +37,27 @@ export default {
} }
}, },
watch: { watch: {
'$route' (to, from) { '$route': {
if (!this.isRepositoryLevel && handler(to, from) {
(from != undefined) && if (!this.isRepositoryLevel &&
(from.path != undefined) && (from != undefined) &&
(to.path != from.path) && (from.path != undefined) &&
(this.collectionId != this.$route.params.collectionId) (to.path != from.path) &&
) { (this.collectionId != this.$route.params.collectionId)
this.isLoadingCollectionBasics = true; ) {
this.collectionId = this.$route.params.collectionId; this.isLoadingCollectionBasics = true;
this.fetchCollectionBasics({ collectionId: this.collectionId, isContextEdit: true }) this.collectionId = this.$route.params.collectionId;
.then(() => { this.fetchCollectionBasics({ collectionId: this.collectionId, isContextEdit: true })
this.isLoadingCollectionBasics = false; .then(() => {
}) this.isLoadingCollectionBasics = false;
.catch((error) => { })
this.$console.error(error); .catch((error) => {
this.isLoadingCollectionBasics = false; this.$console.error(error);
}); this.isLoadingCollectionBasics = false;
} });
}
},
deep: true
} }
}, },
created() { created() {

View File

@ -506,15 +506,18 @@ export default {
} }
}, },
watch: { watch: {
itemsLocations() { itemsLocations: {
setTimeout(() => { handler() {
if ( this.itemsLocations.length && this.$refs['tainacan-view-mode-map'] && this.$refs['tainacan-view-mode-map'].mapObject ) { setTimeout(() => {
if (this.itemsLocations.length == 1) if ( this.itemsLocations.length && this.$refs['tainacan-view-mode-map'] && this.$refs['tainacan-view-mode-map'].mapObject ) {
this.$refs['tainacan-view-mode-map'].mapObject.panInsideBounds(this.itemsLocations.map((anItemLocation) => anItemLocation.location), { animate: true, maxZoom: 16 }); if (this.itemsLocations.length == 1)
else this.$refs['tainacan-view-mode-map'].mapObject.panInsideBounds(this.itemsLocations.map((anItemLocation) => anItemLocation.location), { animate: true, maxZoom: 16 });
this.$refs['tainacan-view-mode-map'].mapObject.flyToBounds(this.itemsLocations.map((anItemLocation) => anItemLocation.location), { animate: true, maxZoom: 16 }); else
} this.$refs['tainacan-view-mode-map'].mapObject.flyToBounds(this.itemsLocations.map((anItemLocation) => anItemLocation.location), { animate: true, maxZoom: 16 });
}, 500) }
}, 500)
},
deep: true
}, },
selectedGeocoordinateMetadatum() { selectedGeocoordinateMetadatum() {
this.clearSelectedMarkers(); this.clearSelectedMarkers();
@ -533,7 +536,8 @@ export default {
else else
this.selectedGeocoordinateMetadatumId = this.$userPrefs.get(prefsGeocoordinateMetadatum); this.selectedGeocoordinateMetadatumId = this.$userPrefs.get(prefsGeocoordinateMetadatum);
}, },
immediate: true immediate: true,
deep: true
} }
}, },
methods: { methods: {

View File

@ -121,7 +121,8 @@ export default {
if (this.chartData && this.chartData.totals) if (this.chartData && this.chartData.totals)
this.buildActivitiesChart(); this.buildActivitiesChart();
}, },
immediate: true immediate: true,
deep: true
}, },
}, },
methods: { methods: {

View File

@ -54,6 +54,7 @@ export default {
this.buildActivitiesPerUserChart(); this.buildActivitiesPerUserChart();
}, },
immediate: true, immediate: true,
deep: true
} }
}, },
methods: { methods: {

View File

@ -45,7 +45,8 @@ export default {
handler() { handler() {
this.buildCollectionsList(); this.buildCollectionsList();
}, },
immediate: true immediate: true,
deep: true
} }
}, },
methods: { methods: {

View File

@ -171,7 +171,8 @@ export default {
if (this.taxonomiesListArray && this.taxonomiesListArray.length) if (this.taxonomiesListArray && this.taxonomiesListArray.length)
this.selectedTaxonomy = this.taxonomiesListArray[0]; this.selectedTaxonomy = this.taxonomiesListArray[0];
}, },
immediate: true immediate: true,
deep: true
}, },
selectedTaxonomy: { selectedTaxonomy: {
handler() { handler() {
@ -179,7 +180,8 @@ export default {
if (this.selectedTaxonomy && this.selectedTaxonomy.id) if (this.selectedTaxonomy && this.selectedTaxonomy.id)
this.loadTaxonomyTerms(); this.loadTaxonomyTerms();
}, },
immediate: true immediate: true,
deep: true
}, },
termsDisplayedPage() { termsDisplayedPage() {
this.buildTaxonomyTermsChart(); this.buildTaxonomyTermsChart();

View File

@ -363,7 +363,8 @@ export default {
if (this.metadataListArray && this.metadataListArray.length) if (this.metadataListArray && this.metadataListArray.length)
this.selectedMetadatum = this.metadataListArray[0]; this.selectedMetadatum = this.metadataListArray[0];
}, },
immediate: true immediate: true,
deep: true
}, },
selectedMetadatum: { selectedMetadatum: {
handler() { handler() {
@ -373,7 +374,8 @@ export default {
this.loadMetadatumTerms(); this.loadMetadatumTerms();
} }
}, },
immediate: true immediate: true,
deep: true
}, },
termsDisplayedPage() { termsDisplayedPage() {
this.buildMetadatumTermsChart(); this.buildMetadatumTermsChart();
@ -389,10 +391,13 @@ export default {
this.childTermsDisplayedPage = 1; this.childTermsDisplayedPage = 1;
this.buildMetadatumChildTermsChart(); this.buildMetadatumChildTermsChart();
}, },
selectedParentTerm() { selectedParentTerm: {
if (this.selectedParentTerm[this.selectedParentTerm.length - 1] && this.selectedParentTerm[this.selectedParentTerm.length - 1].id) { handler() {
this.loadMetadatumChildTerms(); if (this.selectedParentTerm[this.selectedParentTerm.length - 1] && this.selectedParentTerm[this.selectedParentTerm.length - 1].id) {
} this.loadMetadatumChildTerms();
}
},
deep: true
}, },
itemsPerTermChartMode() { itemsPerTermChartMode() {
this.termsDisplayedPage = 1; this.termsDisplayedPage = 1;

View File

@ -36,6 +36,7 @@ export default {
this.buildMetadataDistributionChart(); this.buildMetadataDistributionChart();
}, },
immediate: true, immediate: true,
deep: true
} }
}, },
methods: { methods: {

View File

@ -65,7 +65,8 @@ export default {
if (this.chartData && this.chartData.totals) if (this.chartData && this.chartData.totals)
this.buildMetadataTypeChart(); this.buildMetadataTypeChart();
}, },
immediate: true immediate: true,
deep: true
} }
}, },
methods: { methods: {

View File

@ -198,8 +198,11 @@ export default {
}) })
}, },
watch: { watch: {
totalByStatus() { totalByStatus: {
this.buildVisibilityChart(); handler() {
this.buildVisibilityChart();
},
deep: true
} }
}, },
methods: { methods: {

View File

@ -49,7 +49,8 @@ export default {
handler() { handler() {
this.buildTaxonomiesList(); this.buildTaxonomiesList();
}, },
immediate: true immediate: true,
deep: true
} }
}, },
methods: { methods: {

View File

@ -334,7 +334,8 @@ export default {
this.loadMetadataList(); this.loadMetadataList();
} }
}, },
immediate: true immediate: true,
deep: true
} }
}, },
created() { created() {