Tarea #428 Componentizar descriptor de client
This commit is contained in:
parent
d569c19a8a
commit
296508d216
|
@ -6,7 +6,7 @@
|
||||||
</mg-ajax>
|
</mg-ajax>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-auto class="left-block">
|
<vn-auto class="left-block">
|
||||||
<vn-client-descriptor client="$ctrl.client"></vn-client-descriptor>
|
<vn-client-descriptor client="$ctrl.client" clientFk="$ctrl.client.id"></vn-client-descriptor>
|
||||||
<vn-left-menu></vn-left-menu>
|
<vn-left-menu></vn-left-menu>
|
||||||
</vn-auto>
|
</vn-auto>
|
||||||
<vn-one>
|
<vn-one>
|
||||||
|
|
|
@ -7,6 +7,7 @@ import './basic-data';
|
||||||
import './fiscal-data';
|
import './fiscal-data';
|
||||||
import './billing-data';
|
import './billing-data';
|
||||||
import './descriptor';
|
import './descriptor';
|
||||||
|
import './descriptor-popover';
|
||||||
import './search-panel';
|
import './search-panel';
|
||||||
import './address/index';
|
import './address/index';
|
||||||
import './address/create';
|
import './address/create';
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
<vn-popover vn-id="popover">
|
||||||
|
<vn-client-descriptor client="$ctrl.client" clientFk="$ctrl.clientFk">
|
||||||
|
</vn-client-descriptor>
|
||||||
|
</vn-popover>
|
|
@ -0,0 +1,61 @@
|
||||||
|
import ngModule from '../module';
|
||||||
|
import Component from 'core/src/lib/component';
|
||||||
|
import './style.scss';
|
||||||
|
|
||||||
|
class Controller extends Component {
|
||||||
|
constructor($element, $scope, $http, $timeout) {
|
||||||
|
super($element, $scope);
|
||||||
|
this.$http = $http;
|
||||||
|
this.$timeout = $timeout;
|
||||||
|
this.isTooltip = true;
|
||||||
|
this.client = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.client = {};
|
||||||
|
this.clientFk = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_getClientDebt(clientFk) {
|
||||||
|
this.$http.get(`/client/api/Clients/${clientFk}/getDebt`)
|
||||||
|
.then(response => {
|
||||||
|
this.clientDebt = response.data.debt;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
_getClient(clientFk) {
|
||||||
|
this.$http.get(`/client/api/Clients/${clientFk}/card`)
|
||||||
|
.then(response => {
|
||||||
|
this.client = response.data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
goToClientTickets() {
|
||||||
|
this.$state.go('ticket.index', {q: `{"clientFk": ${this.client.id}}`});
|
||||||
|
}
|
||||||
|
|
||||||
|
set clientFk(value) {
|
||||||
|
if (value) {
|
||||||
|
this._getClient(value);
|
||||||
|
this._getClientDebt(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
show() {
|
||||||
|
this.$.popover.parent = this.parent;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$.popover.show();
|
||||||
|
}, 150);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Controller.$inject = ['$element', '$scope', '$http', '$timeout'];
|
||||||
|
|
||||||
|
ngModule.component('vnClientDescriptorPopover', {
|
||||||
|
template: require('./index.html'),
|
||||||
|
controller: Controller,
|
||||||
|
bindings: {
|
||||||
|
client: '<',
|
||||||
|
clientFk: '<'
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,15 @@
|
||||||
|
vn-client-descriptor-popover {
|
||||||
|
div.popover{
|
||||||
|
width: 16em;
|
||||||
|
}
|
||||||
|
vn-client-descriptor {
|
||||||
|
width: 16em;
|
||||||
|
display: block;
|
||||||
|
&>vn-card{
|
||||||
|
margin: 0!important;
|
||||||
|
}
|
||||||
|
.header > a:first-child {
|
||||||
|
display: none
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,10 +23,10 @@ class Controller {
|
||||||
this.$state.go('ticket.index', {q: `{"clientFk": ${this.client.id}}`});
|
this.$state.go('ticket.index', {q: `{"clientFk": ${this.client.id}}`});
|
||||||
}
|
}
|
||||||
|
|
||||||
$onChanges(changes) {
|
set clientFk(value) {
|
||||||
if (changes.client && this.client) {
|
if (value) {
|
||||||
this._getClient(this.client.id);
|
this._getClient(value);
|
||||||
this._getClientDebt(this.client.id);
|
this._getClientDebt(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,8 @@ Controller.$inject = ['$http', '$state'];
|
||||||
ngModule.component('vnClientDescriptor', {
|
ngModule.component('vnClientDescriptor', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
bindings: {
|
bindings: {
|
||||||
client: '<'
|
client: '<',
|
||||||
|
clientFk: '<?'
|
||||||
},
|
},
|
||||||
controller: Controller
|
controller: Controller
|
||||||
});
|
});
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<td>{{::ticket.shipped | date:'HH:mm'}}</td>
|
<td>{{::ticket.shipped | date:'HH:mm'}}</td>
|
||||||
<td
|
<td
|
||||||
class="link"
|
class="link"
|
||||||
ui-sref="client.card.summary({id: {{::ticket.client.id}}})">
|
ng-click="$ctrl.showDescriptor($event, ticket.clientFk)">
|
||||||
{{::ticket.nickname}}
|
{{::ticket.nickname}}
|
||||||
</td>
|
</td>
|
||||||
<td>{{::ticket.address.province.name}}</td>
|
<td>{{::ticket.address.province.name}}</td>
|
||||||
|
@ -63,6 +63,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<vn-client-descriptor-popover vn-id="descriptor"></vn-client-descriptor-popover>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-pagination
|
<vn-pagination
|
||||||
model="model"
|
model="model"
|
||||||
|
|
|
@ -90,6 +90,17 @@ export default class Controller {
|
||||||
if (comparation < 0)
|
if (comparation < 0)
|
||||||
return 'success';
|
return 'success';
|
||||||
}
|
}
|
||||||
|
showDescriptor(event, clientFk) {
|
||||||
|
this.$.descriptor.clientFk = clientFk;
|
||||||
|
this.$.descriptor.parent = event.target;
|
||||||
|
this.$.descriptor.show();
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
onDescriptorLoad() {
|
||||||
|
this.$.popover.relocate();
|
||||||
|
}
|
||||||
|
|
||||||
preview(event, ticket) {
|
preview(event, ticket) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
Loading…
Reference in New Issue