Merge branch 'master' of ssh://git.verdnatura.es:/var/lib/git/salix
This commit is contained in:
commit
9fcf18594a
|
@ -10,6 +10,7 @@ export const COMPONENT = {
|
|||
var self = this;
|
||||
this.clientId = $state.params.id;
|
||||
this.address = {};
|
||||
|
||||
$http.get('/client/api/Agencies').then(
|
||||
json => this.agencies = json.data
|
||||
);
|
||||
|
|
|
@ -5,23 +5,43 @@ export const NAME = 'vnClientAddressesDataEdit';
|
|||
export const COMPONENT = {
|
||||
template: template,
|
||||
controllerAs: 'addressData',
|
||||
controller: function($http, $stateParams) {
|
||||
controller: function($http, $stateParams, copyObject, equalsObject) {
|
||||
this.address = {};
|
||||
$http.get(`/client/api/Addresses/${$stateParams.addressId}`).then(
|
||||
json => this.address = json.data
|
||||
json => {
|
||||
this.address = json.data;
|
||||
this.copyAddress();
|
||||
}
|
||||
);
|
||||
|
||||
$http.get('/client/api/Agencies').then(
|
||||
json => this.agencies = json.data
|
||||
json => {
|
||||
this.agencies = json.data;
|
||||
}
|
||||
);
|
||||
$http.get('/client/api/Provinces').then(
|
||||
json => this.provinces = json.data
|
||||
json => {
|
||||
this.provinces = json.data;
|
||||
}
|
||||
);
|
||||
|
||||
this.submit = function() {
|
||||
$http.put('/client/api/Addresses', this.address);
|
||||
if (!equalsObject(this.address, this.addressOld)) {
|
||||
$http.put('/client/api/Addresses', this.address).then(
|
||||
json => {
|
||||
this.address = json.data;
|
||||
this.copyAddress();
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
this.copyAddress = () => {
|
||||
this.addressOld = {};
|
||||
copyObject(this.address, this.addressOld);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
COMPONENT.controller.$inject = ['$http', '$stateParams'];
|
||||
COMPONENT.controller.$inject = ['$http', '$stateParams', 'copyObject', 'equalsObject'];
|
||||
module.component(NAME, COMPONENT);
|
||||
|
|
|
@ -26,5 +26,7 @@ export {NAME as CLIENT_ADDRESSES_DATA_EDIT_INDEX,
|
|||
COMPONENT as CLIENT_ADDRESSES_DATA_EDIT_INDEX_COMPONENT} from './addresses-data-edit/index';
|
||||
export {NAME as CLIENT_CONFIRM_INDEX,
|
||||
COMPONENT as CLIENT_CONFIRM_INDEX_COMPONENT} from './confirm/index';
|
||||
export {NAME as NEW_NOTE_INDEX,
|
||||
COMPONENT as NEW_NOTE_INDEX_COMPONENT} from './new-note/index';
|
||||
|
||||
import {default as changePassword} from './change-password/index';
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
<form name="form" ng-submit="form.$valid && newNote.submit()" pad-medium>
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
<vn-title>Nueva nota</vn-title>
|
||||
<vn-textarea label="Nueva nota" model="newNote.note.text" focus padd-medium-top></vn-textarea>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Guardar"></vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
<vn-dialog-confirm object="newNote.note" object-old="newNote.noteOld" state="newNote.state"></vn-dialog-confirm>
|
|
@ -0,0 +1,54 @@
|
|||
import template from './index.html';
|
||||
import {module} from '../../module';
|
||||
|
||||
export const NAME = 'vnNewNote';
|
||||
export const COMPONENT = {
|
||||
template: template,
|
||||
controllerAs: 'newNote',
|
||||
controller: function($http, $state, copyObject, equalsObject, $transitions, $element) {
|
||||
|
||||
this.client = $state.params.id;
|
||||
this.note = {text: null};
|
||||
var self = this;
|
||||
|
||||
var deregister = $transitions.onStart({ }, callback);
|
||||
|
||||
this.submit = function() {
|
||||
if (this.note) {
|
||||
let observation = this.createNote();
|
||||
$http.post('/client/api/ClientObservations', observation).then(
|
||||
json => {
|
||||
this.note = json.data;
|
||||
this.copyNote();
|
||||
$state.go('clientCard.notes');
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
this.$onDestroy = function() {
|
||||
deregister();
|
||||
};
|
||||
|
||||
this.createNote = () => {
|
||||
let observation = {client: this.client, text: this.note.text, salesPerson: 'user', modify: 'ClientObservation'};
|
||||
return observation;
|
||||
};
|
||||
|
||||
function callback(transition) {
|
||||
if (!equalsObject(self.note, self.noteOld)) {
|
||||
self.state = transition.to().name;
|
||||
var dialog = $element[0].querySelector('dialog');
|
||||
dialog.showModal();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.copyNote = () => {
|
||||
this.noteOld = {}
|
||||
copyObject(this.note, this.noteOld);
|
||||
}
|
||||
}
|
||||
};
|
||||
COMPONENT.controller.$inject = ['$http', '$state', 'copyObject', 'equalsObject', '$transitions', '$element'];
|
||||
module.component(NAME, COMPONENT);
|
|
@ -1,19 +1,14 @@
|
|||
<form name="form" ng-submit="form.$valid && observation.submit()" pad-medium>
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
<vn-title>Notas</vn-title>
|
||||
<vn-textarea label="Notas" model="observation.newNote" focus padd-medium-top></vn-textarea>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Guardar"></vn-submit>
|
||||
</vn-button-bar>
|
||||
<vn-card ng-show="observation.observations.length" margin-small-top>
|
||||
<vn-vertical pad-large style="max-height: 300px; overflow: auto;">
|
||||
<vn-card ng-show="observation.observations.length" pad-medium>
|
||||
<vn-vertical pad-large>
|
||||
<vn-title>Notas</vn-title>
|
||||
<div ng-repeat="n in observation.observations">
|
||||
<p><b>{{n.creationDate | date:'medium'}} {{n.salesPerson}}</b></p>
|
||||
<p>{{n.text}}</p>
|
||||
<div class="notes-date">{{n.creationDate | date:'medium'}} {{n.salesPerson}}</div>
|
||||
{{n.text}}
|
||||
</div>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
</form>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-float-button
|
||||
fixed-bottom-right
|
||||
ng-click="observation.newObservation()"
|
||||
icon="add">
|
||||
</vn-float-button>
|
|
@ -1,3 +1,4 @@
|
|||
import './style.css';
|
||||
import template from './index.html';
|
||||
import {module} from '../../module';
|
||||
|
||||
|
@ -8,48 +9,13 @@ export const COMPONENT = {
|
|||
bindings: {
|
||||
client: '<'
|
||||
},
|
||||
controller: function($http, copyObject, equalsObject, $transitions, $element) {
|
||||
var self = this;
|
||||
var deregister = $transitions.onStart({ }, callback);
|
||||
|
||||
this.submit = function() {
|
||||
if (this.newNote) {
|
||||
this.client.modify = "ClientObservation";
|
||||
let observation = {
|
||||
client: this.client.id,
|
||||
text: this.newNote,
|
||||
creationDate: new Date(),
|
||||
salesPerson: 'user'
|
||||
};
|
||||
|
||||
$http.put('/client/api/ClientObservations', observation).then(
|
||||
() => {
|
||||
this.newNote = "";
|
||||
this.observations.unshift(observation);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
controller: function($http, $state) {
|
||||
this.$onChanges = function(changes) {
|
||||
if (this.client) {
|
||||
this.getObservation(this.client.id);
|
||||
}
|
||||
};
|
||||
|
||||
this.$onDestroy = function() {
|
||||
deregister();
|
||||
};
|
||||
|
||||
function callback(transition) {
|
||||
if (!equalsObject(self.observation, self.observationOld)) {
|
||||
self.state = transition.to().name;
|
||||
var dialog = $element[0].querySelector('dialog');
|
||||
dialog.showModal();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.observations = [];
|
||||
this.getObservation = function(clientId) {
|
||||
let json = JSON.stringify({where: {client: this.client.id}, order: 'creationDate DESC'});
|
||||
$http.get(`/client/api/clientObservations?filter=${json}`).then(
|
||||
|
@ -58,7 +24,11 @@ export const COMPONENT = {
|
|||
}
|
||||
);
|
||||
};
|
||||
|
||||
this.newObservation = () => {
|
||||
$state.go("clientCard.newNote", {id: this.client.id});
|
||||
};
|
||||
}
|
||||
};
|
||||
COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element'];
|
||||
COMPONENT.controller.$inject = ['$http', '$state'];
|
||||
module.component(NAME, COMPONENT);
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
.notes-date{
|
||||
font-family: raleway-bold;
|
||||
}
|
|
@ -55,6 +55,12 @@
|
|||
description: "Notas",
|
||||
icon: "insert_drive_file"
|
||||
}, {
|
||||
url: "/new-note",
|
||||
state: "clientCard.newNote",
|
||||
component: "vn-new-note",
|
||||
description: "Nueva nota",
|
||||
icon: "insert_drive_file"
|
||||
},{
|
||||
url: "/create",
|
||||
state: "create",
|
||||
component: "vn-client-create",
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
<vn-title>Web access</vn-title>
|
||||
<vn-check label="Web access enabled" field="web.account.active"></vn-check>
|
||||
<vn-textfield label="User" class="margin-medium-top" field="web.account.user" focus></vn-textfield>
|
||||
<vn-check label="Acceso Web" field="web.account.active"></vn-check>
|
||||
<vn-textfield label="Usuario" class="margin-medium-top" field="web.account.name" focus></vn-textfield>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Save"></vn-submit>
|
||||
<vn-button label="Change password" vn-dialog="vn-client-change-password"></vn-button>
|
||||
<vn-submit label="Guardar"></vn-submit>
|
||||
<vn-button label="Cambiar password" vn-dialog="vn-client-change-password"></vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
<vn-dialog-confirm object="web.account" object-old="web.accountOld" state="web.state"></vn-dialog-confirm>
|
||||
|
|
|
@ -15,7 +15,7 @@ export const COMPONENT = {
|
|||
this.submit = function() {
|
||||
if (!equalsObject(this.account, this.accountOld)) {
|
||||
this.client.modify = "WebAccess";
|
||||
$http.put(`/client/api/Accounts/${this.account.id}`, this.account).then(
|
||||
$http.put('/client/api/Accounts', this.account).then(
|
||||
json => {
|
||||
this.account = json.data;
|
||||
self.copyAccount();
|
||||
|
|
8
db.json
8
db.json
|
@ -9,7 +9,7 @@
|
|||
"Country": 3,
|
||||
"Province": 3,
|
||||
"Agency": 4,
|
||||
"Account": 15,
|
||||
"Account": 20,
|
||||
"ClientObservation": 1265
|
||||
},
|
||||
"models": {
|
||||
|
@ -53,9 +53,9 @@
|
|||
"3": "{\"name\":\"DHL\",\"id\":3}"
|
||||
},
|
||||
"Account": {
|
||||
"1": "{\"id\":1,\"password\":\"12\"}",
|
||||
"12": "{\"id\":12,\"name\":\"prueba12\",\"active\":true,\"user\":\"juanete\"}",
|
||||
"13": "{\"id\":13,\"name\":\"manu\",\"active\":false,\"user\":\"joselito\"}"
|
||||
"1": "{\"id\":1,\"password\":\"joselito\",\"name\":\"asdf\"}",
|
||||
"14": "{\"id\":14,\"active\":true,\"name\":\"f\"}",
|
||||
"15": "{\"id\":15,\"name\":\"asdf\"}"
|
||||
},
|
||||
"ClientObservation": {
|
||||
"1258": "{\"text\":\"Nota de prueba 1\",\"creationDate\":\"2017-01-17T15:24:23.320Z\",\"client\":12,\"salesPerson\":\"user\",\"id\":1258}",
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
module.exports = function(Address) {
|
||||
|
||||
Address.validate('default',isEnabled,{message: 'No se puede poner predeterminado un consignatario desactivado'});
|
||||
function isEnabled(err) {
|
||||
if (!this.enabled && this.default) err();
|
||||
}
|
||||
|
||||
Address.observe('before save', function (ctx, next) {
|
||||
var data = getData(ctx);
|
||||
if (isEnabled(data) && isDefault(data)) {
|
||||
updateData(ctx);
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
function getData(ctx){
|
||||
if(ctx.data)
|
||||
return ctx.data;
|
||||
else
|
||||
return ctx.instance;
|
||||
}
|
||||
|
||||
function isEnabled(data){
|
||||
return data.isEnabled;
|
||||
}
|
||||
|
||||
function isDefault(data){
|
||||
return data.default;
|
||||
}
|
||||
|
||||
function updateData(ctx){
|
||||
ctx.Model.update({client: ctx.data.client}, {default: false});
|
||||
}
|
||||
};
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "Address",
|
||||
"base": "PersistedModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "Agency",
|
||||
"base": "PersistedModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
module.exports = function(ClientObservation) {
|
||||
|
||||
ClientObservation.validate('text',isEnabled,{message: 'Se debe rellenar el campo de texto'});
|
||||
function isEnabled(err) {
|
||||
if (!this.text) err();
|
||||
}
|
||||
|
||||
ClientObservation.observe('before save', function (ctx, next) {
|
||||
ctx.instance.creationDate = Date();
|
||||
next();
|
||||
});
|
||||
|
||||
ClientObservation.on('attached', function() {
|
||||
var override = ClientObservation.find;
|
||||
ClientObservation.find = function(filter, callback) {
|
||||
var elements = override.apply(this, arguments);
|
||||
//return elements;
|
||||
elements = null;
|
||||
}
|
||||
});
|
||||
};
|
|
@ -11,11 +11,11 @@
|
|||
},
|
||||
"text": {
|
||||
"type": "string",
|
||||
"description": "Fiscal indetifier"
|
||||
"description": "Text"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date",
|
||||
"description": "Fiscal indetifier"
|
||||
"description": "Creation Date"
|
||||
},
|
||||
"relations": {
|
||||
"salesPerson": {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "Country",
|
||||
"base": "PersistedModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "PaymentMethod",
|
||||
"base": "PersistedModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "Province",
|
||||
"base": "PersistedModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "SalesPerson",
|
||||
"base": "PersistedModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "Account",
|
||||
"base": "PersistedModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
|
|
Loading…
Reference in New Issue