Skip to content

Commit

Permalink
update entity list when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
TeodoraPavlova committed Feb 2, 2024
1 parent 7729d14 commit f5ed0fa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions frontend/src/components/EntityList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@
</template>
<script>
import {computed} from "vue";
import {computed, watch} from "vue";
import ConfirmButton from "@/components/inputs/ConfirmButton";
import Pagination from "./layout/Pagination.vue";
import EntityListTable from "@/components/EntityListTable";
import SearchPanel from "./SearchPanel.vue";
import {updateEntityListCount} from "@/store";
export default {
components: {EntityListTable, Pagination, SearchPanel, ConfirmButton},
Expand All @@ -75,8 +76,8 @@ export default {
default: false
}
},
activated() {
this.getEntities({resetPage: false});
created() {
watch(updateEntityListCount, (async () => await this.getEntities({resetPage: false})));
},
computed: {
pages: computed(() => {
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/inputs/EntityForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import FloatInput from "@/components/inputs/FloatInput";
import ReferencedEntitySelect from "@/components/inputs/ReferencedEntitySelect";
import Spinner from "@/components/layout/Spinner";
import {TYPE_INPUT_MAP} from "@/utils";
import {updateEntityList} from "@/store";
export default {
Expand Down Expand Up @@ -227,6 +228,8 @@ export default {
body: this.editEntity
});
this.loading = false;
updateEntityList();
return response;
},
async saveEntity() {
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {ref} from 'vue';

export const updateEntityListCount = ref(0);
export const updateEntityList = () => updateEntityListCount.value++;

0 comments on commit f5ed0fa

Please sign in to comment.