ticket.index advanced search mostrar dias en el futuro
This commit is contained in:
parent
a23c636c16
commit
971a2ab891
|
@ -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');
|
|
@ -6,6 +6,10 @@ ALTER TABLE `vn2008`.`Consignatarios` AUTO_INCREMENT = 1;
|
||||||
INSERT INTO `util`.`config` ( `dbVersion`, `hasTriggersDisabled`, `environment`)
|
INSERT INTO `util`.`config` ( `dbVersion`, `hasTriggersDisabled`, `environment`)
|
||||||
VALUES ('1.0.0', '0', 'development');
|
VALUES ('1.0.0', '0', 'development');
|
||||||
|
|
||||||
|
INSERT INTO `vn`.`ticketConfig` (`id`, `scopeDays`)
|
||||||
|
VALUES
|
||||||
|
('1', '6');
|
||||||
|
|
||||||
INSERT INTO `account`.`mailConfig` (`id`, `domain`)
|
INSERT INTO `account`.`mailConfig` (`id`, `domain`)
|
||||||
VALUES
|
VALUES
|
||||||
('1', 'verdnatura.es');
|
('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, 2, DATE_ADD(CURDATE(), INTERVAL -10 DAY)),
|
||||||
(107, 1, DATE_ADD(CURDATE(), INTERVAL -12 DAY)),
|
(107, 1, DATE_ADD(CURDATE(), INTERVAL -12 DAY)),
|
||||||
(107, 2, DATE_ADD(CURDATE(), INTERVAL -20 DAY));
|
(107, 2, DATE_ADD(CURDATE(), INTERVAL -20 DAY));
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ export default class Controller extends Component {
|
||||||
|
|
||||||
set filter(value) {
|
set filter(value) {
|
||||||
this._filter = value;
|
this._filter = value;
|
||||||
this.$state.go('.', {q: JSON.stringify(value)});
|
this.$state.go('.', {q: JSON.stringify(value)}, {location: 'replace'});
|
||||||
}
|
}
|
||||||
|
|
||||||
get filter() {
|
get filter() {
|
||||||
|
|
|
@ -35,13 +35,13 @@ describe('Component vnSearchbar', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('filter() setter', () => {
|
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 = {};
|
controller._filter = {};
|
||||||
spyOn(controller.$state, 'go');
|
spyOn(controller.$state, 'go');
|
||||||
controller.filter = {expected: 'filter'};
|
controller.filter = {expected: 'filter'};
|
||||||
|
|
||||||
expect(controller._filter).toEqual(controller.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'}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -64,5 +64,8 @@
|
||||||
},
|
},
|
||||||
"TicketWeekly": {
|
"TicketWeekly": {
|
||||||
"dataSource": "vn"
|
"dataSource": "vn"
|
||||||
|
},
|
||||||
|
"TicketConfig": {
|
||||||
|
"dataSource": "vn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"name": "TicketConfig",
|
||||||
|
"base": "VnModel",
|
||||||
|
"options": {
|
||||||
|
"mysql": {
|
||||||
|
"table": "ticketConfig"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"id": {
|
||||||
|
"id": true,
|
||||||
|
"type": "Number",
|
||||||
|
"description": "Identifier"
|
||||||
|
},
|
||||||
|
"scopeDays": {
|
||||||
|
"type": "Number"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
<vn-card pad-medium-h>
|
<vn-card pad-medium-h>
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-searchbar
|
<vn-searchbar
|
||||||
|
vn-id="ticketSearchbar"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
panel="vn-ticket-search-panel"
|
panel="vn-ticket-search-panel"
|
||||||
on-search="$ctrl.onSearch($params)"
|
on-search="$ctrl.onSearch($params)"
|
||||||
|
|
|
@ -2,8 +2,9 @@ import ngModule from '../module';
|
||||||
import './style.scss';
|
import './style.scss';
|
||||||
|
|
||||||
export default class Controller {
|
export default class Controller {
|
||||||
constructor($scope, $state, $stateParams, $translate) {
|
constructor($scope, $state, $stateParams, $translate, $http) {
|
||||||
this.$ = $scope;
|
this.$ = $scope;
|
||||||
|
this.$http = $http;
|
||||||
this.$translate = $translate;
|
this.$translate = $translate;
|
||||||
this.$stateParams = $stateParams;
|
this.$stateParams = $stateParams;
|
||||||
this.$state = $state;
|
this.$state = $state;
|
||||||
|
@ -14,30 +15,46 @@ export default class Controller {
|
||||||
}, name: 'Turns', always: true},
|
}, name: 'Turns', always: true},
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!$stateParams.q) {
|
if (!$stateParams.q)
|
||||||
|
this.getScopeDays();
|
||||||
|
}
|
||||||
|
|
||||||
|
getScopeDays() {
|
||||||
|
this.$http.get(`/api/TicketConfigs/findOne`).then(res => {
|
||||||
|
if (res.data) {
|
||||||
|
this.filter = {
|
||||||
|
scopeDays: res.data.scopeDays
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
buildFilterDates() {
|
||||||
let today = new Date();
|
let today = new Date();
|
||||||
today.setHours(0, 0, 0, 0);
|
this.today = today.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
let tomorrow = new Date(today);
|
let buildDate = new Date(today);
|
||||||
tomorrow.setHours(23, 59, 59, 999);
|
buildDate.setDate(today.getDate() + this.scopeDays);
|
||||||
|
buildDate.setHours(23, 59, 59, 999);
|
||||||
|
|
||||||
let sixDays = new Date(today);
|
this.daysOnward = buildDate;
|
||||||
sixDays.setDate(today.getDate() + 6);
|
|
||||||
sixDays.setHours(23, 59, 59, 999);
|
|
||||||
|
|
||||||
this.filter = Object.assign({}, {myTeam: true, from: today, to: sixDays});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$postLink() {
|
defaultFilter() {
|
||||||
if (this.filter && this.filter != {})
|
this.buildFilterDates();
|
||||||
this.onSearch(this.filter);
|
this.$scope.ticketSearchbar.filter = Object.assign({}, {mine: true, from: this.today, to: this.daysOnward});
|
||||||
}
|
}
|
||||||
|
|
||||||
onSearch(params) {
|
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);
|
this.$.model.applyFilter(null, params);
|
||||||
else
|
} else
|
||||||
this.$.model.clear();
|
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', {
|
ngModule.component('vnTicketIndex', {
|
||||||
template: require('./index.html'),
|
template: require('./index.html'),
|
||||||
|
|
|
@ -11,31 +11,19 @@
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
vn-one
|
vn-one
|
||||||
label="Nickname"
|
label="Client id"
|
||||||
model="filter.nickname">
|
model="filter.clientFk">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
vn-one
|
vn-one
|
||||||
label="Ticket id"
|
label="Ticket id"
|
||||||
model="filter.id">
|
model="filter.id">
|
||||||
</vn-textfield>
|
</vn-textfield>
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-textfield
|
<vn-textfield
|
||||||
vn-one
|
vn-one
|
||||||
label="Client id"
|
label="Order id"
|
||||||
model="filter.clientFk">
|
model="filter.orderFk">
|
||||||
</vn-textfield>
|
</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-horizontal>
|
<vn-horizontal>
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
|
@ -48,6 +36,36 @@
|
||||||
label="To"
|
label="To"
|
||||||
model="filter.to">
|
model="filter.to">
|
||||||
</vn-date-picker>
|
</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-horizontal>
|
<vn-horizontal>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
|
@ -56,14 +74,6 @@
|
||||||
field="filter.agencyModeFk"
|
field="filter.agencyModeFk"
|
||||||
url="/api/AgencyModes/isActive">
|
url="/api/AgencyModes/isActive">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
|
||||||
vn-one
|
|
||||||
label="Warehouse"
|
|
||||||
field="filter.warehouseFk"
|
|
||||||
url="/api/Warehouses">
|
|
||||||
</vn-autocomplete>
|
|
||||||
</vn-horizontal>
|
|
||||||
<vn-horizontal>
|
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
label="State"
|
label="State"
|
||||||
|
@ -79,18 +89,6 @@
|
||||||
url="/api/AlertLevels">
|
url="/api/AlertLevels">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-horizontal>
|
</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-horizontal>
|
||||||
<vn-check
|
<vn-check
|
||||||
vn-one
|
vn-one
|
||||||
|
@ -98,6 +96,12 @@
|
||||||
field="filter.myTeam"
|
field="filter.myTeam"
|
||||||
triple-state="true">
|
triple-state="true">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
|
<vn-autocomplete
|
||||||
|
vn-one
|
||||||
|
label="Warehouse"
|
||||||
|
field="filter.warehouseFk"
|
||||||
|
url="/api/Warehouses">
|
||||||
|
</vn-autocomplete>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
label="Province"
|
label="Province"
|
||||||
|
|
|
@ -10,3 +10,4 @@ Province: Provincia
|
||||||
My team: Mi equipo
|
My team: Mi equipo
|
||||||
Order id: Id pedido
|
Order id: Id pedido
|
||||||
Grouped States: Estado agrupado
|
Grouped States: Estado agrupado
|
||||||
|
Days onward: Días adelante
|
Loading…
Reference in New Issue