Added vn-anchor to client and ticket index
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Joan Sanchez 2020-10-19 09:05:38 +02:00
parent cf8ed6f8d3
commit 011bba1660
6 changed files with 18 additions and 22 deletions

View File

@ -20,25 +20,25 @@ export function directive($state, $window) {
ctrlPressed = false; ctrlPressed = false;
}); });
function changeState(event, state) { function changeState(event, data) {
const params = stringifyParams(state); const params = stringifyParams(data);
$state.go(state.url, params); $state.go(data.state, params);
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
} }
function newTab(event, state) { function newTab(event, data) {
const params = stringifyParams(state); const params = stringifyParams(data);
const url = $state.href(state.url, params); const href = $state.href(data.state, params);
$window.open(url); $window.open(href);
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
} }
function stringifyParams(state) { function stringifyParams(data) {
const params = Object.assign({}, state.params); const params = Object.assign({}, data.params);
for (let param in params) for (let param in params)
params[param] = JSON.stringify(params[param]); params[param] = JSON.stringify(params[param]);
@ -48,17 +48,17 @@ export function directive($state, $window) {
return { return {
restrict: 'A', restrict: 'A',
link: function($scope, $element, $attrs) { link: function($scope, $element, $attrs) {
const state = $scope.$eval($attrs.vnAnchor); const data = $scope.$eval($attrs.vnAnchor);
$element.on('click', event => { $element.on('click', event => {
if (ctrlPressed) if (ctrlPressed)
newTab(event, state); newTab(event, data);
else else
changeState(event, state); changeState(event, data);
}); });
$element.on('mousedown', event => { $element.on('mousedown', event => {
if (event.button == 1) if (event.button == 1)
newTab(event, state); newTab(event, data);
}); });
} }
}; };

View File

@ -2,3 +2,4 @@ Simple ticket: Ticket simple
View consumer report: Ver informe de consumo View consumer report: Ver informe de consumo
From date: Fecha desde From date: Fecha desde
To date: Fecha hasta To date: Fecha hasta
Go to user: Ir al usuario

View File

@ -40,7 +40,7 @@
vn-tooltip="Client frozen" vn-tooltip="Client frozen"
icon="icon-frozen"> icon="icon-frozen">
</vn-icon-button> </vn-icon-button>
<vn-icon-button vn-anchor="{url: 'ticket.index', params: {q: {clientFk: client.id}}}" <vn-icon-button vn-anchor="{state: 'ticket.index', params: {q: {clientFk: client.id}}}"
vn-tooltip="Client tickets" vn-tooltip="Client tickets"
icon="icon-ticket"> icon="icon-ticket">
</vn-icon-button> </vn-icon-button>

View File

@ -119,7 +119,7 @@
</vn-td> </vn-td>
<vn-td actions> <vn-td actions>
<vn-icon-button <vn-icon-button
vn-click-stop="$ctrl.goToLines(ticket.id)" vn-anchor="{state: 'ticket.card.sale', params: {id: ticket.id}}"
vn-tooltip="Go to lines" vn-tooltip="Go to lines"
icon="icon-lines"> icon="icon-lines">
</vn-icon-button> </vn-icon-button>

View File

@ -114,11 +114,6 @@ export default class Controller extends Section {
return 'warning'; return 'warning';
} }
goToLines(ticketFk) {
let url = this.$state.href('ticket.card.sale', {id: ticketFk}, {absolute: true});
window.open(url, '_blank');
}
preview(ticket) { preview(ticket) {
this.selectedTicket = ticket; this.selectedTicket = ticket;
this.$.summary.show(); this.$.summary.show();

View File

@ -29,7 +29,7 @@
<vn-item-section side> <vn-item-section side>
<vn-icon-button <vn-icon-button
ng-click="$ctrl.goToTimeControl($event, worker.id)" ng-click="$ctrl.goToTimeControl($event, worker.id)"
vn-tooltip="Preview" vn-tooltip="Time control"
icon="access_time"> icon="access_time">
</vn-icon-button> </vn-icon-button>
<vn-icon-button <vn-icon-button