dialog-confirm y acceso-Web
dialog-confirm ahora es generico y se ha añadido la entidad account
This commit is contained in:
parent
ede68e83b9
commit
102c344859
|
@ -26,4 +26,4 @@
|
|||
<vn-submit margin-small-top label="Guardar" id="save"></vn-submit>
|
||||
</vn-vertical>
|
||||
</form>
|
||||
<vn-confirm-client client="basicData.client" client-old="basicData.clientOld" state="basicData.state"></vn-confirm-client>
|
||||
<vn-dialog-confirm object="basicData.client" object-old="basicData.clientOld" state="basicData.state"></vn-dialog-confirm>
|
||||
|
|
|
@ -9,8 +9,7 @@ export const COMPONENT = {
|
|||
client: '<'
|
||||
},
|
||||
controller: function($http, copyObject, equalsObject, $transitions, $element) {
|
||||
|
||||
var self = this;
|
||||
var self = this;
|
||||
var deregister = $transitions.onStart({ }, callback);
|
||||
|
||||
this.$onChanges = function(changes) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</p>
|
||||
</div>
|
||||
<div class="mdl-dialog__actions mdl-dialog__actions--full-width">
|
||||
<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>
|
||||
<button type="button" class="mdl-button" ng-click="dialogConfirm.accept()">Aceptar</button>
|
||||
<button type="button" class="mdl-button close" ng-click="dialogConfirm.cancel()">Cancelar</button>
|
||||
</div>
|
||||
</dialog>
|
|
@ -1,28 +1,27 @@
|
|||
import template from './index.html';
|
||||
import {module} from '../../module';
|
||||
|
||||
export const NAME = 'vnConfirmClient';
|
||||
export const NAME = 'vnDialogConfirm';
|
||||
export const COMPONENT = {
|
||||
template: template,
|
||||
controllerAs: 'clientConfirm',
|
||||
controllerAs: 'dialogConfirm',
|
||||
bindings: {
|
||||
state: '<',
|
||||
client: '=',
|
||||
clientOld: "="
|
||||
object: '=',
|
||||
objectOld: "="
|
||||
},
|
||||
controller: function($state, $element, copyObject){
|
||||
|
||||
var dialog = $element.find('dialog')[0]
|
||||
controller: function($state, $element, copyObject) {
|
||||
var dialog = $element.find('dialog')[0];
|
||||
|
||||
this.accept = function(){
|
||||
copyObject(this.clientOld, this.client);
|
||||
this.accept = function() {
|
||||
copyObject(this.objectOld, this.object);
|
||||
$state.go(this.state);
|
||||
dialog.close();
|
||||
}
|
||||
};
|
||||
|
||||
this.cancel = function(){
|
||||
this.cancel = function() {
|
||||
dialog.close();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
COMPONENT.controller.$inject = ['$state', '$element', 'copyObject'];
|
||||
|
|
|
@ -60,4 +60,4 @@
|
|||
<vn-vertical>
|
||||
<vn-submit label="Guardar"></vn-submit>
|
||||
</vn-vertical>
|
||||
<vn-confirm-client client="fiscal.client" client-old="fiscal.clientOld" state="fiscal.state"></vn-confirm-client>
|
||||
<vn-dialog-confirm object="fiscal.client" object-old="fiscal.clientOld" state="fiscal.state"></vn-dialog-confirm>
|
||||
|
|
|
@ -9,14 +9,13 @@ export const COMPONENT = {
|
|||
client: '<'
|
||||
},
|
||||
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
|
||||
);
|
||||
|
@ -24,7 +23,7 @@ export const COMPONENT = {
|
|||
$http.get('/client/api/PaymentMethods').then(
|
||||
json => this.payments = json.data
|
||||
);
|
||||
|
||||
|
||||
this.submit = function() {
|
||||
if (!equalsObject(this.client, this.clientOld)) {
|
||||
this.client.modify = "FiscalData";
|
||||
|
|
|
@ -12,13 +12,12 @@ export const COMPONENT = {
|
|||
var where = null;
|
||||
var filter = this.filter;
|
||||
var queryStr = '/client/api/Clients';
|
||||
|
||||
var search = filter.search;
|
||||
if(search)
|
||||
if (search)
|
||||
where = {name: {ilike: search}};
|
||||
|
||||
var params = filter.params;
|
||||
if(params) {
|
||||
if (params) {
|
||||
where = {};
|
||||
let partials = {
|
||||
alias: true,
|
||||
|
@ -26,18 +25,18 @@ export const COMPONENT = {
|
|||
socialName: true,
|
||||
city: true,
|
||||
email: true
|
||||
}
|
||||
for(let param in params)
|
||||
if (params[param]) {
|
||||
if(partials[param])
|
||||
where[param] = {ilike: params[param]};
|
||||
else
|
||||
};
|
||||
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) {
|
||||
if (where) {
|
||||
let json = JSON.stringify({where: where});
|
||||
queryStr = `${queryStr}?filter=${json}`;
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
<vn-card>
|
||||
<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" field="web.client.user" focus></vn-textfield>
|
||||
<vn-check label="Acceso web activo" field="web.account.active"></vn-check>
|
||||
<vn-textfield label="Usuario" class="padd-medium-top margin-medium-top" field="web.account.user" focus></vn-textfield>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-vertical margin-small-top>
|
||||
<vn-vertical margin-small-top>
|
||||
<vn-submit label="Guardar"></vn-submit>
|
||||
</vn-vertical>
|
||||
</form>
|
||||
<vn-confirm-client client="web.client" client-old="web.clientOld" state="web.state"></vn-confirm-client>
|
||||
<vn-dialog-confirm object="web.account" object-old="web.accountOld" state="web.state"></vn-dialog-confirm>
|
||||
|
|
|
@ -9,17 +9,16 @@ export const COMPONENT = {
|
|||
client: '<'
|
||||
},
|
||||
controller: function($http, copyObject, equalsObject, $transitions, $element) {
|
||||
|
||||
var self = this;
|
||||
var deregister = $transitions.onStart({ }, callback);
|
||||
|
||||
|
||||
this.submit = function() {
|
||||
if (!equalsObject(this.client, this.clientOld)) {
|
||||
if (!equalsObject(this.account, this.accountOld)) {
|
||||
this.client.modify = "WebAccess";
|
||||
$http.put('/client/api/Clients', this.client).then(
|
||||
$http.put(`/client/api/Accounts/${this.account.id}`, this.account).then(
|
||||
json => {
|
||||
this.client = json.data;
|
||||
this.copyClient();
|
||||
this.account = json.data;
|
||||
self.copyAccount();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -27,7 +26,7 @@ export const COMPONENT = {
|
|||
|
||||
this.$onChanges = function(changes) {
|
||||
if (this.client) {
|
||||
this.copyClient();
|
||||
this.getAccount(this.client.id);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -36,7 +35,7 @@ export const COMPONENT = {
|
|||
};
|
||||
|
||||
function callback(transition) {
|
||||
if (!equalsObject(self.client, self.clientOld)) {
|
||||
if (!equalsObject(self.account, self.accountOld)) {
|
||||
self.state = transition.to().name;
|
||||
var dialog = $element[0].querySelector('dialog');
|
||||
dialog.showModal();
|
||||
|
@ -44,9 +43,21 @@ export const COMPONENT = {
|
|||
}
|
||||
}
|
||||
|
||||
this.copyClient = function() {
|
||||
this.clientOld = {};
|
||||
copyObject(this.client, this.clientOld);
|
||||
this.copyAccount = function() {
|
||||
this.accountOld = {};
|
||||
copyObject(this.account, this.accountOld);
|
||||
};
|
||||
|
||||
this.getAccount = function(clientId) {
|
||||
$http.get(`/client/api/Accounts/${clientId}`).then(
|
||||
json => {
|
||||
this.account = json.data;
|
||||
this.copyAccount();
|
||||
},
|
||||
json => {
|
||||
this.account = {id: clientId};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
7
db.json
7
db.json
|
@ -8,7 +8,8 @@
|
|||
"Address": 58,
|
||||
"Country": 3,
|
||||
"Province": 3,
|
||||
"Agency": 4
|
||||
"Agency": 4,
|
||||
"Account": 14
|
||||
},
|
||||
"models": {
|
||||
"User": {
|
||||
|
@ -49,6 +50,10 @@
|
|||
"1": "{\"name\":\"Zeleris\",\"id\":1}",
|
||||
"2": "{\"name\":\"MRW\",\"id\":2}",
|
||||
"3": "{\"name\":\"DHL\",\"id\":3}"
|
||||
},
|
||||
"Account": {
|
||||
"12": "{\"id\":12,\"name\":\"prueba12\",\"active\":false,\"user\":\"juanete\"}",
|
||||
"13": "{\"id\":13,\"name\":\"manu\",\"active\":false,\"user\":\"joselito\"}"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "account",
|
||||
"name": "Account",
|
||||
"base": "PersistedModel",
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
|
@ -63,5 +63,9 @@
|
|||
"ClientObservation": {
|
||||
"dataSource": "db",
|
||||
"public": true
|
||||
},
|
||||
"Account": {
|
||||
"dataSource": "db",
|
||||
"public": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue