68 lines
1.4 KiB
JavaScript
68 lines
1.4 KiB
JavaScript
import ngModule from '../module';
|
|
import Component from 'core/lib/component';
|
|
import './style.scss';
|
|
|
|
class Controller extends Component {
|
|
constructor($element, $) {
|
|
super($element, $);
|
|
this.client = null;
|
|
this._quicklinks = {};
|
|
}
|
|
|
|
set clientFk(id) {
|
|
if (id == this._clientFk) return;
|
|
|
|
this._clientFk = id;
|
|
this.client = null;
|
|
this.getCard();
|
|
}
|
|
|
|
set client(value) {
|
|
this._client = value;
|
|
this.$timeout(() => this.$.popover.relocate());
|
|
}
|
|
|
|
get client() {
|
|
return this._client;
|
|
}
|
|
|
|
get quicklinks() {
|
|
return this._quicklinks;
|
|
}
|
|
|
|
set quicklinks(value = {}) {
|
|
Object.keys(value).forEach(key => {
|
|
this._quicklinks[key] = value[key];
|
|
});
|
|
}
|
|
|
|
show() {
|
|
this.$.popover.parent = this.parent;
|
|
this.$.popover.show();
|
|
}
|
|
|
|
getCard() {
|
|
if (this.canceler)
|
|
this.canceler.resolve();
|
|
|
|
this.canceler = this.$q.defer();
|
|
|
|
let options = {timeout: this.canceler.promise};
|
|
this.$http.get(`Clients/${this._clientFk}/getCard`, options).then(
|
|
response => {
|
|
this.client = response.data;
|
|
this.canceler = null;
|
|
}
|
|
);
|
|
}
|
|
}
|
|
|
|
ngModule.component('vnClientDescriptorPopover', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
bindings: {
|
|
clientFk: '<',
|
|
quicklinks: '<'
|
|
}
|
|
});
|