Merge branch 'master' of ssh://git.verdnatura.es:/var/lib/git/salix

This commit is contained in:
Javi Gallego 2017-01-23 15:20:08 +01:00
commit b4cf63b8fb
15 changed files with 107 additions and 67 deletions

View File

@ -1,7 +1,16 @@
import {module} from './module';
run.$inject = ['$rootScope'];
export function run ($rootScope) {
$rootScope.$on('$viewContentLoaded', () => {})
const HOOK_ABORTED_TRANSITION = 3;
run.$inject = ['$rootScope', '$state'];
export function run ($rootScope, $state) {
$rootScope.$on('$viewContentLoaded', () => {});
window.myAppErrorLog = [];
$state.defaultErrorHandler(function(error) {
if (error.type === HOOK_ABORTED_TRANSITION)
window.myAppErrorLog.push(error);
});
}
module.run(run);

View File

@ -44,7 +44,7 @@ function controller($http, $element, $attrs, $scope, $parse, $document, popoverP
Object.assign(this, {
init: function() {
this.input = $element.find('input')[0];
this.input = $element[0].querySelector('input');
this.item = null;
this.data = null;
this.popover = null;

View File

@ -9,6 +9,7 @@ export {NAME as INTERPOLATE, Interpolate} from './interpolate';
export {NAME as ROUTES_LOADER, RoutesLoader} from './routesLoader';
export {NAME as COPY_OBJECT} from './copy';
export {NAME as EQUALS_OBJECT} from './equals';
export {NAME as GET_DATA_MODIFIED, factory as Modified} from './modified';
export {NAME as FOCUS, directive as Focus} from './focus';
export {NAME as RULE, directive as Rule} from './rule';

View File

@ -0,0 +1,27 @@
import {module} from './module';
import * as equals from './equals';
export const NAME = 'getDataModified';
export function factory(equalsObject) {
return function getData(object, objectOld) {
var newObject = {};
for (var k in object) {
var val = object[k];
var valOld = objectOld[k];
if (val instanceof Object && !equalsObject(val, valOld)) {
newObject[k] = getData(val, valOld);
}
else if (val instanceof Array && val.length !== valOld.length) {
newObject[k] = val;
}
else if (val !== valOld) {
newObject[k] = val;
}
}
return newObject;
}
}
factory.$inject = ['equalsObject'];
module.factory(NAME, factory);

View File

@ -12,16 +12,24 @@
<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-autocomplete vn-one
field="addressData.address.province"
url="/client/api/Provinces"
show-field="name"
value-field="id"
label="Provincia">
</vn-autocomplete>
</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-autocomplete vn-one
field="addressData.address.agency"
url="/client/api/Agencies"
show-field="name"
value-field="id"
label="Agencia">
</vn-autocomplete>
<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-vertical>
</vn-card>

View File

@ -10,13 +10,6 @@ export const COMPONENT = {
var self = this;
this.clientId = $state.params.id;
this.address = {};
$http.get('/client/api/Agencies').then(
json => this.agencies = json.data
);
$http.get('/client/api/Provinces').then(
json => this.provinces = json.data
);
this.submit = function(){
this.address.client = self.clientId;

View File

@ -13,16 +13,24 @@
<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-autocomplete vn-one
field="addressData.address.province"
url="/client/api/Provinces"
show-field="name"
value-field="id"
label="Provincia">
</vn-autocomplete>
</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-autocomplete vn-one
field="addressData.address.agency"
url="/client/api/Agencies"
show-field="name"
value-field="id"
label="Agencia">
</vn-autocomplete>
<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-vertical>
</vn-card>

View File

@ -14,17 +14,6 @@ export const COMPONENT = {
}
);
$http.get('/client/api/Agencies').then(
json => {
this.agencies = json.data;
}
);
$http.get('/client/api/Provinces').then(
json => {
this.provinces = json.data;
}
);
this.submit = function() {
if (!equalsObject(this.address, this.addressOld)) {
$http.put('/client/api/Addresses', this.address).then(

View File

@ -29,11 +29,6 @@ export const COMPONENT = {
}
);
};
$http.get('/client/api/Addresses').then(
json => {
this.addresses = json.data;
}
);
this.getNumPages = () => {
var nPages = numRecords / numPerPage;

View File

@ -8,7 +8,7 @@ export const COMPONENT = {
bindings: {
client: '<'
},
controller: function($http, copyObject, equalsObject, $transitions, $element) {
controller: function($http, copyObject, equalsObject, $transitions, $element, modified) {
var self = this;
var deregister = $transitions.onStart({ }, callback);
@ -33,8 +33,10 @@ export const COMPONENT = {
this.submit = function() {
if (!equalsObject(this.client, this.clientOld)) {
this.client.modify = "BasicData";
$http.put('/client/api/Clients', this.client).then(
var newClient = modified(this.client, this.clientOld);
newClient.modify = "BasicData";
newClient.id = this.clientOld.id;
$http.put('/client/api/Clients', newClient).then(
json => {
copyObject(json.data, this.client);
this.copyClient();
@ -50,5 +52,5 @@ export const COMPONENT = {
}
};
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element'];
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element', 'getDataModified'];
module.component(NAME, COMPONENT);

View File

@ -1,9 +1,9 @@
<vn-horizontal>
<vn-empty style="min-width: 18em;">
<vn-empty style="min-width: 18em; padding-left: 1em; padding-bottom: 1em;">
<vn-descriptor client="card.client" class="display-block" ></vn-descriptor>
<vn-left-menu items="card.items"></vn-left-menu>
</vn-empty>
<vn-auto>
<vn-vertical style="max-width: 70em;" ui-view></vn-vertical>
<vn-vertical style="max-width: 70em; margin: 0 auto;" ui-view></vn-vertical>
</vn-auto>
</vn-horizontal>

View File

@ -8,13 +8,15 @@ export const COMPONENT = {
bindings: {
client: '<'
},
controller: function($http, copyObject, equalsObject, $transitions, $element) {
controller: function($http, copyObject, equalsObject, $transitions, $element, modified) {
var self = this;
var deregister = $transitions.onStart({ }, callback);
this.submit = function() {
if (!equalsObject(this.client, this.clientOld)) {
this.client.modify = "FiscalData";
var newClient = modified(this.client, this.clientOld);
newClient.modify = "FiscalData";
newClient.id = this.clientOld.id;
$http.put('/client/api/Clients', this.client).then(
json => {
this.client = json.data;
@ -49,6 +51,6 @@ export const COMPONENT = {
};
}
};
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element'];
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element', 'getDataModified'];
module.component(NAME, COMPONENT);

View File

@ -8,15 +8,16 @@ export const COMPONENT = {
bindings: {
client: '<'
},
controller: function($http, copyObject, equalsObject, $transitions, $element) {
controller: function($http, copyObject, equalsObject, $transitions, $element, modified) {
var self = this;
var deregister = $transitions.onStart({ }, callback);
this.submit = function() {
if (!equalsObject(this.account, this.accountOld)) {
this.client.modify = "WebAccess";
this.account.id = this.client.id;
$http.put('/client/api/Accounts', this.account).then(
var newAccount = modified(this.account, this.accountOld);
newAccount.modify = "WebAccess";
newAccount.id = this.client.id;
$http.put('/client/api/Accounts', newAccount).then(
json => {
this.account = json.data;
self.copyAccount();
@ -59,5 +60,5 @@ export const COMPONENT = {
};
}
};
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element'];
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element', 'getDataModified'];
module.component(NAME, COMPONENT);

23
db.json
View File

@ -2,15 +2,15 @@
"ids": {
"User": 2,
"AccessToken": 2,
"Client": 17,
"Client": 18,
"PaymentMethod": 4,
"SalesPerson": 11,
"Address": 61,
"Address": 63,
"Country": 10,
"Province": 44,
"Agency": 4,
"Account": 21,
"ClientObservation": 1268
"Account": 23,
"ClientObservation": 1269
},
"models": {
"User": {
@ -23,7 +23,8 @@
"12": "{\"name\":\"Verdnatura\",\"id\":12,\"fi\":\"B97367486\",\"salesPerson\":\"1\",\"telefono\":\"963242100\",\"socialName\":\"Verdnatura Levante SL\",\"active\":true,\"user\":\"verdnatura\",\"fax\":\"963242100\",\"phone\":\"963242101d\",\"email\":\"informatica@verdnatura.es\",\"surcharge\":true,\"cyc\":2345,\"credit\":1000,\"iban\":\"456\",\"street\":\"Avenida Espioca, 100\",\"city\":\"Silla\",\"postcode\":\"46013\",\"mobile\":\"654654654\",\"dueDay\":10,\"gestdoc\":23452343,\"province\":\"2\",\"country\":\"1\",\"modify\":\"BasicData\",\"navigate\":true,\"payMethod\":\"1\"}",
"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,\"navigate\":true}",
"15": "{\"name\":\"afsdf\",\"fi\":\"12341234rasf\",\"socialName\":\"asdfasd\",\"dueDay\":5,\"id\":15,\"payMethod\":\"2\",\"salesPerson\":\"1\",\"modify\":\"BasicData\",\"iban\":\"sdfgsdfgsdfg\"}",
"16": "{\"name\":\"floristeria laasdfas\",\"fi\":\"2345234523d\",\"socialName\":\"23452345assdfgsdfgt\",\"active\":true,\"dueDay\":5,\"id\":16,\"modify\":\"FiscalData\",\"email\":\"asdfopi jso@aosijf.com\",\"phone\":\"654654654\",\"mobile\":\"654456456\",\"fax\":\"456456456\",\"street\":\"asdfasdf\"}"
"16": "{\"name\":\"floristeria laasdfas\",\"fi\":\"2345234523d\",\"socialName\":\"23452345assdfgsdfgt\",\"active\":true,\"dueDay\":5,\"id\":16,\"modify\":\"FiscalData\",\"email\":\"asdfopi jso@aosijf.com\",\"phone\":\"654654654\",\"mobile\":\"654456456\",\"fax\":\"456456456\",\"street\":\"asdfasdf\"}",
"17": "{\"name\":\"ccccdddddd\",\"fi\":\"asasdadsa\",\"socialName\":\"asdadasda\",\"active\":false,\"dueDay\":5,\"id\":17,\"modify\":\"BasicData\"}"
},
"PaymentMethod": {
"1": "{\"name\":\"Tarjeta\",\"id\":1}",
@ -47,6 +48,8 @@
"58": "{\"street\":\"asdfasdfsdf\",\"consignee\":\"oiaspjdfopasidjfopsj\",\"city\":\"asdfasd\",\"postcode\":\"46460\",\"enabled\":true,\"phone\":\"23423342\",\"mobile\":\"234423\",\"default\":false,\"province\":\"19\",\"agency\":\"1\",\"client\":\"16\",\"id\":58}",
"59": "{\"street\":\"asdfasdf\",\"consignee\":\"asdfasdfasdf\",\"city\":\"sdfasdf\",\"postcode\":\"asdfa\",\"enabled\":true,\"phone\":\"a\",\"province\":\"14\",\"agency\":\"3\",\"client\":\"16\",\"id\":59,\"default\":false}",
"60": "{\"street\":\"asdfasdf\",\"consignee\":\"aasdfasdf\",\"city\":\"asdf\",\"postcode\":\"asdf\",\"enabled\":false,\"default\":false,\"province\":\"3\",\"client\":\"16\",\"id\":60}",
"61": "{\"street\":\"Avenida Espioca, 100\",\"consignee\":\"Verdnatura\",\"city\":\"Silla\",\"postcode\":\"46013\",\"enabled\":true,\"province\":\"6\",\"agency\":\"2\",\"client\":\"12\",\"id\":61}",
"62": "{\"street\":\"afsdf\",\"consignee\":\"fdsfdf\",\"city\":\"ddasf\",\"postcode\":\"dsfasd\",\"enabled\":true,\"client\":\"17\",\"id\":62}",
"63": "{\"street\":\"Avd. Espioca nº 100\",\"consignee\":\"Verndatura Silla\",\"city\":\"Silla\",\"postcode\":\"46460\",\"phone\":\"66666666\",\"mobile\":\"989898888\",\"id\":63,\"province\":\"2\",\"agency\":\"3\",\"default\":false,\"enabled\":false}",
"64": "{\"street\":\"Aaa\",\"consignee\":\"aaa\",\"city\":\"121212\",\"postcode\":\"11111\",\"phone\":\"963242100\",\"mobile\":\"11231241423\",\"id\":64,\"default\":false,\"province\":\"1\",\"agency\":\"2\",\"enabled\":false}"
},
@ -77,12 +80,11 @@
"13": "{\"id\":13,\"name\":\"Asturias\"}",
"14": "{\"id\":14,\"name\":\"Almería\"}",
"15": "{\"id\":15,\"name\":\"Ávila\"}",
"16": "{\"id\":16,\"name\":\"Vadajoz\"}",
"16": "{\"id\":16,\"name\":\"Badajoz\"}",
"17": "{\"id\":17,\"name\":\"Burgos\"}",
"18": "{\"id\":18,\"name\":\"Málaga\"}",
"19": "{\"id\":19,\"name\":\"Navarra\"}",
"20": "{\"id\":20,\"name\":\"Ceuta\"}",
"21": "{\"id\":21,\"name\":\"Melilla\"}",
"22": "{\"id\":22,\"name\":\"Melilla\"}",
"23": "{\"id\":23,\"name\":\"Zaragoza\"}",
"24": "{\"id\":24,\"name\":\"Zamora\"}",
@ -113,9 +115,11 @@
},
"Account": {
"1": "{\"id\":1,\"password\":\"joselito\",\"name\":\"asdf\"}",
"12": "{\"id\":12,\"name\":\"javierete\"}",
"14": "{\"id\":14,\"active\":true,\"name\":\"f\"}",
"15": "{\"id\":15,\"name\":\"asdf\"}",
"16": "{\"id\":16,\"name\":\"joselito\",\"active\":true}"
"16": "{\"id\":16,\"name\":\"joselito\",\"active\":true}",
"17": "{\"id\":17,\"name\":\"pepe\",\"active\":true}"
},
"ClientObservation": {
"1258": "{\"text\":\"Nota de prueba 1\",\"creationDate\":\"2017-01-17T15:24:23.320Z\",\"client\":12,\"salesPerson\":\"user\",\"id\":1258}",
@ -127,7 +131,8 @@
"1264": "{\"text\":\"Nota 5\",\"creationDate\":\"2017-01-17T15:35:50.064Z\",\"client\":14,\"salesPerson\":\"user\",\"id\":1264}",
"1265": "{\"text\":\"primera nota\",\"creationDate\":\"2017-01-20T10:23:28.000Z\",\"client\":\"16\",\"salesPerson\":\"user\",\"modify\":\"ClientObservation\",\"id\":1265}",
"1266": "{\"text\":\"segunda nota\",\"creationDate\":\"2017-01-20T10:23:37.000Z\",\"client\":\"16\",\"salesPerson\":\"user\",\"modify\":\"ClientObservation\",\"id\":1266}",
"1267": "{\"text\":\"tercera nota\",\"creationDate\":\"2017-01-20T10:23:53.000Z\",\"client\":\"16\",\"salesPerson\":\"user\",\"modify\":\"ClientObservation\",\"id\":1267}"
"1267": "{\"text\":\"tercera nota\",\"creationDate\":\"2017-01-20T10:23:53.000Z\",\"client\":\"16\",\"salesPerson\":\"user\",\"modify\":\"ClientObservation\",\"id\":1267}",
"1268": "{\"text\":\"dsfasdf asf asfdasf sda fdsadf adsf sdafh sdalfhsdlafd haslkfhalsfh alskdhf lasdkfh laskf hlaskdhf lkadsh lkasdhfla ksdhf lsdfh askldfh lasf hsald fhasldf hsalkhf lsdh flkshf lskdhf lskdfh lskf hlsfh lasdkhf lskhf laskfh lsaf ksdh flshf lkashf lsakhf laskfh lsakdhf laskdf hlaskdfh laskhfd lasf hlaskfh lasdkhf laskdf hlsad fhskfhaslkdfh askdfh asklf lsakdf\",\"creationDate\":\"2017-01-23T08:14:58.000Z\",\"client\":\"17\",\"salesPerson\":\"user\",\"modify\":\"ClientObservation\",\"id\":1268}"
}
}
}

View File

@ -7,7 +7,7 @@ module.exports = function(Address) {
Address.observe('before save', function (ctx, next) {
var data = getData(ctx);
if (data.isEnabled && data.default) {
if (data.enabled && data.default) {
ctx.Model.update({client: data.client}, {default: false});
}
next();