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
gitea/salix/pipeline/head This commit looks good
Details
Reviewed-on: #361 Reviewed-by: Carlos Jimenez <carlosjr@verdnatura.es>
This commit is contained in:
commit
156c5de17d
|
@ -31,7 +31,7 @@ describe('Item request path', () => {
|
|||
it('should the status of the request should now be accepted', async() => {
|
||||
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() => {
|
||||
|
@ -40,6 +40,6 @@ describe('Item request path', () => {
|
|||
await page.respondToDialog('accept');
|
||||
let status = await page.waitToGetProperty(selectors.itemRequest.firstRequestStatus, 'innerText');
|
||||
|
||||
expect(status).toContain('Denegada');
|
||||
expect(status).toContain('Denied');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -67,13 +67,13 @@ export default class Contextmenu {
|
|||
get cell() {
|
||||
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() {
|
||||
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(
|
||||
cellItem => cellItem == this.cell
|
||||
);
|
||||
|
|
|
@ -56,12 +56,14 @@
|
|||
label="For me"
|
||||
ng-model="filter.mine">
|
||||
</vn-check>
|
||||
<vn-check
|
||||
vn-one
|
||||
triple-state="true"
|
||||
label="Confirmed"
|
||||
ng-model="filter.isOk">
|
||||
</vn-check>
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
ng-model="filter.state"
|
||||
data="$ctrl.states"
|
||||
value-field="code"
|
||||
label="State">
|
||||
<tpl-item>{{name}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal class="vn-mt-lg">
|
||||
<vn-submit label="Search"></vn-submit>
|
||||
|
|
|
@ -1,7 +1,19 @@
|
|||
import ngModule from '../module';
|
||||
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', {
|
||||
template: require('./index.html'),
|
||||
controller: SearchPanel
|
||||
controller: Controller
|
||||
});
|
||||
|
|
|
@ -24,14 +24,15 @@
|
|||
<vn-tr>
|
||||
<vn-th field="ticketFk" number>Ticket ID</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="price" number>Price</vn-th>
|
||||
<vn-th field="atenderNickname">Atender</vn-th>
|
||||
<vn-th field="itemFk">Item</vn-th>
|
||||
<vn-th field="attenderName">Atender</vn-th>
|
||||
<vn-th>Item</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></vn-th>
|
||||
</vn-tr>
|
||||
</vn-thead>
|
||||
<vn-tbody>
|
||||
|
@ -83,7 +84,7 @@
|
|||
{{request.itemDescription}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td>{{$ctrl.getState(request.isOk)}}</vn-td>
|
||||
<vn-td translate>{{$ctrl.getState(request.isOk)}}</vn-td>
|
||||
<vn-td>
|
||||
<vn-icon
|
||||
ng-if="request.response.length"
|
||||
|
@ -128,4 +129,29 @@
|
|||
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
|
||||
<button response="accept" translate>Save</button>
|
||||
</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>
|
|
@ -17,18 +17,19 @@ export default class Controller extends Section {
|
|||
this.filterParams = {
|
||||
mine: true,
|
||||
from: today,
|
||||
to: nextWeek
|
||||
to: nextWeek,
|
||||
state: 'pending'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
getState(isOk) {
|
||||
if (isOk === null)
|
||||
return 'Nueva';
|
||||
return 'Pending';
|
||||
else if (isOk)
|
||||
return 'Aceptada';
|
||||
return 'Accepted';
|
||||
else
|
||||
return 'Denegada';
|
||||
return 'Denied';
|
||||
}
|
||||
|
||||
confirmRequest(request) {
|
||||
|
@ -92,6 +93,31 @@ export default class Controller extends Section {
|
|||
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', {
|
||||
|
|
|
@ -24,17 +24,17 @@ describe('Item', () => {
|
|||
let isOk = null;
|
||||
let result = controller.getState(isOk);
|
||||
|
||||
expect(result).toEqual('Nueva');
|
||||
expect(result).toEqual('Pending');
|
||||
|
||||
isOk = 1;
|
||||
result = controller.getState(isOk);
|
||||
|
||||
expect(result).toEqual('Aceptada');
|
||||
expect(result).toEqual('Accepted');
|
||||
|
||||
isOk = 0;
|
||||
result = controller.getState(isOk);
|
||||
|
||||
expect(result).toEqual('Denegada');
|
||||
expect(result).toEqual('Denied');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -3,4 +3,7 @@ Specify the reasons to deny this request: Especifica las razones para descartar
|
|||
Buy requests: Peticiones de compra
|
||||
Search request by id or alias: Buscar peticiones por identificador o alias
|
||||
Requested: Solicitado
|
||||
Achieved: Conseguido
|
||||
Achieved: Conseguido
|
||||
Pending: Pendiente
|
||||
Accepted: Aceptada
|
||||
Denied: Rechazada
|
|
@ -44,8 +44,8 @@ module.exports = Self => {
|
|||
type: 'Date',
|
||||
description: `Date to`
|
||||
}, {
|
||||
arg: 'isOk',
|
||||
type: 'Boolean',
|
||||
arg: 'state',
|
||||
type: 'String',
|
||||
description: `Search request by request state`
|
||||
}
|
||||
],
|
||||
|
@ -77,8 +77,13 @@ module.exports = Self => {
|
|||
return {'t.id': value};
|
||||
case 'attenderFk':
|
||||
return {'tr.attenderFk': value};
|
||||
case 'isOk':
|
||||
return {'tr.isOk': value};
|
||||
case 'state':
|
||||
switch (value) {
|
||||
case 'pending':
|
||||
return {'tr.isOk': null};
|
||||
default:
|
||||
return {'tr.isOk': value};
|
||||
}
|
||||
case 'clientFk':
|
||||
return {'t.clientFk': value};
|
||||
case 'from':
|
||||
|
|
|
@ -12,4 +12,4 @@ Order id: Id cesta
|
|||
Grouped States: Estado agrupado
|
||||
Days onward: Días adelante
|
||||
With problems: Con problemas
|
||||
Pending: Pendientes
|
||||
Pending: Pendiente
|
Loading…
Reference in New Issue