diff --git a/back/model-config.json b/back/model-config.json index 5368769fd..73db0a31b 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -79,6 +79,9 @@ "ImageCollectionSize": { "dataSource": "vn" }, + "ImageConfig": { + "dataSource": "vn" + }, "ImageContainer": { "dataSource": "imageStorage" }, diff --git a/back/models/image-config.json b/back/models/image-config.json new file mode 100644 index 000000000..11f4c2284 --- /dev/null +++ b/back/models/image-config.json @@ -0,0 +1,22 @@ +{ + "name": "ImageConfig", + "base": "VnModel", + "options": { + "mysql": { + "table": "hedera.imageConfig" + } + }, + "properties": { + "url": { + "type": "string" + } + }, + "acls": [ + { + "accessType": "READ", + "principalType": "ROLE", + "principalId": "$authenticated", + "permission": "ALLOW" + } + ] +} \ No newline at end of file diff --git a/modules/item/back/methods/item-shelving/getItems.js b/modules/item/back/methods/item-shelving/getItems.js deleted file mode 100644 index 2fe50d785..000000000 --- a/modules/item/back/methods/item-shelving/getItems.js +++ /dev/null @@ -1,51 +0,0 @@ -module.exports = Self => { - Self.remoteMethod('getItems', { - description: 'shelving item list', - accessType: 'READ', - accepts: [{ - arg: 'code', - type: 'string', - required: true, - description: 'Shelving code' - }], - returns: { - type: 'object', - root: true - }, - http: { - path: `/getItems`, - verb: 'GET' - } - }); - - Self.getItems = async(code, options) => { - const models = Self.app.models; - const myOptions = {}; - if (typeof options == 'object') - Object.assign(myOptions, options); - - const shelving = await models.Shelving.findOne({ - fields: ['priority', 'parkingFk'], - include: { - relation: 'parking', - scope: {fields: ['code']} - }, - where: {code} - }, myOptions); - - const itemShelvings = await Self.find({ - fields: ['itemFk', 'visible', 'packing', 'grouping', 'isChecked', 'available', 'buyFk'], - include: { - relation: 'item', - scope: {fields: ['name', 'longName', 'size']} - }, - where: {shelvingFk: code} - }, myOptions); - return { - code: shelving.parking().code, - priority: shelving.priority, - itemShelvings, - }; - // Add image from hedera.imageConfig - }; -}; diff --git a/modules/item/back/models/item-shelving.js b/modules/item/back/models/item-shelving.js index ba6ab780d..be72dac37 100644 --- a/modules/item/back/models/item-shelving.js +++ b/modules/item/back/models/item-shelving.js @@ -5,5 +5,4 @@ module.exports = Self => { require('../methods/item-shelving/getAlternative')(Self); require('../methods/item-shelving/updateFromSale')(Self); require('../methods/item-shelving/getListItemNewer')(Self); - require('../methods/item-shelving/getItems')(Self); }; diff --git a/modules/item/back/models/item-shelving.json b/modules/item/back/models/item-shelving.json index 5df3b0703..b0e3f17fa 100644 --- a/modules/item/back/models/item-shelving.json +++ b/modules/item/back/models/item-shelving.json @@ -41,6 +41,9 @@ }, "available": { "type": "number" + }, + "buyFk": { + "type": "number" } }, "relations": { diff --git a/modules/shelving/back/models/shelving.json b/modules/shelving/back/models/shelving.json index 46fce31e8..f6df57d43 100644 --- a/modules/shelving/back/models/shelving.json +++ b/modules/shelving/back/models/shelving.json @@ -1,6 +1,6 @@ { "name": "Shelving", - "base": "VnModel", + "base": "VnModel", "mixins": { "Loggable": true }, @@ -44,6 +44,12 @@ "type": "belongsTo", "model": "Worker", "foreignKey": "id" + }, + "itemShelving": { + "type": "hasMany", + "model": "ItemShelving", + "foreignKey": "shelvingFk", + "primaryKey": "code" } } -} +} \ No newline at end of file