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