Skip to content
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

ImageGroup provides active image index and/or src #6551

Open
3 tasks done
vasotelvi opened this issue Nov 19, 2024 · 0 comments
Open
3 tasks done

ImageGroup provides active image index and/or src #6551

vasotelvi opened this issue Nov 19, 2024 · 0 comments
Labels
feature request New feature or request pr welcome

Comments

@vasotelvi
Copy link

Clear and concise description of the problem

I did not find any way to get the index or src of the active image in order to add the ability to delete an image and send the necessary data to the server in the toolbar - what exactly needs to be deleted.

Suggested solution

<n-image-group 
  :active ="activeIndex"
  :render-toolbar="renderToolbar" 
  show-toolbar-tooltip
  @update:active="setActiveIndex">
            <n-space>
                <n-image 
                     v-for="(link, index) of photos" 
                     lazy 
                     width="100" 
                     :src="link" 
                     :key="mCode + '-ph-' + index"
                  />
            </n-space>
</n-image-group>
<script setup>
//...
const activeIndex = ref(0);
const setActiveIndex = (index) => {
    activeIndex.value = index; 
    console.log('activeIndex.value: ', activeIndex.value)
};
//...
const renderToolbar = ({ nodes }) => {
    const currentImage = photos.value[activeIndex.value] // ← ???
    return [
        nodes.prev,
        nodes.next,
        nodes.rotateCounterclockwise,
        nodes.rotateClockwise,
        nodes.resizeToOriginalSize,
        nodes.zoomOut,
        nodes.close,
        h(
            NButton,
            {
                circle: true,
                type: "error",
                style: { marginLeft: "22px" },
                tooltip: "Удалить навсегда!",
                onClick: () => {
                    handleConfirm(currentImage); // ← ???
                }
            },
            {
                icon: () => h(TrashBinSharp)
            }
        )
    ]
}
//...

Alternative

Add an event to or that provides the active src and/or index of the active file being displayed

Additional context

No response

Validations

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@vasotelvi vasotelvi added the feature request New feature or request label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request pr welcome
Projects
None yet
Development

No branches or pull requests

2 participants