Skip to content

Commit

Permalink
👔 Improved opening method logic (#492)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 committed Mar 26, 2022
1 parent 16aa14f commit 879b3b8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/components/LinkItems/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<a @click="itemOpened"
@mouseup.right="openContextMenu"
@contextmenu.prevent
:href="hyperLinkHref"
:href="url"
:target="anchorTarget"
:class="`item ${makeClassList}`"
v-tooltip="getTooltipOptions()"
Expand Down Expand Up @@ -141,6 +141,7 @@ export default {
},
/* Get href for anchor, if not in edit mode, or opening in modal/ workspace */
hyperLinkHref() {
// TODO Remove this method, and implement elsewhere
const nothing = '#';
if (this.isEditMode) return nothing;
const noAnchorNeeded = ['modal', 'workspace', 'clipboard'];
Expand Down Expand Up @@ -168,20 +169,28 @@ export default {
itemOpened(e) {
if (this.isEditMode) {
// If in edit mode, open settings, and don't launch app
e.preventDefault();
this.openItemSettings();
return;
}
if (e.altKey || this.accumulatedTarget === 'modal') {
// For certain opening methods, prevent default and manually navigate
if (e.ctrlKey) {
e.preventDefault();
window.open(this.url, '_blank');
} else if (e.altKey || this.accumulatedTarget === 'modal') {
e.preventDefault();
this.$emit('triggerModal', this.url);
} else if (this.accumulatedTarget === 'workspace') {
e.preventDefault();
router.push({ name: 'workspace', query: { url: this.url } });
} else if (this.accumulatedTarget === 'clipboard') {
e.preventDefault();
navigator.clipboard.writeText(this.url);
this.$toasted.show(this.$t('context-menus.item.copied-toast'));
} else {
this.$emit('itemClicked');
}
// Emit event to clear search field, etc
this.$emit('itemClicked');
// Update the most/ last used ledger, for smart-sorting
if (!this.appConfig.disableSmartSort) {
this.incrementMostUsedCount(this.id);
Expand Down

0 comments on commit 879b3b8

Please sign in to comment.