From 26e514666412348727e1a9b99b7e187796337236 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 18 Oct 2024 07:55:37 +0200 Subject: [PATCH 1/4] fix: refs #4774 model backs --- back/model-config.json | 5 ++++- back/models/companyI18n.json | 22 +++++++++++++++++++ .../11309-pinkGalax/00-firstScript.sql | 3 +++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 back/models/companyI18n.json create mode 100644 db/versions/11309-pinkGalax/00-firstScript.sql diff --git a/back/model-config.json b/back/model-config.json index b6d304675..eda9114ac 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -210,5 +210,8 @@ }, "MrwService": { "dataSource": "vn" + }, + "CompanyI18n": { + "dataSource": "vn" } -} \ No newline at end of file +} diff --git a/back/models/companyI18n.json b/back/models/companyI18n.json new file mode 100644 index 000000000..19fc4aa00 --- /dev/null +++ b/back/models/companyI18n.json @@ -0,0 +1,22 @@ +{ + "name": "CompanyI18n", + "base": "VnModel", + "options": { + "mysql": { + "table": "companyI18n" + } + }, + "properties": { + "companyFk": { + "type": "number", + "id": 1 + }, + "lang": { + "type": "string", + "id": 2 + }, + "footnotes": { + "type": "string" + } + } +} diff --git a/db/versions/11309-pinkGalax/00-firstScript.sql b/db/versions/11309-pinkGalax/00-firstScript.sql new file mode 100644 index 000000000..cfe85ed7c --- /dev/null +++ b/db/versions/11309-pinkGalax/00-firstScript.sql @@ -0,0 +1,3 @@ + +INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) + VALUES ('CompanyI18n','*','*','ALLOW','ROLE','employee'); -- 2.40.1 From 3e0a7b3b6a97038913cfa816dea6a003a4cb3ce5 Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 22 Oct 2024 09:48:53 +0200 Subject: [PATCH 2/4] fix: refs #4774 models and back --- back/model-config.json | 18 +++++++++ back/models/inkI18n.json | 22 +++++++++++ back/models/itemCategoryI18n.json | 22 +++++++++++ back/models/itemTypeI18n.json | 22 +++++++++++ back/models/originI18n.json | 22 +++++++++++ back/models/stateI18n.json | 22 +++++++++++ back/models/tagI18n.json | 22 +++++++++++ .../methods/application/getI18nTables.js | 37 +++++++++++++++++++ loopback/common/models/application.js | 1 + 9 files changed, 188 insertions(+) create mode 100644 back/models/inkI18n.json create mode 100644 back/models/itemCategoryI18n.json create mode 100644 back/models/itemTypeI18n.json create mode 100644 back/models/originI18n.json create mode 100644 back/models/stateI18n.json create mode 100644 back/models/tagI18n.json create mode 100644 loopback/common/methods/application/getI18nTables.js diff --git a/back/model-config.json b/back/model-config.json index eda9114ac..851ae2505 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -213,5 +213,23 @@ }, "CompanyI18n": { "dataSource": "vn" + }, + "ItemTypeI18n": { + "dataSource": "vn" + }, + "InkI18n": { + "dataSource": "vn" + }, + "OriginI18n": { + "dataSource": "vn" + }, + "StateI18n": { + "dataSource": "vn" + }, + "TagI18n": { + "dataSource": "vn" + }, + "itemCategoryI18n": { + "dataSource": "vn" } } diff --git a/back/models/inkI18n.json b/back/models/inkI18n.json new file mode 100644 index 000000000..f808dd9f5 --- /dev/null +++ b/back/models/inkI18n.json @@ -0,0 +1,22 @@ +{ + "name": "InkI18n", + "base": "VnModel", + "options": { + "mysql": { + "table": "inkI18n" + } + }, + "properties": { + "inkFk": { + "type": "number", + "id": 1 + }, + "lang": { + "type": "string", + "id": 2 + }, + "name": { + "type": "string" + } + } +} diff --git a/back/models/itemCategoryI18n.json b/back/models/itemCategoryI18n.json new file mode 100644 index 000000000..3226c923d --- /dev/null +++ b/back/models/itemCategoryI18n.json @@ -0,0 +1,22 @@ +{ + "name": "ItemCategoryI18n", + "base": "VnModel", + "options": { + "mysql": { + "table": "itemCategoryI18n" + } + }, + "properties": { + "categoryFk": { + "type": "number", + "id": 1 + }, + "lang": { + "type": "string", + "id": 2 + }, + "name": { + "type": "string" + } + } +} diff --git a/back/models/itemTypeI18n.json b/back/models/itemTypeI18n.json new file mode 100644 index 000000000..a76cfb933 --- /dev/null +++ b/back/models/itemTypeI18n.json @@ -0,0 +1,22 @@ +{ + "name": "ItemTypeI18n", + "base": "VnModel", + "options": { + "mysql": { + "table": "itemTypeI18n" + } + }, + "properties": { + "typeFk": { + "type": "number", + "id": 1 + }, + "lang": { + "type": "string", + "id": 2 + }, + "name": { + "type": "string" + } + } +} diff --git a/back/models/originI18n.json b/back/models/originI18n.json new file mode 100644 index 000000000..a0066ab49 --- /dev/null +++ b/back/models/originI18n.json @@ -0,0 +1,22 @@ +{ + "name": "OriginI18n", + "base": "VnModel", + "options": { + "mysql": { + "table": "originI18n" + } + }, + "properties": { + "originFk": { + "type": "number", + "id": 1 + }, + "lang": { + "type": "string", + "id": 2 + }, + "name": { + "type": "string" + } + } +} diff --git a/back/models/stateI18n.json b/back/models/stateI18n.json new file mode 100644 index 000000000..b136dc9f3 --- /dev/null +++ b/back/models/stateI18n.json @@ -0,0 +1,22 @@ +{ + "name": "StateI18n", + "base": "VnModel", + "options": { + "mysql": { + "table": "stateI18n" + } + }, + "properties": { + "stateFk": { + "type": "number", + "id": 1 + }, + "lang": { + "type": "string", + "id": 2 + }, + "name": { + "type": "string" + } + } +} diff --git a/back/models/tagI18n.json b/back/models/tagI18n.json new file mode 100644 index 000000000..b1d62ed59 --- /dev/null +++ b/back/models/tagI18n.json @@ -0,0 +1,22 @@ +{ + "name": "TagI18n", + "base": "VnModel", + "options": { + "mysql": { + "table": "tagI18n" + } + }, + "properties": { + "tagFk": { + "type": "number", + "id": 1 + }, + "lang": { + "type": "string", + "id": 2 + }, + "name": { + "type": "string" + } + } +} diff --git a/loopback/common/methods/application/getI18nTables.js b/loopback/common/methods/application/getI18nTables.js new file mode 100644 index 000000000..cd00b09e2 --- /dev/null +++ b/loopback/common/methods/application/getI18nTables.js @@ -0,0 +1,37 @@ +module.exports = Self => { + Self.remoteMethod('getI18nTables', { + description: 'Return tables with name end with i18n', + accessType: 'READ', + accepts: [], + returns: { + type: 'Array', + root: true + }, + http: { + path: `/get-i18n-tables`, + verb: 'GET' + } + }); + + Self.getI18nTables = async() => { + const tables = await Self.rawSql(` + SELECT c.table_name tableName, c.column_name primaryKey + FROM information_schema.columns c + WHERE + c.table_name LIKE '%i18n' + AND c.COLUMN_KEY = 'PRI' + AND c.COLUMN_NAME <> 'lang'`); + + const columns = await Self.rawSql(` + SELECT c.table_name tableName, c.column_name field + FROM information_schema.columns c + WHERE + c.table_name LIKE '%i18n' + AND c.COLUMN_KEY <> 'PRI' + `); + + for (const column of columns) + tables.find(t => t.tableName == column.tableName).field = column.field; + return tables; + }; +}; diff --git a/loopback/common/models/application.js b/loopback/common/models/application.js index 80c58ddc1..38e58d5ee 100644 --- a/loopback/common/models/application.js +++ b/loopback/common/models/application.js @@ -5,4 +5,5 @@ module.exports = function(Self) { require('../methods/application/executeProc')(Self); require('../methods/application/executeFunc')(Self); require('../methods/application/getEnumValues')(Self); + require('../methods/application/getI18nTables')(Self); }; -- 2.40.1 From 417305bf8288214dce3b2e1a158e8f48b8a8637f Mon Sep 17 00:00:00 2001 From: carlossa Date: Tue, 22 Oct 2024 10:38:18 +0200 Subject: [PATCH 3/4] fix: refs #4774 translations --- back/model-config.json | 2 +- db/dump/fixtures.before.sql | 45 +++++++++++++++++-- .../11309-pinkGalax/00-firstScript.sql | 12 ++++- 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/back/model-config.json b/back/model-config.json index 851ae2505..bdcfe0090 100644 --- a/back/model-config.json +++ b/back/model-config.json @@ -229,7 +229,7 @@ "TagI18n": { "dataSource": "vn" }, - "itemCategoryI18n": { + "ItemCategoryI18n": { "dataSource": "vn" } } diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 7f7e50dd3..e7866251b 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -3943,9 +3943,9 @@ INSERT INTO vn.medicalReview (id, workerFk, centerFk, `date`, `time`, isFit, amount, invoice, remark) VALUES(3, 9, 2, '2000-01-01', '8:00', 1, 150.0, NULL, NULL); -INSERT INTO vn.stockBought (workerFk, bought, reserve, dated) - VALUES(35, 1.00, 1.00, '2001-01-01'); -INSERT INTO vn.auctionConfig (id,conversionCoefficient,warehouseFk) +INSERT INTO vn.stockBought (workerFk, bought, reserve, dated) + VALUES(35, 1.00, 1.00, '2001-01-01'); +INSERT INTO vn.auctionConfig (id,conversionCoefficient,warehouseFk) VALUES (1,0.6,6); INSERT INTO vn.payrollComponent @@ -4010,4 +4010,41 @@ INSERT IGNORE INTO pbx.queueMember UPDATE vn.department SET pbxQueue = '1000' WHERE name = "CAMARA"; UPDATE vn.department SET pbxQueue = '2000' WHERE name = "VENTAS"; - +INSERT INTO vn.itemTypeI18n (typeFk, lang, name) +VALUES + (1, 'ca', 'Alstroemeria'), + (1, 'en', 'Alstroemeria'), + (1, 'fr', 'Alstroemeria'), + (1, 'pt', 'Alstroemeria'), + (2, 'ca', 'Anthurium'), + (2, 'en', 'Anthurium'), + (2, 'fr', 'Anthurium'), + (2, 'pt', 'Antúrios'), + (3, 'ca', 'Bulbs'), + (3, 'en', 'Bulbs'), + (3, 'fr', 'Bulbes'), + (3, 'pt', 'Bulbos'), + (4, 'ca', 'Cales'), + (4, 'en', 'Calla Lilies'), + (4, 'fr', 'Calas'), + (4, 'pt', 'Jarros (callas)'), + (5, 'ca', 'Clavell'), + (5, 'en', 'Carnation'), + (5, 'fr', 'Oeillet'), + (5, 'pt', 'Cravo'), + (6, 'ca', 'Crisantem'), + (6, 'en', 'Chrysanthemum'), + (6, 'fr', 'Chrysanthème'), + (6, 'pt', 'Margaridas'), + (7, 'ca', 'Rams Variats'), + (7, 'en', 'Mixed Bouquets'), + (7, 'fr', 'Bouquets divers'), + (7, 'pt', 'Bouquet Variados'), + (8, 'ca', 'Flor Variada'), + (8, 'en', 'Assorted Flowers'), + (8, 'fr', 'Fleurs varié'), + (8, 'pt', 'Flores Variadas'), + (9, 'ca', 'Crisantem Santa Dorotea'), + (9, 'en', 'Santa Dorotea Chrysanthemum'), + (9, 'fr', 'Chrysanthème Santa Dorotea'), + (9, 'pt', 'Crisântemo Santa Dorotea'); diff --git a/db/versions/11309-pinkGalax/00-firstScript.sql b/db/versions/11309-pinkGalax/00-firstScript.sql index cfe85ed7c..287449792 100644 --- a/db/versions/11309-pinkGalax/00-firstScript.sql +++ b/db/versions/11309-pinkGalax/00-firstScript.sql @@ -1,3 +1,13 @@ INSERT INTO salix.ACL (model,property,accessType,permission,principalType,principalId) - VALUES ('CompanyI18n','*','*','ALLOW','ROLE','employee'); + VALUES + ('CompanyI18n','*','*','ALLOW','ROLE','employee'), + ('ItemTypeI18n','*','*','ALLOW','ROLE','employee'), + ('InkI18n','*','*','ALLOW','ROLE','employee'), + ('OriginI18n','*','*','ALLOW','ROLE','employee'), + ('StateI18n','*','*','ALLOW','ROLE','employee'), + ('TagI18n','*','*','ALLOW','ROLE','employee'), + ('itemCategoryI18n','*','*','ALLOW','ROLE','employee'); + + + -- 2.40.1 From 75abc3c865d84133ed3e9d5ce5f91764b38d6a18 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 28 Oct 2024 11:52:56 +0100 Subject: [PATCH 4/4] fix: refs #4774 back id + remove --- back/models/companyI18n.json | 4 + back/models/inkI18n.json | 4 + back/models/itemCategoryI18n.json | 4 + back/models/itemTypeI18n.json | 5 + back/models/originI18n.json | 4 + back/models/stateI18n.json | 4 + back/models/tagI18n.json | 4 + db/dump/fixtures.before.sql | 98 +++++++++++++++++++ .../11309-pinkGalax/00-firstScript.sql | 19 ++++ .../methods/application/getI18nTables.js | 2 + 10 files changed, 148 insertions(+) diff --git a/back/models/companyI18n.json b/back/models/companyI18n.json index 19fc4aa00..0c7dd98e4 100644 --- a/back/models/companyI18n.json +++ b/back/models/companyI18n.json @@ -7,6 +7,10 @@ } }, "properties": { + "id": { + "type": "number", + "id": true + }, "companyFk": { "type": "number", "id": 1 diff --git a/back/models/inkI18n.json b/back/models/inkI18n.json index f808dd9f5..f5f1ffb2b 100644 --- a/back/models/inkI18n.json +++ b/back/models/inkI18n.json @@ -7,6 +7,10 @@ } }, "properties": { + "id": { + "type": "number", + "id": true + }, "inkFk": { "type": "number", "id": 1 diff --git a/back/models/itemCategoryI18n.json b/back/models/itemCategoryI18n.json index 3226c923d..ad206b1ca 100644 --- a/back/models/itemCategoryI18n.json +++ b/back/models/itemCategoryI18n.json @@ -7,6 +7,10 @@ } }, "properties": { + "id": { + "type": "number", + "id": true + }, "categoryFk": { "type": "number", "id": 1 diff --git a/back/models/itemTypeI18n.json b/back/models/itemTypeI18n.json index a76cfb933..c3ea723f9 100644 --- a/back/models/itemTypeI18n.json +++ b/back/models/itemTypeI18n.json @@ -7,6 +7,7 @@ } }, "properties": { + "typeFk": { "type": "number", "id": 1 @@ -17,6 +18,10 @@ }, "name": { "type": "string" + }, + "id": { + "type": "number", + "id": true } } } diff --git a/back/models/originI18n.json b/back/models/originI18n.json index a0066ab49..ed5f240db 100644 --- a/back/models/originI18n.json +++ b/back/models/originI18n.json @@ -7,6 +7,10 @@ } }, "properties": { + "id": { + "type": "number", + "id": true + }, "originFk": { "type": "number", "id": 1 diff --git a/back/models/stateI18n.json b/back/models/stateI18n.json index b136dc9f3..52cb8415b 100644 --- a/back/models/stateI18n.json +++ b/back/models/stateI18n.json @@ -7,6 +7,10 @@ } }, "properties": { + "id": { + "type": "number", + "id": true + }, "stateFk": { "type": "number", "id": 1 diff --git a/back/models/tagI18n.json b/back/models/tagI18n.json index b1d62ed59..842512632 100644 --- a/back/models/tagI18n.json +++ b/back/models/tagI18n.json @@ -7,6 +7,10 @@ } }, "properties": { + "id": { + "type": "number", + "id": true + }, "tagFk": { "type": "number", "id": 1 diff --git a/db/dump/fixtures.before.sql b/db/dump/fixtures.before.sql index 9724ff75d..f03dca5b8 100644 --- a/db/dump/fixtures.before.sql +++ b/db/dump/fixtures.before.sql @@ -4056,3 +4056,101 @@ VALUES (9, 'en', 'Santa Dorotea Chrysanthemum'), (9, 'fr', 'Chrysanthème Santa Dorotea'), (9, 'pt', 'Crisântemo Santa Dorotea'); + +INSERT INTO vn.inkI18n (inkFk, lang, name) +VALUES + ('?', 'ca', 'Sense especificar'), + ('?', 'en', 'Unspecified'), + ('?', 'fr', 'Indéterminé'), + ('?', 'mn', 'тодорхойгүй'), + ('?', 'pt', 'Não especificado'), + ('2C', 'ca', '2 Colors'), + ('2C', 'en', '2 Colour'), + ('2C', 'fr', '2 Couleur'), + ('2C', 'mn', '2 Өнгө'), + ('2C', 'pt', '2 Cor'), + ('A/M', 'ca', 'Groc / Marró'), + ('A/M', 'en', 'Yellow / Brown'), + ('A/M', 'fr', 'Yellow / Brown'), + ('A/M', 'mn', 'Шар / Браун'), + ('A/M', 'pt', 'Yellow / Brown'), + ('A/N', 'ca', 'Groc / Taronja'), + ('A/N', 'en', 'Yellow orange'), + ('A/N', 'fr', 'Jaune / Orange'), + ('A/N', 'mn', 'Шар / Улбар шар'), + ('A/N', 'pt', 'Amarelo / Laranja'); + +INSERT INTO vn.itemCategoryI18n (categoryFk, lang, name) +VALUES + (1, 'ca', 'Flor'), + (1, 'en', 'Flower'), + (1, 'fr', 'Fleur'), + (1, 'mn', 'цэцэг'), + (1, 'pt', 'Flores'), + (2, 'ca', 'Planta'), + (2, 'en', 'Plant'), + (2, 'fr', 'Plante'), + (2, 'mn', 'станц'), + (2, 'pt', 'Plantas'), + (3, 'ca', 'Complements'), + (3, 'en', 'Accessories'), + (3, 'fr', 'Accessoires'), + (3, 'mn', 'Дагалдах хэрэгсэл'), + (3, 'pt', 'Acessórios'), + (4, 'ca', 'Artificial'), + (4, 'en', 'Artificial'), + (4, 'fr', 'Artificielle'), + (4, 'mn', 'Хиймэл'), + (4, 'pt', 'Artificial'), + (5, 'ca', 'Verds'), + (5, 'en', 'Green'), + (5, 'fr', 'Vert'), + (5, 'mn', 'ногоон'), + (5, 'pt', 'Verdes'); + +INSERT INTO vn.originI18n (originFk, lang, name) +VALUES + (1, 'ca', 'Chollolandia'), + (1, 'en', 'Chollolandia'), + (1, 'fr', 'Chollolandia'), + (1, 'mn', 'Chollolandia'), + (1, 'pt', 'Chollolandia'), + (2, 'ca', 'Alemanya'), + (2, 'en', 'Germany'), + (2, 'fr', 'Allemagne'), + (2, 'mn', 'Герман'), + (2, 'pt', 'Alemanha'), + (3, 'ca', 'Almeria'), + (3, 'en', 'Almeria'), + (3, 'fr', 'Almeria'), + (3, 'mn', 'Зугаа'), + (3, 'pt', 'Almeria'), + (4, 'ca', 'Austràlia'), + (4, 'en', 'Australia'), + (4, 'fr', 'Australie'), + (4, 'mn', 'Австрали'), + (4, 'pt', 'Austrália'), + (5, 'ca', 'canada'), + (5, 'en', 'Canada'), + (5, 'fr', 'Canada'), + (5, 'mn', 'Канад'), + (5, 'pt', 'Canadá'); + +INSERT INTO vn.stateI18n (stateFk, lang, name) +VALUES + (1, 'en', 'Fix'), + (1, 'es', 'Arreglar'), + (2, 'en', 'Free'), + (2, 'es', 'Libre'), + (3, 'en', 'OK'), + (3, 'es', 'OK'), + (4, 'en', 'Printed'), + (4, 'es', 'Impreso'), + (5, 'en', 'Preparation'), + (5, 'es', 'Preparación'), + (6, 'en', 'In Review'), + (6, 'es', 'En Revisión'), + (7, 'en', 'Unfinished'), + (7, 'es', 'Sin Acabar'); + + diff --git a/db/versions/11309-pinkGalax/00-firstScript.sql b/db/versions/11309-pinkGalax/00-firstScript.sql index 287449792..feb3e424b 100644 --- a/db/versions/11309-pinkGalax/00-firstScript.sql +++ b/db/versions/11309-pinkGalax/00-firstScript.sql @@ -10,4 +10,23 @@ INSERT INTO salix.ACL (model,property,accessType,permission,principalType,princi ('itemCategoryI18n','*','*','ALLOW','ROLE','employee'); +ALTER TABLE vn.companyI18n + ADD id INT AUTO_INCREMENT UNIQUE; +ALTER TABLE vn.inkI18n + ADD id INT AUTO_INCREMENT UNIQUE; + +ALTER TABLE vn.itemCategoryI18n + ADD id INT AUTO_INCREMENT UNIQUE; + +ALTER TABLE vn.itemTypeI18n + ADD id INT AUTO_INCREMENT UNIQUE; + +ALTER TABLE vn.originI18n + ADD id INT AUTO_INCREMENT UNIQUE; + +ALTER TABLE vn.stateI18n + ADD id INT AUTO_INCREMENT UNIQUE; + +ALTER TABLE vn.tagI18n + ADD id INT AUTO_INCREMENT UNIQUE; diff --git a/loopback/common/methods/application/getI18nTables.js b/loopback/common/methods/application/getI18nTables.js index cd00b09e2..2756450a7 100644 --- a/loopback/common/methods/application/getI18nTables.js +++ b/loopback/common/methods/application/getI18nTables.js @@ -20,6 +20,7 @@ module.exports = Self => { WHERE c.table_name LIKE '%i18n' AND c.COLUMN_KEY = 'PRI' + AND c.column_name <> 'id' AND c.COLUMN_NAME <> 'lang'`); const columns = await Self.rawSql(` @@ -28,6 +29,7 @@ module.exports = Self => { WHERE c.table_name LIKE '%i18n' AND c.COLUMN_KEY <> 'PRI' + AND c.column_name <> 'id' `); for (const column of columns) -- 2.40.1