Filtro avanzado clientes

This commit is contained in:
Juan Ferrer Toribio 2017-01-13 15:45:14 +01:00
parent f45fb99e66
commit 6f6d3d4623
14 changed files with 146 additions and 82 deletions

View File

@ -1,9 +1,33 @@
require('./style.css');
import template from './app.html';
import {module} from '../../module';
export const NAME = 'vnApp';
export const COMPONENT = {
template: template
template: require('./app.html')
};
module.component(NAME, COMPONENT);
vnAppInterceptor.$inject = ['$q'];
function vnAppInterceptor($q) {
return {
request: function(config) {
return config;
},
requestError: function(rejection) {
return $q.reject(rejection);
},
response: function(response) {
return response;
},
responseError: function(rejection) {
return $q.reject(rejection);
}
};
}
module.factory('vnAppInterceptor', vnAppInterceptor);
interceptorConfig.$inject = ['$httpProvider'];
function interceptorConfig($httpProvider) {
$httpProvider.interceptors.push('vnAppInterceptor');
}
module.config(interceptorConfig);

View File

@ -20,6 +20,15 @@ function controller($element, $scope, $document, $compile, popover) {
var child = $document[0].createElement(this.popover);
$compile(child)($scope);
popover.show($element, child);
// XXX: ¿Existe una forma más adecuada de acceder al controlador de un componente?
var childCtrl = angular.element(child).isolateScope().$ctrl;
childCtrl.onSubmit = () => {
popover.hide();
this.model.params = childCtrl.filter;
this.search();
};
event.preventDefault();
};
}

View File

@ -1,7 +1,7 @@
import {module} from './module';
export const run = function($rootScope) {
run.$inject = ['$rootScope'];
export function run ($rootScope) {
$rootScope.$on('$viewContentLoaded', () => {})
}
run.$inject = ['$rootScope'];
module.run(run);

View File

@ -4,12 +4,12 @@ export const NAME = 'vnFocus';
export function directive() {
return {
restrict: 'A',
link: function(scope, elements, attrs) {
let element = elements[0];
element.focus();
let len = element.value ? element.value.length : 0;
element.setSelectionRange(0, len);
// element.select();
link: function($scope, $element, $attrs) {
var input = $element[0];
input.focus();
var len = input.value ? input.value.length : 0;
input.setSelectionRange(0, len);
// input.select();
}
};
}

View File

@ -46,8 +46,8 @@ function $get($document) {
var style = popover.style;
var spacing = 0;
var margin = 20;
var dblMargin = margin * 2;
var screenMargin = 20;
var dblMargin = screenMargin * 2;
var width = popover.offsetWidth;
var height = popover.offsetHeight;
@ -75,12 +75,13 @@ function $get($document) {
top -= height + parentNode.offsetHeight + spacing * 2;
if(left < 0)
left = margin;
left = screenMargin;
if(top < 0)
top = margin;
top = screenMargin;
style.top = (top) +'px';
style.left = (left) +'px';
style.minWidth = (rect.width) +'px';
}
$document[0].body.appendChild (popover);

View File

@ -1,34 +1,32 @@
<form name="form" ng-submit="form.$valid && addressData.submit()" >
<vn-vertical pad-medium>
<vn-card >
<vn-vertical pad-large>
<vn-title vn-one>Consignatario</vn-title>
<vn-horizontal>
<vn-check vn-one label="Activo" field="addressData.address.enabled" focus></vn-check>
<vn-check vn-one label="Predeterminado" field="addressData.address.default"></vn-check>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Consignatario" field="addressData.address.consignee"></vn-textfield>
<vn-textfield vn-one label="Domicilio" field="addressData.address.street"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Código Postal" field="addressData.address.postcode"></vn-textfield>
<vn-textfield vn-one label="Municipio" field="addressData.address.city"></vn-textfield>
<vn-combo vn-one label="Provincia" field="addressData.address.province">
<option ng-repeat="p in addressData.provinces | orderBy:'name'" value="{{p.id}}">{{p.name}}</ng-repeat>
</vn-combo>
<vn-textfield vn-one label="Teléfono" field="addressData.address.phone"></vn-textfield>
<vn-textfield vn-one label="Móvil" field="addressData.address.mobile"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-combo vn-one label="Agencia" field="addressData.address.agency">
<option ng-repeat="a in addressData.agencies | orderBy:'name'" value="{{a.id}}">{{a.name}}</ng-repeat>
</vn-combo>
</vn-horizontal>
<vn-empty margin-large-top>
<vn-submit label="Guardar" id="save"></vn-submit>
</vn-empty>
</vn-vertical>
</vn-card>
<form name="form" ng-submit="form.$valid && addressData.submit()" pad-medium>
<vn-card>
<vn-vertical pad-large>
<vn-title vn-one>Consignatario</vn-title>
<vn-horizontal>
<vn-check vn-one label="Activo" field="addressData.address.enabled"></vn-check>
<vn-check vn-one label="Predeterminado" field="addressData.address.default"></vn-check>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Consignatario" field="addressData.address.consignee" focus></vn-textfield>
<vn-textfield vn-one label="Domicilio" field="addressData.address.street"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Código Postal" field="addressData.address.postcode"></vn-textfield>
<vn-textfield vn-one label="Municipio" field="addressData.address.city"></vn-textfield>
<vn-combo vn-one label="Provincia" field="addressData.address.province">
<option ng-repeat="p in addressData.provinces | orderBy:'name'" value="{{p.id}}">{{p.name}}</ng-repeat>
</vn-combo>
<vn-textfield vn-one label="Teléfono" field="addressData.address.phone"></vn-textfield>
<vn-textfield vn-one label="Móvil" field="addressData.address.mobile"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-combo vn-one label="Agencia" field="addressData.address.agency">
<option ng-repeat="a in addressData.agencies | orderBy:'name'" value="{{a.id}}">{{a.name}}</ng-repeat>
</vn-combo>
</vn-horizontal>
<vn-horizontal margin-large-top>
<vn-submit label="Guardar" id="save"></vn-submit>
</vn-horizontal>
</vn-vertical>
</vn-card>
</form>

View File

@ -1,9 +1,8 @@
<vn-vertical pad-medium>
<vn-card>
<vn-vertical pad-large>
<vn-card>
<vn-vertical pad-large>
<vn-horizontal>
<vn-title vn-one>Consignatario</vn-title>
<a vn-empty ui-sref="clientCard.addressCreate" style="align-items: right;"><vn-button label="Nuevo"></vn-button></a>
</vn-horizontal>
<vn-horizontal ng-repeat="i in address.addresses" class="pad-medium-top" style="align-items: center;">
<vn-auto style="border-radius: .5em;" class="pad-small border-solid">
@ -18,6 +17,11 @@
</vn-horizontal>
</vn-auto>
</vn-horizontal>
<vn-horizontal margin-large-top>
<vn-one>
<a ui-sref="clientCard.addressCreate"><vn-button label="Nuevo"></vn-button></a>
</vn-one>
</vn-horizontal>
</vn-vertical>
</vn-card>
</vn-vertical>

View File

@ -18,8 +18,8 @@
</vn-combo>
<vn-two></vn-two>
</vn-horizontal>
<vn-horizontal>
<vn-one margin-large-top>
<vn-horizontal margin-large-top>
<vn-one>
<vn-submit label="Guardar" id="save"></vn-submit>
</vn-one>
</vn-horizontal>

View File

@ -1,6 +1,6 @@
<form name="form" ng-submit="form.$valid && fiscal.submit()" pad-medium>
<vn-card class="display-block" margin-small-bottom>
<vn-card margin-small-bottom>
<vn-vertical pad-large>
<vn-title>Datos fiscales y de facturación</vn-title>
<vn-horizontal>
@ -28,7 +28,7 @@
</vn-horizontal>
</vn-vertical>
</vn-card>
<vn-card class="display-block" margin-small-bottom>
<vn-card margin-small-bottom>
<vn-vertical pad-large>
<vn-title>Información de facturación</vn-title>
<vn-horizontal>
@ -46,17 +46,19 @@
</vn-horizontal>
</vn-vertical>
</vn-card>
<vn-card class="display-block">
<vn-card margin-small-bottom>
<vn-vertical pad-large>
<vn-title>Documentación</vn-title>
<vn-horizontal>
<vn-check vn-two label="Recibido core VNH" field="fiscal.client.coreVnh"></vn-check>
<vn-check vn-two label="Recibido core VNL" field="fiscal.client.coreVnl"></vn-check>
<vn-check vn-two label="Recibido B2B VNL" field="fiscal.client.sepaVnl"></vn-check>
<vn-check vn-one label="Recibido core VNH" field="fiscal.client.coreVnh"></vn-check>
<vn-check vn-one label="Recibido core VNL" field="fiscal.client.coreVnl"></vn-check>
<vn-check vn-one label="Recibido B2B VNL" field="fiscal.client.sepaVnl"></vn-check>
</vn-horizontal>
</vn-vertical>
</vn-card>
<vn-empty margin-large-top>
<vn-submit label="Guardar"></vn-submit>
</vn-empty>
<vn-card margin-small-bottom>
<vn-vertical pad-large>
<vn-submit label="Guardar"></vn-submit>
</vn-vertical>
<vn-card>
</form>

View File

@ -1,5 +1,5 @@
<div>
<div style="max-width: 39em; margin: 0 auto;">
<div style="max-width: 40em; margin: 0 auto;">
<vn-card margin-medium>
<vn-horizontal pad-medium>
<vn-searchbar
@ -7,9 +7,7 @@
model="search.filter"
search="search.find()"
advanced="true"
popover="vn-client-search-panel"
params="search.filter"
return="search.find()">
popover="vn-client-search-panel">
</vn-searchbar>
</vn-horizontal>
</vn-card>

View File

@ -9,12 +9,39 @@ export const COMPONENT = {
controller: function($http) {
this.clients = [];
this.find = function() {
var where = null;
var filter = this.filter;
var queryStr = '/client/api/Clients';
var search = this.filter.search;
if(search) {
let json = JSON.stringify({where: {name: {ilike: search}}});
var queryStr = `${queryStr}?filter=${json}`;
var search = filter.search;
if(search)
where = {name: {ilike: search}};
var params = filter.params;
if(params) {
where = {};
let partials = {
alias: true,
name: true,
socialName: true,
city: true,
email: true
}
for(let param in params)
if (params[param]) {
if(partials[param])
where[param] = {ilike: params[param]};
else
where[param] = params[param];
}
filter.params = undefined;
}
if(where) {
let json = JSON.stringify({where: where});
queryStr = `${queryStr}?filter=${json}`;
}
$http.get(queryStr).then(
json => this.clients = json.data,
json => console.error(json.data.error.message)

View File

@ -1,25 +1,25 @@
<div pad-large style="min-width: 30em;">
<form name="form" ng-submit="form.$valid && search.submit()">
<form name="form" ng-submit="form.$valid && $ctrl.onSubmit()">
<vn-horizontal>
<vn-textfield vn-one label="Id Cliente" field="search.model.id"></vn-textfield>
<vn-textfield vn-one label="NIF/CIF" field="search.model.fi"></vn-textfield>
<vn-textfield vn-one label="Id Cliente" model="$ctrl.filter.id"></vn-textfield>
<vn-textfield vn-one label="NIF/CIF" model="$ctrl.filter.fi"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Alias" field="search.model.alias"></vn-textfield>
<vn-textfield vn-one label="Nombre" model="$ctrl.filter.name"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Razon Social" field="search.model.name"></vn-textfield>
<vn-textfield vn-one label="Razon Social" model="$ctrl.filter.socialName"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Población" field="search.model.city"></vn-textfield>
<vn-textfield vn-one label="Código Postal" field="search.model.postcode"></vn-textfield>
<vn-textfield vn-one label="Población" model="$ctrl.filter.city"></vn-textfield>
<vn-textfield vn-one label="Código Postal" model="$ctrl.filter.postcode"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Email" field="search.model.email"></vn-textfield>
<vn-textfield vn-one label="Teléfono" field="search.model.phone"></vn-textfield>
<vn-textfield vn-one label="Email" model="$ctrl.filter.email"></vn-textfield>
<vn-textfield vn-one label="Teléfono" model="$ctrl.filter.phone"></vn-textfield>
</vn-horizontal>
<vn-horizontal margin-large-top>
<vn-button label="Search"></vn-button>
<vn-submit label="Search"></vn-submit>
</vn-horizontal>
</form>
</div>

View File

@ -1,9 +1,10 @@
import template from './search-panel.html';
import {module} from '../../module';
export const NAME = 'vnClientSearchPanel';
export const COMPONENT = {
controllerAs: 'search',
template: template
template: require('./search-panel.html'),
controller: function($scope) {
this.onSubmit = function() {}
}
};
module.component(NAME, COMPONENT);

View File

@ -18,7 +18,7 @@
"NUf7o684TmteojFX9KmPOpaDLthjP5Def4wuy83Yjv31i43HHiWgV3FyBp6pX8Ue": "{\"id\":\"NUf7o684TmteojFX9KmPOpaDLthjP5Def4wuy83Yjv31i43HHiWgV3FyBp6pX8Ue\",\"ttl\":1209600,\"created\":\"2016-11-21T11:06:11.113Z\",\"userId\":1}"
},
"Client": {
"12": "{\"name\":\"Verdnatura\",\"id\":12,\"fi\":\"B97367486\",\"salesPerson\":\"2\",\"telefono\":\"963242100\",\"socialName\":\"Verdnatura Levante SL\",\"active\":true,\"user\":\"verdnatura\",\"fax\":\"963242100\",\"phone\":\"96324210\",\"email\":\"informatica@verdnatura.es\",\"surcharge\":true,\"cyc\":2345,\"credit\":1000,\"iban\":\"2352345234523452345\",\"street\":\"Avenida Espioca, 100\",\"city\":\"Silla\",\"postcode\":\"46680\",\"mobile\":\"654654654\",\"dueDay\":4,\"gestdoc\":23452343,\"province\":1,\"country\":\"1\"}",
"12": "{\"name\":\"Verdnatura\",\"id\":12,\"fi\":\"B97367486\",\"salesPerson\":\"2\",\"telefono\":\"963242100\",\"socialName\":\"Verdnatura Levante SL\",\"active\":true,\"user\":\"verdnatura\",\"fax\":\"963242100\",\"phone\":\"963242100\",\"email\":\"informatica@verdnatura.es\",\"surcharge\":true,\"cyc\":2345,\"credit\":1000,\"iban\":\"2352345234523452345\",\"street\":\"Avenida Espioca, 100\",\"city\":\"Silla\",\"postcode\":\"46013\",\"mobile\":\"654654654\",\"dueDay\":4,\"gestdoc\":23452343,\"province\":1,\"country\":\"1\",\"modify\":\"BasicData\"}",
"14": "{\"name\":\"Cliente 1\",\"id\":14,\"street\":\"Aaaaaaaaaa\",\"fi\":\"1234567890A\",\"socialName\":\"Cliente 1\",\"fax\":\"963242100\",\"dischargeDate\":\"01/01/2017\",\"telefono\":\"963242100\",\"salesPerson\":\"2\",\"email\":\"informatica@verdnatura.es\",\"city\":\"asdf\",\"postcode\":\"asdf\",\"phone\":\"asdf\",\"mobile\":\"asdf\",\"credit\":2345,\"cyc\":123,\"iban\":\"asdf\",\"dueDay\":345,\"gestdoc\":2435,\"surcharge\":true}"
},
"PaymentMethod": {