Arreglado problema con las provincias

El objeto cliente se copia hacia abajo
Se ha generado la función copy y la función equals
Añadidos márgenes a los botones de guardar
This commit is contained in:
nelo 2017-01-12 09:52:20 +01:00
parent a52ffbc9a3
commit 69ebeb9d0f
15 changed files with 53 additions and 40 deletions

5
@salix/core/src/copy.js Normal file
View File

@ -0,0 +1,5 @@
import {module} from './module';
export const NAME = 'copyObject';
module.value(NAME, angular.copy);

View File

@ -7,6 +7,8 @@ export {SplitingRegister as splitingRegister} from './splitingregister';
export {NAME as RESOLVEDEFAULTCOMPONENT, ResolveDefaultComponent} from './resolveDefaultComponents';
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 FOCUS, directive as Focus} from './focus';
export {NAME as RULE, directive as Rule} from './rule';
@ -51,4 +53,4 @@ export {directive as Icon} from './icon/icon';
export {factory as IconMdl} from './icon/icon.mdl';
export {NAME as TITLE, COMPONENT as TITLE_COMPONENT} from './title/title';
export {NAME as SUBTITLE, COMPONENT as SUBTITLE_COMPONENT} from './subtitle/subtitle';
export {NAME as SUBTITLE, COMPONENT as SUBTITLE_COMPONENT} from './subtitle/subtitle';

View File

@ -0,0 +1,5 @@
import {module} from './module';
export const NAME = 'equalsObject';
module.value(NAME, angular.equals);

View File

@ -25,7 +25,7 @@
<option ng-repeat="a in addressData.agencies | orderBy:'name'" value="{{a.id}}">{{a.name}}</ng-repeat>
</vn-combo>
</vn-horizontal>
<vn-empty>
<vn-empty margin-large-top>
<vn-submit label="Guardar" id="save"></vn-submit>
</vn-empty>
</vn-vertical>

View File

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

View File

@ -6,20 +6,36 @@ export const COMPONENT = {
template: template,
controllerAs: 'basicData',
bindings: {
client: '='
client: '<'
},
controller: function($http) {
controller: function($http, $rootScope, copyObject, equalsObject) {
this.$onChanges = function (changes) {
if(this.client)
this.clientOld = copyObject(this.client);
}
/*$rootScope.$on("$locationChangeStart", function(event) {
if(!equalsObject(this.client, this.clientOld)){
event.preventDefault();
}
});*/
$http.get('/client/api/SalesPeople').then(
json => this.sales = json.data,
json => console.error(json.data.error.message)
);
this.submit = function() {
$http.put('/client/api/Clients', this.client).then(
json => console.log(json.statusText),
json => console.error(json.data.error.message)
);
if(!equalsObject(this.client, this.clientOld)){
this.client.modify = "BasicData";
$http.put('/client/api/Clients', this.client).then(
json => console.log(json.statusText),
json => console.error(json.data.error.message)
);
}
};
}
};
COMPONENT.controller.$inject = ['$http'];
COMPONENT.controller.$inject = ['$http', '$rootScope', 'copyObject', 'equalsObject'];
module.component(NAME, COMPONENT);

View File

@ -2,7 +2,7 @@
<vn-topbar></vn-topbar>
<vn-horizontal class="full-height">
<vn-empty pad-medium-left >
<vn-descriptor descriptor="card.descriptor" class="display-block" ></vn-descriptor>
<vn-descriptor client="card.client" class="display-block" ></vn-descriptor>
<vn-left-menu items="card.items"></vn-left-menu>
</vn-empty>
<vn-auto >

View File

@ -13,12 +13,6 @@ export const COMPONENT = {
$http.get(`/client/api/Clients/${$stateParams.id}`).then(
json => {
this.client = json.data;
this.descriptor = {
clientId: this.client.id,
name: this.client.name,
phone: this.client.phone,
active: this.client.active
};
},
json => console.error(json.data.error.message)
);

View File

@ -12,7 +12,7 @@
<vn-one></vn-one>
</vn-horizontal>
<vn-horizontal>
<vn-one>
<vn-one margin-large-top>
<vn-submit label="Crear" id="create"></vn-submit>
</vn-one>
</vn-horizontal>

View File

@ -5,11 +5,11 @@
<i class="material-icons descriptor-icon">person</i>
</vn-one>
<vn-vertical vn-two>
<div class="margin-none">{{descriptor.descriptor.clientId}}</div>
<div class="margin-none">{{descriptor.descriptor.name}}</div>
<div class="margin-none">{{descriptor.descriptor.phone}}</div>
<div class="margin-none">{{descriptor.client.clientId}}</div>
<div class="margin-none">{{descriptor.client.name}}</div>
<div class="margin-none">{{descriptor.client.phone}}</div>
</vn-vertical>
</vn-horizontal>
<vn-switch label="Activo" field="descriptor.descriptor.active"></vn-switch>
<vn-switch label="Activo" field="descriptor.client.active"></vn-switch>
</vn-vertical>
</vn-card>

View File

@ -7,7 +7,7 @@ export const COMPONENT = {
template: template,
controllerAs: 'descriptor',
bindings: {
descriptor: '<'
client: '<'
}
};
module.component(NAME, COMPONENT);

View File

@ -15,10 +15,10 @@
<vn-horizontal>
<vn-textfield vn-one label="Código postal" field="fiscal.client.postcode"></vn-textfield>
<vn-combo vn-one label="Provincia" field="fiscal.client.province">
<option ng-repeat="p in fiscal.provinces" value="{{p.id}}">{{p.name}}</option>
<option ng-repeat="p in fiscal.provinces | orderBy:'name'" value="{{p.id}}">{{p.name}}</option>
</vn-combo>
<vn-combo vn-one label="País" field="fiscal.client.country">
<option ng-repeat="c in fiscal.countries" value="{{c.id}}">{{c.name}}</option>
<option ng-repeat="c in fiscal.countries | orderBy:'name'" value="{{c.id}}">{{c.name}}</option>
</vn-combo>
</vn-horizontal>
<vn-horizontal>
@ -54,9 +54,9 @@
<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-horizontal>
<vn-empty class="margin-large-top">
<vn-submit label="Guardar"></vn-submit>
</vn-empty>
</vn-vertical>
</vn-card>
<vn-empty margin-large-top>
<vn-submit label="Guardar"></vn-submit>
</vn-empty>
</form>

View File

@ -3,7 +3,7 @@
<vn-vertical pad-large>
<vn-title>Notas</vn-title>
<vn-textfield label="Notas" class="padd-medium-top" field="note.model.notes"></vn-textfield>
<vn-submit label="Guardar"></vn-submit>
<vn-submit margin-large-top label="Guardar"></vn-submit>
</vn-vertical>
</vn-card>

View File

@ -3,8 +3,8 @@
<vn-vertical pad-large>
<vn-title>Acceso Web</vn-title>
<vn-check label="Acceso web activo" field="web.client.active"></vn-check>
<vn-textfield label="Usuario" class="padd-medium-top margin-medium-top margin-medium-bottom" field="web.client.user" focus></vn-textfield>
<vn-submit label="Guardar"></vn-submit>
<vn-textfield label="Usuario" class="padd-medium-top margin-medium-top" field="web.client.user" focus></vn-textfield>
<vn-submit margin-large-top label="Guardar"></vn-submit>
</vn-vertical>
</vn-card>
</form>

View File

@ -36,12 +36,6 @@
"postcode": {
"type": "string"
},
"province": {
"type": "Number"
},
"country": {
"type": "string"
},
"email": {
"type": "string"
},
@ -63,9 +57,6 @@
"iban": {
"type": "string"
},
"payMethod": {
"type": "string"
},
"dueDay": {
"type": "Number"
},