dialogo al cambiar los datos
al realizar un put, machacamos el objeto con la respuesta
This commit is contained in:
parent
0dcb581c78
commit
dabde7e133
|
@ -8,42 +8,51 @@ export const COMPONENT = {
|
|||
bindings: {
|
||||
client: '<'
|
||||
},
|
||||
controller: function($http, copyObject, equalsObject, $transitions, $state) {
|
||||
controller: function($http, copyObject, equalsObject, $transitions, $element) {
|
||||
|
||||
var self = this;
|
||||
|
||||
var self = this;
|
||||
var deregister = $transitions.onStart({ }, callback);
|
||||
|
||||
this.$onChanges = function (changes) {
|
||||
if(this.client){
|
||||
this.clientOld = copyObject(this.client);
|
||||
this.$onChanges = function(changes) {
|
||||
if (this.client) {
|
||||
this.copyClient();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.$onDestroy = function(){
|
||||
this.$onDestroy = function() {
|
||||
deregister();
|
||||
}
|
||||
};
|
||||
|
||||
$http.get('/client/api/SalesPeople').then(
|
||||
json => this.sales = json.data
|
||||
);
|
||||
|
||||
function callback(transition) {
|
||||
if(!equalsObject(self.client, self.clientOld)){
|
||||
if (!equalsObject(self.client, self.clientOld)) {
|
||||
self.state = transition.to().name;
|
||||
var dialog = document.querySelector('dialog');
|
||||
var dialog = $element[0].querySelector('dialog');
|
||||
dialog.showModal();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.submit = function() {
|
||||
if(!equalsObject(this.client, this.clientOld)){
|
||||
if (!equalsObject(this.client, this.clientOld)) {
|
||||
this.client.modify = "BasicData";
|
||||
$http.put('/client/api/Clients', this.client);
|
||||
$http.put('/client/api/Clients', this.client).then(
|
||||
json => {
|
||||
this.client = json.data;
|
||||
this.copyClient();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
this.copyClient = function() {
|
||||
this.clientOld = {};
|
||||
copyObject(this.client, this.clientOld);
|
||||
};
|
||||
}
|
||||
};
|
||||
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$state'];
|
||||
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element'];
|
||||
module.component(NAME, COMPONENT);
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<dialog class="mdl-dialog">
|
||||
<div class="mdl-dialog__content">
|
||||
<p>
|
||||
Allow this site to collect usage data to improve your experience?
|
||||
¿Desea salir sin guardar?
|
||||
</p>
|
||||
</div>
|
||||
<div class="mdl-dialog__actions mdl-dialog__actions--full-width">
|
||||
<button type="button" class="mdl-button" ng-click="clientConfirm.accept()">Agree</button>
|
||||
<button type="button" class="mdl-button close" ng-click="clientConfirm.cancel()">Disagree</button>
|
||||
<button type="button" class="mdl-button" ng-click="clientConfirm.accept()">Aceptar</button>
|
||||
<button type="button" class="mdl-button close" ng-click="clientConfirm.cancel()">Cancelar</button>
|
||||
</div>
|
||||
</dialog>
|
|
@ -1,20 +1,21 @@
|
|||
<form ng-submit="create.submit()" pad-large style="max-width: 67em; margin: 0 auto;">
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
<vn-title>Crear Cliente</vn-title>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Nombre" field="create.model.name" focus></vn-textfield>
|
||||
<vn-textfield vn-one label="NIF/CIF" field="create.model.fi"></vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Razón social" field="create.model.socialName"></vn-textfield>
|
||||
<vn-one></vn-one>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-one margin-large-top>
|
||||
<vn-submit label="Crear" id="create"></vn-submit>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
</form>
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
<vn-title>Crear Cliente</vn-title>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Nombre" field="create.model.name" focus></vn-textfield>
|
||||
<vn-textfield vn-one label="NIF/CIF" field="create.model.fi"></vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Razón social" field="create.model.socialName"></vn-textfield>
|
||||
<vn-one></vn-one>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-one margin-large-top>
|
||||
<vn-submit label="Crear" id="create"></vn-submit>
|
||||
</vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
</form>
|
||||
<vn-confirm-client client="create.model" client-old="create.model" state="create.state"></vn-confirm-client>
|
||||
|
|
|
@ -5,8 +5,8 @@ export const NAME = "vnClientCreate";
|
|||
export const COMPONENT = {
|
||||
template: template,
|
||||
controllerAs: "create",
|
||||
controller: function($http, $state){
|
||||
this.submit = function(){
|
||||
controller: function($http, $state) {
|
||||
this.submit = function() {
|
||||
$http.post('/client/api/Clients', this.model).then(
|
||||
json => $state.go('clientCard.basicData',{id: json.data.id})
|
||||
);
|
||||
|
|
|
@ -61,4 +61,5 @@
|
|||
<vn-submit label="Guardar"></vn-submit>
|
||||
</vn-vertical>
|
||||
<vn-card>
|
||||
</form>
|
||||
</form>
|
||||
<vn-confirm-client client="fiscal.client" client-old="fiscal.clientOld" state="fiscal.state"></vn-confirm-client>
|
|
@ -8,22 +8,60 @@ export const COMPONENT = {
|
|||
bindings: {
|
||||
client: '<'
|
||||
},
|
||||
controller: function($http) {
|
||||
controller: function($http, copyObject, equalsObject, $transitions, $element) {
|
||||
|
||||
var self = this;
|
||||
var deregister = $transitions.onStart({ }, callback);
|
||||
|
||||
$http.get('/client/api/Countries').then(
|
||||
json => this.countries = json.data
|
||||
);
|
||||
|
||||
$http.get('/client/api/Provinces').then(
|
||||
json => this.provinces = json.data
|
||||
);
|
||||
|
||||
$http.get('/client/api/PaymentMethods').then(
|
||||
json => this.payments = json.data
|
||||
);
|
||||
|
||||
this.submit = function() {
|
||||
$http.put('/client/api/Clients', this.client);
|
||||
if (!equalsObject(this.client, this.clientOld)) {
|
||||
this.client.modify = "FiscalData";
|
||||
$http.put('/client/api/Clients', this.client).then(
|
||||
json => {
|
||||
this.client = json.data;
|
||||
this.copyClient();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
this.$onChanges = function(changes) {
|
||||
if (this.client) {
|
||||
this.copyClient();
|
||||
}
|
||||
};
|
||||
|
||||
this.$onDestroy = function() {
|
||||
deregister();
|
||||
};
|
||||
|
||||
function callback(transition) {
|
||||
if (!equalsObject(self.client, self.clientOld)) {
|
||||
self.state = transition.to().name;
|
||||
var dialog = $element[0].querySelector('dialog');
|
||||
dialog.showModal();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.copyClient = function() {
|
||||
this.clientOld = {};
|
||||
copyObject(this.client, this.clientOld);
|
||||
};
|
||||
}
|
||||
};
|
||||
COMPONENT.controller.$inject = ['$http'];
|
||||
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element'];
|
||||
module.component(NAME, COMPONENT);
|
||||
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
<vn-submit margin-large-top label="Guardar"></vn-submit>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
</form>
|
||||
</form>
|
||||
<vn-confirm-client client="web.client" client-old="web.clientOld" state="web.state"></vn-confirm-client>
|
|
@ -8,11 +8,47 @@ export const COMPONENT = {
|
|||
bindings: {
|
||||
client: '<'
|
||||
},
|
||||
controller: function($http) {
|
||||
controller: function($http, copyObject, equalsObject, $transitions, $element) {
|
||||
|
||||
var self = this;
|
||||
var deregister = $transitions.onStart({ }, callback);
|
||||
|
||||
this.submit = function() {
|
||||
$http.put('/client/api/Clients', this.client);
|
||||
if (!equalsObject(this.client, this.clientOld)) {
|
||||
this.client.modify = "WebAccess";
|
||||
$http.put('/client/api/Clients', this.client).then(
|
||||
json => {
|
||||
this.client = json.data;
|
||||
this.copyClient();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
this.$onChanges = function(changes) {
|
||||
if (this.client) {
|
||||
this.copyClient();
|
||||
}
|
||||
};
|
||||
|
||||
this.$onDestroy = function() {
|
||||
deregister();
|
||||
};
|
||||
|
||||
function callback(transition) {
|
||||
if (!equalsObject(self.client, self.clientOld)) {
|
||||
self.state = transition.to().name;
|
||||
var dialog = $element[0].querySelector('dialog');
|
||||
dialog.showModal();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.copyClient = function() {
|
||||
this.clientOld = {};
|
||||
copyObject(this.client, this.clientOld);
|
||||
};
|
||||
}
|
||||
};
|
||||
COMPONENT.controller.$inject = ['$http'];
|
||||
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element'];
|
||||
module.component(NAME, COMPONENT);
|
||||
|
|
Loading…
Reference in New Issue