Merge branch 'v3-ui' into data-tidy-up
This commit is contained in:
commit
ca125cad23
|
@ -238,8 +238,8 @@ export function builtinRoleToNumber(id: string) {
|
||||||
const builtins = getBuiltinRoles()
|
const builtins = getBuiltinRoles()
|
||||||
const MAX = Object.values(builtins).length + 1
|
const MAX = Object.values(builtins).length + 1
|
||||||
if (
|
if (
|
||||||
compareRoleIds(id, BUILTIN_IDS.ADMIN) ||
|
roleIDsAreEqual(id, BUILTIN_IDS.ADMIN) ||
|
||||||
compareRoleIds(id, BUILTIN_IDS.BUILDER)
|
roleIDsAreEqual(id, BUILTIN_IDS.BUILDER)
|
||||||
) {
|
) {
|
||||||
return MAX
|
return MAX
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ export async function roleToNumber(id: string) {
|
||||||
const highestBuiltin: number | undefined = role.inherits
|
const highestBuiltin: number | undefined = role.inherits
|
||||||
.map(roleId => {
|
.map(roleId => {
|
||||||
const foundRole = hierarchy.find(role =>
|
const foundRole = hierarchy.find(role =>
|
||||||
compareRoleIds(role._id!, roleId)
|
roleIDsAreEqual(role._id!, roleId)
|
||||||
)
|
)
|
||||||
if (foundRole) {
|
if (foundRole) {
|
||||||
return findNumber(foundRole) + 1
|
return findNumber(foundRole) + 1
|
||||||
|
@ -403,7 +403,7 @@ async function getAllUserRoles(
|
||||||
): Promise<RoleDoc[]> {
|
): Promise<RoleDoc[]> {
|
||||||
const allRoles = await getAllRoles()
|
const allRoles = await getAllRoles()
|
||||||
// admins have access to all roles
|
// admins have access to all roles
|
||||||
if (compareRoleIds(userRoleId, BUILTIN_IDS.ADMIN)) {
|
if (roleIDsAreEqual(userRoleId, BUILTIN_IDS.ADMIN)) {
|
||||||
return allRoles
|
return allRoles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ export async function getAllRoles(appId?: string): Promise<RoleDoc[]> {
|
||||||
for (let builtinRoleId of externalBuiltinRoles) {
|
for (let builtinRoleId of externalBuiltinRoles) {
|
||||||
const builtinRole = builtinRoles[builtinRoleId]
|
const builtinRole = builtinRoles[builtinRoleId]
|
||||||
const dbBuiltin = roles.filter(dbRole =>
|
const dbBuiltin = roles.filter(dbRole =>
|
||||||
compareRoleIds(dbRole._id!, builtinRoleId)
|
roleIDsAreEqual(dbRole._id!, builtinRoleId)
|
||||||
)[0]
|
)[0]
|
||||||
if (dbBuiltin == null) {
|
if (dbBuiltin == null) {
|
||||||
roles.push(builtinRole || builtinRoles.BASIC)
|
roles.push(builtinRole || builtinRoles.BASIC)
|
||||||
|
@ -574,9 +574,9 @@ export class AccessController {
|
||||||
if (
|
if (
|
||||||
tryingRoleId == null ||
|
tryingRoleId == null ||
|
||||||
tryingRoleId === "" ||
|
tryingRoleId === "" ||
|
||||||
compareRoleIds(tryingRoleId, BUILTIN_IDS.BUILDER) ||
|
roleIDsAreEqual(tryingRoleId, BUILTIN_IDS.BUILDER) ||
|
||||||
compareRoleIds(userRoleId!, tryingRoleId) ||
|
roleIDsAreEqual(userRoleId!, tryingRoleId) ||
|
||||||
compareRoleIds(userRoleId!, BUILTIN_IDS.BUILDER)
|
roleIDsAreEqual(userRoleId!, BUILTIN_IDS.BUILDER)
|
||||||
) {
|
) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -848,6 +848,62 @@ describe.each([
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("boolean column", () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
table = await config.api.table.save(
|
||||||
|
saveTableRequest({
|
||||||
|
schema: {
|
||||||
|
active: {
|
||||||
|
name: "active",
|
||||||
|
type: FieldType.BOOLEAN,
|
||||||
|
default: "true",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("creates a new row with a default value successfully", async () => {
|
||||||
|
const row = await config.api.row.save(table._id!, {})
|
||||||
|
expect(row.active).toEqual(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("does not use default value if value specified", async () => {
|
||||||
|
const row = await config.api.row.save(table._id!, {
|
||||||
|
active: false,
|
||||||
|
})
|
||||||
|
expect(row.active).toEqual(false)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("bigint column", () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
table = await config.api.table.save(
|
||||||
|
saveTableRequest({
|
||||||
|
schema: {
|
||||||
|
bigNumber: {
|
||||||
|
name: "bigNumber",
|
||||||
|
type: FieldType.BIGINT,
|
||||||
|
default: "1234567890",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it("creates a new row with a default value successfully", async () => {
|
||||||
|
const row = await config.api.row.save(table._id!, {})
|
||||||
|
expect(row.bigNumber).toEqual("1234567890")
|
||||||
|
})
|
||||||
|
|
||||||
|
it("does not use default value if value specified", async () => {
|
||||||
|
const row = await config.api.row.save(table._id!, {
|
||||||
|
bigNumber: "9876543210",
|
||||||
|
})
|
||||||
|
expect(row.bigNumber).toEqual("9876543210")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("bindings", () => {
|
describe("bindings", () => {
|
||||||
describe("string column", () => {
|
describe("string column", () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
|
|
@ -57,12 +57,12 @@ const allowDefaultColumnByType: Record<FieldType, boolean> = {
|
||||||
[FieldType.STRING]: true,
|
[FieldType.STRING]: true,
|
||||||
[FieldType.OPTIONS]: true,
|
[FieldType.OPTIONS]: true,
|
||||||
[FieldType.ARRAY]: true,
|
[FieldType.ARRAY]: true,
|
||||||
|
[FieldType.BIGINT]: true,
|
||||||
|
[FieldType.BOOLEAN]: true,
|
||||||
|
|
||||||
[FieldType.AUTO]: false,
|
[FieldType.AUTO]: false,
|
||||||
[FieldType.INTERNAL]: false,
|
[FieldType.INTERNAL]: false,
|
||||||
[FieldType.BARCODEQR]: false,
|
[FieldType.BARCODEQR]: false,
|
||||||
[FieldType.BIGINT]: false,
|
|
||||||
[FieldType.BOOLEAN]: false,
|
|
||||||
[FieldType.FORMULA]: false,
|
[FieldType.FORMULA]: false,
|
||||||
[FieldType.AI]: false,
|
[FieldType.AI]: false,
|
||||||
[FieldType.ATTACHMENTS]: false,
|
[FieldType.ATTACHMENTS]: false,
|
||||||
|
|
|
@ -186,6 +186,16 @@ export interface ArrayFieldMetadata extends BaseFieldSchema {
|
||||||
default?: string[]
|
default?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BooleanFieldMetadata extends BaseFieldSchema {
|
||||||
|
type: FieldType.BOOLEAN
|
||||||
|
default?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BigIntFieldMetadata extends BaseFieldSchema {
|
||||||
|
type: FieldType.BIGINT
|
||||||
|
default?: string
|
||||||
|
}
|
||||||
|
|
||||||
interface BaseFieldSchema extends UIFieldMetadata {
|
interface BaseFieldSchema extends UIFieldMetadata {
|
||||||
type: FieldType
|
type: FieldType
|
||||||
name: string
|
name: string
|
||||||
|
@ -214,6 +224,8 @@ interface OtherFieldMetadata extends BaseFieldSchema {
|
||||||
| FieldType.STRING
|
| FieldType.STRING
|
||||||
| FieldType.ARRAY
|
| FieldType.ARRAY
|
||||||
| FieldType.OPTIONS
|
| FieldType.OPTIONS
|
||||||
|
| FieldType.BOOLEAN
|
||||||
|
| FieldType.BIGINT
|
||||||
>
|
>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,6 +245,8 @@ export type FieldSchema =
|
||||||
| BBReferenceSingleFieldMetadata
|
| BBReferenceSingleFieldMetadata
|
||||||
| ArrayFieldMetadata
|
| ArrayFieldMetadata
|
||||||
| OptionsFieldMetadata
|
| OptionsFieldMetadata
|
||||||
|
| BooleanFieldMetadata
|
||||||
|
| BigIntFieldMetadata
|
||||||
|
|
||||||
export interface TableSchema {
|
export interface TableSchema {
|
||||||
[key: string]: FieldSchema
|
[key: string]: FieldSchema
|
||||||
|
|
Loading…
Reference in New Issue