Merge pull request '2416 - Item request - Added state filter' (#361) from 2408-item_request into dev
gitea/salix/pipeline/head This commit looks good Details

Reviewed-on: #361
Reviewed-by: Carlos Jimenez <carlosjr@verdnatura.es>
This commit is contained in:
Joan Sanchez 2020-08-31 13:23:13 +00:00
commit 156c5de17d
10 changed files with 104 additions and 30 deletions

View File

@ -31,7 +31,7 @@ describe('Item request path', () => {
it('should the status of the request should now be accepted', async() => { it('should the status of the request should now be accepted', async() => {
let status = await page.waitToGetProperty(selectors.itemRequest.firstRequestStatus, 'innerText'); let status = await page.waitToGetProperty(selectors.itemRequest.firstRequestStatus, 'innerText');
expect(status).toContain('Aceptada'); expect(status).toContain('Accepted');
}); });
it('should now click on the second declain request icon then type the reason', async() => { it('should now click on the second declain request icon then type the reason', async() => {
@ -40,6 +40,6 @@ describe('Item request path', () => {
await page.respondToDialog('accept'); await page.respondToDialog('accept');
let status = await page.waitToGetProperty(selectors.itemRequest.firstRequestStatus, 'innerText'); let status = await page.waitToGetProperty(selectors.itemRequest.firstRequestStatus, 'innerText');
expect(status).toContain('Denegada'); expect(status).toContain('Denied');
}); });
}); });

View File

@ -67,13 +67,13 @@ export default class Contextmenu {
get cell() { get cell() {
if (!this.target) return null; if (!this.target) return null;
return this.target.closest('vn-td, .vn-td'); return this.target.closest('vn-td, .vn-td, vn-td-editable');
} }
get cellIndex() { get cellIndex() {
if (!this.row) return null; if (!this.row) return null;
const cells = this.row.querySelectorAll('vn-td, .vn-td'); const cells = this.row.querySelectorAll('vn-td, .vn-td, vn-td-editable');
return Array.from(cells).findIndex( return Array.from(cells).findIndex(
cellItem => cellItem == this.cell cellItem => cellItem == this.cell
); );

View File

@ -56,12 +56,14 @@
label="For me" label="For me"
ng-model="filter.mine"> ng-model="filter.mine">
</vn-check> </vn-check>
<vn-check <vn-autocomplete
vn-one vn-one
triple-state="true" ng-model="filter.state"
label="Confirmed" data="$ctrl.states"
ng-model="filter.isOk"> value-field="code"
</vn-check> label="State">
<tpl-item>{{name}}</tpl-item>
</vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<vn-horizontal class="vn-mt-lg"> <vn-horizontal class="vn-mt-lg">
<vn-submit label="Search"></vn-submit> <vn-submit label="Search"></vn-submit>

View File

@ -1,7 +1,19 @@
import ngModule from '../module'; import ngModule from '../module';
import SearchPanel from 'core/components/searchbar/search-panel'; import SearchPanel from 'core/components/searchbar/search-panel';
class Controller extends SearchPanel {
constructor($element, $) {
super($element, $);
this.states = [
{code: 'pending', name: this.$t('Pending')},
{code: 'accepted', name: this.$t('Accepted')},
{code: 'denied', name: this.$t('Denied')}
];
}
}
ngModule.vnComponent('vnRequestSearchPanel', { ngModule.vnComponent('vnRequestSearchPanel', {
template: require('./index.html'), template: require('./index.html'),
controller: SearchPanel controller: Controller
}); });

View File

@ -24,14 +24,15 @@
<vn-tr> <vn-tr>
<vn-th field="ticketFk" number>Ticket ID</vn-th> <vn-th field="ticketFk" number>Ticket ID</vn-th>
<vn-th field="shipped" expand>Shipped</vn-th> <vn-th field="shipped" expand>Shipped</vn-th>
<vn-th field="description" expand>Description</vn-th> <vn-th field="description" filter-enabled="false" expand>Description</vn-th>
<vn-th field="quantity" number editable>Requested</vn-th> <vn-th field="quantity" number editable>Requested</vn-th>
<vn-th field="price" number>Price</vn-th> <vn-th field="price" number>Price</vn-th>
<vn-th field="atenderNickname">Atender</vn-th> <vn-th field="attenderName">Atender</vn-th>
<vn-th field="itemFk">Item</vn-th> <vn-th>Item</vn-th>
<vn-th field="saleQuantity">Achieved</vn-th> <vn-th field="saleQuantity">Achieved</vn-th>
<vn-th field="description">Concept</vn-th> <vn-th field="description" filter-enabled="false">Concept</vn-th>
<vn-th field="isOk">State</vn-th> <vn-th field="isOk">State</vn-th>
<vn-th></vn-th>
</vn-tr> </vn-tr>
</vn-thead> </vn-thead>
<vn-tbody> <vn-tbody>
@ -83,7 +84,7 @@
{{request.itemDescription}} {{request.itemDescription}}
</span> </span>
</vn-td> </vn-td>
<vn-td>{{$ctrl.getState(request.isOk)}}</vn-td> <vn-td translate>{{$ctrl.getState(request.isOk)}}</vn-td>
<vn-td> <vn-td>
<vn-icon <vn-icon
ng-if="request.response.length" ng-if="request.response.length"
@ -128,4 +129,29 @@
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/> <input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Save</button> <button response="accept" translate>Save</button>
</tpl-buttons> </tpl-buttons>
</vn-dialog> </vn-dialog>
<vn-contextmenu vn-id="contextmenu" targets="['vn-data-viewer']" model="model"
expr-builder="$ctrl.exprBuilder(param, value)">
<slot-menu>
<vn-item translate
ng-if="contextmenu.isFilterAllowed()"
ng-click="contextmenu.filterBySelection()">
Filter by selection
</vn-item>
<vn-item translate
ng-if="contextmenu.isFilterAllowed()"
ng-click="contextmenu.excludeSelection()">
Exclude selection
</vn-item>
<vn-item translate
ng-if="contextmenu.isFilterAllowed()"
ng-click="contextmenu.removeFilter()" >
Remove filter
</vn-item>
<vn-item translate
ng-click="contextmenu.removeAllFilters()" >
Remove all filters
</vn-item>
</slot-menu>
</vn-contextmenu>

View File

@ -17,18 +17,19 @@ export default class Controller extends Section {
this.filterParams = { this.filterParams = {
mine: true, mine: true,
from: today, from: today,
to: nextWeek to: nextWeek,
state: 'pending'
}; };
} }
} }
getState(isOk) { getState(isOk) {
if (isOk === null) if (isOk === null)
return 'Nueva'; return 'Pending';
else if (isOk) else if (isOk)
return 'Aceptada'; return 'Accepted';
else else
return 'Denegada'; return 'Denied';
} }
confirmRequest(request) { confirmRequest(request) {
@ -92,6 +93,31 @@ export default class Controller extends Section {
this.vnApp.showSuccess(this.$t('Data saved!')); this.vnApp.showSuccess(this.$t('Data saved!'));
}); });
} }
exprBuilder(param, value) {
switch (param) {
case 'ticketFk':
case 'quantity':
case 'price':
case 'isOk':
return {[`tr.${param}`]: value};
case 'attenderName':
return {[`ua.name`]: value};
case 'shipped':
return {'t.shipped': {
between: this.dateRange(value)}
};
}
}
dateRange(value) {
const minHour = new Date(value);
minHour.setHours(0, 0, 0, 0);
const maxHour = new Date(value);
maxHour.setHours(23, 59, 59, 59);
return [minHour, maxHour];
}
} }
ngModule.vnComponent('vnItemRequest', { ngModule.vnComponent('vnItemRequest', {

View File

@ -24,17 +24,17 @@ describe('Item', () => {
let isOk = null; let isOk = null;
let result = controller.getState(isOk); let result = controller.getState(isOk);
expect(result).toEqual('Nueva'); expect(result).toEqual('Pending');
isOk = 1; isOk = 1;
result = controller.getState(isOk); result = controller.getState(isOk);
expect(result).toEqual('Aceptada'); expect(result).toEqual('Accepted');
isOk = 0; isOk = 0;
result = controller.getState(isOk); result = controller.getState(isOk);
expect(result).toEqual('Denegada'); expect(result).toEqual('Denied');
}); });
}); });

View File

@ -3,4 +3,7 @@ Specify the reasons to deny this request: Especifica las razones para descartar
Buy requests: Peticiones de compra Buy requests: Peticiones de compra
Search request by id or alias: Buscar peticiones por identificador o alias Search request by id or alias: Buscar peticiones por identificador o alias
Requested: Solicitado Requested: Solicitado
Achieved: Conseguido Achieved: Conseguido
Pending: Pendiente
Accepted: Aceptada
Denied: Rechazada

View File

@ -44,8 +44,8 @@ module.exports = Self => {
type: 'Date', type: 'Date',
description: `Date to` description: `Date to`
}, { }, {
arg: 'isOk', arg: 'state',
type: 'Boolean', type: 'String',
description: `Search request by request state` description: `Search request by request state`
} }
], ],
@ -77,8 +77,13 @@ module.exports = Self => {
return {'t.id': value}; return {'t.id': value};
case 'attenderFk': case 'attenderFk':
return {'tr.attenderFk': value}; return {'tr.attenderFk': value};
case 'isOk': case 'state':
return {'tr.isOk': value}; switch (value) {
case 'pending':
return {'tr.isOk': null};
default:
return {'tr.isOk': value};
}
case 'clientFk': case 'clientFk':
return {'t.clientFk': value}; return {'t.clientFk': value};
case 'from': case 'from':

View File

@ -12,4 +12,4 @@ Order id: Id cesta
Grouped States: Estado agrupado Grouped States: Estado agrupado
Days onward: Días adelante Days onward: Días adelante
With problems: Con problemas With problems: Con problemas
Pending: Pendientes Pending: Pendiente