-
{{n.date}}
+
+
{{n.creationDate}} {{n.salesPerson}}
>{{n.text}}
{{notes.client.notes}}
diff --git a/@salix/crud/src/client/notes/index.js b/@salix/crud/src/client/notes/index.js
index c8d51e132..3f8356074 100644
--- a/@salix/crud/src/client/notes/index.js
+++ b/@salix/crud/src/client/notes/index.js
@@ -4,23 +4,57 @@ import {module} from '../../module';
export const NAME = 'vnClientNotes';
export const COMPONENT = {
template: template,
- controllerAs: 'notes',
+ controllerAs: 'observation',
bindings: {
client: '<'
},
- controller: function($http) {
- this.notes = [];
- this.submit = function() {
- this.notes.push({
- text: this.newNote,
- salesPerson: 'user'
- });
+ controller: function($http, copyObject, equalsObject, $transitions, $element) {
+ var self = this;
+ var deregister = $transitions.onStart({ }, callback);
- $http.put('/client/api/ClientObservation', this.client).then(() => {
- this.newNote = "";
- });
+ this.submit = function() {
+ if (this.newNote) {
+ this.client.modify = "ClientObservation";
+ let observation = {
+ client: this.client.id,
+ text: this.newNote,
+ salesPerson: 'user'
+ };
+ this.observations.unshift(observation);
+
+ $http.put('/client/api/ClientObservations', observation).then(() => {
+ this.newNote = "";
+ });
+ }
+ };
+ 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.getObservation = function(clientId) {
+ let json = JSON.stringify({where: {client: this.client.id}});
+ $http.get(`/client/api/clientObservations?filter=${json}`).then(
+ json => {
+ this.observations = json.data;
+ }
+ );
};
}
};
-COMPONENT.controller.$inject = ['$http'];
+COMPONENT.controller.$inject = ['$http', 'copyObject', 'equalsObject', '$transitions', '$element'];
module.component(NAME, COMPONENT);
diff --git a/@salix/crud/src/client/routes.js b/@salix/crud/src/client/routes.js
index 23dd0d3f1..fa5a6f07d 100644
--- a/@salix/crud/src/client/routes.js
+++ b/@salix/crud/src/client/routes.js
@@ -31,6 +31,9 @@
url: "/addresses",
state: "clientCard.addresses",
component: "vn-client-addresses",
+ params: {
+ client: "card.client"
+ },
description: "Consignatarios",
icon: "local_shipping"
}, {
diff --git a/@salix/package.json b/@salix/package.json
index e9520bc8d..bee8f861f 100644
--- a/@salix/package.json
+++ b/@salix/package.json
@@ -10,6 +10,7 @@
},
"dependencies": {
"angular": "^1.5.8",
+ "angular-paging": "^2.2.2",
"angular-translate": "^2.13.1",
"angular-ui-router": "^1.0.0-beta.3",
"express": "^4.14.0",
diff --git a/@salix/vendor/src/angular-paging.js b/@salix/vendor/src/angular-paging.js
new file mode 100644
index 000000000..52c3085aa
--- /dev/null
+++ b/@salix/vendor/src/angular-paging.js
@@ -0,0 +1,5 @@
+import * as _ngPaging from 'angular-paging';
+
+export const ngPaging = {
+ name: 'bw.paging'
+};
diff --git a/@salix/vendor/src/vendor.js b/@salix/vendor/src/vendor.js
index 740587725..a6667d6d6 100644
--- a/@salix/vendor/src/vendor.js
+++ b/@salix/vendor/src/vendor.js
@@ -2,4 +2,5 @@ export * from './angular-vendor';
export * from './oclazyload-vendor';
export * from './uirouter-vendor';
export * from './angular-translate-vendor';
-export * from './materialdesignlite-vendor';
\ No newline at end of file
+export * from './materialdesignlite-vendor';
+export * from './angular-paging';
\ No newline at end of file
diff --git a/db.json b/db.json
index c5f833f7d..91d306c41 100644
--- a/db.json
+++ b/db.json
@@ -9,7 +9,8 @@
"Country": 3,
"Province": 3,
"Agency": 4,
- "Account": 14
+ "Account": 14,
+ "ClientObservation": 1248
},
"models": {
"User": {
@@ -54,6 +55,15 @@
"Account": {
"12": "{\"id\":12,\"name\":\"prueba12\",\"active\":false,\"user\":\"juanete\"}",
"13": "{\"id\":13,\"name\":\"manu\",\"active\":false,\"user\":\"joselito\"}"
+ },
+ "ClientObservation": {
+ "12": "{\"id\":12,\"text\":\"prueba12\"}",
+ "41": "{\"id\":41,\"text\":\"text41\",\"creationDate\":\"2017-01-17T00:00:00.000Z\",\"client\":12,\"sdfopi\":24}",
+ "1243": "{\"id\":1243,\"text\":\"string\",\"creationDate\":\"2017-01-17T00:00:00.000Z\",\"relations\":{\"clientId\":12},\"client\":1289034237891}",
+ "1244": "{\"text\":\"asdf\",\"client\":12,\"salesPerson\":\"user\",\"id\":1244}",
+ "1245": "{\"text\":\"asdf\",\"client\":12,\"salesPerson\":\"user\",\"id\":1245}",
+ "1246": "{\"text\":\"asdf\",\"client\":12,\"salesPerson\":\"user\",\"id\":1246}",
+ "1247": "{\"text\":\"zzzz\",\"client\":12,\"salesPerson\":\"user\",\"id\":1247}"
}
}
}
\ No newline at end of file
diff --git a/services/client/common/models/Address.json b/services/client/common/models/Address.json
index 69ab68a20..9a60529e5 100644
--- a/services/client/common/models/Address.json
+++ b/services/client/common/models/Address.json
@@ -49,6 +49,11 @@
"type": "belongsTo",
"model": "Province",
"foreignKey": "provinceId"
+ },
+ "client": {
+ "type": "belongsTo",
+ "model":"Client",
+ "foreignKey": "clientId"
}
}
}
diff --git a/services/client/common/models/ClientObservation.json b/services/client/common/models/ClientObservation.json
index 380c752d5..bca37a29f 100644
--- a/services/client/common/models/ClientObservation.json
+++ b/services/client/common/models/ClientObservation.json
@@ -24,9 +24,9 @@
"foreignKey": "salePersonId"
},
"client": {
- "type": "belongsTo",
"model": "Client",
- "foreignKey": "clientId"
+ "type": "belongsTo",
+ "foreignKey": "id"
}
}
}
diff --git a/services/nginx/logs/error.log b/services/nginx/logs/error.log
index 34c0b0e91..829a7a1c9 100644
--- a/services/nginx/logs/error.log
+++ b/services/nginx/logs/error.log
@@ -51,3 +51,5 @@
2017/01/13 15:37:25 [notice] 5088#9876: signal process started
2017/01/16 07:49:58 [notice] 9028#8132: signal process started
2017/01/16 08:26:22 [notice] 1256#3772: signal process started
+2017/01/17 13:27:35 [notice] 7104#204: signal process started
+2017/01/17 13:38:00 [notice] 1592#8484: signal process started