#762 refactor componente fetched tags
This commit is contained in:
parent
35e6132b17
commit
e06798cf90
|
@ -1,10 +1,10 @@
|
|||
<vn-horizontal>
|
||||
<vn-one>{{::$ctrl.concept}}</vn-one>
|
||||
<vn-one>{{::$ctrl.item.name}}</vn-one>
|
||||
<vn-auto>
|
||||
<section
|
||||
class="inline-tag ellipsize" ng-class="{'empty': !fetchedTag.value}"
|
||||
ng-repeat="fetchedTag in $ctrl.tags track by $index"
|
||||
vn-tooltip="{{::fetchedTag.tag.name}}: {{::fetchedTag.value}}">
|
||||
vn-tooltip="{{::fetchedTag.name}}: {{::fetchedTag.value}}">
|
||||
{{::fetchedTag.value}}
|
||||
</section>
|
||||
</vn-auto>
|
||||
|
|
|
@ -1,10 +1,53 @@
|
|||
import ngModule from '../../module';
|
||||
import './style.scss';
|
||||
|
||||
export default class FetchedTags {
|
||||
set item(value) {
|
||||
if (value) {
|
||||
let tags = [];
|
||||
for (let i = 5; i < 5 + this.maxLength; i++)
|
||||
if (value['tag' + i]) {
|
||||
let tagValue = value['value' + i];
|
||||
let tagKey = value['tag' + i];
|
||||
tags.push({name: tagKey, value: tagValue, position: i - 5});
|
||||
}
|
||||
this.tags = tags;
|
||||
}
|
||||
this._item = value;
|
||||
}
|
||||
|
||||
get item() {
|
||||
return this._item;
|
||||
}
|
||||
|
||||
set tags(value) {
|
||||
if (value) {
|
||||
let organizedTags = new Array(parseInt(this.maxLength));
|
||||
for (let i = 0; i < this.maxLength; i++) {
|
||||
let organizedTag = {};
|
||||
for (let j = 0; j < value.length; j++) {
|
||||
if (value[j].position === i) {
|
||||
organizedTag.name = value[j].name;
|
||||
organizedTag.value = value[j].value;
|
||||
}
|
||||
organizedTags[i] = JSON.parse(JSON.stringify(organizedTag));
|
||||
}
|
||||
}
|
||||
this._tags = organizedTags;
|
||||
}
|
||||
}
|
||||
|
||||
get tags() {
|
||||
return this._tags;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ngModule.component('vnFetchedTags', {
|
||||
template: require('./index.html'),
|
||||
controller: FetchedTags,
|
||||
bindings: {
|
||||
concept: '<',
|
||||
tags: '<'
|
||||
maxLength: '<',
|
||||
item: '<'
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
@import "colors";
|
||||
|
||||
vn-fetched-tags {
|
||||
&.noTitle vn-one {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 1600px){
|
||||
& vn-horizontal {
|
||||
flex-direction: column;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<vn-label-value label="Buyer"
|
||||
value="{{::$ctrl.item.firstName}} {{::$ctrl.item.worker}}">
|
||||
</vn-label-value>
|
||||
<vn-fetched-tags tags="$ctrl.item.tags"/>
|
||||
<vn-fetched-tags max-length="4" item="$ctrl.item" class="noTitle"/>
|
||||
</vn-one>
|
||||
<vn-horizontal class="buttons">
|
||||
<vn-icon
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
{{("000000"+row.itemFk).slice(-6)}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td><vn-fetched-tags concept="row.item.name" tags="row.item.tags"/></vn-td>
|
||||
<vn-td><vn-fetched-tags max-length="6" item="row.item"/></vn-td>
|
||||
<vn-td>{{row.warehouse.name}}</vn-td>
|
||||
<vn-td>{{row.shipped | dashIfEmpty}}</vn-td>
|
||||
<vn-td number>{{row.quantity}}</vn-td>
|
||||
|
|
|
@ -20,22 +20,7 @@ class Controller {
|
|||
let filter = {
|
||||
where: {orderFk: this.$state.params.id},
|
||||
include: [{
|
||||
relation: 'item',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'tags',
|
||||
scope: {
|
||||
fields: ['tagFk', 'value'],
|
||||
include: {
|
||||
relation: 'tag',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
fields: ['itemFk', 'name', 'image']
|
||||
}
|
||||
relation: 'item'
|
||||
},
|
||||
{relation: 'warehouse'}]
|
||||
};
|
||||
|
|
|
@ -29,22 +29,7 @@ describe('Order', () => {
|
|||
let filter = {
|
||||
where: {orderFk: controller.$state.params.id},
|
||||
include: [{
|
||||
relation: 'item',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'tags',
|
||||
scope: {
|
||||
fields: ['tagFk', 'value'],
|
||||
include: {
|
||||
relation: 'tag',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
fields: ['itemFk', 'name', 'image']
|
||||
}
|
||||
relation: 'item'
|
||||
},
|
||||
{relation: 'warehouse'}]
|
||||
};
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
{{("000000"+row.itemFk).slice(-6)}}
|
||||
</span>
|
||||
</td>
|
||||
<td><vn-fetched-tags concept="row.item.name" tags="row.item.tags"/></td>
|
||||
<td><vn-fetched-tags max-length="6" item="row.item"/></td>
|
||||
<td number>{{::row.quantity}}</td>
|
||||
<td number>{{::row.price | currency:'€':2}}</td>
|
||||
<td number>{{::row.quantity * row.price | currency:'€':2}}</td>
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
{{::row.itemFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td><vn-fetched-tags concept="row.item.name" tags="row.item.tags"/></vn-td>
|
||||
<vn-td><vn-fetched-tags max-length="6" item="row.item"/></vn-td>
|
||||
<vn-td number>{{::row.quantity}}</vn-td>
|
||||
<vn-td number>{{::row.volume | number:3}}</vn-td>
|
||||
</vn-tr>
|
||||
|
|
|
@ -8,23 +8,7 @@ class Controller {
|
|||
this.$stateParams = $stateParams;
|
||||
this.filter = {
|
||||
include: [{
|
||||
relation: 'item',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'tags',
|
||||
scope: {
|
||||
fields: ['tagFk', 'value'],
|
||||
include: {
|
||||
relation: 'tag',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
limit: 6
|
||||
}
|
||||
},
|
||||
fields: ['itemFk', 'name']
|
||||
}
|
||||
relation: 'item'
|
||||
}]
|
||||
};
|
||||
this.order = {};
|
||||
|
@ -34,15 +18,13 @@ class Controller {
|
|||
onDataChange() {
|
||||
this.$http.get(`/order/api/Orders/${this.$stateParams.id}/getVolumes`)
|
||||
.then(response => {
|
||||
if (response.data) {
|
||||
if (response.data)
|
||||
this.$scope.model.data.forEach(order => {
|
||||
response.data.volumes.forEach(volume => {
|
||||
if (order.itemFk === volume.itemFk) {
|
||||
if (order.itemFk === volume.itemFk)
|
||||
order.volume = volume.volume;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
</td>
|
||||
<td rowspan="{{
|
||||
::sale.components.length + 1
|
||||
}}"><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></td>
|
||||
}}"><vn-fetched-tags max-length="6" item="sale.item"/></td>
|
||||
<td rowspan="{{
|
||||
::sale.components.length + 1
|
||||
}}" number>{{::sale.quantity}}</td>
|
||||
|
|
|
@ -9,22 +9,6 @@ class Controller {
|
|||
order: 'concept ASC',
|
||||
include: [{
|
||||
relation: 'item',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'tags',
|
||||
scope: {
|
||||
fields: ['tagFk', 'value'],
|
||||
include: {
|
||||
relation: 'tag',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
limit: 6
|
||||
}
|
||||
},
|
||||
fields: ['itemFk', 'name']
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'components',
|
||||
|
@ -52,9 +36,10 @@ class Controller {
|
|||
let sum = 0;
|
||||
if (!sales) return;
|
||||
|
||||
for (let sale of sales)
|
||||
for (let sale of sales) {
|
||||
for (let component of sale.components)
|
||||
sum += sale.quantity * component.value;
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
@ -65,10 +50,12 @@ class Controller {
|
|||
|
||||
if (!sales) return;
|
||||
|
||||
for (let sale of sales)
|
||||
for (let component of sale.components)
|
||||
for (let sale of sales) {
|
||||
for (let component of sale.components) {
|
||||
if (component.componentRate.name == 'valor de compra')
|
||||
sum += sale.quantity * component.value;
|
||||
}
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
@ -79,10 +66,12 @@ class Controller {
|
|||
|
||||
if (!sales) return;
|
||||
|
||||
for (let sale of sales)
|
||||
for (let component of sale.components)
|
||||
for (let sale of sales) {
|
||||
for (let component of sale.components) {
|
||||
if (component.componentRate.name != 'valor de compra')
|
||||
sum += sale.quantity * component.value;
|
||||
}
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<tbody>
|
||||
<tr ng-repeat="sale in $ctrl.ticket.sale.items track by sale.id">
|
||||
<td number>{{("000000"+sale.itemFk).slice(-6)}}</td>
|
||||
<td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></td>
|
||||
<td><vn-fetched-tags max-length="6" item="sale.item"/></td>
|
||||
<td number>{{::sale.quantity}}</td>
|
||||
<td number>{{::sale.price | currency: '€': 2}}</td>
|
||||
<td number>{{::sale.component.newPrice | currency: '€': 2}}</td>
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
{{("000000"+sale.itemFk).slice(-6)}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></vn-td>
|
||||
<vn-td><vn-fetched-tags max-length="6" item="sale.item"/></vn-td>
|
||||
<vn-td number>{{::sale.quantity}}</vn-td>
|
||||
</vn-tr>
|
||||
</vn-tbody>
|
||||
|
|
|
@ -6,23 +6,7 @@ class Controller {
|
|||
this.$stateParams = $stateParams;
|
||||
this.filter = {
|
||||
include: [{
|
||||
relation: 'item',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'tags',
|
||||
scope: {
|
||||
fields: ['tagFk', 'value'],
|
||||
include: {
|
||||
relation: 'tag',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
limit: 6
|
||||
}
|
||||
},
|
||||
fields: ['itemFk', 'name']
|
||||
}
|
||||
relation: 'item'
|
||||
},
|
||||
{
|
||||
relation: 'isChecked',
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
{{("000000"+sale.itemFk).slice(-6)}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></vn-td>
|
||||
<vn-td><vn-fetched-tags max-length="6" item="sale.item"/></vn-td>
|
||||
<vn-td>{{::sale.quantity}}</vn-td>
|
||||
<vn-td>{{::sale.originalQuantity}}</vn-td>
|
||||
<vn-td title="{{::sale.firstName}} {{::sale.name}}"
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
{{("000000"+sale.itemFk).slice(-6)}}
|
||||
</span>
|
||||
</td>
|
||||
<td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></td>
|
||||
<td><vn-fetched-tags max-length="6" item="sale.item"/></td>
|
||||
<td number>{{::sale.quantity}}</td>
|
||||
<td number>{{::sale.price | currency:'€':2}}</td>
|
||||
<td number>{{::sale.discount}} %</td>
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
{{("000000"+sale.itemFk).slice(-6)}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td><vn-fetched-tags concept="sale.concept" tags="sale.item.tags"/></vn-td>
|
||||
<vn-td><vn-fetched-tags max-length="6" item="sale.item"/></vn-td>
|
||||
<vn-td number>{{::sale.quantity}}</vn-td>
|
||||
<vn-td number>{{::sale.volume.m3 | number:3}}</vn-td>
|
||||
</vn-tr>
|
||||
|
|
|
@ -8,23 +8,7 @@ class Controller {
|
|||
this.$stateParams = $stateParams;
|
||||
this.filter = {
|
||||
include: [{
|
||||
relation: 'item',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'tags',
|
||||
scope: {
|
||||
fields: ['tagFk', 'value'],
|
||||
include: {
|
||||
relation: 'tag',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
limit: 6
|
||||
}
|
||||
},
|
||||
fields: ['itemFk', 'name']
|
||||
}
|
||||
relation: 'item'
|
||||
}]
|
||||
};
|
||||
|
||||
|
@ -37,9 +21,8 @@ class Controller {
|
|||
if (response.data) {
|
||||
this.$scope.model.data.forEach(sale => {
|
||||
response.data.volumes.forEach(volume => {
|
||||
if (sale.id === volume.saleFk) {
|
||||
if (sale.id === volume.saleFk)
|
||||
sale.volume = volume;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -32,23 +32,7 @@ module.exports = Self => {
|
|||
},
|
||||
order: 'concept ASC',
|
||||
include: [{
|
||||
relation: 'item',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'tags',
|
||||
scope: {
|
||||
fields: ['tagFk', 'value'],
|
||||
include: {
|
||||
relation: 'tag',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
limit: 6
|
||||
}
|
||||
},
|
||||
fields: ['itemFk', 'name']
|
||||
}
|
||||
relation: 'item'
|
||||
}]
|
||||
};
|
||||
let salesObj = {};
|
||||
|
|
|
@ -92,22 +92,6 @@ module.exports = Self => {
|
|||
order: 'itemFk ASC',
|
||||
include: [{
|
||||
relation: 'item',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'tags',
|
||||
scope: {
|
||||
fields: ['tagFk', 'value'],
|
||||
include: {
|
||||
relation: 'tag',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
limit: 6
|
||||
}
|
||||
},
|
||||
fields: ['itemFk', 'name']
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
|
|
|
@ -75,6 +75,18 @@
|
|||
},
|
||||
"value8": {
|
||||
"type": "String"
|
||||
},
|
||||
"tag9": {
|
||||
"type": "String"
|
||||
},
|
||||
"value9": {
|
||||
"type": "String"
|
||||
},
|
||||
"tag10": {
|
||||
"type": "String"
|
||||
},
|
||||
"value10": {
|
||||
"type": "String"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -59,12 +59,7 @@ module.exports = Self => {
|
|||
relation: 'rows',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'item',
|
||||
scope: {
|
||||
include: {
|
||||
relation: 'tags'
|
||||
}
|
||||
}
|
||||
relation: 'item'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,23 +46,7 @@ module.exports = Self => {
|
|||
let salesFilter = {
|
||||
include: [
|
||||
{
|
||||
relation: 'item',
|
||||
scope: {
|
||||
fields: ['itemFk', 'name'],
|
||||
include: {
|
||||
relation: 'tags',
|
||||
scope: {
|
||||
fields: ['tagFk', 'value'],
|
||||
include: {
|
||||
relation: 'tag',
|
||||
scope: {
|
||||
fields: ['name']
|
||||
}
|
||||
},
|
||||
limit: 6
|
||||
}
|
||||
}
|
||||
}
|
||||
relation: 'item'
|
||||
}
|
||||
],
|
||||
where: {ticketFk: filter.where.ticketFk}
|
||||
|
|
Loading…
Reference in New Issue