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': {
handler(to) {
this.isMenuCompressed = (to.params.collectionId != undefined); this.isMenuCompressed = (to.params.collectionId != undefined);
this.activeRoute = to.name; this.activeRoute = to.name;
this.isRepositoryLevel = this.$route.params.collectionId == undefined; this.isRepositoryLevel = this.$route.params.collectionId == undefined;
},
deep: true
} }
}, },
created() { created() {

View File

@ -65,8 +65,11 @@
} }
}, },
watch: { watch: {
'query'() { 'query': {
handler() {
this.updateSelectedValues(); 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': {
handler() {
this.updateSelectedValues(); this.updateSelectedValues();
},
deep: true
} }
}, },
mounted() { mounted() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -67,8 +67,11 @@
}, },
immediate: true immediate: true
}, },
'query'() { 'query': {
handler() {
this.updateSelectedValues(); 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,12 +392,16 @@ export default {
} }
}, },
watch: { watch: {
collections() { collections: {
handler() {
this.selectedCollections = []; this.selectedCollections = [];
for (let i = 0; i < this.collections.length; i++) for (let i = 0; i < this.collections.length; i++)
this.selectedCollections.push(false); this.selectedCollections.push(false);
}, },
selectedCollections() { deep: true
},
selectedCollections: {
handler() {
let allSelected = true; let allSelected = true;
let isSelecting = false; let isSelecting = false;
for (let i = 0; i < this.selectedCollections.length; i++) { for (let i = 0; i < this.selectedCollections.length; i++) {
@ -409,6 +413,8 @@ export default {
} }
this.allCollectionsOnPageSelected = allSelected; this.allCollectionsOnPageSelected = allSelected;
this.isSelectingCollections = isSelecting; this.isSelectingCollections = isSelecting;
},
deep: true
} }
}, },
methods: { methods: {

View File

@ -358,7 +358,8 @@
} }
}, },
watch: { watch: {
processes() { processes: {
handler() {
this.selected = []; this.selected = [];
for (let i = 0; i < this.processes.length; i++) for (let i = 0; i < this.processes.length; i++)
this.selected.push(false); this.selected.push(false);
@ -367,7 +368,10 @@
for (let i = 0; i < this.processes.length; i++) for (let i = 0; i < this.processes.length; i++)
this.collapses.push(false); this.collapses.push(false);
}, },
selected() { deep: true
},
selected: {
handler() {
let allSelected = true; let allSelected = true;
let isSelecting = false; let isSelecting = false;
for (let i = 0; i < this.selected.length; i++) { for (let i = 0; i < this.selected.length; i++) {
@ -379,6 +383,8 @@
} }
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,12 +275,15 @@
} }
}, },
watch: { watch: {
taxonomies() { taxonomies: {
handler() {
this.selected = []; this.selected = [];
for (let i = 0; i < this.taxonomies.length; i++) for (let i = 0; i < this.taxonomies.length; i++)
this.selected.push(false); this.selected.push(false);
}
}, },
selected() { selected: {
handler() {
let allSelected = true; let allSelected = true;
let isSelecting = false; let isSelecting = false;
for (let i = 0; i < this.selected.length; i++) { for (let i = 0; i < this.selected.length; i++) {
@ -292,6 +295,8 @@
} }
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

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

View File

@ -76,11 +76,14 @@
} }
}, },
watch: { watch: {
selected() { selected: {
hanlder() {
if (this.allowSelectToCreate && this.selected[0]) { if (this.allowSelectToCreate && this.selected[0]) {
this.selected[0].label.includes(`(${this.$i18n.get('select_to_create')})`); this.selected[0].label.includes(`(${this.$i18n.get('select_to_create')})`);
this.selected[0].label = this.selected[0].label.split('(')[0]; 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': {
hanlder(to, from) {
if (to !== from) if (to !== from)
this.$parent.close(); this.$parent.close();
},
deep: true
} }
}, },
created() { created() {

View File

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

View File

@ -169,7 +169,8 @@ export default {
} }
}, },
watch: { watch: {
updatedProcesses() { updatedProcesses: {
handler() {
if (this.updatedProcesses.length !== 0) { if (this.updatedProcesses.length !== 0) {
for (let updatedProcess of this.updatedProcesses) { for (let updatedProcess of this.updatedProcesses) {
let updatedProcessIndex = this.bgProcesses.findIndex((aProcess) => aProcess.ID == updatedProcess.ID); let updatedProcessIndex = this.bgProcesses.findIndex((aProcess) => aProcess.ID == updatedProcess.ID);
@ -178,8 +179,13 @@ export default {
} }
} }
}, },
bgProcesses(newBG) { deep: true
},
bgProcesses: {
hanlder(newBG) {
this.hasAnyProcessExecuting = newBG.some((element) => element.done <= 0); this.hasAnyProcessExecuting = newBG.some((element) => element.done <= 0);
},
deep: true
} }
}, },
created() { created() {

View File

@ -134,9 +134,12 @@
} }
}, },
watch: { watch: {
filterTags() { filterTags: {
handler() {
if (typeof this.swiper.update == 'function') if (typeof this.swiper.update == 'function')
this.swiper.update(); 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,7 +37,8 @@ export default {
} }
}, },
watch: { watch: {
'$route' (to, from) { '$route': {
handler(to, from) {
if (!this.isRepositoryLevel && if (!this.isRepositoryLevel &&
(from != undefined) && (from != undefined) &&
(from.path != undefined) && (from.path != undefined) &&
@ -55,6 +56,8 @@ export default {
this.isLoadingCollectionBasics = false; this.isLoadingCollectionBasics = false;
}); });
} }
},
deep: true
} }
}, },
created() { created() {

View File

@ -506,7 +506,8 @@ export default {
} }
}, },
watch: { watch: {
itemsLocations() { itemsLocations: {
handler() {
setTimeout(() => { setTimeout(() => {
if ( this.itemsLocations.length && this.$refs['tainacan-view-mode-map'] && this.$refs['tainacan-view-mode-map'].mapObject ) { if ( this.itemsLocations.length && this.$refs['tainacan-view-mode-map'] && this.$refs['tainacan-view-mode-map'].mapObject ) {
if (this.itemsLocations.length == 1) if (this.itemsLocations.length == 1)
@ -516,6 +517,8 @@ export default {
} }
}, 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,11 +391,14 @@ export default {
this.childTermsDisplayedPage = 1; this.childTermsDisplayedPage = 1;
this.buildMetadatumChildTermsChart(); this.buildMetadatumChildTermsChart();
}, },
selectedParentTerm() { selectedParentTerm: {
handler() {
if (this.selectedParentTerm[this.selectedParentTerm.length - 1] && this.selectedParentTerm[this.selectedParentTerm.length - 1].id) { if (this.selectedParentTerm[this.selectedParentTerm.length - 1] && this.selectedParentTerm[this.selectedParentTerm.length - 1].id) {
this.loadMetadatumChildTerms(); this.loadMetadatumChildTerms();
} }
}, },
deep: true
},
itemsPerTermChartMode() { itemsPerTermChartMode() {
this.termsDisplayedPage = 1; this.termsDisplayedPage = 1;
this.loadMetadatumTerms(); this.loadMetadatumTerms();

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: {
handler() {
this.buildVisibilityChart(); 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() {