Skip to content

Commit

Permalink
Added a method to obtain the screen id for editing collections
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavobascope committed Nov 14, 2024
1 parent 11d5129 commit 36160d3
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions src/components/inspector/collection-records-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export default {
dataRecordList: [],
idCollectionScreenView: null,
idCollectionScreenEdit: null,
screenMode: null
screenMode: null,
collectionsMap: {}
};
},
computed: {
Expand All @@ -76,6 +77,7 @@ export default {
},
collectionId: {
handler() {
this.updateScreenIds();
this.getFields();
}
},
Expand Down Expand Up @@ -114,17 +116,20 @@ export default {
},
getCollections() {
this.$dataProvider.getCollections().then((response) => {
const [firstItem = {}] = response.data.data || [];
this.idCollectionScreenView = firstItem.read_screen_id;
this.idCollectionScreenEdit = firstItem.create_screen_id;
this.collectionsMap = response.data.data.reduce((acc, collection) => {
acc[collection.id] = {
read_screen_id: collection.read_screen_id,
create_screen_id: collection.create_screen_id
};
return acc;
}, {});
this.collections = [
{ value: null, text: this.$t("Select a collection") },
...response.data.data.map((collection) => {
return {
text: collection.name,
value: collection.id
};
})
...response.data.data.map((collection) => ({
text: collection.name,
value: collection.id
}))
];
});
},
Expand Down Expand Up @@ -155,6 +160,16 @@ export default {
},
onPmqlChange(pmql) {
this.pmql = pmql;
},
updateScreenIds() {
if (this.collectionId && this.collectionsMap[this.collectionId]) {
const selectedCollection = this.collectionsMap[this.collectionId];
this.idCollectionScreenView = selectedCollection.read_screen_id;
this.idCollectionScreenEdit = selectedCollection.create_screen_id;
} else {
this.idCollectionScreenView = null;
this.idCollectionScreenEdit = null;
}
}
}
};
Expand Down

0 comments on commit 36160d3

Please sign in to comment.