diff --git a/modules/entry/back/model-config.json b/modules/entry/back/model-config.json index 0e37b947f..eddef9c41 100644 --- a/modules/entry/back/model-config.json +++ b/modules/entry/back/model-config.json @@ -7,5 +7,8 @@ }, "EntryLog": { "dataSource": "vn" + }, + "EntryObservation": { + "dataSource": "vn" } } diff --git a/modules/entry/back/models/entry-observation.js b/modules/entry/back/models/entry-observation.js new file mode 100644 index 000000000..77d15d85c --- /dev/null +++ b/modules/entry/back/models/entry-observation.js @@ -0,0 +1,9 @@ +const UserError = require('vn-loopback/util/user-error'); + +module.exports = Self => { + Self.rewriteDbError(function(err) { + if (err.code === 'ER_DUP_ENTRY') + return new UserError(`The observation type can't be repeated`); + return err; + }); +}; diff --git a/modules/entry/back/models/entry-observation.json b/modules/entry/back/models/entry-observation.json new file mode 100644 index 000000000..87d3fd964 --- /dev/null +++ b/modules/entry/back/models/entry-observation.json @@ -0,0 +1,38 @@ +{ + "name": "EntryObservation", + "base": "Loggable", + "log": { + "model": "EntryLog", + "relation": "entry" + }, + "options": { + "mysql": { + "table": "entryObservation" + } + }, + "properties": { + "id": { + "id": true, + "type": "Number", + "description": "Identifier" + }, + "description": { + "type": "String", + "required": true + } + }, + "relations": { + "entry": { + "type": "belongsTo", + "model": "Entry", + "foreignKey": "entryFk", + "required": true + }, + "observationType": { + "type": "belongsTo", + "model": "ObservationType", + "foreignKey": "observationTypeFk", + "required": true + } + } +} diff --git a/modules/entry/front/index.js b/modules/entry/front/index.js index e92f23fc1..14aecc8db 100644 --- a/modules/entry/front/index.js +++ b/modules/entry/front/index.js @@ -10,6 +10,7 @@ import './latest-buys-search-panel'; import './descriptor'; import './descriptor-popover'; import './card'; +import './note'; import './summary'; import './log'; import './buy'; diff --git a/modules/entry/front/note/index.html b/modules/entry/front/note/index.html new file mode 100644 index 000000000..5f3c7f77e --- /dev/null +++ b/modules/entry/front/note/index.html @@ -0,0 +1,72 @@ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/modules/entry/front/note/index.js b/modules/entry/front/note/index.js new file mode 100644 index 000000000..fccd60913 --- /dev/null +++ b/modules/entry/front/note/index.js @@ -0,0 +1,20 @@ +import ngModule from '../module'; +import Section from 'salix/components/section'; + +class Controller extends Section { + onSubmit() { + this.$.watcher.check(); + this.$.model.save().then(() => { + this.$.watcher.notifySaved(); + this.$.watcher.updateOriginalData(); + }); + } +} + +ngModule.vnComponent('vnEntryObservation', { + template: require('./index.html'), + controller: Controller, + bindings: { + entry: '<' + } +}); diff --git a/modules/entry/front/routes.json b/modules/entry/front/routes.json index a430a95fa..010e738b3 100644 --- a/modules/entry/front/routes.json +++ b/modules/entry/front/routes.json @@ -12,6 +12,7 @@ "card": [ {"state": "entry.card.basicData", "icon": "settings"}, {"state": "entry.card.buy", "icon": "icon-lines"}, + {"state": "entry.card.observation", "icon": "insert_drive_file"}, {"state": "entry.card.log", "icon": "history"} ] }, @@ -61,7 +62,15 @@ "params": { "entry": "$ctrl.entry" } - }, { + },{ + "url": "/observation", + "state": "entry.card.observation", + "component": "vn-entry-observation", + "description": "Notes", + "params": { + "entry": "$ctrl.entry" + } + },{ "url" : "/log", "state": "entry.card.log", "component": "vn-entry-log",