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

Allow opening in new tab for common controls #46

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
Documentation:
permissions:
Expand Down
3 changes: 3 additions & 0 deletions documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.83.0
* Allow opening in new tab for common controls

## 0.82.0
* Use proper close icon reference
* Add style presentation as buttton for mass action with only one option
Expand Down
28 changes: 22 additions & 6 deletions src/js/components/mainNavigation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
:href="item.url"
:class="['item', item.icon ? 'icon' + item.icon : '', {selected: item.selected}]"
:title="item.caption"
@click.prevent="openItem(item)"
@click="openItem(item, $event)"
>
{{ item.caption }}
<span v-if="!item.icon" class="initials">{{ item.initials }}</span>
Expand Down Expand Up @@ -57,7 +57,7 @@
:href="subItem.url"
:class="['item', {selected: subItem.selected}]"
:title="subItem.caption"
@click.prevent="openItem(subItem)"
@click="openItem(subItem, $event)"
>
{{ subItem.caption }}
</a>
Expand All @@ -83,7 +83,7 @@
class="item"
:href="item.url"
v-html="item.caption"
@click.prevent="openUserItem(item)"
@click="openUserItem(item, $event)"
></a>
<button
v-else
Expand All @@ -107,7 +107,7 @@
</template>

<script>
import {pickTo} from '../library/toolkit.js';
import {pickTo, isNewTabClick} from '../library/toolkit.js';
import vueDismiss from '../dependencies/vue-dismiss/index.js';
import serviceContainer from '../library/serviceContainer.js';
import {GlobalEvents} from 'vue-global-events';
Expand Down Expand Up @@ -234,7 +234,15 @@ export default {

},

openItem(item) {
openItem(item, event) {

if (isNewTabClick(event)) {
return;
}

if (event) {
event.preventDefault();
}

if (item.action) {
item.action(this);
Expand Down Expand Up @@ -288,7 +296,15 @@ export default {

},

openUserItem(item) {
openUserItem(item, event) {

if (isNewTabClick(event)) {
return;
}

if (event) {
event.preventDefault();
}

if (item.action) {
item.action(this);
Expand Down
22 changes: 13 additions & 9 deletions src/js/components/resourceControls.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<template>
<nav class="resourceControls" v-if="parsedControls.length">
<template v-for="(control, index) in parsedControls">
<template v-for="(control, index) in parsedControls" :key="control.caption + index">
<div
v-if="control.isDropdown"
:key="control.caption + index"
class="dropdownControls"
:class="{active: control.active, accentedAdjecent: control.accentedAdjecent}"
v-on-dismiss="{callback: () => closeDropdown(control), watch: control.active}"
Expand Down Expand Up @@ -31,21 +30,19 @@
<a
v-else-if="control.url"
:href="control.url"
:key="control.caption + index"
:class="control.className"
:title="control.caption"
@click.prevent="runControlAction(control)"
@click="runControlAction(control, $event)"
>
<span>{{ control.caption }}</span>
</a>
<button
v-else
class="nBtn"
type="button"
:key="control.caption + index"
:class="control.className"
:title="control.caption"
@click.prevent="runControlAction(control)"
@click="runControlAction(control, $event)"
>
<span>{{ control.caption }}</span>
</button>
Expand All @@ -56,7 +53,7 @@
<script>

import translate from '../library/translate.js';
import {assign} from '../library/toolkit.js';
import {assign, isNewTabClick} from '../library/toolkit.js';
import vueDismiss from '../dependencies/vue-dismiss/index.js';
import screenSize from '../mixins/screenSize.js';

Expand Down Expand Up @@ -119,9 +116,16 @@ export default {

},

runControlAction(config) {
runControlAction(config, event) {

config.action.call(config.actionContext);
if (isNewTabClick(event)) {
// do nothing
} else {
if (event) {
event.preventDefault();
}
config.action.call(config.actionContext);
}

},

Expand Down
15 changes: 9 additions & 6 deletions src/js/components/resourceHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
<header class="headerType1" :class={hasBottomBorder}>
<h1 class="projectCaption">{{ projectCaption }}</h1>
<h2 v-if="breadcrumbs.length" class="title">
<template v-for="(breadcrumb, index) in breadcrumbs">
<template v-for="(breadcrumb, index) in breadcrumbs" :key="breadcrumb.caption">
<a
v-if="breadcrumb.url"
:key="breadcrumb.caption"
:href="breadcrumb.url"
:class="{iconChevronRight: index + 1 < breadcrumbs.length}"
@click.prevent="clickBreadcrumb(breadcrumb)"
@click="clickBreadcrumb(breadcrumb, $event)"
>
{{ breadcrumb.caption }}
</a>
<span
v-else
:key="breadcrumb.caption"
:class="{iconChevronRight: index + 1 < breadcrumbs.length}"
>
{{ breadcrumb.caption }}
Expand All @@ -26,6 +24,7 @@
</template>

<script>
import {isNewTabClick} from '../library/toolkit.js';

export default {

Expand All @@ -46,11 +45,15 @@ export default {

methods: {

clickBreadcrumb(breadcrumb) {
clickBreadcrumb(breadcrumb, e) {

if (breadcrumb.action) {
if (isNewTabClick(e)) {
// do nothing
} else if (breadcrumb.action) {
e.preventDefault();
breadcrumb.action();
} else if (breadcrumb.url) {
e.preventDefault();
this.$router.navigateTo(breadcrumb.url);
}

Expand Down
23 changes: 15 additions & 8 deletions src/js/components/resourcePagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
v-if="currentPage !== 1"
class="iconArrowLeft icon page icr"
:href="getUrlForPage(currentPage - 1)"
@click.prevent="selectPage(currentPage - 1)"
@click="selectPage(currentPage - 1, $event)"
>
{{ currentPage - 1 }}
</a>
Expand All @@ -38,7 +38,7 @@
<a
:class="['page', {selected: 1 == currentPage}]"
:href="getUrlForPage(1)"
@click.prevent="selectPage(1)"
@click="selectPage(1, $event)"
>1</a>
</li>

Expand All @@ -51,7 +51,7 @@
<a
:class="['page', {selected: page == currentPage}]"
:href="getUrlForPage(page)"
@click.prevent="selectPage(page)"
@click="selectPage(page, $event)"
>{{ page }}</a>
</li>

Expand All @@ -64,7 +64,7 @@
<a
:class="['page', {selected: totalPages === currentPage}]"
:href="getUrlForPage(totalPages)"
@click.prevent="selectPage(totalPages)"
@click="selectPage(totalPages, $event)"
>{{ totalPages }}</a>
</li>

Expand All @@ -73,7 +73,7 @@
v-if="currentPage < totalPages"
class="iconArrowRight page icon icr"
:href="getUrlForPage(currentPage + 1)"
@click.prevent="selectPage(currentPage + 1)"
@click="selectPage(currentPage + 1, $event)"
>{{ currentPage + 1 }}
</a>
<button v-else class="iconArrowRight disabled icon icr"></button>
Expand All @@ -88,7 +88,7 @@

import userPreferences from '../library/userPreferences.js';
import translate from '../library/translate.js';
import {range} from '../library/toolkit.js';
import {range, isNewTabClick} from '../library/toolkit.js';
import bootData from '../library/bootData.js';
import screenSize from '../mixins/screenSize.js';

Expand Down Expand Up @@ -172,9 +172,16 @@ const Pagination = {

},

selectPage(page) {
selectPage(page, event) {

this.$emit('pageRequest', page);
if (isNewTabClick(event)) {
// do nothing
} else {
if (event) {
event.preventDefault();
}
this.$emit('pageRequest', page);
}

}

Expand Down
2 changes: 1 addition & 1 deletion src/js/layouts/adminDefault.vue
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default {
this.currentControllerType = ControllerType;
}

if (controller.method) {
if (controller.method && this.$refs.currentController[controller.method]) {

this.$nextTick(() => {
this.$refs.currentController[controller.method](
Expand Down
6 changes: 6 additions & 0 deletions src/js/library/toolkit.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,3 +329,9 @@ export function getComponentInitialValue(Component, options = {}) {
}

}

export function isNewTabClick(event) {
return event
? Boolean(event.ctrlKey || event.metaKey || event.which === 2)
: false;
}
7 changes: 4 additions & 3 deletions src/js/listElements/link.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script>

import base from './base.js';
import {result} from '../library/toolkit.js';
import {result, isNewTabClick} from '../library/toolkit.js';

export default {

Expand Down Expand Up @@ -52,7 +52,9 @@ export default {

handleClick(e) {

if (this.action) {
if (isNewTabClick(e)) {
// do nothing
} else if (this.action) {
e.preventDefault();
this.action(this.resourceModel, e);
} else if (!this.isExternalLink) {
Expand All @@ -65,7 +67,6 @@ export default {
}

};

</script>

<style lang="scss" scoped>
Expand Down