Merge branch 'master' of ssh://git.verdnatura.es:/var/lib/git/salix

This commit is contained in:
Juan Ferrer Toribio 2017-01-19 14:45:59 +01:00
commit 17de3cbe5b
5 changed files with 18 additions and 35 deletions

View File

@ -12,21 +12,22 @@ export const COMPONENT = {
var self = this; var self = this;
var deregister = $transitions.onStart({ }, callback); var deregister = $transitions.onStart({ }, callback);
copyNote();
this.submit = function() { this.submit = function() {
if (this.note) { if (this.note) {
let observation = this.createNote(); let observation = this.createNote();
$http.post('/client/api/ClientObservations', observation).then( $http.post('/client/api/ClientObservations', observation).then(
json => { json => {
this.note = json.data; this.note = json.data;
this.copyNote(); copyNote();
$state.go('clientCard.notes'); $state.go('clientCard.notes');
} }
); );
} }
}; };
this.$onDestroy = function() { this.$onDestroy = () => {
deregister(); deregister();
}; };
@ -44,9 +45,9 @@ export const COMPONENT = {
} }
} }
this.copyNote = () => { function copyNote() {
this.noteOld = {} self.noteOld = {};
copyObject(this.note, this.noteOld); copyObject(self.note, self.noteOld);
} }
} }
}; };

View File

@ -1,10 +1,13 @@
<vn-card ng-show="observation.observations.length" pad-medium> <vn-card ng-show="observation.observations.length" pad-medium>
<vn-vertical pad-large> <vn-vertical pad-large>
<vn-title>Notas</vn-title> <vn-title>Notas</vn-title>
<div ng-repeat="n in observation.observations"> <vn-horizontal ng-repeat="n in observation.observations" margin-small-bottom style="align-items: center;">
<div class="notes-date">{{n.creationDate | date:'medium'}} {{n.salesPerson}}</div> <vn-auto style="border-radius: .3em;" class="pad-small border-solid">
{{n.text}} <div class="notes-date">{{n.creationDate | date:'dd/MM/yyyy HH:mm'}}</div>
</div> <div class="notes-date">{{n.salesPerson}}</div>
<div>{{n.text}}</div>
</vn-auto>
</vn-horizontal>
</vn-vertical> </vn-vertical>
</vn-card> </vn-card>
<vn-float-button <vn-float-button

View File

@ -57,9 +57,7 @@
}, { }, {
url: "/new-note", url: "/new-note",
state: "clientCard.newNote", state: "clientCard.newNote",
component: "vn-new-note", component: "vn-new-note"
description: "Nueva nota",
icon: "insert_drive_file"
},{ },{
url: "/create", url: "/create",
state: "create", state: "create",

View File

@ -7,8 +7,8 @@ module.exports = function(Address) {
Address.observe('before save', function (ctx, next) { Address.observe('before save', function (ctx, next) {
var data = getData(ctx); var data = getData(ctx);
if (isEnabled(data) && isDefault(data)) { if (data.isEnabled && data.default) {
updateData(ctx); ctx.Model.update({client: data.client}, {default: false});
} }
next(); next();
}); });
@ -20,15 +20,4 @@ module.exports = function(Address) {
return ctx.instance; 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});
}
}; };

View File

@ -6,16 +6,8 @@ module.exports = function(ClientObservation) {
} }
ClientObservation.observe('before save', function (ctx, next) { ClientObservation.observe('before save', function (ctx, next) {
var loopback = require('loopback');
ctx.instance.creationDate = Date(); ctx.instance.creationDate = Date();
next(); next();
}); });
ClientObservation.on('attached', function() {
var override = ClientObservation.find;
ClientObservation.find = function(filter, callback) {
var elements = override.apply(this, arguments);
//return elements;
elements = null;
}
});
}; };