Bug #422 refactorizar el summary y el card de item y añadir el visible y el available
This commit is contained in:
parent
4b0a75cc0c
commit
b2d3451360
|
@ -3,15 +3,23 @@ import Component from 'core/src/lib/component';
|
|||
import './style.scss';
|
||||
|
||||
class Controller extends Component {
|
||||
constructor($element, $scope, $http, $timeout) {
|
||||
constructor($element, $scope, $http) {
|
||||
super($element, $scope);
|
||||
this.$http = $http;
|
||||
this.$timeout = $timeout;
|
||||
this._quicklinks = {};
|
||||
this.isTooltip = true;
|
||||
this.clear();
|
||||
}
|
||||
|
||||
set itemFk(id) {
|
||||
this._itemFk = id;
|
||||
|
||||
if (id) {
|
||||
this._getItem();
|
||||
} else
|
||||
this.clear();
|
||||
}
|
||||
|
||||
set quicklinks(value = {}) {
|
||||
this._quicklinks = Object.assign(value, this._quicklinks);
|
||||
}
|
||||
|
@ -30,70 +38,13 @@ class Controller extends Component {
|
|||
this.$.popover.parent = this.parent;
|
||||
this.$.popover.show();
|
||||
}
|
||||
|
||||
_getTags() {
|
||||
this.$http.get(`/item/api/Tags`).then(response => {
|
||||
response.data.forEach(tag => {
|
||||
this.tags[tag.id] = Object.assign({}, tag);
|
||||
});
|
||||
|
||||
this.$.popover.relocate();
|
||||
_getItem() {
|
||||
this.$http.get(`/item/api/Items/${this._itemFk}/getCard`).then(response => {
|
||||
this.item = response.data;
|
||||
});
|
||||
}
|
||||
|
||||
_getItem() {
|
||||
let filter = {
|
||||
fields: ['id', 'name', 'image'],
|
||||
include: [
|
||||
{
|
||||
relation: 'itemType',
|
||||
scope: {
|
||||
fields: ['workerFk'],
|
||||
include: {
|
||||
relation: 'worker',
|
||||
scope: {
|
||||
fields: ['firstName', 'name']
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
relation: 'tags',
|
||||
scope: {
|
||||
fields: ['value', 'tagFk'],
|
||||
order: 'priority ASC',
|
||||
include: {
|
||||
relation: 'tag',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
let json = encodeURIComponent(JSON.stringify(filter));
|
||||
this.$http.get(`/item/api/Items/${this._itemFk}?filter=${json}`)
|
||||
.then(res => {
|
||||
if (!res.data) return;
|
||||
this.item = res.data;
|
||||
this.itemTags = this.item.tags;
|
||||
this.$.popover.relocate();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
set itemFk(id) {
|
||||
this._itemFk = id;
|
||||
|
||||
if (id) {
|
||||
this._getItem();
|
||||
this._getTags();
|
||||
} else
|
||||
this.clear();
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$element', '$scope', '$http', '$timeout'];
|
||||
Controller.$inject = ['$element', '$scope', '$http'];
|
||||
|
||||
ngModule.component('vnItemDescriptorPopover', {
|
||||
template: require('./index.html'),
|
||||
|
|
|
@ -22,18 +22,28 @@
|
|||
</vn-float-button>
|
||||
</a>
|
||||
</vn-auto>
|
||||
<vn-horizontal class="state">
|
||||
<vn-one>
|
||||
<p class="title" uppercase text-center>Visible</p>
|
||||
<h5 class="title" text-center>{{$ctrl.item.visible}}</h5>
|
||||
</vn-one>
|
||||
<vn-one>
|
||||
<p class="title" uppercase translate text-center>Available</p>
|
||||
<h5 text-center class="title">{{$ctrl.item.available}}</h5>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
<vn-auto pad-medium>
|
||||
<h5>{{$ctrl.item.id}}</h5>
|
||||
<vn-label-value label="Name"
|
||||
value="{{$ctrl.item.name}}">
|
||||
value="{{::$ctrl.item.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Buyer"
|
||||
value="{{$ctrl.item.itemType.worker.firstName}} {{$ctrl.item.itemType.worker.name}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
ng-repeat="itemTag in $ctrl.itemTags | limitTo:4"
|
||||
label="{{$ctrl.tags[itemTag.tagFk].name}}"
|
||||
value="{{itemTag.value}}">
|
||||
ng-repeat="tag in $ctrl.item.tags | limitTo:4"
|
||||
label="{{tag.tag.name}}"
|
||||
value="{{tag.value}}">
|
||||
</vn-label-value>
|
||||
</vn-auto>
|
||||
</vn-vertical>
|
||||
|
|
Loading…
Reference in New Issue