salix/modules/client/front/descriptor-popover/index.js

69 lines
1.6 KiB
JavaScript
Raw Normal View History

import ngModule from '../module';
2018-12-27 11:54:16 +00:00
import Component from 'core/lib/component';
import './style.scss';
class Controller extends Component {
2018-10-18 09:41:25 +00:00
constructor($element, $scope, $http, $timeout, $q) {
super($element, $scope);
this.$timeout = $timeout;
2018-10-18 09:41:25 +00:00
this.$http = $http;
this.$q = $q;
this.client = null;
}
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-10-18 09:41:25 +00:00
set client(value) {
this._client = value;
this.$timeout(() => this.$.popover.relocate());
}
2018-10-18 09:41:25 +00:00
get client() {
return this._client;
}
2018-10-18 09:41:25 +00:00
set quicklinks(value = {}) {
this._quicklinks = Object.assign(value, this._quicklinks);
}
2018-10-18 09:41:25 +00:00
get quicklinks() {
return this._quicklinks;
}
show() {
this.$.popover.parent = this.parent;
2018-10-18 09:41:25 +00:00
this.$.popover.show();
}
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};
this.$http.get(`/client/api/Clients/${this._clientFk}/getCard`, options).then(
response => {
this.client = response.data;
this.canceler = null;
}
);
}
}
2018-10-18 09:41:25 +00:00
Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q'];
ngModule.component('vnClientDescriptorPopover', {
template: require('./index.html'),
controller: Controller,
bindings: {
clientFk: '<',
quicklinks: '<'
}
});