2018-07-26 10:06:53 +00:00
|
|
|
import ngModule from '../module';
|
2018-12-27 11:54:16 +00:00
|
|
|
import Component from 'core/lib/component';
|
2018-07-26 10:06:53 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
class Controller extends Component {
|
2020-03-18 13:08:04 +00:00
|
|
|
constructor($element, $) {
|
|
|
|
super($element, $);
|
2018-10-18 09:41:25 +00:00
|
|
|
this.client = null;
|
2019-05-07 09:32:35 +00:00
|
|
|
this._quicklinks = {};
|
2018-08-01 10:15:09 +00:00
|
|
|
}
|
|
|
|
|
2018-10-18 09:41:25 +00:00
|
|
|
set clientFk(id) {
|
|
|
|
if (id == this._clientFk) return;
|
|
|
|
|
|
|
|
this._clientFk = id;
|
|
|
|
this.client = null;
|
|
|
|
this.getCard();
|
2018-08-01 10:15:09 +00:00
|
|
|
}
|
|
|
|
|
2018-10-18 09:41:25 +00:00
|
|
|
set client(value) {
|
|
|
|
this._client = value;
|
|
|
|
this.$timeout(() => this.$.popover.relocate());
|
2018-08-01 10:15:09 +00:00
|
|
|
}
|
|
|
|
|
2018-10-18 09:41:25 +00:00
|
|
|
get client() {
|
|
|
|
return this._client;
|
2018-07-26 10:06:53 +00:00
|
|
|
}
|
|
|
|
|
2018-10-18 09:41:25 +00:00
|
|
|
get quicklinks() {
|
|
|
|
return this._quicklinks;
|
2018-07-26 10:06:53 +00:00
|
|
|
}
|
|
|
|
|
2019-05-07 09:32:35 +00:00
|
|
|
set quicklinks(value = {}) {
|
|
|
|
Object.keys(value).forEach(key => {
|
|
|
|
this._quicklinks[key] = value[key];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-07-26 10:06:53 +00:00
|
|
|
show() {
|
|
|
|
this.$.popover.parent = this.parent;
|
2018-10-18 09:41:25 +00:00
|
|
|
this.$.popover.show();
|
2018-07-26 10:06:53 +00:00
|
|
|
}
|
|
|
|
|
2018-10-18 09:41:25 +00:00
|
|
|
getCard() {
|
|
|
|
if (this.canceler)
|
|
|
|
this.canceler.resolve();
|
|
|
|
|
|
|
|
this.canceler = this.$q.defer();
|
|
|
|
|
|
|
|
let options = {timeout: this.canceler.promise};
|
2019-10-24 22:53:53 +00:00
|
|
|
this.$http.get(`Clients/${this._clientFk}/getCard`, options).then(
|
2018-10-18 09:41:25 +00:00
|
|
|
response => {
|
|
|
|
this.client = response.data;
|
|
|
|
this.canceler = null;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2018-07-26 10:06:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ngModule.component('vnClientDescriptorPopover', {
|
|
|
|
template: require('./index.html'),
|
|
|
|
controller: Controller,
|
|
|
|
bindings: {
|
2018-08-01 10:15:09 +00:00
|
|
|
clientFk: '<',
|
|
|
|
quicklinks: '<'
|
2018-07-26 10:06:53 +00:00
|
|
|
}
|
|
|
|
});
|