-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix imports for public/common/components/FileListModal.vue
- Loading branch information
Showing
10 changed files
with
231 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<template> | ||
<v-menu | ||
:class="className()" | ||
:model-value="showContextMenu" | ||
:transition="false" | ||
:open-on-click="false" | ||
:open-on-focus="false" | ||
:open-on-hover="false" | ||
:open-delay="0" | ||
:close-delay="0" | ||
:close-on-back="false" | ||
@update:modelValue="onUpdate" | ||
> | ||
<v-list> | ||
<v-list-item | ||
v-for="(item, index) in getContextMenuItems()" | ||
:key="index" | ||
@click="item.action" | ||
> | ||
<template v-slot:prepend> | ||
<v-icon :color="item.iconColor"> | ||
{{item.icon}} | ||
</v-icon> | ||
</template> | ||
<template v-slot:title>{{ item.title }}</template> | ||
</v-list-item> | ||
</v-list> | ||
</v-menu> | ||
</template> | ||
|
||
<script> | ||
import contextMenuMixin from "../mixins/contextMenuMixin"; | ||
export default { | ||
mixins: [ | ||
contextMenuMixin(), | ||
], | ||
methods:{ | ||
className() { | ||
return "file-item-context-menu" | ||
}, | ||
onShowContextMenu(e, menuableItem) { | ||
this.onShowContextMenuBase(e, menuableItem); | ||
}, | ||
onCloseContextMenu() { | ||
this.onCloseContextMenuBase(); | ||
}, | ||
getContextMenuItems() { | ||
const ret = []; | ||
if (this.menuableItem) { | ||
if (this.isMobile()) { | ||
ret.push({ | ||
title: this.$vuetify.locale.t('$vuetify.close'), | ||
icon: 'mdi-close', | ||
action: () => { | ||
this.onCloseContextMenu() | ||
} | ||
}); | ||
} | ||
if (this.menuableItem.canShowAsImage) { | ||
ret.push({ | ||
title: this.$vuetify.locale.t('$vuetify.view'), | ||
icon: 'mdi-image', | ||
action: () => { | ||
this.$emit('showAsImage', this.menuableItem) | ||
} | ||
}); | ||
} | ||
if (this.menuableItem.canPlayAsVideo) { | ||
ret.push({ | ||
title: this.$vuetify.locale.t('$vuetify.play'), | ||
icon: 'mdi-play', | ||
action: () => { | ||
this.$emit('playAsVideo', this.menuableItem) | ||
} | ||
}); | ||
} | ||
if (this.menuableItem.canPlayAsAudio) { | ||
ret.push({ | ||
title: this.$vuetify.locale.t('$vuetify.play'), | ||
icon: 'mdi-play', | ||
action: () => { | ||
this.$emit('playAsAudio', this.menuableItem) | ||
} | ||
}); | ||
} | ||
} | ||
return ret; | ||
}, | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {differenceInDays, format, parseISO} from "date-fns"; | ||
import {enUS} from "date-fns/locale"; | ||
|
||
export const getHumanReadableDate = (timestamp) => { | ||
const parsedDate = parseISO(timestamp); | ||
let formatString = 'HH:mm:ss'; | ||
if (differenceInDays(new Date(), parsedDate) >= 1) { | ||
formatString = formatString + ', d MMM yyyy'; | ||
} | ||
|
||
const localeObj = {}; | ||
localeObj.locale = enUS; | ||
|
||
return `${format(parsedDate, formatString, localeObj)}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const KEY_FILE_LIST_MODE = 'fileListMode'; | ||
|
||
export const getStoredFileListMode = () => { | ||
let v = JSON.parse(localStorage.getItem(KEY_FILE_LIST_MODE)); | ||
if (v === null) { | ||
console.log("Resetting fileListMode to default"); | ||
const defaultFileListMode = !isMobileBrowser(); | ||
setStoredFileListMode(defaultFileListMode); | ||
v = JSON.parse(localStorage.getItem(KEY_FILE_LIST_MODE)); | ||
} | ||
return v; | ||
} | ||
|
||
export const setStoredFileListMode = (v) => { | ||
localStorage.setItem(KEY_FILE_LIST_MODE, JSON.stringify(v)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
export default () => { | ||
return { | ||
data(){ | ||
return { | ||
showContextMenu: false, | ||
menuableItem: null, | ||
contextMenuX: 0, | ||
contextMenuY: 0, | ||
} | ||
}, | ||
methods: { | ||
setPosition() { | ||
const element = document.querySelector("." + this.className() + " .v-overlay__content"); | ||
if (element) { | ||
element.style.position = "absolute"; | ||
element.style.top = this.contextMenuY + "px"; | ||
element.style.left = this.contextMenuX + "px"; | ||
|
||
const bottom = Number(getComputedStyle(element).bottom.replace("px", '')); | ||
if (bottom < 0) { | ||
const newTop = this.contextMenuY + bottom - 8; | ||
element.style.top = newTop + "px"; | ||
} | ||
|
||
const width = Number(getComputedStyle(element).width.replace("px", '')); | ||
if (width < 260) { | ||
const delta = Math.abs(260 - width); | ||
const newLeft = this.contextMenuX - delta - 8; | ||
element.style.left = newLeft + "px"; | ||
} | ||
} | ||
}, | ||
onShowContextMenuBase(e, menuableItem) { | ||
e.preventDefault(); | ||
|
||
this.contextMenuX = e.clientX; | ||
this.contextMenuY = e.clientY; | ||
|
||
this.menuableItem = menuableItem; | ||
|
||
if (!this.getContextMenuItems().length) { | ||
console.log("No items in the context menu"); | ||
return; | ||
} | ||
|
||
this.$nextTick(() => { | ||
this.showContextMenu = true; | ||
}).then(() => { | ||
this.setPosition() | ||
}) | ||
}, | ||
onCloseContextMenuBase() { | ||
this.showContextMenu = false; | ||
this.menuableItem = null; | ||
}, | ||
onUpdate(v) { | ||
if (!v) { | ||
this.onCloseContextMenu(); | ||
} | ||
}, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters