feat(entry.buys): each buy groupingMode can now changed
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
485da4d0a7
commit
00f8946675
|
@ -111,17 +111,45 @@
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<vn-input-number class="dense"
|
<vn-input-number
|
||||||
title="{{::buy.packing | dashIfEmpty}}"
|
title="{{::buy.packing | dashIfEmpty}}"
|
||||||
ng-model="buy.packing"
|
ng-model="buy.packing"
|
||||||
on-change="$ctrl.saveBuy(buy)">
|
on-change="$ctrl.saveBuy(buy)">
|
||||||
|
<append>
|
||||||
|
<vn-icon
|
||||||
|
pointer
|
||||||
|
ng-show="buy.groupingMode == '2'"
|
||||||
|
ng-click="$ctrl.toggleGroupingMode(buy, 'packing')"
|
||||||
|
icon="lock">
|
||||||
|
</vn-icon>
|
||||||
|
<vn-icon
|
||||||
|
pointer
|
||||||
|
ng-show="buy.groupingMode != '2'"
|
||||||
|
ng-click="$ctrl.toggleGroupingMode(buy, 'packing')"
|
||||||
|
icon="lock_open">
|
||||||
|
</vn-icon>
|
||||||
|
</append>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<vn-input-number class="dense"
|
<vn-input-number
|
||||||
title="{{::buy.grouping | dashIfEmpty}}"
|
title="{{::buy.grouping | dashIfEmpty}}"
|
||||||
ng-model="buy.grouping"
|
ng-model="buy.grouping"
|
||||||
on-change="$ctrl.saveBuy(buy)">
|
on-change="$ctrl.saveBuy(buy)">
|
||||||
|
<append>
|
||||||
|
<vn-icon
|
||||||
|
pointer
|
||||||
|
ng-show="buy.groupingMode == '1'"
|
||||||
|
ng-click="$ctrl.toggleGroupingMode(buy, 'grouping')"
|
||||||
|
icon="lock">
|
||||||
|
</vn-icon>
|
||||||
|
<vn-icon
|
||||||
|
pointer
|
||||||
|
ng-show="buy.groupingMode != '1'"
|
||||||
|
ng-click="$ctrl.toggleGroupingMode(buy, 'grouping')"
|
||||||
|
icon="lock_open">
|
||||||
|
</vn-icon>
|
||||||
|
</append>
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -213,7 +241,6 @@
|
||||||
vn-id="item-descriptor"
|
vn-id="item-descriptor"
|
||||||
warehouse-fk="$ctrl.vnConfig.warehouseFk">
|
warehouse-fk="$ctrl.vnConfig.warehouseFk">
|
||||||
</vn-item-descriptor-popover>
|
</vn-item-descriptor-popover>
|
||||||
|
|
||||||
<vn-confirm
|
<vn-confirm
|
||||||
vn-id="delete-buys"
|
vn-id="delete-buys"
|
||||||
question="You are going to delete buy(s) from this entry"
|
question="You are going to delete buy(s) from this entry"
|
||||||
|
|
|
@ -56,6 +56,23 @@ export default class Controller extends Section {
|
||||||
this.buys.splice(index, 1);
|
this.buys.splice(index, 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toggleGroupingMode(buy, mode) {
|
||||||
|
const groupingFk = 1;
|
||||||
|
const packingFk = 2;
|
||||||
|
const grouingMode = mode === 'grouping' ? groupingFk : packingFk;
|
||||||
|
|
||||||
|
const newGroupingMode = buy.groupingMode === grouingMode ? 0 : grouingMode;
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
groupingMode: newGroupingMode
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$http.patch(`Buys/${buy.id}`, params).then(() => {
|
||||||
|
buy.groupingMode = newGroupingMode;
|
||||||
|
this.vnApp.showSuccess(this.$t('Data saved!'));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngModule.vnComponent('vnEntryBuyIndex', {
|
ngModule.vnComponent('vnEntryBuyIndex', {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint max-len: ["error", { "code": 150 }]*/
|
||||||
import './index.js';
|
import './index.js';
|
||||||
|
|
||||||
describe('Entry buy', () => {
|
describe('Entry buy', () => {
|
||||||
|
@ -64,4 +65,50 @@ describe('Entry buy', () => {
|
||||||
expect(controller.buys.length).toEqual(1);
|
expect(controller.buys.length).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('toggleGroupingMode()', () => {
|
||||||
|
it(`should toggle grouping mode from grouping to packing`, () => {
|
||||||
|
const groupingFk = 1;
|
||||||
|
const packingFk = 2;
|
||||||
|
const buy = {id: 999, groupingMode: groupingFk};
|
||||||
|
|
||||||
|
const query = `Buys/${buy.id}`;
|
||||||
|
$httpBackend.expectPATCH(query, {groupingMode: packingFk}).respond(200);
|
||||||
|
controller.toggleGroupingMode(buy, 'packing');
|
||||||
|
$httpBackend.flush();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should toggle grouping mode from packing to grouping`, () => {
|
||||||
|
const groupingFk = 1;
|
||||||
|
const packingFk = 2;
|
||||||
|
const buy = {id: 999, groupingMode: packingFk};
|
||||||
|
|
||||||
|
const query = `Buys/${buy.id}`;
|
||||||
|
$httpBackend.expectPATCH(query, {groupingMode: groupingFk}).respond(200);
|
||||||
|
controller.toggleGroupingMode(buy, 'grouping');
|
||||||
|
$httpBackend.flush();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should toggle off the grouping mode if it was packing to packing`, () => {
|
||||||
|
const noGroupingFk = 0;
|
||||||
|
const packingFk = 2;
|
||||||
|
const buy = {id: 999, groupingMode: packingFk};
|
||||||
|
|
||||||
|
const query = `Buys/${buy.id}`;
|
||||||
|
$httpBackend.expectPATCH(query, {groupingMode: noGroupingFk}).respond(200);
|
||||||
|
controller.toggleGroupingMode(buy, 'packing');
|
||||||
|
$httpBackend.flush();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should toggle off the grouping mode if it was grouping to grouping`, () => {
|
||||||
|
const noGroupingFk = 0;
|
||||||
|
const groupingFk = 1;
|
||||||
|
const buy = {id: 999, groupingMode: groupingFk};
|
||||||
|
|
||||||
|
const query = `Buys/${buy.id}`;
|
||||||
|
$httpBackend.expectPATCH(query, {groupingMode: noGroupingFk}).respond(200);
|
||||||
|
controller.toggleGroupingMode(buy, 'grouping');
|
||||||
|
$httpBackend.flush();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue