Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into 2321-log_web_access
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Bernat Exposito Domenech 2020-06-10 12:08:54 +02:00
commit 704e27a657
6 changed files with 118 additions and 31 deletions

View File

@ -1,4 +1,5 @@
import ngModule from '../../module'; import ngModule from '../../module';
import {buildFilter} from 'vn-loopback/util/filter';
import './style.scss'; import './style.scss';
export default class Contextmenu { export default class Contextmenu {
@ -137,27 +138,73 @@ export default class Contextmenu {
* Filter by current field selection * Filter by current field selection
*/ */
filterBySelection() { filterBySelection() {
const filter = {where: {}}; let where = {[this.fieldName]: this.fieldValue};
filter['where'][this.fieldName] = this.fieldValue; if (this.exprBuilder) {
where = buildFilter(where, (param, value) =>
this.exprBuilder({param, value})
);
}
this.model.addFilter(filter); this.model.addFilter({where});
} }
/** /**
* Exclude by current field selection * Exclude by current field selection
*/ */
excludeSelection() { excludeSelection() {
const filter = {where: {}}; let where = {[this.fieldName]: {neq: this.fieldValue}};
filter['where'][this.fieldName] = {neq: this.fieldValue}; if (this.exprBuilder) {
where = buildFilter(where, (param, value) =>
this.exprBuilder({param, value})
);
}
this.model.addFilter(filter); this.model.addFilter({where});
}
removeFilter() {
const userFilter = this.model.userFilter;
const userParams = this.model.userParams;
const where = userFilter.where;
let filterKey = this.fieldName;
if (this.exprBuilder) {
const param = this.exprBuilder({
param: filterKey,
value: null
});
[filterKey] = Object.keys(param);
}
const whereKeys = Object.keys(where);
for (let key of whereKeys)
removeProp(where, filterKey, key);
function removeProp(instance, findProp, prop) {
if (prop == findProp)
delete instance[prop];
if (prop === 'and') {
for (let [index, param] of instance[prop].entries()) {
const [key] = Object.keys(param);
if (key == findProp)
instance[prop].splice(index, 1);
if (param[key] instanceof Array)
removeProp(param, filterKey, key);
}
}
}
this.model.applyFilter(userFilter, userParams);
} }
/** /**
* Removes all applied filters * Removes all applied filters
*/ */
removeFilter() { removeAllFilters() {
this.model.removeFilter(); const userParams = this.model.userParams;
this.model.applyFilter(null, userParams);
} }
} }
@ -168,7 +215,8 @@ ngModule.vnComponent('vnContextmenu', {
template: require('./index.html'), template: require('./index.html'),
bindings: { bindings: {
targets: '<?', targets: '<?',
model: '<?' model: '<?',
exprBuilder: '&?'
}, },
transclude: { transclude: {
menu: '?slotMenu' menu: '?slotMenu'

View File

@ -138,22 +138,22 @@ module.exports = Self => {
switch (param) { switch (param) {
case 'search': case 'search':
return /^\d+$/.test(value) return /^\d+$/.test(value)
? {'id': {inq: value}} ? {'t.id': {inq: value}}
: {'nickname': {like: `%${value}%`}}; : {'t.nickname': {like: `%${value}%`}};
case 'from': case 'from':
return {'shipped': {gte: value}}; return {'t.shipped': {gte: value}};
case 'to': case 'to':
return {'shipped': {lte: value}}; return {'t.shipped': {lte: value}};
case 'nickname': case 'nickname':
return {'nickname': {like: `%${value}%`}}; return {'t.nickname': {like: `%${value}%`}};
case 'refFk': case 'refFk':
return {'refFk': value}; return {'t.refFk': value};
case 'salesPersonFk': case 'salesPersonFk':
return {'salesPersonFk': value}; return {'c.salesPersonFk': value};
case 'provinceFk': case 'provinceFk':
return {'provinceFk': value}; return {'a.provinceFk': value};
case 'stateFk': case 'stateFk':
return {'stateFk': value}; return {'ts.stateFk': value};
case 'mine': case 'mine':
case 'myTeam': case 'myTeam':
return {'c.salesPersonFk': {inq: teamIds}}; return {'c.salesPersonFk': {inq: teamIds}};
@ -162,13 +162,13 @@ module.exports = Self => {
case 'pending': case 'pending':
if (value) { if (value) {
return {and: [ return {and: [
{'alertLevel': 0}, {'st.alertLevel': 0},
{'alertLevelCode': {neq: 'OK'}}, {'st.code': {neq: 'OK'}},
{'alertLevelCode': {neq: 'BOARDING'}} {'st.code': {neq: 'BOARDING'}}
]}; ]};
} else { } else {
return {and: [ return {and: [
{'alertLevel': {gt: 0}} {'st.alertLevel': {gt: 0}}
]}; ]};
} }
case 'id': case 'id':
@ -190,7 +190,6 @@ module.exports = Self => {
`CREATE TEMPORARY TABLE tmp.filter `CREATE TEMPORARY TABLE tmp.filter
(INDEX (id)) (INDEX (id))
ENGINE = MEMORY ENGINE = MEMORY
SELECT * FROM (
SELECT SELECT
t.id, t.id,
t.shipped, t.shipped,
@ -214,7 +213,8 @@ module.exports = Self => {
c.salesPersonFk, c.salesPersonFk,
z.hour zoneLanding, z.hour zoneLanding,
HOUR(z.hour) zoneHour, HOUR(z.hour) zoneHour,
MINUTE(z.hour) zoneMinute MINUTE(z.hour) zoneMinute,
CAST(z.hour AS CHAR) AS hour
FROM ticket t FROM ticket t
LEFT JOIN zone z ON z.id = t.zoneFk LEFT JOIN zone z ON z.id = t.zoneFk
LEFT JOIN address a ON a.id = t.addressFk LEFT JOIN address a ON a.id = t.addressFk
@ -225,7 +225,7 @@ module.exports = Self => {
LEFT JOIN state st ON st.id = ts.stateFk LEFT JOIN state st ON st.id = ts.stateFk
LEFT JOIN client c ON c.id = t.clientFk LEFT JOIN client c ON c.id = t.clientFk
LEFT JOIN worker wk ON wk.id = c.salesPersonFk LEFT JOIN worker wk ON wk.id = c.salesPersonFk
LEFT JOIN account.user u ON u.id = wk.userFk) t`); LEFT JOIN account.user u ON u.id = wk.userFk`);
if (args.orderFk) { if (args.orderFk) {
stmt.merge({ stmt.merge({

View File

@ -16,7 +16,7 @@
<vn-th></vn-th> <vn-th></vn-th>
<vn-th field="id" number>Id</vn-th> <vn-th field="id" number>Id</vn-th>
<vn-th field="salesPersonFk" class="expendable">Salesperson</vn-th> <vn-th field="salesPersonFk" class="expendable">Salesperson</vn-th>
<vn-th field="shippedDate">Date</vn-th> <vn-th field="shipped">Date</vn-th>
<vn-th>Hour</vn-th> <vn-th>Hour</vn-th>
<vn-th field="nickname">Alias</vn-th> <vn-th field="nickname">Alias</vn-th>
<vn-th field="provinceFk" class="expendable">Province</vn-th> <vn-th field="provinceFk" class="expendable">Province</vn-th>
@ -24,7 +24,7 @@
<vn-th field="agencyModeFk">Agency</vn-th> <vn-th field="agencyModeFk">Agency</vn-th>
<vn-th field="warehouseFk">Warehouse</vn-th> <vn-th field="warehouseFk">Warehouse</vn-th>
<vn-th field="refFk" class="expendable">Invoice</vn-th> <vn-th field="refFk" class="expendable">Invoice</vn-th>
<vn-th field="zoneHour" shrink>Closure</vn-th> <vn-th field="hour" shrink>Closure</vn-th>
<vn-th number>Total</vn-th> <vn-th number>Total</vn-th>
<vn-th></vn-th> <vn-th></vn-th>
</vn-tr> </vn-tr>
@ -151,7 +151,8 @@
<vn-client-balance-create <vn-client-balance-create
vn-id="balanceCreateDialog"> vn-id="balanceCreateDialog">
</vn-client-balance-create> </vn-client-balance-create>
<vn-contextmenu vn-id="contextmenu" targets="['vn-data-viewer']" model="model"> <vn-contextmenu vn-id="contextmenu" targets="['vn-data-viewer']" model="model"
expr-builder="$ctrl.exprBuilder(param, value)">
<slot-menu> <slot-menu>
<vn-item translate <vn-item translate
ng-if="contextmenu.isFilterAllowed()" ng-if="contextmenu.isFilterAllowed()"
@ -164,8 +165,13 @@
Exclude selection Exclude selection
</vn-item> </vn-item>
<vn-item translate <vn-item translate
ng-if="contextmenu.isFilterAllowed()"
ng-click="contextmenu.removeFilter()" > ng-click="contextmenu.removeFilter()" >
Remove filter Remove filter
</vn-item> </vn-item>
<vn-item translate
ng-click="contextmenu.removeAllFilters()" >
Remove all filters
</vn-item>
</slot-menu> </slot-menu>
</vn-contextmenu> </vn-contextmenu>

View File

@ -92,6 +92,38 @@ export default class Controller extends Section {
this.selectedTicket = ticket; this.selectedTicket = ticket;
this.$.summary.show(); this.$.summary.show();
} }
exprBuilder(param, value) {
switch (param) {
case 'stateFk':
return {'ts.stateFk': value};
case 'salesPersonFk':
return {'c.salesPersonFk': value};
case 'provinceFk':
return {'a.provinceFk': value};
case 'hour':
return {'z.hour': value};
case 'shipped':
return {'t.shipped': {
between: this.dateRange(value)}
};
case 'id':
case 'refFk':
case 'nickname':
case 'agencyModeFk':
case 'warehouseFk':
return {[`t.${param}`]: 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.component('vnTicketIndex', { ngModule.component('vnTicketIndex', {

View File

@ -6,4 +6,5 @@ Closure: Cierre
You cannot make a payment on account from multiple clients: No puedes realizar un pago a cuenta de clientes diferentes You cannot make a payment on account from multiple clients: No puedes realizar un pago a cuenta de clientes diferentes
Filter by selection: Filtro por selección Filter by selection: Filtro por selección
Exclude selection: Excluir selección Exclude selection: Excluir selección
Remove filter: Eliminar filtro Remove filter: Quitar filtro por selección
Remove all filters: Eliminar todos los filtros

View File

@ -5,11 +5,11 @@
<div class="attributes"> <div class="attributes">
<vn-label-value <vn-label-value
label="Wh. In" label="Wh. In"
value="{{$ctrl.travel.warehouseOut.name}}"> value="{{$ctrl.travel.warehouseIn.name}}">
</vn-label-value> </vn-label-value>
<vn-label-value <vn-label-value
label="Wh. Out" label="Wh. Out"
value="{{$ctrl.travel.warehouseIn.name}}"> value="{{$ctrl.travel.warehouseOut.name}}">
</vn-label-value> </vn-label-value>
<vn-label-value <vn-label-value
label="Shipped" label="Shipped"