enpoint now receives all data for a buy + css refactor

This commit is contained in:
Carlos Jimenez Ruiz 2021-04-28 11:15:02 +02:00
parent 65457d6dac
commit ddc19ddbcd
4 changed files with 42 additions and 13 deletions

View File

@ -21,8 +21,8 @@ vn-chip {
} }
} }
&.white { &.transparent {
background-color: $color-bg-panel; background-color: transparent;
} }
&.colored { &.colored {
background-color: $color-main; background-color: $color-main;

View File

@ -3,7 +3,7 @@ const ParameterizedSQL = require('loopback-connector').ParameterizedSQL;
module.exports = Self => { module.exports = Self => {
Self.remoteMethodCtx('addBuy', { Self.remoteMethodCtx('addBuy', {
description: 'Inserts or updates buy for the current entry', description: 'Inserts a new buy for the current entry',
accessType: 'WRITE', accessType: 'WRITE',
accepts: [{ accepts: [{
arg: 'id', arg: 'id',
@ -26,6 +26,34 @@ module.exports = Self => {
arg: 'packageFk', arg: 'packageFk',
type: 'string', type: 'string',
required: true required: true
},
{
arg: 'packing',
type: 'number',
},
{
arg: 'grouping',
type: 'number'
},
{
arg: 'weight',
type: 'number',
},
{
arg: 'stickers',
type: 'number',
},
{
arg: 'price2',
type: 'number',
},
{
arg: 'price3',
type: 'number',
},
{
arg: 'buyingValue',
type: 'number'
}], }],
returns: { returns: {
type: 'object', type: 'object',
@ -53,12 +81,13 @@ module.exports = Self => {
try { try {
const models = Self.app.models; const models = Self.app.models;
const newBuy = await models.Buy.create({ ctx.args.entryFk = ctx.args.id;
itemFk: ctx.args.itemFk,
entryFk: ctx.args.id, // remove unwanted properties
packageFk: ctx.args.packageFk, delete ctx.args.id;
quantity: ctx.args.quantity delete ctx.args.ctx;
}, myOptions);
const newBuy = await models.Buy.create(ctx.args, myOptions);
let filter = { let filter = {
fields: [ fields: [

View File

@ -83,12 +83,12 @@
</span> </span>
</vn-td> </vn-td>
<vn-td number> <vn-td number>
<vn-chip class="white" translate-attr="buy.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': buy.groupingMode == 2}"> <vn-chip class="transparent" translate-attr="buy.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': buy.groupingMode == 2}">
<span translate>{{::buy.packing | dashIfEmpty}}</span> <span translate>{{::buy.packing | dashIfEmpty}}</span>
</vn-chip> </vn-chip>
</vn-td> </vn-td>
<vn-td number> <vn-td number>
<vn-chip class="white" translate-attr="buy.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': buy.groupingMode == 1}"> <vn-chip class="transparent" translate-attr="buy.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': buy.groupingMode == 1}">
<span translate>{{::buy.grouping | dashIfEmpty}}</span> <span translate>{{::buy.grouping | dashIfEmpty}}</span>
</vn-chip> </vn-chip>
</vn-td> </vn-td>

View File

@ -102,12 +102,12 @@
<td center title="{{::line.packageFk | dashIfEmpty}}">{{::line.packageFk | dashIfEmpty}}</td> <td center title="{{::line.packageFk | dashIfEmpty}}">{{::line.packageFk | dashIfEmpty}}</td>
<td center title="{{::line.weight}}">{{::line.weight}}</td> <td center title="{{::line.weight}}">{{::line.weight}}</td>
<td center> <td center>
<vn-chip class="white" translate-attr="line.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': line.groupingMode == 2}"> <vn-chip class="transparent" translate-attr="line.groupingMode == 2 ? {title: 'Minimun amount'} : {title: 'Packing'}" ng-class="{'message': line.groupingMode == 2}">
<span translate>{{::line.packing | dashIfEmpty}}</span> <span translate>{{::line.packing | dashIfEmpty}}</span>
</vn-chip> </vn-chip>
</td> </td>
<td center> <td center>
<vn-chip class="white" translate-attr="line.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': line.groupingMode == 1}"> <vn-chip class="transparent" translate-attr="line.groupingMode == 1 ? {title: 'Minimun amount'} : {title: 'Grouping'}" ng-class="{'message': line.groupingMode == 1}">
<span translate>{{::line.grouping | dashIfEmpty}}</span> <span translate>{{::line.grouping | dashIfEmpty}}</span>
</vn-chip> </vn-chip>
</vn-td> </vn-td>