Skip to content

Commit

Permalink
Merge pull request #5 from natrontech/tidy
Browse files Browse the repository at this point in the history
feat: enhance download of CSV for admin user
  • Loading branch information
janlauber authored Jun 30, 2024
2 parents d555a53 + 42d9057 commit 72538a2
Show file tree
Hide file tree
Showing 16 changed files with 575 additions and 376 deletions.
33 changes: 33 additions & 0 deletions pb/pb_migrations/1719742575_updated_users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("_pb_users_auth_")

// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "61gndav1",
"name": "role",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"user",
"admin"
]
}
}))

return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("_pb_users_auth_")

// remove
collection.schema.removeField("61gndav1")

return dao.saveCollection(collection)
})
18 changes: 18 additions & 0 deletions pb/pb_migrations/1719742705_updated_expenses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("frv5fa0d678jb4c")

collection.listRule = "@request.auth.id != \"\" && (@request.auth.id = user.id || @request.auth.role = \"admin\")\n"
collection.viewRule = "@request.auth.id != \"\" && (@request.auth.id = user.id || @request.auth.role = \"admin\")\n"

return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("frv5fa0d678jb4c")

collection.listRule = "@request.auth.id != \"\" && @request.auth.id = user.id"
collection.viewRule = "@request.auth.id != \"\" && @request.auth.id = user.id"

return dao.saveCollection(collection)
})
18 changes: 18 additions & 0 deletions pb/pb_migrations/1719742711_updated_expenses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("frv5fa0d678jb4c")

collection.listRule = "@request.auth.id != \"\" && (@request.auth.id = user.id || @request.auth.role = \"admin\")"
collection.viewRule = "@request.auth.id != \"\" && (@request.auth.id = user.id || @request.auth.role = \"admin\")"

return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("frv5fa0d678jb4c")

collection.listRule = "@request.auth.id != \"\" && (@request.auth.id = user.id || @request.auth.role = \"admin\")\n"
collection.viewRule = "@request.auth.id != \"\" && (@request.auth.id = user.id || @request.auth.role = \"admin\")\n"

return dao.saveCollection(collection)
})
48 changes: 48 additions & 0 deletions pb/pb_migrations/1719742738_updated_users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("_pb_users_auth_")

// remove
collection.schema.removeField("61gndav1")

// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "ntdnwymg",
"name": "admin",
"type": "bool",
"required": false,
"presentable": false,
"unique": false,
"options": {}
}))

return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("_pb_users_auth_")

// add
collection.schema.addField(new SchemaField({
"system": false,
"id": "61gndav1",
"name": "role",
"type": "select",
"required": false,
"presentable": false,
"unique": false,
"options": {
"maxSelect": 1,
"values": [
"user",
"admin"
]
}
}))

// remove
collection.schema.removeField("ntdnwymg")

return dao.saveCollection(collection)
})
18 changes: 18 additions & 0 deletions pb/pb_migrations/1719742767_updated_expenses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("frv5fa0d678jb4c")

collection.listRule = "@request.auth.id != \"\" && (@request.auth.id = user.id || @request.auth.admin = true)"
collection.viewRule = "@request.auth.id != \"\" && (@request.auth.id = user.id || @request.auth.admin = true)"

return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("frv5fa0d678jb4c")

collection.listRule = "@request.auth.id != \"\" && (@request.auth.id = user.id || @request.auth.role = \"admin\")"
collection.viewRule = "@request.auth.id != \"\" && (@request.auth.id = user.id || @request.auth.role = \"admin\")"

return dao.saveCollection(collection)
})
18 changes: 18 additions & 0 deletions pb/pb_migrations/1719743138_updated_users.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/// <reference path="../pb_data/types.d.ts" />
migrate((db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("_pb_users_auth_")

collection.listRule = "id = @request.auth.id || @request.auth.admin = true"
collection.viewRule = "id = @request.auth.id || @request.auth.admin = true"

return dao.saveCollection(collection)
}, (db) => {
const dao = new Dao(db)
const collection = dao.findCollectionByNameOrId("_pb_users_auth_")

collection.listRule = "id = @request.auth.id"
collection.viewRule = "id = @request.auth.id"

return dao.saveCollection(collection)
})
Loading

0 comments on commit 72538a2

Please sign in to comment.