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

View File

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

View File

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

View File

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