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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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