2018-04-26 14:41:08 +00:00
|
|
|
import ngModule from '../module';
|
2018-12-27 11:54:16 +00:00
|
|
|
import Component from 'core/lib/component';
|
2018-04-26 14:41:08 +00:00
|
|
|
import './style.scss';
|
|
|
|
|
|
|
|
class Controller extends Component {
|
2018-10-18 09:41:25 +00:00
|
|
|
constructor($element, $scope, $http, $timeout, $q) {
|
2018-04-26 14:41:08 +00:00
|
|
|
super($element, $scope);
|
2018-10-18 09:41:25 +00:00
|
|
|
this.$timeout = $timeout;
|
2018-04-26 14:41:08 +00:00
|
|
|
this.$http = $http;
|
2018-10-18 09:41:25 +00:00
|
|
|
this.$q = $q;
|
|
|
|
this.item = null;
|
2019-05-07 09:32:35 +00:00
|
|
|
this._quicklinks = {};
|
2018-04-26 14:41:08 +00:00
|
|
|
}
|
|
|
|
|
2018-08-08 12:45:29 +00:00
|
|
|
set itemFk(id) {
|
2018-10-18 09:41:25 +00:00
|
|
|
if (id == this._itemFk) return;
|
|
|
|
|
2018-08-08 12:45:29 +00:00
|
|
|
this._itemFk = id;
|
2018-10-18 09:41:25 +00:00
|
|
|
this.item = null;
|
2019-05-07 09:32:35 +00:00
|
|
|
this._quicklinks = {
|
|
|
|
btnThree: {
|
|
|
|
icon: 'icon-transaction',
|
|
|
|
state: `item.card.diary({
|
|
|
|
id: ${id},
|
|
|
|
})`,
|
|
|
|
tooltip: 'Item diary'
|
|
|
|
}
|
|
|
|
};
|
2018-10-18 09:41:25 +00:00
|
|
|
this.getCard();
|
|
|
|
}
|
|
|
|
|
|
|
|
set item(value) {
|
|
|
|
this._item = value;
|
|
|
|
this.$timeout(() => this.$.popover.relocate());
|
|
|
|
}
|
2018-08-08 12:45:29 +00:00
|
|
|
|
2018-10-18 09:41:25 +00:00
|
|
|
get item() {
|
|
|
|
return this._item;
|
2018-08-08 12:45:29 +00:00
|
|
|
}
|
|
|
|
|
2018-08-01 10:15:09 +00:00
|
|
|
get quicklinks() {
|
|
|
|
return this._quicklinks;
|
|
|
|
}
|
|
|
|
|
2019-05-07 09:32:35 +00:00
|
|
|
set quicklinks(value = {}) {
|
|
|
|
Object.keys(value).forEach(key => {
|
|
|
|
this._quicklinks[key] = value[key];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-04-26 14:41:08 +00:00
|
|
|
show() {
|
|
|
|
this.$.popover.parent = this.parent;
|
|
|
|
this.$.popover.show();
|
|
|
|
}
|
2018-09-14 11:43:51 +00:00
|
|
|
|
|
|
|
getCard() {
|
2018-10-18 09:41:25 +00:00
|
|
|
if (this.canceler)
|
|
|
|
this.canceler.resolve();
|
|
|
|
|
|
|
|
this.canceler = this.$q.defer();
|
|
|
|
|
|
|
|
let options = {timeout: this.canceler.promise};
|
|
|
|
this.$http.get(`/item/api/Items/${this._itemFk}/getCard`, options).then(
|
|
|
|
response => {
|
|
|
|
this.item = response.data;
|
|
|
|
this.canceler = null;
|
|
|
|
}
|
|
|
|
);
|
2018-04-26 14:41:08 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-18 09:41:25 +00:00
|
|
|
Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q'];
|
2018-04-26 14:41:08 +00:00
|
|
|
|
|
|
|
ngModule.component('vnItemDescriptorPopover', {
|
2018-05-25 08:03:45 +00:00
|
|
|
template: require('./index.html'),
|
2018-10-18 09:41:25 +00:00
|
|
|
controller: Controller,
|
2018-04-26 14:41:08 +00:00
|
|
|
bindings: {
|
2018-08-01 10:15:09 +00:00
|
|
|
itemFk: '<',
|
|
|
|
quicklinks: '<'
|
2018-10-18 09:41:25 +00:00
|
|
|
}
|
2018-04-26 14:41:08 +00:00
|
|
|
});
|