1- import { computed , onUnmounted , ref , toRefs } from 'vue' ;
2- import { useUrl } from '@/composables/useUrl' ;
3- import { useFetch } from '@/composables/useFetch' ;
1+ import { computed , toRefs } from 'vue' ;
42import { defineComponentStore } from '@/utils/defineComponentStore' ;
53import { useExtender } from '@/composables/useExtender' ;
4+ import { useDataChanged } from '@/composables/useDataChanged' ;
65import { useDataCitationManagerConfig } from './useDataCitationManagerConfig' ;
76import { useDataCitationManagerActions } from './useDataCitationManagerActions' ;
87
98export const useDataCitationManagerStore = defineComponentStore (
109 'dataCitationManager' ,
1110 ( props ) => {
12-
1311 const extender = useExtender ( ) ;
14- const dataCitationManagerConfig = extender . addFns ( useDataCitationManagerConfig ( ) ) ;
12+ const dataCitationManagerConfig = extender . addFns (
13+ useDataCitationManagerConfig ( ) ,
14+ ) ;
1515 const columns = computed ( ( ) => dataCitationManagerConfig . getColumns ( ) ) ;
1616 const topItems = computed ( ( ) => dataCitationManagerConfig . getTopItems ( ) ) ;
1717
@@ -22,26 +22,23 @@ export const useDataCitationManagerStore = defineComponentStore(
2222 } ) ;
2323 }
2424
25- const {
26- submission,
27- publication,
28- } = toRefs ( props ) ;
29-
30- const { apiUrl } = useUrl ( `dataCitations/publications/${ publication . value . id } ` ) ;
31- const { data : apiResponse , fetch : fetchDataCitations } = useFetch ( apiUrl , {
32- method : 'GET' ,
33- } ) ;
25+ const { submission, publication} = toRefs ( props ) ;
26+
27+ // Get data citations directly from publication prop
28+ const dataCitations = computed (
29+ ( ) => publication . value ?. dataCitations ?? [ ] ,
30+ ) ;
3431
35- fetchDataCitations ( ) ;
36- const dataCitations = computed ( ( ) => { return apiResponse . value ?. items ?? [ ] ; } ) ;
32+ // Use triggerDataChange to notify parent to refetch submission/publication
33+ const { triggerDataChange } = useDataChanged ( ) ;
3734
3835 /**
3936 * Actions
4037 */
4138 const dataCitationManagerActions = useDataCitationManagerActions ( ) ;
4239
4340 function dataUpdateCallback ( ) {
44- fetchDataCitations ( ) ;
41+ triggerDataChange ( ) ;
4542 }
4643
4744 function getActionArgs ( additionalArgs = { } ) {
@@ -52,7 +49,7 @@ export const useDataCitationManagerStore = defineComponentStore(
5249 ...additionalArgs ,
5350 } ;
5451 }
55- function dataCitationAddDataCitation ( { } ) {
52+ function dataCitationAddDataCitation ( ) {
5653 dataCitationManagerActions . dataCitationAddDataCitation (
5754 getActionArgs ( { } ) ,
5855 dataUpdateCallback ,
0 commit comments