Localizador: restablecer filtros, datePicker con formato 'es'

This commit is contained in:
Dani Herrero 2017-07-03 14:50:48 +02:00
parent 06537bcf8d
commit f670c0f4fd
6 changed files with 30 additions and 11 deletions

View File

@ -402,6 +402,9 @@ export default class Autocomplete extends Component {
if (!this.locked)
this.value = value;
if (this.onChange)
this.onChange({item: this.value});
}
showItem(item) {
this.input.value = item ? item[this.showField] : '';
@ -422,6 +425,7 @@ module.component('vnAutocomplete', {
valueField: '@?',
selectFields: '@?',
initialData: '<?',
onChange: '&?',
data: '<?',
itemAs: '@?',
field: '=',

View File

@ -7,8 +7,8 @@ import Flatpickr from 'vendor/src/flatpickr';
const _NAME = 'datePicker';
export const NAME = util.getName(_NAME);
directive.$inject = [resolveFactory.NAME, normalizerFactory.NAME, '$translate', '$document', '$transitions'];
export function directive(resolve, normalizer, $translate, $document, $transitions) {
directive.$inject = [resolveFactory.NAME, normalizerFactory.NAME, '$translate'];
export function directive(resolve, normalizer, $translate) {
return {
restrict: 'E',
template: function(_, attrs) {
@ -26,6 +26,9 @@ export function directive(resolve, normalizer, $translate, $document, $transitio
if (!initOptions.locale)
initOptions.locale = $translate.use();
if (!initOptions.dateFormat && initOptions.locale === 'es')
initOptions.dateFormat = 'd-m-Y';
if (!input.matches('input'))
input = input.querySelector('input');

View File

@ -23,9 +23,10 @@
value-field="id"
field="$ctrl.filter.warehouseFk"
url="/production/api/Warehouses/production"
on-change = "$ctrl.onChangeWareHouse(item)"
label="Store">
</vn-autocomplete>
<vn-icon-button vn-none pad-ten-top icon="refresh" ng-click="$ctrl.searchTickets()"></vn-icon-button>
<vn-icon-button vn-none pad-ten-top icon="refresh" ng-click="$ctrl.refreshTickets()"></vn-icon-button>
</vn-one>
</vn-horizontal>
<vn-horizontal vn-one margin-large-bottom>

View File

@ -72,8 +72,10 @@ export default class ProductionIndex {
delete this.child;
}
searchTickets(filter) {
this.filter = Object.assign({}, filter || {}, this.filter);
let filters = Object.assign({}, {
where: Object.assign({}, filter, this.filter)
where: this.filter
}, {
page: 1,
limit: 700
@ -87,6 +89,17 @@ export default class ProductionIndex {
}
);
}
refreshTickets() {
this.filter = {};
this.filter.warehouseFk = this.userProfile.warehouseId;
this.searchTickets();
}
onChangeWareHouse(item) {
if (item && item != this.filter.warehouseFk) {
this.filter.warehouseFk = item;
this.searchTickets();
}
}
$onInit() {
for (let i = 1; i <= 24; i++) {
let hour = [i].join('');

View File

@ -40,10 +40,10 @@ function config($stateProvider, $urlRouterProvider, aclServiceProvider) {
for (let file in routes) {
let fileRoutes = routes[file].routes;
let moduleName = routes[file].module;
let validations = routes[file].validations;
let validations = routes[file].validations || false;
fileRoutes.forEach(function(route) {
if (aclService.routeHasPermission(route)) {
let routeOptions = {
$stateProvider.state(route.state, {
url: route.url,
abstract: route.abstract || false,
template: `<${route.component} ${getParams(route)}></${route.component}>`,
@ -53,9 +53,7 @@ function config($stateProvider, $urlRouterProvider, aclServiceProvider) {
data: {
routes: fileRoutes
}
};
$stateProvider.state(route.state, routeOptions);
});
}
});
}