2084 - Keep categoryId selected on item confirmation
gitea/salix/2084-order_catalog_keep_category This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-02-06 12:46:44 +01:00
parent d400e63aac
commit 20f9f7af24
5 changed files with 36 additions and 17 deletions

View File

@ -125,5 +125,6 @@
"MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} (#{{clientId}})]({{{url}}}) a *{{credit}} €*", "MESSAGE_INSURANCE_CHANGE": "He cambiado el crédito asegurado del cliente [{{clientName}} (#{{clientId}})]({{{url}}}) a *{{credit}} €*",
"MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} (#{{clientId}})]({{{url}}})", "MESSAGE_CHANGED_PAYMETHOD": "He cambiado la forma de pago del cliente [{{clientName}} (#{{clientId}})]({{{url}}})",
"MESSAGE_CLAIM_ITEM_REGULARIZE": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a {{nickname}} provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})", "MESSAGE_CLAIM_ITEM_REGULARIZE": "Envio *{{quantity}}* unidades de [{{concept}} (#{{itemId}})]({{{itemUrl}}}) a {{nickname}} provenientes del ticket id [#{{ticketId}}]({{{ticketUrl}}})",
"Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}" "Client checked as validated despite of duplication": "Cliente comprobado a pesar de que existe el cliente id {{clientId}}",
"ORDER_ROW_UNAVAILABLE": "No hay disponibilidad de este producto"
} }

View File

@ -29,7 +29,7 @@
ng-class="{'active': $ctrl.categoryId == category.id}" ng-class="{'active': $ctrl.categoryId == category.id}"
icon="{{::category.icon}}" icon="{{::category.icon}}"
vn-tooltip="{{::category.name}}" vn-tooltip="{{::category.name}}"
ng-click="$ctrl.categoryId = category.id"> ng-click="$ctrl.changeCategory(category.id)">
</vn-icon> </vn-icon>
</vn-one> </vn-one>
</vn-horizontal> </vn-horizontal>

View File

@ -107,8 +107,7 @@ class Controller {
} }
set categoryId(value) { set categoryId(value) {
if (!value || (this.categoryId == value)) if (!value) value = null;
value = null;
this._categoryId = value; this._categoryId = value;
this.itemTypes = []; this.itemTypes = [];
@ -123,6 +122,11 @@ class Controller {
this.updateItemTypes(); this.updateItemTypes();
} }
changeCategory(id) {
if (this._categoryId == id) id = null;
this.categoryId = id;
}
get typeId() { get typeId() {
return this._typeId; return this._typeId;
} }

View File

@ -20,6 +20,7 @@ describe('Order', () => {
$state.params.typeId = 2; $state.params.typeId = 2;
$state.current.name = 'my.current.state'; $state.current.name = 'my.current.state';
controller = $componentController('vnOrderCatalog', {$scope, $state}); controller = $componentController('vnOrderCatalog', {$scope, $state});
controller._order = {id: 4};
})); }));
describe('order() setter', () => { describe('order() setter', () => {
@ -59,13 +60,28 @@ describe('Order', () => {
it(`should set category property and then call updateStateParams() and applyFilters() methods`, () => { it(`should set category property and then call updateStateParams() and applyFilters() methods`, () => {
spyOn(controller, 'updateStateParams'); spyOn(controller, 'updateStateParams');
controller._order = {id: 4};
controller.categoryId = 2; controller.categoryId = 2;
expect(controller.updateStateParams).toHaveBeenCalledWith(); expect(controller.updateStateParams).toHaveBeenCalledWith();
}); });
}); });
describe('changeCategory()', () => {
it(`should set categoryId property to null if the new value equals to the old one`, () => {
controller.categoryId = 2;
controller.changeCategory(2);
expect(controller.categoryId).toBeNull();
});
it(`should set categoryId property`, () => {
controller.categoryId = 2;
controller.changeCategory(1);
expect(controller.categoryId).toEqual(1);
});
});
describe('typeId() setter', () => { describe('typeId() setter', () => {
it(`should set type property to null, call updateStateParams() method and not call applyFilters()`, () => { it(`should set type property to null, call updateStateParams() method and not call applyFilters()`, () => {
spyOn(controller, 'updateStateParams'); spyOn(controller, 'updateStateParams');
@ -132,7 +148,6 @@ describe('Order', () => {
spyOn(model, 'applyFilter'); spyOn(model, 'applyFilter');
controller._categoryId = 2; controller._categoryId = 2;
controller._typeId = 4; controller._typeId = 4;
controller._order = {id: 4};
controller.applyFilters(); controller.applyFilters();

View File

@ -127,19 +127,18 @@ class Controller extends Component {
return; return;
} }
setTimeout(() => {
let params = {
orderFk: this.order.id,
items: filledLines
};
this.$http.post(`OrderRows/addToOrder`, params).then(res => { let params = {
this.vnApp.showSuccess(this.$translate.instant('Data saved!')); orderFk: this.order.id,
this.$.popover.hide(); items: filledLines
};
if (this.card) this.$http.post(`OrderRows/addToOrder`, params).then(res => {
this.card.reload(); this.vnApp.showSuccess(this.$translate.instant('Data saved!'));
}); this.$.popover.hide();
if (this.card)
this.card.reload();
}); });
} }
} }