claim search-panel & connector-mysql fix date

This commit is contained in:
Joan Sanchez 2018-09-04 15:08:36 +02:00
parent ba51c0cc97
commit d3406fecde
8 changed files with 114 additions and 30 deletions

View File

@ -2,6 +2,7 @@ export * from './module';
import './index/'; import './index/';
import './card'; import './card';
import './search-panel';
import './detail'; import './detail';
import './descriptor'; import './descriptor';
import './basic-data'; import './basic-data';

View File

@ -10,7 +10,7 @@
<div class="vn-list"> <div class="vn-list">
<vn-card pad-medium-h> <vn-card pad-medium-h>
<vn-searchbar <vn-searchbar
panel="vn-ticket-search-panel" panel="vn-claim-search-panel"
model="model" model="model"
expr-builder="$ctrl.exprBuilder(param, value)"> expr-builder="$ctrl.exprBuilder(param, value)">
</vn-searchbar> </vn-searchbar>
@ -25,7 +25,6 @@
<vn-th field="clientFk">Client</vn-th> <vn-th field="clientFk">Client</vn-th>
<vn-th field="created">Created</vn-th> <vn-th field="created">Created</vn-th>
<vn-th field="workerFk">Worker</vn-th> <vn-th field="workerFk">Worker</vn-th>
<vn-th field="observation">Observation</vn-th>
<vn-th field="claimStateFk">State</vn-th> <vn-th field="claimStateFk">State</vn-th>
<vn-th></vn-th> <vn-th></vn-th>
</vn-tr> </vn-tr>
@ -37,7 +36,6 @@
<vn-td>{{::claim.client.name}}</vn-td> <vn-td>{{::claim.client.name}}</vn-td>
<vn-td>{{::claim.created | date:'dd/MM/yyyy'}}</vn-td> <vn-td>{{::claim.created | date:'dd/MM/yyyy'}}</vn-td>
<vn-td>{{::claim.worker.firstName}} {{::claim.worker.name}}</vn-td> <vn-td>{{::claim.worker.firstName}} {{::claim.worker.name}}</vn-td>
<vn-td>{{::claim.observation}}</vn-td>
<vn-td>{{::claim.claimState.description}}</vn-td> <vn-td>{{::claim.claimState.description}}</vn-td>
<vn-td> <vn-td>
<vn-icon-button <vn-icon-button

View File

@ -30,6 +30,24 @@ export default class Controller {
}; };
} }
exprBuilder(param, value) {
switch (param) {
case 'search':
return /^\d+$/.test(value)
? {id: value}
: {client: {regexp: value}};
case 'client':
return {[param]: {regexp: value}};
case 'created':
return {created: {between: [value, value]}};
case 'id':
case 'clientFk':
case 'workerFk':
case 'claimStateFk':
return {[param]: value};
}
}
showDescriptor(event, clientFk) { showDescriptor(event, clientFk) {
this.$.descriptor.clientFk = clientFk; this.$.descriptor.clientFk = clientFk;
this.$.descriptor.parent = event.target; this.$.descriptor.parent = event.target;

View File

@ -0,0 +1,54 @@
<div pad-large style="min-width: 30em">
<form ng-submit="$ctrl.onSearch()">
<vn-horizontal>
<vn-textfield
vn-one
label="Client"
model="filter.client"
vn-focus>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Claim id"
model="filter.id">
</vn-textfield>
<vn-textfield
vn-one
label="Client id"
model="filter.clientFk">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
label="State"
field="filter.claimStateFk"
url="/claim/api/ClaimStates"
show-field="description"
value-field="id">
<tpl-item>{{description}}</tpl-item>
</vn-autocomplete>
<vn-autocomplete
vn-one
label="Worker"
field="filter.workerFk"
url="/claim/api/Workers"
show-field="firstName"
value-field="id">
<tpl-item>{{firstName}} {{name}}</tpl-item>
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-date-picker
vn-one
label="Created"
model="filter.created">
</vn-date-picker>
</vn-horizontal>
<vn-horizontal margin-large-top>
<vn-submit label="Search"></vn-submit>
</vn-horizontal>
</form>
</div>

View File

@ -0,0 +1,7 @@
import ngModule from '../module';
import SearchPanel from 'core/src/components/searchbar/search-panel';
ngModule.component('vnClaimSearchPanel', {
template: require('./index.html'),
controller: SearchPanel
});

View File

@ -0,0 +1,7 @@
Ticket id: Id ticket
Client id: Id cliente
Nickname: Alias
From: Desde
To: Hasta
Agency: Agencia
Warehouse: Almacén

View File

@ -22,18 +22,17 @@ describe('Claim', () => {
}); });
}); });
// descomentar este test despues de completar la tarea #629 claim index buscador avanzado it('should search for the claim with id 1', () => {
// it('should search for the claim with id 1', () => { return nightmare
// return nightmare .wait(selectors.claimsIndex.searchResult)
// .wait(selectors.claimsIndex.searchResult) .type(selectors.claimsIndex.searchClaimInput, '1')
// .type(selectors.claimsIndex.searchClaimInput, '1') .click(selectors.claimsIndex.searchButton)
// .click(selectors.claimsIndex.searchButton) .waitForNumberOfElements(selectors.claimsIndex.searchResult, 1)
// .waitForNumberOfElements(selectors.claimsIndex.searchResult, 1) .countElement(selectors.claimsIndex.searchResult)
// .countElement(selectors.claimsIndex.searchResult) .then(result => {
// .then(result => { expect(result).toEqual(1);
// expect(result).toEqual(1); });
// }); });
// });
it(`should click on the search result to access to the ticket Basic Data`, () => { it(`should click on the search result to access to the ticket Basic Data`, () => {
return nightmare return nightmare

View File

@ -45,12 +45,14 @@ VnMySQL.prototype.toColumnValue = function(prop, val) {
if (val == null || !prop || prop.type !== Date) if (val == null || !prop || prop.type !== Date)
return MySQL.prototype.toColumnValue.call(this, prop, val); return MySQL.prototype.toColumnValue.call(this, prop, val);
val = new Date(val);
return val.getFullYear() + '-' + return val.getFullYear() + '-' +
fillZeros(val.getMonth() + 1) + '-' + fillZeros(val.getMonth() + 1) + '-' +
fillZeros(val.getDate()) + ' ' + fillZeros(val.getDate()) + ' ' +
fillZeros(val.getHours()) + ':' + fillZeros(val.getHours()) + ':' +
fillZeros(val.getMinutes()) + ':' + fillZeros(val.getMinutes()) + ':' +
fillZeros(val.getSeconds()); fillZeros(val.getSeconds());
function fillZeros(v) { function fillZeros(v) {
return v < 10 ? '0' + v : v; return v < 10 ? '0' + v : v;
@ -96,7 +98,7 @@ VnMySQL.prototype._makeWhere = function(model, where) {
} }
stmt.merge({ stmt.merge({
sql: branches.join(' ' + key.toUpperCase() + ' '), sql: branches.join(' ' + key.toUpperCase() + ' '),
params: branchParams, params: branchParams
}); });
whereStmts.push(stmt); whereStmts.push(stmt);
continue; continue;
@ -154,15 +156,13 @@ VnMySQL.prototype._makeWhere = function(model, where) {
columnValue = self.toColumnValue(p, expression); columnValue = self.toColumnValue(p, expression);
if (columnValue === null) { if (columnValue === null) {
stmt.merge(columnName + ' IS NULL'); stmt.merge(columnName + ' IS NULL');
} else if (columnValue instanceof ParameterizedSQL) {
stmt.merge(columnName + '=').merge(columnValue);
} else { } else {
if (columnValue instanceof ParameterizedSQL) { stmt.merge({
stmt.merge(columnName + '=').merge(columnValue); sql: columnName + '=?',
} else { params: [columnValue]
stmt.merge({ });
sql: columnName + '=?',
params: [columnValue],
});
}
} }
} }
whereStmts.push(stmt); whereStmts.push(stmt);
@ -175,7 +175,7 @@ VnMySQL.prototype._makeWhere = function(model, where) {
} }
var whereStmt = new ParameterizedSQL({ var whereStmt = new ParameterizedSQL({
sql: sqls.join(' AND '), sql: sqls.join(' AND '),
params: params, params: params
}); });
return whereStmt; return whereStmt;
}; };