-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from astoria-tech/azlyth/bunch-o-updates
Add store roles, vendor dashboard and inventory manager, and misc page updates
- Loading branch information
Showing
53 changed files
with
4,239 additions
and
762 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("_pb_users_auth_"); | ||
|
||
// add roles field | ||
collection.fields.addAt(0, new Field({ | ||
"system": false, | ||
"id": "roles", | ||
"name": "roles", | ||
"type": "select", | ||
"required": false, | ||
"presentable": false, | ||
"unique": false, | ||
"maxSelect": 3, | ||
"values": [ | ||
"admin", | ||
"delivery", | ||
"vendor" | ||
] | ||
})); | ||
|
||
return app.save(collection); | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("_pb_users_auth_"); | ||
|
||
// remove roles field | ||
collection.fields.removeById("roles"); | ||
|
||
return app.save(collection); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("_pb_users_auth_"); | ||
|
||
// Update view rule to allow admin users to view all user data | ||
collection.viewRule = '@request.auth.roles ?= "admin" || @request.auth.id = id'; | ||
|
||
// Update list rule to allow admin users to list all users | ||
collection.listRule = '@request.auth.roles ?= "admin" || @request.auth.id = id'; | ||
|
||
return app.save(collection); | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("_pb_users_auth_"); | ||
|
||
// Revert to default rules | ||
collection.viewRule = '@request.auth.id = id'; | ||
collection.listRule = '@request.auth.id = id'; | ||
|
||
return app.save(collection); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("orders"); | ||
|
||
// Update view rule to allow admin users to view all orders and their expanded data | ||
collection.viewRule = '@request.auth.roles ?= "admin" || user.id = @request.auth.id'; | ||
|
||
// Update list rule to allow admin users to list all orders | ||
collection.listRule = '@request.auth.roles ?= "admin" || user.id = @request.auth.id'; | ||
|
||
// Update expand rule to allow admin users to expand all relations | ||
collection.options = { | ||
...collection.options, | ||
expandRule: '@request.auth.roles ?= "admin" || user.id = @request.auth.id' | ||
}; | ||
|
||
return app.save(collection); | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("orders"); | ||
|
||
// Revert to default rules | ||
collection.viewRule = 'user.id = @request.auth.id'; | ||
collection.listRule = 'user.id = @request.auth.id'; | ||
collection.options = { | ||
...collection.options, | ||
expandRule: 'user.id = @request.auth.id' | ||
}; | ||
|
||
return app.save(collection); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = new Collection({ | ||
"id": "store_roles", | ||
"name": "store_roles", | ||
"type": "base", | ||
"system": false, | ||
"fields": [ | ||
{ | ||
"id": "user_relation", | ||
"name": "user", | ||
"type": "relation", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"cascadeDelete": true, | ||
"collectionId": "_pb_users_auth_", | ||
"maxSelect": 1, | ||
"minSelect": 1 | ||
}, | ||
{ | ||
"id": "store_relation", | ||
"name": "store", | ||
"type": "relation", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"cascadeDelete": true, | ||
"collectionId": "pbc_3800236418", | ||
"maxSelect": 1, | ||
"minSelect": 1 | ||
}, | ||
{ | ||
"id": "store_role", | ||
"name": "role", | ||
"type": "select", | ||
"required": true, | ||
"presentable": false, | ||
"system": false, | ||
"values": ["admin", "staff"], | ||
"maxSelect": 1 | ||
}, | ||
{ | ||
"id": "created", | ||
"name": "created", | ||
"type": "autodate", | ||
"required": false, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false, | ||
"onCreate": true, | ||
"onUpdate": false | ||
}, | ||
{ | ||
"id": "updated", | ||
"name": "updated", | ||
"type": "autodate", | ||
"required": false, | ||
"presentable": false, | ||
"system": false, | ||
"hidden": false, | ||
"onCreate": true, | ||
"onUpdate": true | ||
} | ||
], | ||
"indexes": ["CREATE UNIQUE INDEX idx_unique_user_store ON store_roles (user, store)"], | ||
"listRule": "@request.auth.id != ''", | ||
"viewRule": "@request.auth.id != ''", | ||
"createRule": "@request.auth.roles.admin = true", | ||
"updateRule": "@request.auth.roles.admin = true", | ||
"deleteRule": "@request.auth.roles.admin = true" | ||
}); | ||
|
||
return app.save(collection); | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("store_roles"); | ||
return app.delete(collection); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_3527180448") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"listRule": "@request.auth.roles ?~ \"admin\" || user.id = @request.auth.id", | ||
"viewRule": "@request.auth.roles ?~ \"admin\" || user.id = @request.auth.id" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_3527180448") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"listRule": "@request.auth.roles ?= \"admin\" || user.id = @request.auth.id", | ||
"viewRule": "@request.auth.roles ?= \"admin\" || user.id = @request.auth.id" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("_pb_users_auth_") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"listRule": "@request.auth.roles ?~ \"admin\" || @request.auth.id = id", | ||
"viewRule": "@request.auth.roles ?~ \"admin\" || @request.auth.id = id" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("_pb_users_auth_") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"listRule": "@request.auth.roles ?= \"admin\" || @request.auth.id = id", | ||
"viewRule": "@request.auth.roles ?= \"admin\" || @request.auth.id = id" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_2456927940") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"createRule": "@request.auth.roles ?~ 'admin' || @collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin'", | ||
"deleteRule": "@request.auth.roles ?~ 'admin' || @collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin'", | ||
"listRule": "@request.auth.roles ?~ 'admin' || @collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin'", | ||
"updateRule": "@request.auth.roles ?~ 'admin' || @collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin'", | ||
"viewRule": "@request.auth.roles ?~ 'admin' || @collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin'" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_2456927940") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"createRule": "", | ||
"deleteRule": null, | ||
"listRule": "", | ||
"updateRule": null, | ||
"viewRule": "" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_2456927940") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"createRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')", | ||
"deleteRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')", | ||
"listRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')", | ||
"updateRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')", | ||
"viewRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_2456927940") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"createRule": "@request.auth.roles ?~ 'admin' || @collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin'", | ||
"deleteRule": "@request.auth.roles ?~ 'admin' || @collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin'", | ||
"listRule": "@request.auth.roles ?~ 'admin' || @collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin'", | ||
"updateRule": "@request.auth.roles ?~ 'admin' || @collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin'", | ||
"viewRule": "@request.auth.roles ?~ 'admin' || @collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin'" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_1842453536") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"updateRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_1842453536") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"updateRule": null | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_2456927940") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"createRule": "@request.auth.roles ?~ 'admin'", | ||
"deleteRule": "@request.auth.roles ?~ 'admin'", | ||
"listRule": "@request.auth.roles ?~ 'admin'", | ||
"updateRule": "@request.auth.roles ?~ 'admin'", | ||
"viewRule": "@request.auth.roles ?~ 'admin'" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_2456927940") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"createRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')", | ||
"deleteRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')", | ||
"listRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')", | ||
"updateRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')", | ||
"viewRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_2456927940") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"createRule": "@request.auth.role ?= 'admin' || @request.body.order.user.id = @request.auth.id", | ||
"deleteRule": null, | ||
"listRule": "@request.auth.role ?= 'admin' || @request.body.order.user.id = @request.auth.id", | ||
"updateRule": null, | ||
"viewRule": "@request.auth.role ?= 'admin' || @request.body.order.user.id = @request.auth.id" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_2456927940") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"createRule": "@request.auth.roles ?~ 'admin'", | ||
"deleteRule": "@request.auth.roles ?~ 'admin'", | ||
"listRule": "@request.auth.roles ?~ 'admin'", | ||
"updateRule": "@request.auth.roles ?~ 'admin'", | ||
"viewRule": "@request.auth.roles ?~ 'admin'" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/// <reference path="../pb_data/types.d.ts" /> | ||
migrate((app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_1842453536") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"createRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')", | ||
"deleteRule": "@request.auth.roles ?~ 'admin' || (@collection.store_roles.user.id = @request.auth.id && @collection.store_roles.store.id = @request.body.store_item.store.id && @collection.store_roles.role = 'admin')" | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}, (app) => { | ||
const collection = app.findCollectionByNameOrId("pbc_1842453536") | ||
|
||
// update collection data | ||
unmarshal({ | ||
"createRule": null, | ||
"deleteRule": null | ||
}, collection) | ||
|
||
return app.save(collection) | ||
}) |
Oops, something went wrong.