Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8b65172
fix: Added advanced Shift-Click-Handling for Files
tammi-23 Jun 12, 2025
4b429f8
fix: merge conflict resolved and components updated
tammi-23 Jun 12, 2025
1e5cd1f
fix: merge conflict resolved and components updated
tammi-23 Jun 12, 2025
3daa9f9
wip: fixed unit test
tammi-23 Jun 12, 2025
d5486b8
wip: Changes for Selection
tammi-23 Jun 13, 2025
875aa32
wip: added clickhandling for unittests
tammi-23 Jun 24, 2025
c4a0fe1
wip: removed comment line
tammi-23 Jun 24, 2025
14c2d52
wip: added handle for shortcuts
tammi-23 Jun 24, 2025
4fc1115
wip: fixed shortcut issue
tammi-23 Jun 26, 2025
229b37e
wip: fixed an issue with tags
tammi-23 Jun 26, 2025
21a537c
wip: cleanup console entries
tammi-23 Jun 26, 2025
e1c9b49
wip: added missing handling in tiles view
tammi-23 Jul 1, 2025
03576da
wip: deleted console entries and comments
tammi-23 Jul 1, 2025
0f2e851
wip: chnaged event type
tammi-23 Jul 1, 2025
896ebf2
wip: Added CTRL+META Key handling
tammi-23 Jul 10, 2025
e428275
wip: delete unnecessary imports
tammi-23 Jul 15, 2025
d983c59
wip: added MouseEvent mock
tammi-23 Jul 17, 2025
1dd0043
wip: adapted Code to suggested changes
tammi-23 Aug 5, 2025
6b9dcd4
wip: adjusted one more call
tammi-23 Aug 5, 2025
106408c
wip: resolved requested changes
tammi-23 Aug 6, 2025
c130d44
wip: fixed linting error
tammi-23 Aug 6, 2025
d74feeb
fix: adjusted snapdshots for unit tests
tammi-23 Aug 6, 2025
e959e3d
wip: resolved requested changes
tammi-23 Aug 7, 2025
7fcd91e
wip: more adjustment
tammi-23 Aug 7, 2025
555b651
wip: fixed event handling
tammi-23 Aug 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:data-testid="indicator.id"
:data-test-indicator-type="indicator.type"
no-hover
@click="indicator.handler(resource)"
@click="(e: MouseEvent) => indicator.handler?.(resource, e)"
>
<oc-icon :name="indicator.icon" size="small" :fill-type="indicator.fillType" />
</oc-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ export const useKeyboardTableMouseActions = (
resource: Item
skipTargetSelection: boolean
}) => {
const parent = document.querySelectorAll(`[data-item-id='${resource.id}']`)[0]
const targetNode = document.querySelector(`[data-item-id='${resource.id}']`)
const parent = targetNode?.closest('tr') || targetNode?.parentElement

const resourceNodes = Object.values(parent.parentNode.children)
const latestNode = resourceNodes.find(
(r) => r.getAttribute('data-item-id') === unref(lastSelectedRowId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
appearance="raw"
class="oc-ml-xs quick-action-button oc-p-xs"
:class="`files-quick-action-${action.name}`"
@click="action.handler({ space, resources: [item] })"
@click="(e: MouseEvent) => action.handler({ space, resources: [item], event: e })"
>
<oc-icon :name="action.icon" fill-type="line" />
</oc-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ import {
useResourcesStore,
formatDateFromJSDate,
useResourceContents,
useLoadPreview
useLoadPreview,
useInterceptModifierClick
} from '@opencloud-eu/web-pkg'
import upperFirst from 'lodash-es/upperFirst'
import {
Expand Down Expand Up @@ -173,7 +174,7 @@ const { $gettext, current: currentLanguage } = language

const resourcesStore = useResourcesStore()
const { ancestorMetaData, currentFolder } = storeToRefs(resourcesStore)

const { interceptModifierClick } = useInterceptModifierClick()
const { user } = storeToRefs(userStore)

const resource = inject<Ref<Resource>>('resource')
Expand Down Expand Up @@ -229,7 +230,8 @@ const shareIndicators = computed(() => {
space: unref(space),
resource: unref(resource),
ancestorMetaData: unref(ancestorMetaData),
user: unref(user)
user: unref(user),
interceptModifierClick
}).filter(({ category }) => category === 'sharing')
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useKeyboardFileMouseActions = (
skipTargetSelection: boolean
}) => {
if (!shiftSelectionAnchorId) {
shiftSelectionAnchorId = unref(latestSelectedId)
shiftSelectionAnchorId = unref(latestSelectedId) || resource.id
}
resourcesStore.setSelection([])

Expand Down Expand Up @@ -69,7 +69,7 @@ export const useKeyboardFileMouseActions = (
skipTargetSelection: boolean
}) => {
if (!shiftSelectionAnchorId) {
shiftSelectionAnchorId = unref(latestSelectedId)
shiftSelectionAnchorId = unref(latestSelectedId) || resource.id
}
resourcesStore.setSelection([])

Expand All @@ -84,6 +84,10 @@ export const useKeyboardFileMouseActions = (
(r: { getAttribute: (arg0: string) => string }) =>
r.getAttribute('data-item-id') === shiftSelectionAnchorId
)

if (startIndex === -1 || endIndex === -1) {
return
}
const minIndex = Math.min(endIndex, startIndex)
const maxIndex = Math.max(endIndex, startIndex)

Expand Down
11 changes: 8 additions & 3 deletions packages/web-pkg/src/components/FilesList/ResourceLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ export default {
},
computed: {
isNavigatable() {
if (!this.resource) {
return false
}
return (this.resource.isFolder || this.link) && !this.resource.disabled
},
componentType() {
Expand All @@ -90,15 +93,17 @@ export default {
}
},
methods: {
emitClick() {
emitClick(e: MouseEvent) {
if (!e || typeof e.stopPropagation !== 'function') {
return
}
if (this.isNavigatable) {
return
}

/**
* Triggered when the resource is a file and the name is clicked
*/
this.$emit('click')
this.$emit('click', e)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { getIndicators, ResourceIndicator } from '../../helpers'
import { computed, useAttrs } from 'vue'
import { useResourcesStore, useUserStore } from '../../composables/piniaStores'
import { OcStatusIndicators } from '@opencloud-eu/design-system/components'
import { useInterceptModifierClick } from '../../composables/keyboardActions'

const attrs = useAttrs() as (typeof OcStatusIndicators)['props']
const {
Expand All @@ -27,12 +28,15 @@ const {

const userStore = useUserStore()
const resourcesStore = useResourcesStore()
const { interceptModifierClick } = useInterceptModifierClick()

const indicators = computed(() => {
const list = getIndicators({
space,
resource,
ancestorMetaData: resourcesStore.ancestorMetaData,
user: userStore.user
user: userStore.user,
interceptModifierClick
})

if (filter) {
Expand Down
71 changes: 60 additions & 11 deletions packages/web-pkg/src/components/FilesList/ResourceTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@
:disabled="isResourceDisabled(item)"
:model-value="isResourceSelected(item)"
:outline="isLatestSelectedItem(item)"
@click.stop="toggleSelection(item.id)"
@click.stop="
(e: MouseEvent) => {
if (!interceptModifierClick(e, item)) {
toggleSelection(item.id)
}
}
"
/>
</template>
<template #name="{ item }">
Expand Down Expand Up @@ -97,7 +103,14 @@
v-if="hasRenameAction(item)"
class="resource-table-edit-name raw-hover-surface oc-p-xs"
appearance="raw"
@click="openRenameDialog(item)"
@click.stop="
(e: MouseEvent) => {
if (interceptModifierClick(e, item)) {
return
}
openRenameDialog(item)
}
"
>
<oc-icon name="edit-2" fill-type="line" size="small" />
</oc-button>
Expand Down Expand Up @@ -133,7 +146,7 @@
v-if="item.tags.length > 2"
size="small"
class="resource-table-tag-more"
@click="openTagsSidebar"
@click="openTagsSidebar()"
>
+ {{ item.tags.length - 2 }}
</oc-tag>
Expand Down Expand Up @@ -187,7 +200,14 @@
appearance="raw-inverse"
class="resource-table-shared-by"
no-hover
@click="openSharingSidebar(item)"
@click.stop="
(e: MouseEvent) => {
if (interceptModifierClick(e, item)) {
return
}
openSharingSidebar(item, e)
}
"
>
<oc-avatars
class="resource-table-people"
Expand All @@ -213,7 +233,14 @@
appearance="raw-inverse"
class="resource-table-shared-with"
no-hover
@click="openSharingSidebar(item)"
@click.stop="
(e: MouseEvent) => {
if (interceptModifierClick(e, item)) {
return
}
openSharingSidebar(item, e)
}
"
>
<oc-avatars
class="resource-table-people"
Expand Down Expand Up @@ -320,6 +347,7 @@ import {
} from '../../helpers'
import { SideBarEventTopics } from '../../composables/sideBar'
import ContextMenuQuickAction from '../ContextActions/ContextMenuQuickAction.vue'
import { useInterceptModifierClick } from '../../composables/keyboardActions'

import { useResourceRouteResolver } from '../../composables/filesList/useResourceRouteResolver'
import { ClipboardActions } from '../../helpers/clipboardActions'
Expand Down Expand Up @@ -569,6 +597,7 @@ export default defineComponent({
const capabilityStore = useCapabilityStore()
const { getMatchingSpace } = useGetMatchingSpace()
const { canBeOpenedWithSecureView } = useCanBeOpenedWithSecureView()
const { interceptModifierClick } = useInterceptModifierClick()
const folderLinkUtils = useFolderLink({
space: ref(props.space),
targetRouteCallback: computed(() => props.targetRouteCallback)
Expand Down Expand Up @@ -729,6 +758,8 @@ export default defineComponent({
isEmbedModeEnabled,
emitSelect,
toggleSelection,
eventBus,
interceptModifierClick,
areFileExtensionsShown,
latestSelectedId,
isResourceClickable,
Expand Down Expand Up @@ -1028,8 +1059,17 @@ export default defineComponent({
openTagsSidebar() {
eventBus.publish(SideBarEventTopics.open)
},
openSharingSidebar(file: Resource) {
let panelToOpen
handleFileClick(e: MouseEvent, resource: Resource) {
if (this.interceptModifierClick(e, resource)) {
return
}
this.$emit('fileClick', { space: this.getMatchingSpace(resource), resources: [resource] })
},
openSharingSidebar(file: Resource, event?: MouseEvent) {
if (event instanceof MouseEvent && this.interceptModifierClick(event, file)) {
return
}
let panelToOpen: unknown
if (file.type === 'space') {
panelToOpen = 'space-share'
} else {
Expand Down Expand Up @@ -1096,11 +1136,16 @@ export default defineComponent({
this.toggleSelection(file.id)
},
showContextMenuOnBtnClick(data: ContextMenuBtnClickEventData, item: Resource) {
const { dropdown, event } = data

if (event instanceof MouseEvent && this.interceptModifierClick(event, item)) {
return
}

if (this.isResourceDisabled(item)) {
return false
}

const { dropdown, event } = data
if (dropdown?.tippy === undefined) {
return
}
Expand All @@ -1110,8 +1155,10 @@ export default defineComponent({
displayPositionedDropdown(dropdown.tippy, event, this.contextMenuButton)
},
showContextMenu(row: ComponentPublicInstance<unknown>, event: MouseEvent, item: Resource) {
if (event instanceof MouseEvent && this.interceptModifierClick(event, item)) {
return
}
event.preventDefault()

if (this.isResourceDisabled(item)) {
return false
}
Expand Down Expand Up @@ -1208,9 +1255,11 @@ export default defineComponent({
.map((resource) => resource.id)
)
},
emitFileClick(resource: Resource) {
emitFileClick(resource: Resource, event?: MouseEvent) {
if (this.interceptModifierClick(event, resource)) {
return
}
const space = this.getMatchingSpace(resource)

/**
* Triggered when a default action is triggered on a file
* @property {object} resource resource for which the event is triggered
Expand Down
13 changes: 10 additions & 3 deletions packages/web-pkg/src/components/FilesList/ResourceTile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
:aria-label="tooltipLabelIcon"
>
<slot name="imageField" :item="resource">
<oc-image v-if="resource.thumbnail" class="tile-preview" :src="resource.thumbnail" />
<oc-image
v-if="resource.thumbnail"
class="tile-preview"
:src="resource.thumbnail"
@click="toggleTile([resource, $event])"
/>
<resource-icon
v-else
:resource="resource"
Expand All @@ -53,7 +58,7 @@
</slot>
</div>
</resource-link>
<div class="oc-card-body oc-p-s">
<div class="oc-card-body oc-p-s" @click.stop="toggleTile([resource, $event])">
<div class="oc-flex oc-flex-between oc-flex-middle">
<div class="oc-flex oc-flex-middle oc-text-truncate resource-name-wrapper">
<resource-list-item
Expand All @@ -62,7 +67,7 @@
:is-extension-displayed="isExtensionDisplayed"
:is-resource-clickable="isResourceClickable"
:link="resourceRoute"
@click="$emit('click')"
@click.stop="$emit('click')"
/>
</div>
<div class="oc-flex oc-flex-middle">
Expand Down Expand Up @@ -93,6 +98,7 @@ import { isSpaceResource } from '@opencloud-eu/web-client'
import { RouteLocationRaw } from 'vue-router'
import { useIsVisible } from '@opencloud-eu/design-system/composables'
import { SizeType } from '@opencloud-eu/design-system/helpers'
import { useToggleTile } from '../../composables/selection'

const {
resource,
Expand Down Expand Up @@ -130,6 +136,7 @@ defineSlots<{
selection?: (props: { item: Resource }) => unknown
}>()

const { toggleTile } = useToggleTile()
const { $gettext } = useGettext()

const observerTarget = customRef((track, trigger) => {
Expand Down
Loading