show itemDiary icon on ticket descriptor popover. #441 - CR Javi

This commit is contained in:
Joan Sanchez 2018-08-01 12:15:09 +02:00
parent b5356eb07d
commit d83665a0c5
11 changed files with 145 additions and 26 deletions

View File

@ -1,4 +1,7 @@
<vn-popover vn-id="popover"> <vn-popover vn-id="popover">
<vn-client-descriptor client="$ctrl.client" clientFk="$ctrl.clientFk"> <vn-client-descriptor
client="$ctrl.client"
clientFk="$ctrl.clientFk"
quicklinks="$ctrl.quicklinks">
</vn-client-descriptor> </vn-client-descriptor>
</vn-popover> </vn-popover>

View File

@ -9,6 +9,22 @@ class Controller extends Component {
this.$timeout = $timeout; this.$timeout = $timeout;
this.isTooltip = true; this.isTooltip = true;
this.client = {}; this.client = {};
this.links = {};
}
set clientFk(value) {
if (value) {
this._getClient(value);
this._getClientDebt(value);
}
}
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this.links);
}
get quicklinks() {
return this._quicklinks;
} }
clear() { clear() {
@ -34,13 +50,6 @@ class Controller extends Component {
this.$state.go('ticket.index', {q: `{"clientFk": ${this.client.id}}`}); this.$state.go('ticket.index', {q: `{"clientFk": ${this.client.id}}`});
} }
set clientFk(value) {
if (value) {
this._getClient(value);
this._getClientDebt(value);
}
}
show() { show() {
this.$.popover.parent = this.parent; this.$.popover.parent = this.parent;
setTimeout(() => { setTimeout(() => {
@ -56,6 +65,7 @@ ngModule.component('vnClientDescriptorPopover', {
controller: Controller, controller: Controller,
bindings: { bindings: {
client: '<', client: '<',
clientFk: '<' clientFk: '<',
quicklinks: '<'
} }
}); });

View File

@ -53,11 +53,23 @@
ng-class="{bright: $ctrl.client.isTaxDataChecked == false}"> ng-class="{bright: $ctrl.client.isTaxDataChecked == false}">
</vn-icon> </vn-icon>
</vn-horizontal> </vn-horizontal>
<vn-horizontal pad-small class="buttons"> <vn-horizontal pad-small class="quicklinks">
<vn-button <vn-button ng-if="$ctrl.quicklinks.btnOne" pad-small-right
vn-tooltip="Client ticket list" vn-tooltip="{{::$ctrl.quicklinks.btnOne.tooltip}}"
icon="icon-ticket" icon="{{::$ctrl.quicklinks.btnOne.icon}}"
ng-click="$ctrl.goToClientTickets()"> ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnOne.state, $ctrl.quicklinks.btnOne.params)">
</vn-button>
<vn-button ng-if="$ctrl.quicklinks.btnTwo" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnTwo.tooltip}}"
icon="{{::$ctrl.quicklinks.btnTwo.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnTwo.state, $ctrl.quicklinks.btnTwo.params)">
</vn-button>
<vn-button ng-if="$ctrl.quicklinks.btnThree" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnThree.tooltip}}"
icon="{{::$ctrl.quicklinks.btnThree.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnThree.state, $ctrl.quicklinks.btnThree.params)">
</vn-button> </vn-button>
</vn-horizontal> </vn-horizontal>
</vn-card> </vn-card>

View File

@ -4,7 +4,31 @@ class Controller {
constructor($http, $state) { constructor($http, $state) {
this.$state = $state; this.$state = $state;
this.$http = $http; this.$http = $http;
this.links = {
btnOne: {
icon: 'icon-ticket',
state: 'ticket.index',
params: {q: `{"clientFk": ${$state.params.id}}`},
tooltip: 'Client ticket list'
}
};
} }
set clientFk(value) {
if (value) {
this._getClient(value);
this._getClientDebt(value);
}
}
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this.links);
}
get quicklinks() {
return this._quicklinks;
}
_getClientDebt(clientFk) { _getClientDebt(clientFk) {
this.$http.get(`/client/api/Clients/${clientFk}/getDebt`) this.$http.get(`/client/api/Clients/${clientFk}/getDebt`)
.then(response => { .then(response => {
@ -23,11 +47,8 @@ class Controller {
this.$state.go('ticket.index', {q: `{"clientFk": ${this.client.id}}`}); this.$state.go('ticket.index', {q: `{"clientFk": ${this.client.id}}`});
} }
set clientFk(value) { quicklinkGo(state, params) {
if (value) { this.$state.go(state, params);
this._getClient(value);
this._getClientDebt(value);
}
} }
} }
@ -37,7 +58,8 @@ ngModule.component('vnClientDescriptor', {
template: require('./index.html'), template: require('./index.html'),
bindings: { bindings: {
client: '<', client: '<',
clientFk: '<?' clientFk: '<?',
quicklinks: '<'
}, },
controller: Controller controller: Controller
}); });

View File

@ -2,6 +2,7 @@
<vn-item-descriptor <vn-item-descriptor
item="$ctrl.item" item="$ctrl.item"
item-tags="$ctrl.itemTags" item-tags="$ctrl.itemTags"
tags="$ctrl.tags"> tags="$ctrl.tags"
quicklinks="$ctrl.quicklinks">
</vn-item-descriptor> </vn-item-descriptor>
</vn-popover> </vn-popover>

View File

@ -7,11 +7,19 @@ class Controller extends Component {
super($element, $scope); super($element, $scope);
this.$http = $http; this.$http = $http;
this.$timeout = $timeout; this.$timeout = $timeout;
this.links = {};
this.isTooltip = true; this.isTooltip = true;
this.clear(); this.clear();
} }
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this.links);
}
get quicklinks() {
return this._quicklinks;
}
clear() { clear() {
this.item = null; this.item = null;
this.tags = {}; this.tags = {};
@ -90,7 +98,8 @@ Controller.$inject = ['$element', '$scope', '$http', '$timeout'];
ngModule.component('vnItemDescriptorPopover', { ngModule.component('vnItemDescriptorPopover', {
template: require('./index.html'), template: require('./index.html'),
bindings: { bindings: {
itemFk: '<' itemFk: '<',
quicklinks: '<'
}, },
controller: Controller controller: Controller
}); });

View File

@ -37,4 +37,23 @@
</vn-label-value> </vn-label-value>
</vn-auto> </vn-auto>
</vn-vertical> </vn-vertical>
<vn-horizontal pad-small class="quicklinks">
<vn-button ng-if="$ctrl.quicklinks.btnOne" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnOne.tooltip}}"
icon="{{::$ctrl.quicklinks.btnOne.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnOne.state, $ctrl.quicklinks.btnOne.params)">
</vn-button>
<vn-button ng-if="$ctrl.quicklinks.btnTwo" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnTwo.tooltip}}"
icon="{{::$ctrl.quicklinks.btnTwo.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnTwo.state, $ctrl.quicklinks.btnTwo.params)">
</vn-button>
<vn-button ng-if="$ctrl.quicklinks.btnThree" pad-small-right
vn-tooltip="{{::$ctrl.quicklinks.btnThree.tooltip}}"
icon="{{::$ctrl.quicklinks.btnThree.icon}}"
ng-click="$ctrl.quicklinkGo($ctrl.quicklinks.btnThree.state, $ctrl.quicklinks.btnThree.params)">
</vn-button>
</vn-horizontal>
</vn-card> </vn-card>

View File

@ -1,11 +1,34 @@
import ngModule from '../module'; import ngModule from '../module';
import './style.scss'; import './style.scss';
class Controller {
constructor($state) {
this.$state = $state;
this.links = {};
}
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this.links);
}
get quicklinks() {
return this._quicklinks;
}
quicklinkGo(state, params) {
this.$state.go(state, params);
}
}
Controller.$inject = ['$state'];
ngModule.component('vnItemDescriptor', { ngModule.component('vnItemDescriptor', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller,
bindings: { bindings: {
item: '<', item: '<',
itemTags: '<', itemTags: '<',
tags: '<' tags: '<',
quicklinks: '<'
} }
}); });

View File

@ -206,7 +206,7 @@ vn-main-block {
} }
} }
.buttons { .quicklinks {
justify-content: center; justify-content: center;
align-items: center; align-items: center;

View File

@ -164,7 +164,8 @@
</vn-table> </vn-table>
</vn-vertical> </vn-vertical>
</vn-card> </vn-card>
<vn-item-descriptor-popover vn-id="descriptor"> <vn-item-descriptor-popover vn-id="descriptor"
quicklinks="$ctrl.quicklinks">
</vn-item-descriptor-popover> </vn-item-descriptor-popover>
<!-- Add Turn Dialog --> <!-- Add Turn Dialog -->

View File

@ -20,6 +20,25 @@ class Controller {
]; ];
} }
set ticket(value) {
this._ticket = value;
if (!value) return;
this.quicklinks = {
btnThree: {
icon: 'icon-transaction',
state: 'item.card.diary',
params: {id: value.id, q: `{"warehouseFk": ${value.warehouseFk}}`},
tooltip: 'Item diary'
}
};
}
get ticket() {
return this._ticket;
}
onDataChange() { onDataChange() {
this.sales = this.$scope.model.data; this.sales = this.$scope.model.data;
this.getTaxes(); this.getTaxes();