33 <component
44 v-for =" c in coreStore?.resourceOptions?.pageInjections?.edit?.beforeBreadcrumbs || []"
55 :is =" getCustomComponent(c)"
6- :meta =" c .meta"
6+ :meta =" (c as AdminForthComponentDeclarationFull) .meta"
77 :record =" editableRecord"
88 :resource =" coreStore.resource"
99 :adminUser =" coreStore.adminUser"
2727 </button >
2828
2929 <ThreeDotsMenu
30- :threeDotsDropdownItems =" coreStore.resourceOptions?.pageInjections?.edit?.threeDotsDropdownItems"
30+ :threeDotsDropdownItems =" Array.isArray(coreStore.resourceOptions?.pageInjections?.edit?.threeDotsDropdownItems)
31+ ? coreStore.resourceOptions.pageInjections.edit.threeDotsDropdownItems
32+ : coreStore.resourceOptions?.pageInjections?.edit?.threeDotsDropdownItems
33+ ? [coreStore.resourceOptions.pageInjections.edit.threeDotsDropdownItems]
34+ : undefined"
3135 ></ThreeDotsMenu >
3236
3337 </BreadcrumbsWithButtons >
3438
3539 <component
3640 v-for =" c in coreStore?.resourceOptions?.pageInjections?.edit?.afterBreadcrumbs || []"
3741 :is =" getCustomComponent(c)"
38- :meta =" c .meta"
42+ :meta =" (c as AdminForthComponentDeclarationFull) .meta"
3943 :record =" coreStore.record"
4044 :resource =" coreStore.resource"
4145 :adminUser =" coreStore.adminUser"
4448 <SingleSkeletLoader v-if =" loading" ></SingleSkeletLoader >
4549
4650 <ResourceForm
47- v-else
51+ v-else-if = " coreStore.resource "
4852 :record =" editableRecord"
4953 :resource =" coreStore.resource"
5054 :adminUser =" coreStore.adminUser"
5862 <component
5963 v-for =" c in coreStore?.resourceOptions?.pageInjections?.edit?.bottom || []"
6064 :is =" getCustomComponent(c)"
61- :meta =" c .meta"
65+ :meta =" (c as AdminForthComponentDeclarationFull) .meta"
6266 :record =" coreStore.record"
6367 :resource =" coreStore.resource"
6468 :adminUser =" coreStore.adminUser"
@@ -76,12 +80,13 @@ import SingleSkeletLoader from '@/components/SingleSkeletLoader.vue';
7680import { useCoreStore } from ' @/stores/core' ;
7781import { callAdminForthApi , getCustomComponent ,checkAcessByAllowedActions , initThreeDotsDropdown } from ' @/utils' ;
7882import { IconFloppyDiskSolid } from ' @iconify-prerendered/vue-flowbite' ;
79- import { computed , onMounted , ref } from ' vue' ;
83+ import { computed , onMounted , ref , type Ref } from ' vue' ;
8084import { useRoute , useRouter } from ' vue-router' ;
8185import { showErrorTost } from ' @/composables/useFrontendApi' ;
8286import ThreeDotsMenu from ' @/components/ThreeDotsMenu.vue' ;
8387import adminforth from ' @/adminforth' ;
8488import { useI18n } from ' vue-i18n' ;
89+ import { type AdminForthComponentDeclarationFull } from ' @/types/Common.js' ;
8590
8691const { t } = useI18n ();
8792const coreStore = useCoreStore ();
@@ -96,9 +101,9 @@ const loading = ref(true);
96101
97102const saving = ref (false );
98103
99- const record = ref ({});
104+ const record: Ref < Record < string , any >> = ref ({});
100105
101- async function onUpdateRecord(newRecord ) {
106+ async function onUpdateRecord(newRecord : Record < string , any > ) {
102107 record .value = newRecord ;
103108}
104109
@@ -110,7 +115,7 @@ const editableRecord = computed(() => {
110115 coreStore .resource .columns .forEach (column => {
111116 if (column .foreignResource ) {
112117 if (column .isArray ?.enabled ) {
113- newRecord [column .name ] = newRecord [column .name ]?.map (fr => fr .pk );
118+ newRecord [column .name ] = newRecord [column .name ]?.map (( fr : { pk : any }) => fr .pk );
114119 } else {
115120 newRecord [column .name ] = newRecord [column .name ]?.pk ;
116121 }
@@ -123,16 +128,20 @@ onMounted(async () => {
123128 loading .value = true ;
124129
125130 await coreStore .fetchResourceFull ({
126- resourceId: route .params .resourceId
131+ resourceId: route .params .resourceId as string // POTENTIONAL PROBLEM: resourceId can requires only <sting> type, but inside params.resourceId can be string[]
127132 });
128133 initThreeDotsDropdown ();
129134
130135 await coreStore .fetchRecord ({
131- resourceId: route .params .resourceId ,
132- primaryKey: route .params .primaryKey ,
136+ resourceId: route .params .resourceId as string , // POTENTIONAL PROBLEM: resourceId can requires only <sting> type, but inside params.resourceId can be string[]
137+ primaryKey: route .params .primaryKey as string , // POTENTIONAL PROBLEM: resourceId can requires only <sting> type, but inside params.resourceId can be string[]
133138 source: ' edit' ,
134139 });
135- checkAcessByAllowedActions (coreStore .resourceOptions .allowedActions ,' edit' );
140+
141+ if (coreStore .resourceOptions ) {
142+ checkAcessByAllowedActions (coreStore .resourceOptions .allowedActions ,' edit' );
143+ }
144+
136145 loading .value = false ;
137146});
138147
@@ -145,7 +154,7 @@ async function saveRecord() {
145154 }
146155
147156 saving .value = true ;
148- const updates = {};
157+ const updates: Record < string , any > = {};
149158 for (const key in record .value ) {
150159 let columnIsUpdated = false ;
151160
@@ -157,7 +166,8 @@ async function saveRecord() {
157166 columnIsUpdated = record .value [key ] !== coreStore .record [key ];
158167 }
159168
160- const column = coreStore .resource .columns .find ((c ) => c .name === key );
169+ if (! coreStore .resource ) return ;
170+ const column = coreStore .resource .columns .find ((c ) => c .name === key );
161171
162172 if (column ?.foreignResource ) {
163173 columnIsUpdated = record .value [key ] !== coreStore .record [key ]?.pk ;
0 commit comments