@nocobase/plugin-departments 1.6.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/LICENSE.txt +161 -0
  2. package/README.md +1 -0
  3. package/client.d.ts +2 -0
  4. package/client.js +1 -0
  5. package/dist/client/ResourcesProvider.d.ts +20 -0
  6. package/dist/client/collections/departments.d.ts +144 -0
  7. package/dist/client/collections/users.d.ts +205 -0
  8. package/dist/client/components/DepartmentOwnersField.d.ts +18 -0
  9. package/dist/client/components/ReadOnlyAssociationField.d.ts +18 -0
  10. package/dist/client/components/UserDepartmentsField.d.ts +18 -0
  11. package/dist/client/components/UserMainDepartmentField.d.ts +18 -0
  12. package/dist/client/components/fieldSettings.d.ts +22 -0
  13. package/dist/client/components/index.d.ts +20 -0
  14. package/dist/client/departments/AggregateSearch.d.ts +18 -0
  15. package/dist/client/departments/Department.d.ts +45 -0
  16. package/dist/client/departments/DepartmentBlock.d.ts +18 -0
  17. package/dist/client/departments/DepartmentField.d.ts +18 -0
  18. package/dist/client/departments/DepartmentManagement.d.ts +18 -0
  19. package/dist/client/departments/DepartmentOwnersField.d.ts +10 -0
  20. package/dist/client/departments/DepartmentTable.d.ts +18 -0
  21. package/dist/client/departments/DepartmentTree.d.ts +30 -0
  22. package/dist/client/departments/DepartmentTreeSelect.d.ts +24 -0
  23. package/dist/client/departments/IsOwnerField.d.ts +18 -0
  24. package/dist/client/departments/Member.d.ts +19 -0
  25. package/dist/client/departments/NewDepartment.d.ts +10 -0
  26. package/dist/client/departments/UserDepartmentsField.d.ts +10 -0
  27. package/dist/client/departments/schemas/departments.d.ts +257 -0
  28. package/dist/client/departments/schemas/users.d.ts +443 -0
  29. package/dist/client/hooks/departments-manager.d.ts +37 -0
  30. package/dist/client/hooks/index.d.ts +18 -0
  31. package/dist/client/hooks/tree-manager.d.ts +38 -0
  32. package/dist/client/hooks/useTableBlockProps.d.ts +28 -0
  33. package/dist/client/index.d.ts +23 -0
  34. package/dist/client/index.js +10 -0
  35. package/dist/client/locale.d.ts +9 -0
  36. package/dist/client/roles/RoleDepartmentsManager.d.ts +18 -0
  37. package/dist/client/roles/schemas/departments.d.ts +235 -0
  38. package/dist/client/utils.d.ts +17 -0
  39. package/dist/externalVersion.js +29 -0
  40. package/dist/index.d.ts +18 -0
  41. package/dist/index.js +48 -0
  42. package/dist/locale/en-US.json +35 -0
  43. package/dist/locale/zh-CN.json +35 -0
  44. package/dist/server/actions/departments.d.ts +21 -0
  45. package/dist/server/actions/departments.js +114 -0
  46. package/dist/server/actions/users.d.ts +20 -0
  47. package/dist/server/actions/users.js +151 -0
  48. package/dist/server/collections/departmentRoles.d.ts +10 -0
  49. package/dist/server/collections/departmentRoles.js +37 -0
  50. package/dist/server/collections/departments.d.ts +37 -0
  51. package/dist/server/collections/departments.js +172 -0
  52. package/dist/server/collections/departmentsUsers.d.ts +10 -0
  53. package/dist/server/collections/departmentsUsers.js +53 -0
  54. package/dist/server/collections/roles.d.ts +14 -0
  55. package/dist/server/collections/roles.js +48 -0
  56. package/dist/server/collections/users.d.ts +67 -0
  57. package/dist/server/collections/users.js +96 -0
  58. package/dist/server/department-data-sync-resource.d.ts +27 -0
  59. package/dist/server/department-data-sync-resource.js +339 -0
  60. package/dist/server/index.d.ts +17 -0
  61. package/dist/server/index.js +42 -0
  62. package/dist/server/middlewares/destroy-department-check.d.ts +18 -0
  63. package/dist/server/middlewares/destroy-department-check.js +62 -0
  64. package/dist/server/middlewares/index.d.ts +22 -0
  65. package/dist/server/middlewares/index.js +40 -0
  66. package/dist/server/middlewares/reset-user-departments-cache.d.ts +18 -0
  67. package/dist/server/middlewares/reset-user-departments-cache.js +48 -0
  68. package/dist/server/middlewares/set-department-owners.d.ts +18 -0
  69. package/dist/server/middlewares/set-department-owners.js +83 -0
  70. package/dist/server/middlewares/set-departments-roles.d.ts +18 -0
  71. package/dist/server/middlewares/set-departments-roles.js +71 -0
  72. package/dist/server/middlewares/set-main-department.d.ts +18 -0
  73. package/dist/server/middlewares/set-main-department.js +114 -0
  74. package/dist/server/middlewares/update-department-isleaf.d.ts +18 -0
  75. package/dist/server/middlewares/update-department-isleaf.js +93 -0
  76. package/dist/server/migrations/update-field-uischemas-20240307124823.d.ts +20 -0
  77. package/dist/server/migrations/update-field-uischemas-20240307124823.js +106 -0
  78. package/dist/server/models/department.d.ts +20 -0
  79. package/dist/server/models/department.js +47 -0
  80. package/dist/server/plugin.d.ts +19 -0
  81. package/dist/server/plugin.js +154 -0
  82. package/package.json +22 -0
  83. package/server.d.ts +2 -0
  84. package/server.js +1 -0
package/dist/index.js ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __export = (target, all) => {
17
+ for (var name in all)
18
+ __defProp(target, name, { get: all[name], enumerable: true });
19
+ };
20
+ var __copyProps = (to, from, except, desc) => {
21
+ if (from && typeof from === "object" || typeof from === "function") {
22
+ for (let key of __getOwnPropNames(from))
23
+ if (!__hasOwnProp.call(to, key) && key !== except)
24
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
25
+ }
26
+ return to;
27
+ };
28
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
29
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
+ // If the importer is in node compatibility mode or this is not an ESM
31
+ // file that has been converted to a CommonJS file using a Babel-
32
+ // compatible transform (i.e. "__esModule" has not been set), then set
33
+ // "default" to the CommonJS "module.exports" for node compatibility.
34
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
+ mod
36
+ ));
37
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
+ var src_exports = {};
39
+ __export(src_exports, {
40
+ default: () => import_server.default
41
+ });
42
+ module.exports = __toCommonJS(src_exports);
43
+ __reExport(src_exports, require("./server"), module.exports);
44
+ var import_server = __toESM(require("./server"));
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ ...require("./server")
48
+ });
@@ -0,0 +1,35 @@
1
+ {
2
+ "Department": "Department",
3
+ "All users": "All users",
4
+ "New department": "New department",
5
+ "Add department": "Add department",
6
+ "Add departments": "Add departments",
7
+ "New sub department": "New sub department",
8
+ "Edit department": "Edit department",
9
+ "Delete department": "Delete department",
10
+ "Departments": "Departments",
11
+ "Main department": "Main department",
12
+ "Owner": "Owner",
13
+ "Department name": "Department name",
14
+ "Superior department": "Superior department",
15
+ "Owners": "Owners",
16
+ "Add members": "Add members",
17
+ "Search for departments, users": "Search for departments, users",
18
+ "Search results": "Search results",
19
+ "Departments management": "Departments management",
20
+ "Roles management": "Roles management",
21
+ "Remove members": "Remove members",
22
+ "Remove member": "Remove member",
23
+ "Remove departments": "Remove departments",
24
+ "Remove department": "Remove department",
25
+ "Are you sure you want to remove it?": "Are you sure you want to remove it?",
26
+ "Are you sure you want to remove these members?": "Are you sure you want to remove these members?",
27
+ "Are you sure you want to remove these departments?": "Are you sure you want to remove these departments?",
28
+ "Please select members": "Please select members",
29
+ "Please select departments": "Please select departments",
30
+ "The department has sub-departments, please delete them first": "The department has sub-departments, please delete them first",
31
+ "The department has members, please remove them first": "The department has members, please remove them first",
32
+ "Main": "Main",
33
+ "Set as main department": "Set as main department",
34
+ "This field is currently not supported for use in form blocks.": "This field is currently not supported for use in form blocks."
35
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "Department": "部门",
3
+ "All users": "所有用户",
4
+ "New department": "新建部门",
5
+ "New sub department": "新建子部门",
6
+ "Add department": "添加部门",
7
+ "Add departments": "添加部门",
8
+ "Edit department": "编辑部门",
9
+ "Delete department": "删除部门",
10
+ "Departments": "部门",
11
+ "Main department": "主属部门",
12
+ "Owner": "负责人",
13
+ "Department name": "部门名称",
14
+ "Superior department": "上级部门",
15
+ "Owners": "负责人",
16
+ "Add members": "添加成员",
17
+ "Search for departments, users": "搜索部门、用户",
18
+ "Search results": "搜索结果",
19
+ "Departments management": "部门管理",
20
+ "Roles management": "角色管理",
21
+ "Remove members": "移除成员",
22
+ "Remove member": "移除成员",
23
+ "Remove departments": "移除部门",
24
+ "Remove department": "移除部门",
25
+ "Are you sure you want to remove it?": "你确定要移除吗?",
26
+ "Are you sure you want to remove these members?": "你确定要移除这些成员吗?",
27
+ "Are you sure you want to remove these departments?": "你确定要移除这些部门吗?",
28
+ "Please select members": "请选择成员",
29
+ "Please select departments": "请选择部门",
30
+ "The department has sub-departments, please delete them first": "部门下有子部门,请先删除子部门",
31
+ "The department has members, please remove them first": "部门下有成员,请先移除",
32
+ "Main": "主属部门",
33
+ "Set as main department": "设置为主属部门",
34
+ "This field is currently not supported for use in form blocks.": "该字段目前不支持在表单区块中使用。"
35
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ /**
10
+ * This file is part of the NocoBase (R) project.
11
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
12
+ * Authors: NocoBase Team.
13
+ *
14
+ * This program is offered under a commercial license.
15
+ * For more information, see <https://www.nocobase.com/agreement>
16
+ */
17
+ import { Context, Next } from '@nocobase/actions';
18
+ export declare const getAppendsOwners: (ctx: Context, next: Next) => Promise<void>;
19
+ export declare const aggregateSearch: (ctx: Context, next: Next) => Promise<void>;
20
+ export declare const setOwner: (ctx: Context, next: Next) => Promise<void>;
21
+ export declare const removeOwner: (ctx: Context, next: Next) => Promise<void>;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var departments_exports = {};
28
+ __export(departments_exports, {
29
+ aggregateSearch: () => aggregateSearch,
30
+ getAppendsOwners: () => getAppendsOwners,
31
+ removeOwner: () => removeOwner,
32
+ setOwner: () => setOwner
33
+ });
34
+ module.exports = __toCommonJS(departments_exports);
35
+ const getAppendsOwners = async (ctx, next) => {
36
+ const { filterByTk, appends } = ctx.action.params;
37
+ const repo = ctx.db.getRepository("departments");
38
+ const department = await repo.findOne({
39
+ filterByTk,
40
+ appends
41
+ });
42
+ const owners = await department.getOwners();
43
+ department.setDataValue("owners", owners);
44
+ ctx.body = department;
45
+ await next();
46
+ };
47
+ const aggregateSearch = async (ctx, next) => {
48
+ const { keyword, type, last = 0, limit = 10 } = ctx.action.params.values || {};
49
+ let users = [];
50
+ let departments = [];
51
+ if (!type || type === "user") {
52
+ const repo = ctx.db.getRepository("users");
53
+ users = await repo.find({
54
+ filter: {
55
+ id: { $gt: last },
56
+ $or: [
57
+ { username: { $includes: keyword } },
58
+ { nickname: { $includes: keyword } },
59
+ { phone: { $includes: keyword } },
60
+ { email: { $includes: keyword } }
61
+ ]
62
+ },
63
+ limit
64
+ });
65
+ }
66
+ if (!type || type === "department") {
67
+ const repo = ctx.db.getRepository("departments");
68
+ departments = await repo.find({
69
+ filter: {
70
+ id: { $gt: last },
71
+ title: { $includes: keyword }
72
+ },
73
+ appends: ["parent(recursively=true)"],
74
+ limit
75
+ });
76
+ }
77
+ ctx.body = { users, departments };
78
+ await next();
79
+ };
80
+ const setOwner = async (ctx, next) => {
81
+ const { userId, departmentId } = ctx.action.params.values || {};
82
+ const throughRepo = ctx.db.getRepository("departmentsUsers");
83
+ await throughRepo.update({
84
+ filter: {
85
+ userId,
86
+ departmentId
87
+ },
88
+ values: {
89
+ isOwner: true
90
+ }
91
+ });
92
+ await next();
93
+ };
94
+ const removeOwner = async (ctx, next) => {
95
+ const { userId, departmentId } = ctx.action.params.values || {};
96
+ const throughRepo = ctx.db.getRepository("departmentsUsers");
97
+ await throughRepo.update({
98
+ filter: {
99
+ userId,
100
+ departmentId
101
+ },
102
+ values: {
103
+ isOwner: false
104
+ }
105
+ });
106
+ await next();
107
+ };
108
+ // Annotate the CommonJS export names for ESM import in node:
109
+ 0 && (module.exports = {
110
+ aggregateSearch,
111
+ getAppendsOwners,
112
+ removeOwner,
113
+ setOwner
114
+ });
@@ -0,0 +1,20 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ /**
10
+ * This file is part of the NocoBase (R) project.
11
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
12
+ * Authors: NocoBase Team.
13
+ *
14
+ * This program is offered under a commercial license.
15
+ * For more information, see <https://www.nocobase.com/agreement>
16
+ */
17
+ import { Context, Next } from '@nocobase/actions';
18
+ export declare const listExcludeDept: (ctx: Context, next: Next) => Promise<void>;
19
+ export declare const setDepartments: (ctx: Context, next: Next) => Promise<void>;
20
+ export declare const setMainDepartment: (ctx: Context, next: Next) => Promise<void>;
@@ -0,0 +1,151 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var users_exports = {};
28
+ __export(users_exports, {
29
+ listExcludeDept: () => listExcludeDept,
30
+ setDepartments: () => setDepartments,
31
+ setMainDepartment: () => setMainDepartment
32
+ });
33
+ module.exports = __toCommonJS(users_exports);
34
+ var import_actions = require("@nocobase/actions");
35
+ const listExcludeDept = async (ctx, next) => {
36
+ const { departmentId, page = import_actions.DEFAULT_PAGE, pageSize = import_actions.DEFAULT_PER_PAGE } = ctx.action.params;
37
+ const repo = ctx.db.getRepository("users");
38
+ const members = await repo.find({
39
+ fields: ["id"],
40
+ filter: {
41
+ "departments.id": departmentId
42
+ }
43
+ });
44
+ const memberIds = members.map((member) => member.id);
45
+ if (memberIds.length) {
46
+ ctx.action.mergeParams({
47
+ filter: {
48
+ id: {
49
+ $notIn: memberIds
50
+ }
51
+ }
52
+ });
53
+ }
54
+ const { filter } = ctx.action.params;
55
+ const [rows, count] = await repo.findAndCount({
56
+ context: ctx,
57
+ offset: (page - 1) * pageSize,
58
+ limit: +pageSize,
59
+ filter
60
+ });
61
+ ctx.body = {
62
+ count,
63
+ rows,
64
+ page: Number(page),
65
+ pageSize: Number(pageSize),
66
+ totalPage: Math.ceil(count / pageSize)
67
+ };
68
+ await next();
69
+ };
70
+ const setDepartments = async (ctx, next) => {
71
+ const { values = {} } = ctx.action.params;
72
+ const { userId, departments = [] } = values;
73
+ const repo = ctx.db.getRepository("users");
74
+ const throughRepo = ctx.db.getRepository("departmentsUsers");
75
+ const user = await repo.findOne({ filterByTk: userId });
76
+ if (!user) {
77
+ ctx.throw(400, ctx.t("User does not exist"));
78
+ }
79
+ const departmentIds = departments.map((department) => department.id);
80
+ const main = departments.find((department) => department.isMain);
81
+ const owners = departments.filter((department) => department.isOwner);
82
+ await ctx.db.sequelize.transaction(async (t) => {
83
+ await user.setDepartments(departmentIds, {
84
+ through: {
85
+ isMain: false,
86
+ isOwner: false
87
+ },
88
+ transaction: t
89
+ });
90
+ if (main) {
91
+ await throughRepo.update({
92
+ filter: {
93
+ userId,
94
+ departmentId: main.id
95
+ },
96
+ values: {
97
+ isMain: true
98
+ },
99
+ transaction: t
100
+ });
101
+ }
102
+ if (owners.length) {
103
+ await throughRepo.update({
104
+ filter: {
105
+ userId,
106
+ departmentId: {
107
+ $in: owners.map((owner) => owner.id)
108
+ }
109
+ },
110
+ values: {
111
+ isOwner: true
112
+ },
113
+ transaction: t
114
+ });
115
+ }
116
+ });
117
+ await next();
118
+ };
119
+ const setMainDepartment = async (ctx, next) => {
120
+ const { userId, departmentId } = ctx.action.params.values || {};
121
+ const throughRepo = ctx.db.getRepository("departmentsUsers");
122
+ await ctx.db.sequelize.transaction(async (t) => {
123
+ await throughRepo.update({
124
+ filter: {
125
+ userId,
126
+ isMain: true
127
+ },
128
+ values: {
129
+ isMain: false
130
+ },
131
+ transaction: t
132
+ });
133
+ await throughRepo.update({
134
+ filter: {
135
+ userId,
136
+ departmentId
137
+ },
138
+ values: {
139
+ isMain: true
140
+ },
141
+ transaction: t
142
+ });
143
+ });
144
+ await next();
145
+ };
146
+ // Annotate the CommonJS export names for ESM import in node:
147
+ 0 && (module.exports = {
148
+ listExcludeDept,
149
+ setDepartments,
150
+ setMainDepartment
151
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ declare const _default: import("@nocobase/database").CollectionOptions;
10
+ export default _default;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var departmentRoles_exports = {};
28
+ __export(departmentRoles_exports, {
29
+ default: () => departmentRoles_default
30
+ });
31
+ module.exports = __toCommonJS(departmentRoles_exports);
32
+ var import_database = require("@nocobase/database");
33
+ var departmentRoles_default = (0, import_database.defineCollection)({
34
+ name: "departmentsRoles",
35
+ dumpRules: "required",
36
+ migrationRules: ["overwrite"]
37
+ });
@@ -0,0 +1,37 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ export declare const ownersField: {
10
+ interface: string;
11
+ type: string;
12
+ name: string;
13
+ collectionName: string;
14
+ target: string;
15
+ through: string;
16
+ foreignKey: string;
17
+ otherKey: string;
18
+ targetKey: string;
19
+ sourceKey: string;
20
+ throughScope: {
21
+ isOwner: boolean;
22
+ };
23
+ uiSchema: {
24
+ type: string;
25
+ title: string;
26
+ 'x-component': string;
27
+ 'x-component-props': {
28
+ multiple: boolean;
29
+ fieldNames: {
30
+ label: string;
31
+ value: string;
32
+ };
33
+ };
34
+ };
35
+ };
36
+ declare const _default: import("@nocobase/database").CollectionOptions;
37
+ export default _default;
@@ -0,0 +1,172 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var departments_exports = {};
28
+ __export(departments_exports, {
29
+ default: () => departments_default,
30
+ ownersField: () => ownersField
31
+ });
32
+ module.exports = __toCommonJS(departments_exports);
33
+ var import_database = require("@nocobase/database");
34
+ const ownersField = {
35
+ interface: "m2m",
36
+ type: "belongsToMany",
37
+ name: "owners",
38
+ collectionName: "departments",
39
+ target: "users",
40
+ through: "departmentsUsers",
41
+ foreignKey: "departmentId",
42
+ otherKey: "userId",
43
+ targetKey: "id",
44
+ sourceKey: "id",
45
+ throughScope: {
46
+ isOwner: true
47
+ },
48
+ uiSchema: {
49
+ type: "m2m",
50
+ title: '{{t("Owners")}}',
51
+ "x-component": "DepartmentOwnersField",
52
+ "x-component-props": {
53
+ multiple: true,
54
+ fieldNames: {
55
+ label: "nickname",
56
+ value: "id"
57
+ }
58
+ }
59
+ }
60
+ };
61
+ var departments_default = (0, import_database.defineCollection)({
62
+ name: "departments",
63
+ migrationRules: ["overwrite"],
64
+ title: '{{t("Departments")}}',
65
+ dumpRules: "required",
66
+ tree: "adjacency-list",
67
+ template: "tree",
68
+ shared: true,
69
+ sortable: true,
70
+ model: "DepartmentModel",
71
+ createdBy: true,
72
+ updatedBy: true,
73
+ logging: true,
74
+ fields: [
75
+ {
76
+ type: "bigInt",
77
+ name: "id",
78
+ primaryKey: true,
79
+ autoIncrement: true,
80
+ interface: "id",
81
+ uiSchema: {
82
+ type: "number",
83
+ title: '{{t("ID")}}',
84
+ "x-component": "InputNumber",
85
+ "x-read-pretty": true
86
+ }
87
+ },
88
+ {
89
+ type: "string",
90
+ name: "title",
91
+ interface: "input",
92
+ uiSchema: {
93
+ type: "string",
94
+ title: '{{t("Department name")}}',
95
+ "x-component": "Input"
96
+ }
97
+ },
98
+ {
99
+ type: "boolean",
100
+ name: "isLeaf"
101
+ },
102
+ {
103
+ type: "belongsTo",
104
+ name: "parent",
105
+ target: "departments",
106
+ foreignKey: "parentId",
107
+ treeParent: true,
108
+ onDelete: "CASCADE",
109
+ interface: "m2o",
110
+ uiSchema: {
111
+ type: "m2o",
112
+ title: '{{t("Superior department")}}',
113
+ "x-component": "AssociationField",
114
+ "x-component-props": {
115
+ multiple: false,
116
+ fieldNames: {
117
+ label: "title",
118
+ value: "id"
119
+ }
120
+ }
121
+ }
122
+ },
123
+ {
124
+ type: "hasMany",
125
+ name: "children",
126
+ target: "departments",
127
+ foreignKey: "parentId",
128
+ treeChildren: true,
129
+ onDelete: "CASCADE"
130
+ },
131
+ {
132
+ type: "belongsToMany",
133
+ name: "members",
134
+ target: "users",
135
+ through: "departmentsUsers",
136
+ foreignKey: "departmentId",
137
+ otherKey: "userId",
138
+ targetKey: "id",
139
+ sourceKey: "id",
140
+ onDelete: "CASCADE"
141
+ },
142
+ {
143
+ interface: "m2m",
144
+ type: "belongsToMany",
145
+ name: "roles",
146
+ target: "roles",
147
+ through: "departmentsRoles",
148
+ foreignKey: "departmentId",
149
+ otherKey: "roleName",
150
+ targetKey: "name",
151
+ sourceKey: "id",
152
+ onDelete: "CASCADE",
153
+ uiSchema: {
154
+ type: "m2m",
155
+ title: '{{t("Roles")}}',
156
+ "x-component": "AssociationField",
157
+ "x-component-props": {
158
+ multiple: true,
159
+ fieldNames: {
160
+ label: "title",
161
+ value: "name"
162
+ }
163
+ }
164
+ }
165
+ },
166
+ ownersField
167
+ ]
168
+ });
169
+ // Annotate the CommonJS export names for ESM import in node:
170
+ 0 && (module.exports = {
171
+ ownersField
172
+ });