From 946d08e5432a34e0259ac0fa01e90c5da76780c7 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 20 Jan 2025 17:29:18 +0100 Subject: [PATCH] feat: refs #7119 update ACLs and remove unused models for vehicle management --- .../11394-brownAsparagus/00-firstScript.sql | 2 + modules/route/back/methods/vehicle/filter.js | 10 ++-- modules/route/back/model-config.json | 6 --- modules/route/back/models/fuel-type.json | 2 +- modules/route/back/models/ppe.json | 10 +--- modules/route/back/models/vehicle-event.json | 51 ------------------- modules/route/back/models/vehicle-notes.json | 35 ------------- modules/route/back/models/vehicle-state.json | 10 +--- 8 files changed, 9 insertions(+), 117 deletions(-) delete mode 100644 modules/route/back/models/vehicle-event.json delete mode 100644 modules/route/back/models/vehicle-notes.json diff --git a/db/versions/11394-brownAsparagus/00-firstScript.sql b/db/versions/11394-brownAsparagus/00-firstScript.sql index d02482efd..4d6cedb69 100644 --- a/db/versions/11394-brownAsparagus/00-firstScript.sql +++ b/db/versions/11394-brownAsparagus/00-firstScript.sql @@ -2,4 +2,6 @@ INSERT INTO salix.ACL (model, property, accessType, permission, principalType, p VALUES ('Vehicle', 'filter', 'READ', 'ALLOW', 'ROLE', 'delivery'), ('Vehicle', 'updateAttributes', 'WRITE', 'ALLOW', 'ROLE', 'delivery'), ('BankPolicy', 'find', 'READ', 'ALLOW', 'ROLE', 'delivery'), + ('VehicleState', 'find', 'READ', 'ALLOW', 'ROLE', 'delivery' ), + ('Ppe', 'find', 'READ', 'ALLOW', 'ROLE', 'delivery' ), ('Vehicle', 'deleteById', 'WRITE', 'ALLOW', 'ROLE', 'deliveryBoss'); \ No newline at end of file diff --git a/modules/route/back/methods/vehicle/filter.js b/modules/route/back/methods/vehicle/filter.js index 17c132c2c..ea2a94281 100644 --- a/modules/route/back/methods/vehicle/filter.js +++ b/modules/route/back/methods/vehicle/filter.js @@ -92,9 +92,9 @@ module.exports = Self => { case 'vehicleStateFk': return {vehicleStateFk: value}; } - }); + }) || {}; - const myFilter = mergeFilters(filter, {where}); + const myFilter = mergeFilters(filter, {where: {...where, isActive: true}}); const stmt = new ParameterizedSQL(` SELECT v.id, @@ -122,16 +122,14 @@ module.exports = Self => { FROM vehicleEvent e LEFT JOIN vehicleState s ON e.vehicleStateFk = s.id ) sub ON sub.vehicleFk = v.id AND sub.rn = 1 - ` - ); + `); const sqlWhere = conn.makeWhere(myFilter.where); stmt.merge(sqlWhere); stmt.merge(conn.makePagination(myFilter)); const sql = ParameterizedSQL.join([stmt], ';'); - const result = await conn.executeStmt(sql, myOptions); - return result; + return conn.executeStmt(sql, myOptions); }; }; diff --git a/modules/route/back/model-config.json b/modules/route/back/model-config.json index 07054061f..16e6d6967 100644 --- a/modules/route/back/model-config.json +++ b/modules/route/back/model-config.json @@ -44,12 +44,6 @@ "Vehicle": { "dataSource": "vn" }, - "VehicleEvent": { - "dataSource": "vn" - }, - "VehicleNotes": { - "dataSource": "vn" - }, "VehicleState": { "dataSource": "vn" }, diff --git a/modules/route/back/models/fuel-type.json b/modules/route/back/models/fuel-type.json index c7f96b325..d42614837 100644 --- a/modules/route/back/models/fuel-type.json +++ b/modules/route/back/models/fuel-type.json @@ -23,7 +23,7 @@ { "accessType": "READ", "principalType": "ROLE", - "principalId": "employee", + "principalId": "$everyone", "permission": "ALLOW" } ] diff --git a/modules/route/back/models/ppe.json b/modules/route/back/models/ppe.json index 7af5cb684..0825d348c 100644 --- a/modules/route/back/models/ppe.json +++ b/modules/route/back/models/ppe.json @@ -11,13 +11,5 @@ "type": "number", "id": true } - }, - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "delivery", - "permission": "ALLOW" - } - ] + } } \ No newline at end of file diff --git a/modules/route/back/models/vehicle-event.json b/modules/route/back/models/vehicle-event.json deleted file mode 100644 index 324076723..000000000 --- a/modules/route/back/models/vehicle-event.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "name": "VehicleEvent", - "base": "VnModel", - "options": { - "mysql": { - "table": "vehicleEvent" - } - }, - "properties": { - "id": { - "type": "number", - "id": true - }, - "started": { - "type": "date" - }, - "finished": { - "type": "date" - }, - "vehicleStateFk": { - "type": "number" - }, - "description": { - "type": "string" - }, - "vehicleFk": { - "type": "number" - }, - "userFk": { - "type": "number" - }, - "notified": { - "type": "date" - } - }, - "relations": { - "state": { - "type": "belongsTo", - "model": "VehicleState", - "foreignKey": "vehicleStateFk" - } - }, - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] -} \ No newline at end of file diff --git a/modules/route/back/models/vehicle-notes.json b/modules/route/back/models/vehicle-notes.json deleted file mode 100644 index 922f9b14b..000000000 --- a/modules/route/back/models/vehicle-notes.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "VehicleNotes", - "base": "VnModel", - "options": { - "mysql": { - "table": "vehicleNotes" - } - }, - "properties": { - "id": { - "type": "number", - "id": true - }, - "vehicleFk": { - "type": "number" - }, - "created": { - "type": "date" - }, - "note": { - "type": "string" - }, - "userFk": { - "type": "number" - } - }, - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "delivery", - "permission": "ALLOW" - } - ] -} \ No newline at end of file diff --git a/modules/route/back/models/vehicle-state.json b/modules/route/back/models/vehicle-state.json index 1f71333eb..b53719f63 100644 --- a/modules/route/back/models/vehicle-state.json +++ b/modules/route/back/models/vehicle-state.json @@ -17,13 +17,5 @@ "hasToNotify": { "type": "number" } - }, - "acls": [ - { - "accessType": "READ", - "principalType": "ROLE", - "principalId": "$everyone", - "permission": "ALLOW" - } - ] + } } \ No newline at end of file