Loopback 3, Errores solucionados

This commit is contained in:
Juan Ferrer Toribio 2017-06-03 13:01:47 +02:00
parent 8cd312e145
commit b427361156
46 changed files with 348 additions and 387 deletions

View File

@ -7,6 +7,10 @@
"url": "/clients",
"state": "clients",
"component": "vn-client-index"
}, {
"url": "/create",
"state": "create",
"component": "vn-client-create"
}, {
"url": "/clients/:id",
"state": "clientCard",
@ -23,7 +27,7 @@
"description": "Datos básicos",
"icon": "person"
}
}, {
}, {
"url": "/fiscal-data",
"state": "clientCard.fiscalData",
"component": "vn-client-fiscal-data",
@ -45,7 +49,7 @@
"description": "Datos facturación",
"icon": "assignment"
}
},{
}, {
"url": "/addresses",
"state": "clientCard.addresses",
"component": "ui-view",
@ -80,7 +84,7 @@
"description": "Acceso web",
"icon": "language"
}
},{
}, {
"url": "/notes",
"state": "clientCard.notes",
"component": "ui-view",
@ -96,15 +100,10 @@
"description": "Notas",
"icon": "insert_drive_file"
}
}, {
"url": "/create",
"state": "clientCard.notes.create",
"component": "vn-new-note"
},{
"url": "/create",
"state": "create",
"component": "vn-client-create"
"component": "vn-note-create"
}
]
}

View File

@ -5,7 +5,7 @@
data="$ctrl.address"
form="form">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" pad-medium>
<form ng-submit="watcher.submitGo('clientCard.addresses')" pad-medium>
<vn-card >
<vn-vertical pad-large>
<vn-title>Consignatario</vn-title>

View File

@ -1,25 +1,16 @@
import {module} from '../module';
import ngModule from '../module';
class Controller {
constructor($scope, $state) {
this.$ = $scope;
this.$state = $state;
export default class Controller {
constructor($state) {
this.address = {
clientFk: parseInt($state.params.id),
enabled: true
};
}
onSubmit() {
this.$.watcher.submit().then(
() => this.$state.go('clientCard.addresses')
);
}
}
Controller.$inject = ['$scope', '$state'];
Controller.$inject = ['$state'];
export const NAME = 'vnAddressCreate';
export const COMPONENT = {
ngModule.component('vnAddressCreate', {
template: require('./address-create.html'),
controller: Controller
};
module.component(NAME, COMPONENT);
});

View File

@ -3,7 +3,7 @@
get="true"
url="/client/api/Addresses"
id-field="id"
data="addressData.address"
data="$ctrl.address"
form="form">
</vn-watcher>
<form name="form" ng-submit="watcher.submitBack()" pad-medium>
@ -11,18 +11,18 @@
<vn-vertical pad-large>
<vn-title>Consignatario</vn-title>
<vn-horizontal>
<vn-check vn-one label="Activo" field="addressData.address.enabled"></vn-check>
<vn-check vn-one label="Predeterminado" field="addressData.address.default"></vn-check>
<vn-check vn-one label="Activo" field="$ctrl.address.enabled"></vn-check>
<vn-check vn-one label="Predeterminado" field="$ctrl.address.default"></vn-check>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Consignatario" field="addressData.address.consignee" vn-focus></vn-textfield>
<vn-textfield vn-one label="Domicilio" field="addressData.address.street"></vn-textfield>
<vn-textfield vn-one label="Consignatario" field="$ctrl.address.consignee" vn-focus></vn-textfield>
<vn-textfield vn-one label="Domicilio" field="$ctrl.address.street"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Código Postal" field="addressData.address.postcode"></vn-textfield>
<vn-textfield vn-one label="Municipio" field="addressData.address.city"></vn-textfield>
<vn-textfield vn-one label="Código Postal" field="$ctrl.address.postcode"></vn-textfield>
<vn-textfield vn-one label="Municipio" field="$ctrl.address.city"></vn-textfield>
<vn-autocomplete vn-one
field="addressData.address.provinceFk"
field="$ctrl.address.provinceFk"
url="/client/api/Provinces"
show-field="name"
value-field="id"
@ -31,14 +31,14 @@
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one
field="addressData.address.defaultAgencyFk"
field="$ctrl.address.defaultAgencyFk"
url="/client/api/AgencyServices"
show-field="name"
value-field="id"
label="Agencia">
</vn-autocomplete>
<vn-textfield vn-one label="Teléfono" field="addressData.address.phone"></vn-textfield>
<vn-textfield vn-one label="Móvil" field="addressData.address.mobile"></vn-textfield>
<vn-textfield vn-one label="Teléfono" field="$ctrl.address.phone"></vn-textfield>
<vn-textfield vn-one label="Móvil" field="$ctrl.address.mobile"></vn-textfield>
</vn-horizontal>
</vn-vertical>
</vn-card>

View File

@ -1,18 +1,5 @@
import {module} from '../module';
import ngModule from '../module';
class Controller {
constructor($stateParams) {
this.address = {
id: $stateParams.addressId
};
}
}
Controller.$inject = ['$stateParams'];
export const NAME = 'vnAddressEdit';
export const COMPONENT = {
template: require('./address-edit.html'),
controllerAs: 'addressData',
controller: Controller
};
module.component(NAME, COMPONENT);
ngModule.component('vnAddressEdit', {
template: require('./address-edit.html')
});

View File

@ -1,6 +1,5 @@
import {module} from '../module';
import ngModule from '../module';
export const component = {
ngModule.component('vnClientAddresses', {
template: require('./addresses.html')
};
module.component('vnClientAddresses', component);
});

View File

@ -1,9 +1,9 @@
<mg-ajax path="/client/api/Clients/{{put.params.id}}" options="vnPut"></mg-ajax>
<mg-ajax path="/client/api/Clients/{{patch.params.id}}" options="vnPatch"></mg-ajax>
<vn-watcher
vn-id="watcher"
data="$ctrl.client"
form="form"
save="put">
save="patch">
</vn-watcher>
<form name="form" ng-submit="watcher.submit()" pad-medium>
<vn-card>

View File

@ -1,9 +1,8 @@
import {module} from '../module';
import ngModule from '../module';
export const component = {
ngModule.component('vnClientBasicData', {
template: require('./basic-data.html'),
bindings: {
client: '<'
}
};
module.component('vnClientBasicData', component);
});

View File

@ -1,30 +1,30 @@
<mg-ajax path="/client/api/Clients/{{put.params.id}}" options="vnPut"></mg-ajax>
<mg-ajax path="/client/api/Clients/{{patch.params.id}}" options="vnPatch"></mg-ajax>
<vn-watcher
vn-id="watcher"
data="bill.client"
data="$ctrl.client"
form="form"
save="put">
save="patch">
</vn-watcher>
<form name="form" ng-submit="bill.checkChanges() && watcher.submit()" pad-medium>
<form name="form" ng-submit="$ctrl.checkChanges() && watcher.submit()" pad-medium>
<vn-card margin-small-bottom>
<vn-vertical pad-large>
<vn-title>Información de facturación</vn-title>
<vn-horizontal>
<vn-autocomplete vn-two
field="bill.client.payMethodFk"
field="$ctrl.client.payMethodFk"
url="/client/api/PayMethods"
select-fields="ibanRequired"
initial-data="bill.client.payMethod"
initial-data="$ctrl.client.payMethod"
label="Forma de pago">
</vn-autocomplete>
<vn-textfield vn-two label="IBAN" field="bill.client.iban"></vn-textfield>
<vn-textfield vn-one label="Vencimiento" field="bill.client.dueDay"></vn-textfield>
<vn-textfield vn-two label="IBAN" field="$ctrl.client.iban"></vn-textfield>
<vn-textfield vn-one label="Vencimiento" field="$ctrl.client.dueDay"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Descuento" field="bill.client.discount"></vn-textfield>
<vn-textfield vn-one label="Crédito" field="bill.client.credit"></vn-textfield>
<vn-textfield vn-one label="Crédito asegurado" field="bill.client.creditInsurance"></vn-textfield>
<vn-check vn-three label="Recargo de equivalencia" field="bill.client.equalizationTax"></vn-check>
<vn-textfield vn-one label="Descuento" field="$ctrl.client.discount"></vn-textfield>
<vn-textfield vn-one label="Crédito" field="$ctrl.client.credit"></vn-textfield>
<vn-textfield vn-one label="Crédito asegurado" field="$ctrl.client.creditInsurance"></vn-textfield>
<vn-check vn-three label="Recargo de equivalencia" field="$ctrl.client.equalizationTax"></vn-check>
</vn-horizontal>
</vn-vertical>
</vn-card>
@ -32,9 +32,9 @@
<vn-vertical pad-large>
<vn-title>Documentación</vn-title>
<vn-horizontal>
<vn-check vn-one label="Recibido core VNH" field="bill.client.coreVnh"></vn-check>
<vn-check vn-one label="Recibido core VNL" field="bill.client.coreVnl"></vn-check>
<vn-check vn-one label="Recibido B2B VNL" field="bill.client.sepaVnl"></vn-check>
<vn-check vn-one label="Recibido core VNH" field="$ctrl.client.coreVnh"></vn-check>
<vn-check vn-one label="Recibido core VNL" field="$ctrl.client.coreVnl"></vn-check>
<vn-check vn-one label="Recibido B2B VNL" field="$ctrl.client.sepaVnl"></vn-check>
</vn-horizontal>
</vn-vertical>
</vn-card>
@ -44,7 +44,7 @@
</form>
<vn-dialog
vn-id="send-mail"
on-response="bill.returnDialog(response)">
on-response="$ctrl.returnDialog(response)">
<tpl-body>
<vn-vertical>
<vn-one text-center translate>Changed terms</vn-one>

View File

@ -1,8 +1,6 @@
import {module} from '../module';
import ngModule from '../module';
export const NAME = 'vnClientBillingData';
class billingData {
export default class Controller {
constructor($scope, $http, $timeout, vnAppLogger, $translate) {
this.$ = $scope;
this.http = $http;
@ -13,18 +11,15 @@ class billingData {
this.dueDay = null;
this.copyData();
}
$onChanges(changes) {
this.copyData();
}
copyData() {
if (this.client) {
this.payId = this.client.payMethodFk || null;
this.dueDay = this.client.dueDay ? this.client.dueDay : null;
}
}
checkChanges() {
let payId = this.client.payMethodFk || null;
let dueDay = this.client.dueDay || null;
@ -45,19 +40,16 @@ class billingData {
}
this.timeout(() => this.$.watcher.submit());
}
sendMail() {
return this.http.post(`/mailer/manuscript/paymentUpdate`, {user: this.client.id});
}
}
billingData.$inject = ['$scope', '$http', '$timeout', 'vnAppLogger', '$translate'];
Controller.$inject = ['$scope', '$http', '$timeout', 'vnAppLogger', '$translate'];
export const COMPONENT = {
ngModule.component('vnClientBillingData', {
template: require('./billing-data.html'),
controller: billingData,
controllerAs: 'bill',
controller: Controller,
bindings: {
client: '<'
}
};
module.component(NAME, COMPONENT);
});

View File

@ -1,7 +1,15 @@
<vn-horizontal>
<mg-ajax path="/client/api/Clients/{{edit.params.id}}/card" options="mgEdit" actions="card.client=edit.model;"></mg-ajax>
<mg-ajax
path="/client/api/Clients/{{edit.params.id}}/card"
actions="card.client = edit.model"
options="mgEdit">
</mg-ajax>
<vn-empty style="min-width: 18em; padding-left: 1em; padding-bottom: 1em;">
<vn-descriptor client="card.client" active="card.client.active" class="display-block" ></vn-descriptor>
<vn-descriptor
client="card.client"
active="card.client.active"
class="display-block" >
</vn-descriptor>
<vn-left-menu></vn-left-menu>
</vn-empty>
<vn-auto>

View File

@ -1,17 +1,14 @@
import {module} from '../module';
import ngModule from '../module';
import './style.css';
export const NAME = 'vnClientCard';
export default class vnClientCard {
export default class Controller {
constructor() {
this.client = null;
}
}
module.component(NAME, {
ngModule.component('vnClientCard', {
template: require('./card.html'),
controllerAs: 'card',
controller: vnClientCard
controller: Controller,
controllerAs: 'card'
});

View File

@ -1,27 +1,16 @@
export * from './module';
export {NAME as CLIENT_CARD,
COMPONENT as CLIENT_CARD_COMPONENT} from './card/card';
export {NAME as CLIENTS,
COMPONENT as CLIENTS_COMPONENT} from './index/index';
export {NAME as CLIENT_FISCAL_DATA_INDEX,
COMPONENT as CLIENT_FISCAL_DATA_INDEX_COMPONENT} from './fiscal-data/fiscal-data';
export {NAME as CLIENT_BILLING_DATA_INDEX,
COMPONENT as CLIENT_BILLINGL_DATA_INDEX_COMPONENT} from './billing-data/billing-data';
export {NAME as CLIENT_DESCRIPTOR,
COMPONENT as CLIENT_DESCRIPTOR_COMPONENT} from './descriptor/descriptor';
export {NAME as CLIENT_NOTES,
COMPONENT as CLIENT_NOTES_COMPONENT} from './notes/notes';
export {NAME as CLIENT_SEARCH_PANEL,
COMPONENT as CLIENT_SEARCH_PANEL_COMPONENT} from './search-panel/search-panel';
export {NAME as CLIENT_CREATE,
COMPONENT as CLIENT_CREATE_COMPONENT} from './create/create';
export {NAME as CLIENT_ADDRESS_EDIT_INDEX,
COMPONENT as CLIENT_ADDRESS_EDIT_INDEX_COMPONENT} from './address-edit/address-edit';
export {NAME as NEW_NOTE_INDEX,
COMPONENT as NEW_NOTE_INDEX_COMPONENT} from './new-note/new-note';
import './index/index';
import './card/card';
import './create/create';
import './basic-data/basic-data';
import './fiscal-data/fiscal-data';
import './billing-data/billing-data';
import './descriptor/descriptor';
import './search-panel/search-panel';
import './addresses/addresses';
import './address-create/address-create';
import './basic-data/basic-data';
import './address-edit/address-edit';
import './notes/notes';
import './note-create/note-create';
import './web-access/web-access';

View File

@ -1,23 +1,22 @@
import {module} from '../module';
import ngModule from '../module';
class Controller {
export default class Controller {
constructor($scope, $state) {
this.$scope = $scope;
this.$ = $scope;
this.$state = $state;
this.client = {
active: true
};
}
onSubmit() {
this.$scope.watcher.submit().then(
this.$.watcher.submit().then(
json => this.$state.go('clientCard.basicData', {id: json.data.id})
);
}
}
Controller.$inject = ['$scope', '$state'];
export const component = {
ngModule.component('vnClientCreate', {
template: require('./create.html'),
controller: Controller
};
module.component('vnClientCreate', component);
});

View File

@ -5,10 +5,10 @@
<i class="material-icons descriptor-icon">person</i>
</vn-one>
<vn-vertical vn-two>
<div class="margin-none">{{descriptor.client.id}}</div>
<div class="margin-none">{{descriptor.client.name}}</div>
<div class="margin-none">{{descriptor.client.phone}}</div>
<vn-switch label="Activo" model="descriptor.active"></vn-switch>
<div class="margin-none">{{$ctrl.client.id}}</div>
<div class="margin-none">{{$ctrl.client.name}}</div>
<div class="margin-none">{{$ctrl.client.phone}}</div>
<vn-switch label="Activo" model="$ctrl.active"></vn-switch>
</vn-vertical>
</vn-horizontal>
</vn-vertical>

View File

@ -1,21 +1,27 @@
import {module} from '../module';
import ngModule from '../module';
import './style.css';
export const NAME = 'vnDescriptor';
export const COMPONENT = {
export default class Controller {
constructor($scope, $http) {
this.$http = $http;
}
$onChanges(changes) {
let active = changes.active;
let sendPut = active
&& !active.isFirstChange()
&& active.previousValue !== active.currentValue;
if (sendPut)
$http.put(`/client/api/Clients/${this.client.id}/activate`);
}
}
Controller.$inject = ['$scope', '$http'];
ngModule.component('vnDescriptor', {
template: require('./descriptor.html'),
controllerAs: 'descriptor',
controller: Controller,
bindings: {
client: '<',
active: '<'
},
controller: function($http, $scope) {
var self = this;
$scope.$watch('descriptor.active', function(newValue, oldValue) {
if (oldValue !== undefined)
$http.put(`/client/api/Clients/${self.client.id}/activate`);
});
}
};
COMPONENT.controller.$inject = ['$http', '$scope'];
module.component(NAME, COMPONENT);
});

View File

@ -1,35 +1,35 @@
<mg-ajax path="/client/api/Clients/{{put.params.id}}" options="vnPut"></mg-ajax>
<mg-ajax path="/client/api/Clients/{{patch.params.id}}" options="vnPatch"></mg-ajax>
<vn-watcher
vn-id="watcher"
data="fiscal.client"
data="$ctrl.client"
form="form"
save="put">
save="patch">
</vn-watcher>
<form name="form" ng-submit="watcher.submit()" pad-medium>
<vn-card margin-small-bottom>
<vn-vertical pad-large>
<vn-title>Datos fiscales y de facturación</vn-title>
<vn-horizontal>
<vn-check vn-one label="Facturar" field="fiscal.client.hasToInvoice"></vn-check>
<vn-check vn-one label="Factura impresa" field="fiscal.client.invoiceByEmail"></vn-check>
<vn-check vn-one label="Facturar" field="$ctrl.client.hasToInvoice"></vn-check>
<vn-check vn-one label="Factura impresa" field="$ctrl.client.invoiceByEmail"></vn-check>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-two label="Domicilio fiscal" field="fiscal.client.street" vn-focus></vn-textfield>
<vn-textfield vn-one label="Municipio" field="fiscal.client.city"></vn-textfield>
<vn-textfield vn-two label="Domicilio fiscal" field="$ctrl.client.street" vn-focus></vn-textfield>
<vn-textfield vn-one label="Municipio" field="$ctrl.client.city"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Código postal" field="fiscal.client.postcode"></vn-textfield>
<vn-textfield vn-one label="Código postal" field="$ctrl.client.postcode"></vn-textfield>
<vn-autocomplete vn-one
initial-value="fiscal.client.province"
field="fiscal.client.provinceFk"
initial-value="$ctrl.client.province"
field="$ctrl.client.provinceFk"
url="/client/api/Provinces"
show-field="name"
value-field="id"
label="Provincia">
</vn-autocomplete>
<vn-autocomplete vn-one
initial-value="fiscal.client.country"
field="fiscal.client.countryFk"
initial-value="$ctrl.client.country"
field="$ctrl.client.countryFk"
url="/client/api/Countries"
show-field="name"
value-field="id"

View File

@ -1,11 +1,8 @@
import {module} from '../module';
import ngModule from '../module';
export const NAME = 'vnClientFiscalData';
export const COMPONENT = {
ngModule.component('vnClientFiscalData', {
template: require('./fiscal-data.html'),
controllerAs: 'fiscal',
bindings: {
client: '<'
}
};
module.component(NAME, COMPONENT);
});

View File

@ -1,17 +1,15 @@
import {module} from '../module';
import ngModule from '../module';
import './style.css';
import './item-client';
class Controller {
export default class Controller {
search(index) {
index.filter.search = this.model.search;
index.accept();
}
}
export const NAME = 'vnClientIndex';
export const COMPONENT = {
ngModule.component('vnClientIndex', {
template: require('./index.html'),
controller: Controller
};
module.component(NAME, COMPONENT);
});

View File

@ -1,7 +1,7 @@
<a ui-sref="clientCard.basicData({ id: {{itemClient.client.id}} })" pad-medium border-solid-bottom>
<div class="vn-item-client-name">{{itemClient.client.name}}</div>
<div>Id Cliente: <b>{{itemClient.client.id}}</b></div>
<div>Teléfono: <b>{{itemClient.client.phone | phone}}</b></div>
<div>Población: <b>{{itemClient.client.city}}</b></div>
<div>email: <b>{{itemClient.client.email}}</b></div>
<a ui-sref="clientCard.basicData({ id: {{$ctrl.client.id}} })" pad-medium border-solid-bottom>
<div class="vn-item-client-name">{{$ctrl.client.name}}</div>
<div>Id Cliente: <b>{{$ctrl.client.id}}</b></div>
<div>Teléfono: <b>{{$ctrl.client.phone | phone}}</b></div>
<div>Población: <b>{{$ctrl.client.city}}</b></div>
<div>email: <b>{{$ctrl.client.email}}</b></div>
</a>

View File

@ -1,11 +1,8 @@
import {module} from '../module';
import ngModule from '../module';
export const NAME = 'vnItemClient';
export const COMPONENT = {
ngModule.component('vnItemClient', {
template: require('./item-client.html'),
controllerAs: 'itemClient',
bindings: {
client: '<'
}
};
module.component(NAME, COMPONENT);
});

View File

@ -1,4 +1,5 @@
import {ng} from 'vendor';
import 'core';
export const module = ng.module('client', []);
const ngModule = ng.module('client', []);
export default ngModule;

View File

@ -1,27 +0,0 @@
import template from './new-note.html';
import {module} from '../module';
class Controller {
constructor($element, $state) {
this.element = $element[0];
this.$state = $state;
this.note = {
clientFk: $state.params.id,
text: null
};
}
onSubmit() {
this.element.querySelector('vn-watcher').$ctrl.submit().then(
() => this.$state.go('clientCard.notes')
);
}
}
Controller.$inject = ['$element', '$state'];
export const NAME = 'vnNewNote';
export const COMPONENT = {
template: template,
controllerAs: 'newNote',
controller: Controller
};
module.component(NAME, COMPONENT);

View File

@ -2,14 +2,14 @@
vn-id="watcher"
url="/client/api/ClientObservations"
id-field="id"
data="newNote.note"
data="$ctrl.note"
form="form">
</vn-watcher>
<form name="form" ng-submit="newNote.onSubmit()" pad-medium>
<form ng-submit="watcher.submitGo('clientCard.notes.list')" pad-medium>
<vn-card>
<vn-vertical pad-large>
<vn-title>Nueva nota</vn-title>
<vn-textarea label="Nueva nota" model="newNote.note.text" vn-focus padd-medium-top></vn-textarea>
<vn-textarea label="Nueva nota" model="$ctrl.note.text" vn-focus padd-medium-top></vn-textarea>
</vn-vertical>
</vn-card>
<vn-button-bar>

View File

@ -0,0 +1,16 @@
import ngModule from '../module';
export default class Controller {
constructor($state) {
this.note = {
clientFk: parseInt($state.params.id),
text: null
};
}
}
Controller.$inject = ['$state'];
ngModule.component('vnNoteCreate', {
template: require('./note-create.html'),
controller: Controller
});

View File

@ -1,7 +1,7 @@
<vn-card ng-show="observation.observations.length" pad-medium>
<vn-card ng-show="$ctrl.observations.length" pad-medium>
<vn-vertical pad-large>
<vn-title>Notas</vn-title>
<vn-horizontal ng-repeat="n in observation.observations" margin-small-bottom style="align-items: center;">
<vn-horizontal ng-repeat="n in $ctrl.observations" margin-small-bottom style="align-items: center;">
<vn-auto style="border-radius: .3em;" class="pad-small border-solid">
<div class="notes-date">{{n.created | date:'dd/MM/yyyy HH:mm'}}</div>
<div class="notes-date">{{n.employee.name}}</div>
@ -12,6 +12,6 @@
</vn-card>
<vn-float-button
fixed-bottom-right
ng-click="observation.newObservation()"
ng-click="$ctrl.newObservation()"
icon="add">
</vn-float-button>

View File

@ -1,34 +1,34 @@
import ngModule from '../module';
import './style.css';
import template from './notes.html';
import {module} from '../module';
export const NAME = 'vnClientNotes';
export const COMPONENT = {
template: template,
controllerAs: 'observation',
export default class Controller {
constructor($http, $state) {
this.$http = $http;
this.$state = $state;
}
$onChanges(changes) {
if (this.client) {
this.getObservation(this.client.id);
}
}
getObservation(clientId) {
let json = JSON.stringify({where: {clientFk: this.client.id}, order: 'created DESC'});
this.$http.get(`/client/api/clientObservations?filter=${json}`).then(
json => {
this.observations = json.data;
}
);
}
newObservation() {
this.$state.go("clientCard.notes.create", {id: this.client.id});
}
}
Controller.$inject = ['$http', '$state'];
ngModule.component('vnClientNotes', {
template: require('./notes.html'),
controller: Controller,
bindings: {
client: '<'
},
controller: function($http, $state) {
this.$onChanges = function(changes) {
if (this.client) {
this.getObservation(this.client.id);
}
};
this.getObservation = function(clientId) {
let json = JSON.stringify({where: {clientFk: this.client.id}, order: 'created DESC'});
$http.get(`/client/api/clientObservations?filter=${json}`).then(
json => {
this.observations = json.data;
}
);
};
this.newObservation = () => {
$state.go("clientCard.notes.create", {id: this.client.id});
};
}
};
COMPONENT.controller.$inject = ['$http', '$state'];
module.component(NAME, COMPONENT);
});

View File

@ -1,5 +1,5 @@
<div pad-large style="min-width: 30em;" ng-show="$ctrl.formVisibility">
<form name="form" ng-submit="form.$valid && $ctrl.onSearch()" ng-keyup="$ctrl.getKeyPressed($event)">
<div pad-large style="min-width: 30em">
<form name="form" ng-submit="$ctrl.onSearch()">
<vn-horizontal>
<vn-textfield vn-one label="Id Cliente" model="$ctrl.filter.id" vn-focus></vn-textfield>
<vn-textfield vn-one label="NIF/CIF" model="$ctrl.filter.fi"></vn-textfield>

View File

@ -1,28 +1,35 @@
import {module} from '../module';
import ngModule from '../module';
export const NAME = 'vnClientSearchPanel';
export const COMPONENT = {
template: require('./search-panel.html'),
controller: function($scope, $window) {
this.filter = {id: null, fi: null, name: null, socialName: null, city: null, postcode: null, email: null, phone: null};
this.formVisibility = true;
this.onSearch = () => {
this.setStorageValue();
this.onSubmit(this.filter);
};
this.getKeyPressed = function(event) {
if (event.which === 27)
this.formVisibility = false;
};
this.$onChanges = () => {
var value = JSON.parse($window.sessionStorage.getItem('filter'));
if (value !== undefined)
this.filter = value;
};
this.setStorageValue = () => {
$window.sessionStorage.setItem('filter', JSON.stringify(this.filter));
export default class Controller {
constructor($window) {
this.$window = $window;
this.filter = {
id: null,
fi: null,
name: null,
socialName: null,
city: null,
postcode: null,
email: null,
phone: null
};
}
};
onSearch() {
this.setStorageValue();
this.onSubmit(this.filter);
}
$onChanges() {
var value = JSON.parse(this.$window.sessionStorage.getItem('filter'));
if (value !== undefined)
this.filter = value;
}
setStorageValue() {
this.$window.sessionStorage.setItem('filter', JSON.stringify(this.filter));
}
}
Controller.$inject = ['$window'];
module.component(NAME, COMPONENT);
ngModule.component('vnClientSearchPanel', {
template: require('./search-panel.html'),
controller: Controller
});

View File

@ -1,8 +1,8 @@
import {module} from '../module';
import ngModule from '../module';
class Controller {
export default class Controller {
constructor($scope, $http, vnAppLogger) {
this.$scope = $scope;
this.$ = $scope;
this.$http = $http;
this.vnAppLogger = vnAppLogger;
}
@ -13,7 +13,7 @@ class Controller {
onPassOpen() {
this.newPassword = '';
this.repeatPassword = '';
this.$scope.$apply();
this.$.$apply();
}
onPassChange(response) {
if (response == 'ACCEPT')
@ -26,7 +26,7 @@ class Controller {
password: this.newPassword
};
this.$http.put(`/client/api/Accounts/${this.client.id}`, account);
this.$http.patch(`/client/api/Accounts/${this.client.id}`, account);
} catch (e) {
this.vnAppLogger.showError(e.message);
return false;
@ -37,10 +37,10 @@ class Controller {
}
Controller.$inject = ['$scope', '$http', 'vnAppLogger'];
module.component('vnClientWebAccess', {
ngModule.component('vnClientWebAccess', {
template: require('./web-access.html'),
controller: Controller,
bindings: {
client: '<'
},
controller: Controller
}
});

View File

@ -56,6 +56,9 @@ export default class Dialog extends Component {
}
/**
* Calls the response handler.
*
* @param {String} response The response code
* @return {Boolean} %true if response was canceled, %false otherwise
*/
fireResponse(response) {
let cancel = false;

View File

@ -24,6 +24,14 @@ function put(mgPut) {
}
module.factory('vnPut', put);
put.$inject = ['mgPatch'];
function patch(mgPatch) {
return Object.assign({}, mgPatch, {
success: 'vnSuccessFactoryCreate'
});
}
module.factory('vnPatch', patch);
post.$inject = ['mgCreate'];
function post(mgCreate) {
return Object.assign({}, mgCreate, {

View File

@ -2,12 +2,12 @@ import {module} from '../module';
import './style.css';
directive.$inject = ['vnPopover'];
export function directive(popover) {
export function directive(vnPopover) {
return {
restrict: 'A',
link: function($scope, $element, $attrs) {
$element.on('click', function(event) {
popover.showComponent($attrs.vnDialog, $scope, $element);
vnPopover.showComponent($attrs.vnDialog, $scope, $element);
event.preventDefault();
});
}
@ -24,7 +24,7 @@ export class Popover {
let popover = this.document.createElement('div');
popover.className = 'vn-popover';
popover.addEventListener('mousedown',
event => this.onPopoverMouseDown(event));
e => this.onPopoverMouseDown(e));
popover.appendChild(childElement);
this.popover = popover;
@ -70,8 +70,12 @@ export class Popover {
}
this.document.body.appendChild(popover);
this.docMouseDownHandler = event => this.onDocMouseDown(event);
this.docMouseDownHandler = e => this.onDocMouseDown(e);
this.document.addEventListener('mousedown', this.docMouseDownHandler);
this.docKeyDownHandler = e => this.onDocKeyDown(e);
this.document.addEventListener('keydown', this.docKeyDownHandler);
}
showComponent(childComponent, $scope, parent) {
let childElement = this.document.createElement(childComponent);
@ -81,15 +85,21 @@ export class Popover {
hide() {
if (!this.popover) return;
this.document.removeEventListener('mousedown', this.docMouseDownHandler);
this.document.removeEventListener('keydown', this.docKeyDownHandler);
this.document.body.removeChild(this.popover);
this.popover = null;
this.lastEvent = null;
this.docMouseDownHandler = null;
this.docKeyDownHandler = null;
}
onDocMouseDown(event) {
if (event != this.lastEvent)
this.hide();
}
onDocKeyDown(event) {
if (event.keyCode === 27)
this.hide();
}
onPopoverMouseDown(event) {
this.lastEvent = event;
}

View File

@ -54,6 +54,16 @@ export default class Watcher extends Component {
() => this.window.history.back()
);
}
/**
* Submits the data and goes another state.
*
* @param {String} state The state name
*/
submitGo(state) {
this.submit().then(
() => this.$state.go(state)
);
}
/**
* Submits the data to the server.
*
@ -91,7 +101,7 @@ export default class Watcher extends Component {
if (id) {
return new Promise((resolve, reject) => {
this.$http.put(`${this.url}/${id}`, changedData).then(
this.$http.patch(`${this.url}/${id}`, changedData).then(
json => this.writeData(json, resolve),
json => reject(json)
);

View File

@ -1,5 +1,5 @@
{
"name": "login",
"name": "vn-auth",
"version": "1.0.0",
"main": "server/server.js",
"scripts": {
@ -11,14 +11,14 @@
"compression": "^1.0.3",
"cors": "^2.5.2",
"helmet": "^1.3.0",
"loopback": "^2.22.0",
"loopback-boot": "^2.6.5",
"loopback-component-explorer": "^2.4.0",
"loopback": "^3.8.0",
"loopback-boot": "^2.24.0",
"loopback-component-explorer": "^4.2.0",
"loopback-connector-mysql": "^3.0.0",
"loopback-datasource-juggler": "^2.39.0",
"loopback-context": "^3.1.0",
"md5": "^2.2.1",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^1.0.1"
"strong-error-handler": "^2.1.0"
},
"devDependencies": {
"eslint": "^2.13.1",
@ -27,8 +27,8 @@
},
"repository": {
"type": "git",
"url": "http://git.verdnatura.es:/salix"
"url": "https://git.verdnatura.es/salix"
},
"license": "UNLICENSED",
"description": "app"
"license": "GPL-3.0",
"description": "Authentication service"
}

View File

@ -1,7 +1,4 @@
module.exports = function(Client) {
// Validations
var card = require('./card.json');
Client.remoteMethod('card', {
description: 'Get client for card call',
accepts: {
@ -27,7 +24,7 @@ module.exports = function(Client) {
where: {
id: id
},
include: card
include: require('./card.json')
};
Client.find(filter, function(err, instances) {

View File

@ -0,0 +1,33 @@
[
{
"relation": "salesPerson",
"scope": {
"fields": ["id", "name"]
}
}, {
"relation": "contactChannel",
"scope": {
"fields": ["id", "name"]
}
}, {
"relation": "province",
"scope": {
"fields": ["id", "name"]
}
}, {
"relation": "country",
"scope": {
"fields": ["id", "name"]
}
}, {
"relation": "payMethod",
"scope": {
"fields": ["id", "name"]
}
}, {
"relation": "account",
"scope": {
"fields": ["id", "name", "active"]
}
}
]

View File

@ -1,7 +1,8 @@
module.exports = function(Client){
Client.installMethod('filter', filterClients);
function filterClients(p) {
if(p.search && p.search !== "")
if(p.search)
return searchWhere(p);
return andWhere(p);
}

View File

@ -5,11 +5,11 @@ module.exports = function(Client) {
// Methods
require('../scopes/client/card.js')(Client);
require('../scopes/client/activate.js')(Client);
require('../scopes/client/addresses.js')(Client);
require('../scopes/client/filter.js')(Client);
require('../scopes/client/before-save.js')(Client);
require('../methods/client/card.js')(Client);
require('../methods/client/activate.js')(Client);
require('../methods/client/addresses.js')(Client);
require('../methods/client/filter.js')(Client);
require('../methods/client/before-save.js')(Client);
// Validations
@ -62,7 +62,7 @@ module.exports = function(Client) {
done();
});
}
/*
Client.validateAsync('credit', validateCredit, {
message: 'No tienes privilegios para modificar el crédito'
});
@ -137,4 +137,5 @@ module.exports = function(Client) {
done();
}
}
*/
};

View File

@ -1,57 +0,0 @@
[
{
"relation": "salesPerson",
"scope": {
"fields": [
"id",
"name"
]
}
},
{
"relation": "contactChannel",
"scope": {
"fields": [
"id",
"name"
]
}
},
{
"relation": "province",
"scope": {
"fields": [
"id",
"name"
]
}
},
{
"relation": "country",
"scope": {
"fields": [
"id",
"name"
]
}
},
{
"relation": "payMethod",
"scope": {
"fields": [
"id",
"name"
]
}
},
{
"relation": "account",
"scope": {
"fields": [
"id",
"name",
"active"
]
}
}
]

View File

@ -1,5 +1,5 @@
{
"name": "client",
"name": "vn-client",
"version": "1.0.0",
"main": "server/server.js",
"scripts": {
@ -12,14 +12,13 @@
"cors": "^2.5.2",
"helmet": "^1.3.0",
"i18n": "^0.8.3",
"loopback": "^2.38.3",
"loopback-boot": "^2.6.5",
"loopback-component-explorer": "^2.7.0",
"loopback": "^3.8.0",
"loopback-boot": "^2.24.0",
"loopback-component-explorer": "^4.2.0",
"loopback-connector-mysql": "^3.0.0",
"loopback-context": "^3.1.0",
"loopback-datasource-juggler": "^2.54.1",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^1.2.1"
"strong-error-handler": "^2.1.0"
},
"devDependencies": {
"eslint": "^2.13.1",
@ -27,9 +26,9 @@
"nsp": "^2.1.0"
},
"repository": {
"type": "",
"url": ""
"type": "git",
"url": "https://git.verdnatura.es/salix"
},
"license": "UNLICENSED",
"description": "client"
"license": "GPL-3.0",
"description": "Client service"
}

View File

@ -1,5 +1,5 @@
{
"name": "app",
"name": "salix",
"version": "1.0.0",
"main": "server/server.js",
"scripts": {
@ -9,15 +9,16 @@
},
"dependencies": {
"compression": "^1.0.3",
"cookie-parser": "^1.4.3",
"cors": "^2.5.2",
"helmet": "^1.3.0",
"loopback": "^2.22.0",
"loopback-boot": "^2.6.5",
"loopback-component-explorer": "^2.4.0",
"loopback-connector-mysql": "^4.1.0",
"loopback-datasource-juggler": "^2.39.0",
"loopback": "^3.8.0",
"loopback-boot": "^2.24.0",
"loopback-component-explorer": "^4.2.0",
"loopback-connector-mysql": "^3.0.0",
"loopback-context": "^3.1.0",
"serve-favicon": "^2.0.1",
"strong-error-handler": "^1.0.1"
"strong-error-handler": "^2.1.0"
},
"devDependencies": {
"eslint": "^2.13.1",
@ -25,9 +26,9 @@
"nsp": "^2.1.0"
},
"repository": {
"type": "",
"url": ""
"type": "git",
"url": "https://git.verdnatura.es/salix"
},
"license": "UNLICENSED",
"description": "app"
"license": "GPL-3.0",
"description": "Salix application service"
}

View File

@ -57,7 +57,7 @@ var config = {
names: ['bundle.vendor', 'bundle.manifest']
})
],
devtool: 'source-map'
devtool: 'eval-source-map'
};
if (!devMode) {