File tree Expand file tree Collapse file tree 3 files changed +21
-4
lines changed
documentation/docs/tutorial/03-Customization Expand file tree Collapse file tree 3 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ Keep the `<slot />` (that's where AdminForth renders the default button) and emi
224224 < ! -- Keep the slot : AdminForth renders the default action button / icon here -- >
225225 < ! -- Emit ` callAction ` (optionally with a payload ) to trigger the action when the wrapper is clicked -- >
226226 < ! -- Example : provide ` meta.extra ` to send custom data . In list views we merge with ` row ` so recordId context is kept . -- >
227- < div :style = " styleObj" @click = " emit('callAction', { ...props.row, ...(props.meta?.extra ?? {}) })" >
227+ < div :style = " styleObj" @click = " click( { ...props.row, ...(props.meta?.extra ?? {}) })" >
228228 < slot / >
229229 < / div >
230230< / template >
@@ -248,6 +248,14 @@ const styleObj = computed(() => ({
248248 borderRadius: (props .meta ?.radius ?? 8 ) + ' px' ,
249249 padding: (props .meta ?.padding ?? 2 ) + ' px' ,
250250}));
251+
252+ function click(payload : any ) {
253+ emit (' callAction' , { ... props .row , ... (props .meta ?.extra ?? {}) })
254+ }
255+ // we need to define this expose, because padding is added by adminforth wrapper and to trigger click on this padding we use this expose
256+ defineExpose ({
257+ click
258+ });
251259< / script >
252260```
253261
Original file line number Diff line number Diff line change 4343 </div >
4444 </div >
4545 </li >
46- <li v-for =" action in customActions" :key =" action.id" >
47- <div class =" wrapper" >
46+ <li v-for =" (action, i) in customActions" :key =" action.id" >
47+ <div
48+ class =" wrapper"
49+ @click =" injectedComponentClick(threeDotsDropdownItems ? threeDotsDropdownItems.length + i : i)"
50+ >
4851 <component
52+ :ref =" (el: any) => setComponentRef(el, threeDotsDropdownItems ? threeDotsDropdownItems.length + i : i)"
4953 :is =" (action.customComponent && getCustomComponent(formatComponent(action.customComponent))) || CallActionWrapper"
5054 :meta =" formatComponent(action.customComponent).meta"
5155 @callAction =" (payload? : Object) => handleActionClick(action, payload)"
52- >
56+ ] >
5357 <a @click.prevent class =" block" >
5458 <div class =" flex items-center gap-2 hover:text-lightThreeDotsMenuBodyTextHover hover:bg-lightThreeDotsMenuBodyBackgroundHover dark:hover:bg-darkThreeDotsMenuBodyBackgroundHover dark:hover:text-darkThreeDotsMenuBodyTextHover" >
5559 <component
@@ -173,6 +177,7 @@ function startBulkAction(actionId: string) {
173177}
174178
175179async function injectedComponentClick(index : number ) {
180+ console .log (' Injected component click triggered for index:' , index );
176181 const componentRef = threeDotsDropdownItemsRefs .value [index ];
177182 if (componentRef && ' click' in componentRef ) {
178183 (componentRef as any ).click ?.();
Original file line number Diff line number Diff line change 1515 const verificationResult = await modal .get2FaConfirmationResult ();
1616 emit (' callAction' , { verificationResult } );
1717 }
18+
19+ defineExpose ({
20+ click: onClick
21+ });
1822 </script >
You can’t perform that action at this time.
0 commit comments