dialog confirmar guardar cambio clientes
This commit is contained in:
parent
30e5bd9c0b
commit
93693acd0c
|
@ -5,4 +5,3 @@ export {NAME as LEFT_MENU, COMPONENT as LEFTMENU_COMPONENT} from './components/l
|
||||||
export {NAME as MENU_ITEM, COMPONENT as MENU_ITEM_COMPONENT} from './components/left-menu/menu-item';
|
export {NAME as MENU_ITEM, COMPONENT as MENU_ITEM_COMPONENT} from './components/left-menu/menu-item';
|
||||||
export {NAME as TOPBAR, COMPONENT as TOPBAR_COMPONENT} from './components/topbar/topbar';
|
export {NAME as TOPBAR, COMPONENT as TOPBAR_COMPONENT} from './components/topbar/topbar';
|
||||||
export {NAME as SEARCHBAR, COMPONENT as SEARCHBAR_COMPONENT} from './components/searchbar/searchbar';
|
export {NAME as SEARCHBAR, COMPONENT as SEARCHBAR_COMPONENT} from './components/searchbar/searchbar';
|
||||||
export {NAME as CONFIRM, COMPONENT as CONFIRM_COMPONENT} from './components/confirm/confirm';
|
|
|
@ -1,11 +0,0 @@
|
||||||
<dialog class="mdl-dialog">
|
|
||||||
<div class="mdl-dialog__content">
|
|
||||||
<p>
|
|
||||||
Allow this site to collect usage data to improve your experience?
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="mdl-dialog__actions mdl-dialog__actions--full-width">
|
|
||||||
<button type="button" class="mdl-button" ng-click="dialogController.accept()">Agree</button>
|
|
||||||
<button type="button" class="mdl-button close" ng-click="dialogController.cancel()">Disagree</button>
|
|
||||||
</div>
|
|
||||||
</dialog>
|
|
|
@ -1,18 +0,0 @@
|
||||||
import template from './confirm.html';
|
|
||||||
import {module} from '../../module';
|
|
||||||
|
|
||||||
export const NAME = 'vnConfirm';
|
|
||||||
export const COMPONENT = {
|
|
||||||
template: template,
|
|
||||||
controllerAs: 'dialogController',
|
|
||||||
controller: function(){
|
|
||||||
this.accept = function(){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.cancel = function(){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
module.component(NAME, COMPONENT);
|
|
|
@ -26,3 +26,4 @@
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</form>
|
</form>
|
||||||
|
<vn-confirm-client client="basicData.client" state="basicData.state"></vn-confirm-client>
|
||||||
|
|
|
@ -8,14 +8,17 @@ export const COMPONENT = {
|
||||||
bindings: {
|
bindings: {
|
||||||
client: '<'
|
client: '<'
|
||||||
},
|
},
|
||||||
controller: function($http, copyObject, equalsObject, $transitions) {
|
controller: function($http, copyObject, equalsObject, $transitions, $state) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var deregister = $transitions.onStart({ }, callback);
|
var deregister = $transitions.onStart({ }, callback);
|
||||||
|
|
||||||
this.$onChanges = function (changes) {
|
this.$onChanges = function (changes) {
|
||||||
if(this.client)
|
if(this.client){
|
||||||
this.clientOld = copyObject(this.client);
|
this.clientOld = copyObject(this.client);
|
||||||
|
this.client.navigate = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$onDestroy = function(){
|
this.$onDestroy = function(){
|
||||||
|
@ -28,8 +31,14 @@ export const COMPONENT = {
|
||||||
);
|
);
|
||||||
|
|
||||||
function callback(transition) {
|
function callback(transition) {
|
||||||
if(!equalsObject(self.client, self.clientOld) && !confirm("¿Desea salir sin guardar los cambios?"))
|
if(!equalsObject(self.client, self.clientOld) && !self.client.navigate){
|
||||||
return false;
|
self.state = transition.to().name;
|
||||||
|
var dialog = document.querySelector('dialog');
|
||||||
|
dialog.showModal();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
self.client = copyObject(self.clientOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.submit = function() {
|
this.submit = function() {
|
||||||
|
@ -43,5 +52,5 @@ export const COMPONENT = {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions'];
|
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$state'];
|
||||||
module.component(NAME, COMPONENT);
|
module.component(NAME, COMPONENT);
|
||||||
|
|
|
@ -22,3 +22,5 @@ export {NAME as CLIENT_CREATE,
|
||||||
COMPONENT as CLIENT_CREATE_COMPONENT} from './create/index';
|
COMPONENT as CLIENT_CREATE_COMPONENT} from './create/index';
|
||||||
export {NAME as CLIENT_ADDRESSES_DATA_INDEX,
|
export {NAME as CLIENT_ADDRESSES_DATA_INDEX,
|
||||||
COMPONENT as CLIENT_ADDRESSES_DATA_INDEX_COMPONENT} from './addresses-data/index';
|
COMPONENT as CLIENT_ADDRESSES_DATA_INDEX_COMPONENT} from './addresses-data/index';
|
||||||
|
export {NAME as CLIENT_CONFIRM_INDEX,
|
||||||
|
COMPONENT as CLIENT_CONFIRM_INDEX_COMPONENT} from './confirm/index';
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<dialog class="mdl-dialog">
|
||||||
|
<div class="mdl-dialog__content">
|
||||||
|
<p>
|
||||||
|
Allow this site to collect usage data to improve your experience?
|
||||||
|
</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>
|
||||||
|
</div>
|
||||||
|
</dialog>
|
|
@ -0,0 +1,28 @@
|
||||||
|
import template from './index.html';
|
||||||
|
import {module} from '../../module';
|
||||||
|
|
||||||
|
export const NAME = 'vnConfirmClient';
|
||||||
|
export const COMPONENT = {
|
||||||
|
template: template,
|
||||||
|
controllerAs: 'clientConfirm',
|
||||||
|
bindings: {
|
||||||
|
state: '<',
|
||||||
|
client: '='
|
||||||
|
},
|
||||||
|
controller: function($state, $element, copyObject){
|
||||||
|
|
||||||
|
var dialog = $element.find('dialog')[0]
|
||||||
|
|
||||||
|
this.accept = function(){
|
||||||
|
this.client.navigate = true;
|
||||||
|
$state.go(this.state);
|
||||||
|
dialog.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.cancel = function(){
|
||||||
|
dialog.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
COMPONENT.controller.$inject = ['$state', '$element', 'copyObject'];
|
||||||
|
module.component(NAME, COMPONENT);
|
Loading…
Reference in New Issue