-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add three dots menu for the each record in listView #410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
The head ref may contain hidden characters: "feature/AdminForth/333/lets-add-add-plugin-\"clonerow\""
Changes from 1 commit
4eea42c
64f1810
2fc9a83
1d9a218
bc13264
1215d7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,218 @@ | ||||||
| <template> | ||||||
| <div class="relative inline-block"> | ||||||
| <div | ||||||
| ref="triggerRef" | ||||||
| class="border border-gray-300 dark:border-gray-700 dark:border-opacity-0 border-opacity-0 hover:border-opacity-100 dark:hover:border-opacity-100 rounded-md hover:bg-gray-100 dark:hover:bg-gray-800 cursor-pointer" | ||||||
| @click="toggleMenu" | ||||||
| > | ||||||
| <IconDotsHorizontalOutline class="w-6 h-6 text-lightPrimary dark:text-darkPrimary" /> | ||||||
| </div> | ||||||
| <teleport to="body"> | ||||||
| <div | ||||||
| v-if="showMenu" | ||||||
| ref="menuRef" | ||||||
| class="z-50 bg-white dark:bg-gray-900 rounded-md shadow-lg border dark:border-gray-700 py-1" | ||||||
| :style="menuStyles" | ||||||
| > | ||||||
| <template v-if="resourceOptions.moveBaseActionsOutOfThreeDotsMenu !== true"> | ||||||
| <RouterLink | ||||||
| v-if="resourceOptions?.allowedActions?.show" | ||||||
| class="flex text-nowrap p-1 hover:bg-gray-100 dark:hover:bg-gray-800 w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300" | ||||||
| :to="{ | ||||||
| name: 'resource-show', | ||||||
| params: { | ||||||
| resourceId: props.resourceId, | ||||||
| primaryKey: record._primaryKeyValue, | ||||||
| } | ||||||
| }" | ||||||
|
|
||||||
| > | ||||||
| <IconEyeSolid class="w-5 h-5 mr-2 text-lightPrimary dark:text-darkPrimary"/> | ||||||
| Show item | ||||||
| </RouterLink> | ||||||
|
|
||||||
| <RouterLink | ||||||
| v-if="resourceOptions?.allowedActions?.edit" | ||||||
| class="flex text-nowrap p-1 hover:bg-gray-100 dark:hover:bg-gray-800 w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300" | ||||||
| :to="{ | ||||||
| name: 'resource-edit', | ||||||
| params: { | ||||||
| resourceId: props.resourceId, | ||||||
| primaryKey: record._primaryKeyValue, | ||||||
| } | ||||||
| }" | ||||||
| > | ||||||
| <IconPenSolid class="w-5 h-5 mr-2 text-lightPrimary dark:text-darkPrimary"/> | ||||||
| Edit item | ||||||
| </RouterLink> | ||||||
|
|
||||||
| <button | ||||||
| v-if="resourceOptions?.allowedActions?.delete" | ||||||
| class="flex text-nowrap p-1 hover:bg-gray-100 dark:hover:bg-gray-800 w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300" | ||||||
| @click="deleteRecord(record)" | ||||||
| > | ||||||
| <IconTrashBinSolid class="w-5 h-5 mr-2 text-lightPrimary dark:text-darkPrimary"/> | ||||||
| Delete item | ||||||
| </button> | ||||||
| </template> | ||||||
| <div v-for="action in resourceOptions.actions.filter(a => a.showIn?.listThreeDotsMenu)" :key="action.id" > | ||||||
|
||||||
| <div v-for="action in resourceOptions.actions.filter(a => a.showIn?.listThreeDotsMenu)" :key="action.id" > | |
| <div v-for="action in (resourceOptions.actions ?? []).filter(a => a.showIn?.listThreeDotsMenu)" :key="action.id" > |
Outdated
Copilot
AI
Oct 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra space before closing parenthesis in rect.bottom ).
| top: `${Math.round(rect.bottom )}px`, | |
| top: `${Math.round(rect.bottom)}px`, |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,57 +113,58 @@ | |
| </td> | ||
| <td class=" items-center px-2 md:px-3 lg:px-6 py-4 cursor-default" @click="(e)=>{e.stopPropagation()}"> | ||
| <div class="flex text-lightPrimary dark:text-darkPrimary items-center"> | ||
| <Tooltip> | ||
| <RouterLink | ||
| v-if="resource.options?.allowedActions?.show" | ||
| :to="{ | ||
| name: 'resource-show', | ||
| params: { | ||
| resourceId: resource.resourceId, | ||
| primaryKey: row._primaryKeyValue, | ||
| } | ||
| }" | ||
|
|
||
| > | ||
| <IconEyeSolid class="af-show-icon w-5 h-5 me-2"/> | ||
| </RouterLink> | ||
|
|
||
| <template v-slot:tooltip> | ||
| {{ $t('Show item') }} | ||
| </template> | ||
| </Tooltip> | ||
|
|
||
| <Tooltip> | ||
| <RouterLink | ||
| v-if="resource.options?.allowedActions?.edit" | ||
| :to="{ | ||
| name: 'resource-edit', | ||
| params: { | ||
| resourceId: resource.resourceId, | ||
| primaryKey: row._primaryKeyValue, | ||
| } | ||
| }" | ||
| > | ||
| <IconPenSolid class="af-edit-icon w-5 h-5 me-2"/> | ||
| </RouterLink> | ||
| <template v-slot:tooltip> | ||
| {{ $t('Edit item') }} | ||
| </template> | ||
| </Tooltip> | ||
|
|
||
| <Tooltip> | ||
| <button | ||
| v-if="resource.options?.allowedActions?.delete" | ||
| @click="deleteRecord(row)" | ||
| > | ||
| <IconTrashBinSolid class="af-delete-icon w-5 h-5 me-2"/> | ||
| </button> | ||
|
|
||
| <template v-slot:tooltip> | ||
| {{ $t('Delete item') }} | ||
| </template> | ||
| </Tooltip> | ||
|
|
||
| <template v-if="resource.options.moveBaseActionsOutOfThreeDotsMenu === true"> | ||
| <Tooltip> | ||
| <RouterLink | ||
| v-if="resource.options?.allowedActions?.show" | ||
| :to="{ | ||
| name: 'resource-show', | ||
| params: { | ||
| resourceId: resource.resourceId, | ||
| primaryKey: row._primaryKeyValue, | ||
| } | ||
| }" | ||
|
|
||
| > | ||
| <IconEyeSolid class="af-show-icon w-5 h-5 me-2"/> | ||
| </RouterLink> | ||
|
|
||
| <template v-slot:tooltip> | ||
| {{ $t('Show item') }} | ||
| </template> | ||
| </Tooltip> | ||
|
|
||
| <Tooltip> | ||
| <RouterLink | ||
| v-if="resource.options?.allowedActions?.edit" | ||
| :to="{ | ||
| name: 'resource-edit', | ||
| params: { | ||
| resourceId: resource.resourceId, | ||
| primaryKey: row._primaryKeyValue, | ||
| } | ||
| }" | ||
| > | ||
| <IconPenSolid class="af-edit-icon w-5 h-5 me-2"/> | ||
| </RouterLink> | ||
| <template v-slot:tooltip> | ||
| {{ $t('Edit item') }} | ||
| </template> | ||
| </Tooltip> | ||
|
|
||
| <Tooltip> | ||
| <button | ||
| v-if="resource.options?.allowedActions?.delete" | ||
| @click="deleteRecord(row)" | ||
| > | ||
| <IconTrashBinSolid class="af-delete-icon w-5 h-5 me-2"/> | ||
| </button> | ||
|
|
||
| <template v-slot:tooltip> | ||
| {{ $t('Delete item') }} | ||
| </template> | ||
| </Tooltip> | ||
| </template> | ||
| <template v-if="customActionsInjection"> | ||
| <component | ||
| v-for="c in customActionsInjection" | ||
|
|
@@ -177,7 +178,7 @@ | |
| </template> | ||
|
|
||
| <template v-if="resource.options?.actions"> | ||
| <Tooltip v-for="action in resource.options.actions.filter(a => a.showIn?.list)" :key="action.id"> | ||
| <Tooltip v-for="action in resource.options.actions.filter(a => a.showIn?.list || a.showIn?.listQuickIcon)" :key="action.id"> | ||
| <button | ||
| @click="startCustomAction(action.id, row)" | ||
| > | ||
|
|
@@ -188,6 +189,16 @@ | |
| </template> | ||
| </Tooltip> | ||
| </template> | ||
| <ListActionsThreeDots | ||
| v-if="resource.options?.actions?.some(a => a.showIn?.listThreeDotsMenu) || (props.customActionIconsThreeDotsMenuItems && props.customActionIconsThreeDotsMenuItems.length > 0) || resource.options.moveBaseActionsOutOfThreeDotsMenu !== true" | ||
|
||
| :resourceOptions="resource?.options" | ||
| :record="row" | ||
| :updateRecords="()=>emits('update:records', true)" | ||
| :deleteRecord="deleteRecord" | ||
| :resourceId="resource.resourceId" | ||
| :startCustomAction="startCustomAction" | ||
| :customActionIconsThreeDotsMenuItems="customActionIconsThreeDotsMenuItems" | ||
| /> | ||
| </div> | ||
| </td> | ||
| </tr> | ||
|
|
@@ -312,6 +323,7 @@ import { Tooltip } from '@/afcl'; | |
| import type { AdminForthResourceCommon, AdminForthResourceColumnInputCommon, AdminForthResourceColumnCommon } from '@/types/Common'; | ||
| import adminforth from '@/adminforth'; | ||
| import Checkbox from '@/afcl/Checkbox.vue'; | ||
| import ListActionsThreeDots from '@/components/ListActionsThreeDots.vue'; | ||
|
|
||
| const coreStore = useCoreStore(); | ||
| const { t } = useI18n(); | ||
|
|
@@ -326,6 +338,7 @@ const props = defineProps<{ | |
| noRoundings?: boolean, | ||
| customActionsInjection?: any[], | ||
| tableBodyStartInjection?: any[], | ||
| customActionIconsThreeDotsMenuItems?: any[] | ||
| }>(); | ||
|
|
||
| // emits, update page | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yaroslav8765 can you open menu on @hover also (and close on @blur