ticket.index advanced search mostrar dias en el futuro
This commit is contained in:
Carlos Jimenez Ruiz 2019-04-03 15:16:32 +02:00
parent a23c636c16
commit 971a2ab891
11 changed files with 118 additions and 63 deletions

View File

@ -0,0 +1,5 @@
DROP TABLE IF EXISTS `vn`.`ticketConfig`;
CREATE TABLE `vn`.`ticketConfig` (`id` INT NOT NULL AUTO_INCREMENT, `scopeDays` TINYINT(3) NULL, PRIMARY KEY (`id`));
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('TicketConfig', '*', 'READ', 'ALLOW', 'ROLE', 'employee');

View File

@ -6,6 +6,10 @@ ALTER TABLE `vn2008`.`Consignatarios` AUTO_INCREMENT = 1;
INSERT INTO `util`.`config` ( `dbVersion`, `hasTriggersDisabled`, `environment`)
VALUES ('1.0.0', '0', 'development');
INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
VALUES
('1', '6');
INSERT INTO `account`.`mailConfig` (`id`, `domain`)
VALUES
('1', 'verdnatura.es');
@ -1318,3 +1322,4 @@ INSERT INTO `postgresql`.`calendar_employee` (`business_id`, `calendar_state_id`
(107, 2, DATE_ADD(CURDATE(), INTERVAL -10 DAY)),
(107, 1, DATE_ADD(CURDATE(), INTERVAL -12 DAY)),
(107, 2, DATE_ADD(CURDATE(), INTERVAL -20 DAY));

View File

@ -38,7 +38,7 @@ export default class Controller extends Component {
set filter(value) {
this._filter = value;
this.$state.go('.', {q: JSON.stringify(value)});
this.$state.go('.', {q: JSON.stringify(value)}, {location: 'replace'});
}
get filter() {

View File

@ -35,13 +35,13 @@ describe('Component vnSearchbar', () => {
});
describe('filter() setter', () => {
it(`should call $state.go()`, () => {
it(`should call $state.go() to replace the current state location instead of creating a new one`, () => {
controller._filter = {};
spyOn(controller.$state, 'go');
controller.filter = {expected: 'filter'};
expect(controller._filter).toEqual(controller.filter);
expect(controller.$state.go).toHaveBeenCalledWith('.', Object({q: '{"expected":"filter"}'}));
expect(controller.$state.go).toHaveBeenCalledWith('.', Object({q: '{"expected":"filter"}'}), Object({location: 'replace'}));
});
});

View File

@ -64,5 +64,8 @@
},
"TicketWeekly": {
"dataSource": "vn"
},
"TicketConfig": {
"dataSource": "vn"
}
}

View File

@ -8,9 +8,9 @@
},
"properties": {
"id": {
"id": true,
"type": "Number",
"description": "Identifier"
"id": true,
"type": "Number",
"description": "Identifier"
},
"concept": {
"type": "String"

View File

@ -0,0 +1,19 @@
{
"name": "TicketConfig",
"base": "VnModel",
"options": {
"mysql": {
"table": "ticketConfig"
}
},
"properties": {
"id": {
"id": true,
"type": "Number",
"description": "Identifier"
},
"scopeDays": {
"type": "Number"
}
}
}

View File

@ -11,6 +11,7 @@
<vn-card pad-medium-h>
<vn-horizontal>
<vn-searchbar
vn-id="ticketSearchbar"
style="width: 100%"
panel="vn-ticket-search-panel"
on-search="$ctrl.onSearch($params)"

View File

@ -2,8 +2,9 @@ import ngModule from '../module';
import './style.scss';
export default class Controller {
constructor($scope, $state, $stateParams, $translate) {
constructor($scope, $state, $stateParams, $translate, $http) {
this.$ = $scope;
this.$http = $http;
this.$translate = $translate;
this.$stateParams = $stateParams;
this.$state = $state;
@ -14,30 +15,46 @@ export default class Controller {
}, name: 'Turns', always: true},
];
if (!$stateParams.q) {
let today = new Date();
today.setHours(0, 0, 0, 0);
let tomorrow = new Date(today);
tomorrow.setHours(23, 59, 59, 999);
let sixDays = new Date(today);
sixDays.setDate(today.getDate() + 6);
sixDays.setHours(23, 59, 59, 999);
this.filter = Object.assign({}, {myTeam: true, from: today, to: sixDays});
}
if (!$stateParams.q)
this.getScopeDays();
}
$postLink() {
if (this.filter && this.filter != {})
this.onSearch(this.filter);
getScopeDays() {
this.$http.get(`/api/TicketConfigs/findOne`).then(res => {
if (res.data) {
this.filter = {
scopeDays: res.data.scopeDays
};
}
});
}
buildFilterDates() {
let today = new Date();
this.today = today.setHours(0, 0, 0, 0);
let buildDate = new Date(today);
buildDate.setDate(today.getDate() + this.scopeDays);
buildDate.setHours(23, 59, 59, 999);
this.daysOnward = buildDate;
}
defaultFilter() {
this.buildFilterDates();
this.$scope.ticketSearchbar.filter = Object.assign({}, {mine: true, from: this.today, to: this.daysOnward});
}
onSearch(params) {
if (params)
if (params) {
if (params.scopeDays) {
this.scopeDays = params.scopeDays;
this.buildFilterDates();
params = Object.assign(params, {from: this.today, to: this.daysOnward});
}
this.$.model.applyFilter(null, params);
else
} else
this.$.model.clear();
}
@ -111,7 +128,7 @@ export default class Controller {
}
}
Controller.$inject = ['$scope', '$state', '$stateParams', '$translate'];
Controller.$inject = ['$scope', '$state', '$stateParams', '$translate', '$http'];
ngModule.component('vnTicketIndex', {
template: require('./index.html'),

View File

@ -11,31 +11,19 @@
<vn-horizontal>
<vn-textfield
vn-one
label="Nickname"
model="filter.nickname">
label="Client id"
model="filter.clientFk">
</vn-textfield>
<vn-textfield
vn-one
label="Ticket id"
model="filter.id">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Client id"
model="filter.clientFk">
label="Order id"
model="filter.orderFk">
</vn-textfield>
<vn-autocomplete
vn-one
field="filter.salesPersonFk"
url="/client/api/Clients/activeWorkersWithRole"
search-function="{firstName: $search}"
value-field="id"
where="{role: 'employee'}"
label="Sales person">
<tpl-item>{{firstName}} {{name}}</tpl-item>
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-date-picker
@ -48,6 +36,36 @@
label="To"
model="filter.to">
</vn-date-picker>
<vn-input-number
vn-one
min="0"
step="1"
label="Days onward"
model="filter.scopeDays"
display-controls="true">
</vn-input-number>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Nickname"
model="filter.nickname">
</vn-textfield>
<vn-autocomplete
vn-one
field="filter.salesPersonFk"
url="/client/api/Clients/activeWorkersWithRole"
search-function="{firstName: $search}"
value-field="id"
where="{role: 'employee'}"
label="Sales person">
<tpl-item>{{firstName}} {{name}}</tpl-item>
</vn-autocomplete>
<vn-textfield
vn-one
label="Invoice"
model="filter.refFk">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
@ -56,14 +74,6 @@
field="filter.agencyModeFk"
url="/api/AgencyModes/isActive">
</vn-autocomplete>
<vn-autocomplete
vn-one
label="Warehouse"
field="filter.warehouseFk"
url="/api/Warehouses">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete
vn-one
label="State"
@ -79,18 +89,6 @@
url="/api/AlertLevels">
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Order id"
model="filter.orderFk">
</vn-textfield>
<vn-textfield
vn-one
label="Invoice"
model="filter.refFk">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-check
vn-one
@ -98,6 +96,12 @@
field="filter.myTeam"
triple-state="true">
</vn-check>
<vn-autocomplete
vn-one
label="Warehouse"
field="filter.warehouseFk"
url="/api/Warehouses">
</vn-autocomplete>
<vn-autocomplete
vn-one
label="Province"

View File

@ -9,4 +9,5 @@ Sales person: Comercial
Province: Provincia
My team: Mi equipo
Order id: Id pedido
Grouped States: Estado agrupado
Grouped States: Estado agrupado
Days onward: Días adelante