refactor
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
1c0d5dbd76
commit
605fbe7999
|
@ -4,11 +4,12 @@ import './smart-table.scss';
|
|||
|
||||
/**
|
||||
* Directive to hide/show selected columns of a table, don't use with rowspan.
|
||||
* Property smart-table-ignore ignores one or more vn-th with prop field.
|
||||
*/
|
||||
directive.$inject = ['$http', '$compile', 'vnApp', '$translate'];
|
||||
export function directive($http, $compile, vnApp, $translate) {
|
||||
function getHeaderList($element, $scope) {
|
||||
let filtrableHeaders = $element[0].querySelectorAll('vn-th[field]');
|
||||
let filtrableHeaders = $element[0].querySelectorAll('vn-th[field]:not([smart-table-ignore])');
|
||||
let headerList = Array.from(filtrableHeaders);
|
||||
let ids = [];
|
||||
let titles = {};
|
||||
|
|
|
@ -3,10 +3,16 @@ module.exports = Self => {
|
|||
description: 'Updates a column for one or more buys',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
arg: 'column',
|
||||
type: 'Object',
|
||||
arg: 'field',
|
||||
type: 'String',
|
||||
required: true,
|
||||
description: `the column to edit and it's new value`
|
||||
description: `the column to edit`
|
||||
},
|
||||
{
|
||||
arg: 'newValue',
|
||||
type: 'Any',
|
||||
required: true,
|
||||
description: `The new value to save`
|
||||
},
|
||||
{
|
||||
arg: 'lines',
|
||||
|
@ -24,11 +30,11 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.editLatestBuys = async(column, lines) => {
|
||||
Self.editLatestBuys = async(field, newValue, lines) => {
|
||||
let modelName;
|
||||
let identifier;
|
||||
|
||||
switch (column.field) {
|
||||
switch (field) {
|
||||
case 'size':
|
||||
case 'density':
|
||||
case 'minPrice':
|
||||
|
@ -65,8 +71,9 @@ module.exports = Self => {
|
|||
});
|
||||
|
||||
let value = {};
|
||||
value[column.field] = column.newValue;
|
||||
value[field] = newValue;
|
||||
|
||||
// intentarlo con updateAll
|
||||
for (let target of targets)
|
||||
promises.push(model.upsertWithWhere({id: target}, value, options));
|
||||
|
||||
|
|
|
@ -11,17 +11,18 @@ describe('Buy editLatestsBuys()', () => {
|
|||
|
||||
let [original] = await model.latestBuysFilter(ctx);
|
||||
|
||||
const column = {field: 'size', newValue: 99};
|
||||
const buys = [{itemFk: 1, id: 3}];
|
||||
const field = 'size';
|
||||
let newValue = 99;
|
||||
const lines = [{itemFk: original.itemFk, id: original.id}];
|
||||
|
||||
await model.editLatestBuys(column, buys);
|
||||
await model.editLatestBuys(field, newValue, lines);
|
||||
|
||||
let [result] = await model.latestBuysFilter(ctx);
|
||||
|
||||
expect(result.size).toEqual(99);
|
||||
|
||||
column.newValue = original.size;
|
||||
await model.editLatestBuys(column, buys);
|
||||
newValue = original.size;
|
||||
await model.editLatestBuys(field, newValue, lines);
|
||||
|
||||
let [restoredFixture] = await model.latestBuysFilter(ctx);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ class Controller extends SearchPanel {
|
|||
constructor($element, $) {
|
||||
super($element, $);
|
||||
let model = 'Item';
|
||||
let moreFields = ['id', 'description', 'name'];
|
||||
let moreFields = ['description', 'name'];
|
||||
|
||||
let properties;
|
||||
let validations = window.validations;
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
Ink: Tinta
|
||||
Origin: Origen
|
||||
Producer: Productor.
|
||||
With visible: Con visible
|
||||
Field: Campo
|
||||
More fields: Más campos
|
||||
Add field: Añadir campo
|
||||
Remove field: Quitar campo
|
|
@ -24,12 +24,12 @@
|
|||
vn-smart-table="latestBuys">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th shrink>
|
||||
<vn-th smart-table-ignore shrink>
|
||||
<vn-multi-check
|
||||
model="model">
|
||||
</vn-multi-check>
|
||||
</vn-th>
|
||||
<vn-th field="picture">Picture</vn-th>
|
||||
<vn-th smart-table-ignore shrink></vn-th>
|
||||
<vn-th field="id">Id</vn-th>
|
||||
<vn-th field="packing">Packing</vn-th>
|
||||
<vn-th field="grouping">Grouping</vn-th>
|
||||
|
@ -45,11 +45,11 @@
|
|||
<vn-th field="quantity">Quantity</vn-th>
|
||||
<vn-th field="buyingValue">Buying value</vn-th>
|
||||
<vn-th field="freightValue">Freight value</vn-th>
|
||||
<vn-th field="comissionValue" expand>Comission value</vn-th>
|
||||
<vn-th field="comissionValue" expand>Commission value</vn-th>
|
||||
<vn-th field="packageValue" expand>Package value</vn-th>
|
||||
<vn-th field="isIgnored">Is ignored</vn-th>
|
||||
<vn-th expand field="price2">price2</vn-th>
|
||||
<vn-th expand field="price3">price3</vn-th>
|
||||
<vn-th expand field="price2">Grouping price</vn-th>
|
||||
<vn-th expand field="price3">Packing price</vn-th>
|
||||
<vn-th field="minPrice">Min price</vn-th>
|
||||
<vn-th field="ektFk">Ekt</vn-th>
|
||||
<vn-th field="weight">Weight</vn-th>
|
||||
|
@ -68,7 +68,7 @@
|
|||
<vn-td shrink >
|
||||
<img
|
||||
ng-src="{{::$root.imagePath}}/catalog/50x50/{{::buy.image}}"
|
||||
zoom-image="{{::$root.imagePath}}/catalog/1600x900/{{::item.image}}"
|
||||
zoom-image="{{::$root.imagePath}}/catalog/1600x900/{{::buy.image}}"
|
||||
vn-click-stop
|
||||
on-error-src/>
|
||||
</vn-td>
|
||||
|
@ -145,6 +145,7 @@
|
|||
<vn-dialog class="edit"
|
||||
vn-id="edit"
|
||||
on-accept="$ctrl.onEditAccept()"
|
||||
on-close="$ctrl.editedColumn = null"
|
||||
message="Edit buy(s)">
|
||||
<tpl-body>
|
||||
<vn-horizontal>
|
||||
|
@ -152,8 +153,8 @@
|
|||
vn-two
|
||||
ng-model="$ctrl.editedColumn.field"
|
||||
data="$ctrl.columns"
|
||||
show-field="displayName"
|
||||
value-field="field"
|
||||
show-field="displayName"
|
||||
label="Field to edit">
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
|
|
|
@ -15,20 +15,20 @@ export default class Controller extends Section {
|
|||
if (this._columns) return this._columns;
|
||||
|
||||
this._columns = [
|
||||
{field: 'quantity', displayName: 'quantity'},
|
||||
{field: 'buyingValue', displayName: 'buyingValue'},
|
||||
{field: 'freightValue', displayName: 'freightValue'},
|
||||
{field: 'packing', displayName: 'packing'},
|
||||
{field: 'grouping', displayName: 'grouping'},
|
||||
{field: 'comissionValue', displayName: 'comissionValue'},
|
||||
{field: 'packageValue', displayName: 'packageValue'},
|
||||
{field: 'price2', displayName: 'price2'},
|
||||
{field: 'price3', displayName: 'price3'},
|
||||
{field: 'weight', displayName: 'weight'},
|
||||
{field: 'description', displayName: 'description'},
|
||||
{field: 'minPrice', displayName: 'minPrice'},
|
||||
{field: 'size', displayName: 'size'},
|
||||
{field: 'density', displayName: 'density'}
|
||||
{field: 'quantity', displayName: this.$t('Quantity')},
|
||||
{field: 'buyingValue', displayName: this.$t('Buying value')},
|
||||
{field: 'freightValue', displayName: this.$t('Freight value')},
|
||||
{field: 'packing', displayName: this.$t('Packing')},
|
||||
{field: 'grouping', displayName: this.$t('Grouping')},
|
||||
{field: 'comissionValue', displayName: this.$t('Commission value')},
|
||||
{field: 'packageValue', displayName: this.$t('Package value')},
|
||||
{field: 'price2', displayName: this.$t('Grouping price')},
|
||||
{field: 'price3', displayName: this.$t('Packing price')},
|
||||
{field: 'weight', displayName: this.$t('Weight')},
|
||||
{field: 'description', displayName: this.$t('Description')},
|
||||
{field: 'minPrice', displayName: this.$t('Min price')},
|
||||
{field: 'size', displayName: this.$t('Size')},
|
||||
{field: 'density', displayName: this.$t('Density')}
|
||||
];
|
||||
|
||||
return this._columns;
|
||||
|
@ -59,18 +59,16 @@ export default class Controller extends Section {
|
|||
|
||||
onEditAccept() {
|
||||
let data = {
|
||||
column: this.editedColumn,
|
||||
field: this.editedColumn.field,
|
||||
newValue: this.editedColumn.newValue,
|
||||
lines: this.checked
|
||||
};
|
||||
|
||||
this.$http.post('Buys/editLatestBuys', data)
|
||||
return this.$http.post('Buys/editLatestBuys', data)
|
||||
.then(() => {
|
||||
this.$.edit.hide();
|
||||
this.uncheck();
|
||||
this.$.model.refresh();
|
||||
});
|
||||
|
||||
this.editedColumn = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,17 +65,9 @@ describe('Entry', () => {
|
|||
});
|
||||
|
||||
describe('onEditAccept()', () => {
|
||||
it(`should perform a query to update columns and then `, () => {
|
||||
controller.editedColumn = {someColumnName: 'some Value'};
|
||||
it(`should perform a query to update columns`, () => {
|
||||
controller.editedColumn = {field: 'my field', newValue: 'the new value'};
|
||||
let query = 'Buys/editLatestBuys';
|
||||
controller.$.model.data = [
|
||||
{checked: true, id: 1},
|
||||
{checked: true, id: 2},
|
||||
{checked: true, id: 3},
|
||||
{checked: false, id: 4},
|
||||
];
|
||||
|
||||
expect(controller.editedColumn).toBeDefined();
|
||||
|
||||
$httpBackend.expectPOST(query).respond();
|
||||
controller.onEditAccept();
|
||||
|
@ -84,7 +76,6 @@ describe('Entry', () => {
|
|||
const result = controller.checked;
|
||||
|
||||
expect(result.length).toEqual(0);
|
||||
expect(controller.editedColumn).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
Minimun amount: Minimun purchase quantity
|
||||
price2: Grouping price
|
||||
price3: Packing price
|
||||
Minimun amount: Minimun purchase quantity
|
|
@ -4,9 +4,10 @@ Freight value: Porte
|
|||
Commission value: Comisión
|
||||
Package value: Embalaje
|
||||
Is ignored: Ignorado
|
||||
price2: Precio grouping
|
||||
price3: Precio packing
|
||||
Grouping price: Precio grouping
|
||||
Packing price: Precio packing
|
||||
Min price: Precio min
|
||||
Ekt: Ekt
|
||||
Weight: Peso
|
||||
Minimun amount: Cantidad mínima de compra
|
||||
Minimun amount: Cantidad mínima de compra
|
||||
Field to edit: Campo a editar
|
|
@ -11,7 +11,7 @@
|
|||
vn-smart-table="itemIndex">
|
||||
<vn-thead>
|
||||
<vn-tr>
|
||||
<vn-th field="picture" shrink></vn-th>
|
||||
<vn-th shrink></vn-th>
|
||||
<vn-th field="id" shrink>Id</vn-th>
|
||||
<vn-th field="grouping" shrink>Grouping</vn-th>
|
||||
<vn-th field="packing" shrink>Packing</vn-th>
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
</vn-multi-check>
|
||||
</vn-th>
|
||||
<vn-th field="id" number>Id</vn-th>
|
||||
<vn-th field="worker">Worker</vn-th>
|
||||
<vn-th field="agency">Agency</vn-th>
|
||||
<vn-th field="vehicle">Vehicle</vn-th>
|
||||
<vn-th field="created">Date</vn-th>
|
||||
<vn-th field="m3" number>m³</vn-th>
|
||||
<vn-th field="description">Description</vn-th>
|
||||
<vn-th th-id="worker">Worker</vn-th>
|
||||
<vn-th th-id="agency">Agency</vn-th>
|
||||
<vn-th th-id="vehicle">Vehicle</vn-th>
|
||||
<vn-th th-id="created">Date</vn-th>
|
||||
<vn-th th-id="m3" number>m³</vn-th>
|
||||
<vn-th th-id="description">Description</vn-th>
|
||||
<vn-th shrink></vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
|
|
|
@ -70,7 +70,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
|||
|
||||
window.open = jasmine.createSpy('open');
|
||||
const params = {
|
||||
clientId: ticket.client.id,
|
||||
recipientId: ticket.client.id,
|
||||
ticketId: ticket.id
|
||||
};
|
||||
controller.showDeliveryNote();
|
||||
|
@ -85,7 +85,7 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
|||
|
||||
const params = {
|
||||
recipient: ticket.client.email,
|
||||
clientId: ticket.client.id,
|
||||
recipientId: ticket.client.id,
|
||||
ticketId: ticket.id
|
||||
};
|
||||
controller.sendDeliveryNote();
|
||||
|
@ -179,13 +179,10 @@ describe('Ticket Component vnTicketDescriptor', () => {
|
|||
|
||||
describe('loadData()', () => {
|
||||
it(`should perform a get query to store the ticket data into the controller`, () => {
|
||||
controller.ticket = null;
|
||||
|
||||
$httpBackend.expectRoute('GET', `Tickets/${ticket.id}`).respond(ticket);
|
||||
controller.id = ticket.id;
|
||||
$httpBackend.when('GET', `Tickets/${ticket.id}/isEditable`).respond();
|
||||
$httpBackend.expectRoute('GET', `Tickets/${ticket.id}`).respond();
|
||||
controller.loadData();
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.ticket).toEqual(ticket);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue