Contextmenu fixes
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
0a2366194a
commit
1fed4c7913
|
@ -1,4 +1,5 @@
|
|||
import ngModule from '../../module';
|
||||
import {buildFilter} from 'vn-loopback/util/filter';
|
||||
import './style.scss';
|
||||
|
||||
export default class Contextmenu {
|
||||
|
@ -137,27 +138,80 @@ export default class Contextmenu {
|
|||
* Filter by current field selection
|
||||
*/
|
||||
filterBySelection() {
|
||||
const filter = {where: {}};
|
||||
filter['where'][this.fieldName] = this.fieldValue;
|
||||
let 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
|
||||
*/
|
||||
excludeSelection() {
|
||||
const filter = {where: {}};
|
||||
filter['where'][this.fieldName] = {neq: this.fieldValue};
|
||||
let where = {[this.fieldName]: {neq: this.fieldValue}};
|
||||
if (this.exprBuilder) {
|
||||
where = buildFilter(where, (param, value) =>
|
||||
this.exprBuilder({param, value})
|
||||
);
|
||||
}
|
||||
console.log(where);
|
||||
|
||||
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()) {
|
||||
if (param === undefined)
|
||||
console.log('param undefined');
|
||||
|
||||
const [key] = Object.keys(param);
|
||||
if (key == findProp)
|
||||
instance[prop].splice(index, 1);
|
||||
|
||||
if (instance[prop] instanceof Array) {
|
||||
if (!instance[prop][index]) return;
|
||||
const [firstKey] = Object.keys(instance[prop][index]);
|
||||
removeProp(instance[prop][index], filterKey, firstKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.model.applyFilter(userFilter, userParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all applied filters
|
||||
*/
|
||||
removeFilter() {
|
||||
this.model.removeFilter();
|
||||
removeAllFilters() {
|
||||
const userParams = this.model.userParams;
|
||||
this.model.applyFilter(null, userParams);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -168,7 +222,8 @@ ngModule.vnComponent('vnContextmenu', {
|
|||
template: require('./index.html'),
|
||||
bindings: {
|
||||
targets: '<?',
|
||||
model: '<?'
|
||||
model: '<?',
|
||||
exprBuilder: '&?'
|
||||
},
|
||||
transclude: {
|
||||
menu: '?slotMenu'
|
||||
|
|
|
@ -138,22 +138,22 @@ module.exports = Self => {
|
|||
switch (param) {
|
||||
case 'search':
|
||||
return /^\d+$/.test(value)
|
||||
? {'id': {inq: value}}
|
||||
: {'nickname': {like: `%${value}%`}};
|
||||
? {'t.id': {inq: value}}
|
||||
: {'t.nickname': {like: `%${value}%`}};
|
||||
case 'from':
|
||||
return {'shipped': {gte: value}};
|
||||
return {'t.shipped': {gte: value}};
|
||||
case 'to':
|
||||
return {'shipped': {lte: value}};
|
||||
return {'t.shipped': {lte: value}};
|
||||
case 'nickname':
|
||||
return {'nickname': {like: `%${value}%`}};
|
||||
return {'t.nickname': {like: `%${value}%`}};
|
||||
case 'refFk':
|
||||
return {'refFk': value};
|
||||
return {'t.refFk': value};
|
||||
case 'salesPersonFk':
|
||||
return {'salesPersonFk': value};
|
||||
return {'c.salesPersonFk': value};
|
||||
case 'provinceFk':
|
||||
return {'provinceFk': value};
|
||||
return {'a.provinceFk': value};
|
||||
case 'stateFk':
|
||||
return {'stateFk': value};
|
||||
return {'ts.stateFk': value};
|
||||
case 'mine':
|
||||
case 'myTeam':
|
||||
return {'c.salesPersonFk': {inq: teamIds}};
|
||||
|
@ -162,13 +162,13 @@ module.exports = Self => {
|
|||
case 'pending':
|
||||
if (value) {
|
||||
return {and: [
|
||||
{'alertLevel': 0},
|
||||
{'alertLevelCode': {neq: 'OK'}},
|
||||
{'alertLevelCode': {neq: 'BOARDING'}}
|
||||
{'st.alertLevel': 0},
|
||||
{'st.code': {neq: 'OK'}},
|
||||
{'st.code': {neq: 'BOARDING'}}
|
||||
]};
|
||||
} else {
|
||||
return {and: [
|
||||
{'alertLevel': {gt: 0}}
|
||||
{'st.alertLevel': {gt: 0}}
|
||||
]};
|
||||
}
|
||||
case 'id':
|
||||
|
@ -190,7 +190,6 @@ module.exports = Self => {
|
|||
`CREATE TEMPORARY TABLE tmp.filter
|
||||
(INDEX (id))
|
||||
ENGINE = MEMORY
|
||||
SELECT * FROM (
|
||||
SELECT
|
||||
t.id,
|
||||
t.shipped,
|
||||
|
@ -214,7 +213,8 @@ module.exports = Self => {
|
|||
c.salesPersonFk,
|
||||
z.hour zoneLanding,
|
||||
HOUR(z.hour) zoneHour,
|
||||
MINUTE(z.hour) zoneMinute
|
||||
MINUTE(z.hour) zoneMinute,
|
||||
CAST(z.hour AS CHAR) AS hour
|
||||
FROM ticket t
|
||||
LEFT JOIN zone z ON z.id = t.zoneFk
|
||||
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 client c ON c.id = t.clientFk
|
||||
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) {
|
||||
stmt.merge({
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<vn-th></vn-th>
|
||||
<vn-th field="id" number>Id</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 field="nickname">Alias</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="warehouseFk">Warehouse</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></vn-th>
|
||||
</vn-tr>
|
||||
|
@ -151,7 +151,8 @@
|
|||
<vn-client-balance-create
|
||||
vn-id="balanceCreateDialog">
|
||||
</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>
|
||||
<vn-item translate
|
||||
ng-if="contextmenu.isFilterAllowed()"
|
||||
|
@ -167,5 +168,9 @@
|
|||
ng-click="contextmenu.removeFilter()" >
|
||||
Remove filter
|
||||
</vn-item>
|
||||
<vn-item translate
|
||||
ng-click="contextmenu.removeAllFilters()" >
|
||||
Remove all filters
|
||||
</vn-item>
|
||||
</slot-menu>
|
||||
</vn-contextmenu>
|
|
@ -92,6 +92,38 @@ export default class Controller extends Section {
|
|||
this.selectedTicket = ticket;
|
||||
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', {
|
||||
|
|
|
@ -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
|
||||
Filter by selection: Filtro por 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
|
Loading…
Reference in New Issue