Allow selecting multiple users
This commit is contained in:
parent
23702391ff
commit
17df64c588
|
@ -52,14 +52,14 @@
|
||||||
|
|
||||||
let mounted = false
|
let mounted = false
|
||||||
const fieldDefinitions = Object.values(FIELDS).reduce((acc, field) => {
|
const fieldDefinitions = Object.values(FIELDS).reduce((acc, field) => {
|
||||||
const fieldId = makeFieldId(field)
|
const fieldId = makeFieldId(field.type, field.subtype)
|
||||||
|
|
||||||
acc[fieldId] = { ...field, fieldId }
|
acc[fieldId] = { ...field, fieldId }
|
||||||
return acc
|
return acc
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
function makeFieldId(field) {
|
function makeFieldId(type, subtype) {
|
||||||
return `${field.type}${field.subtype || ""}`.toUpperCase()
|
return `${type}${subtype || ""}`.toUpperCase()
|
||||||
}
|
}
|
||||||
|
|
||||||
$: console.warn(fieldDefinitions)
|
$: console.warn(fieldDefinitions)
|
||||||
|
@ -150,7 +150,10 @@
|
||||||
$tables.selected.primaryDisplay == null ||
|
$tables.selected.primaryDisplay == null ||
|
||||||
$tables.selected.primaryDisplay === editableColumn.name
|
$tables.selected.primaryDisplay === editableColumn.name
|
||||||
|
|
||||||
editableColumn.fieldId = makeFieldId(editableColumn)
|
editableColumn.fieldId = makeFieldId(
|
||||||
|
editableColumn.type,
|
||||||
|
editableColumn.subtype
|
||||||
|
)
|
||||||
|
|
||||||
// Here we are setting the relationship values based on the editableColumn
|
// Here we are setting the relationship values based on the editableColumn
|
||||||
// This part of the code is used when viewing an existing field hence the check
|
// This part of the code is used when viewing an existing field hence the check
|
||||||
|
@ -181,7 +184,10 @@
|
||||||
editableColumn.name = "Column 01"
|
editableColumn.name = "Column 01"
|
||||||
}
|
}
|
||||||
|
|
||||||
editableColumn.fieldId = makeFieldId(editableColumn)
|
editableColumn.fieldId = makeFieldId(
|
||||||
|
editableColumn.type,
|
||||||
|
editableColumn.subtype
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
allowedTypes = getAllowedTypes()
|
allowedTypes = getAllowedTypes()
|
||||||
|
@ -326,7 +332,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleTypeChange(event) {
|
function onHandleTypeChange(event) {
|
||||||
|
handleTypeChange(event.detail)
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleTypeChange(type) {
|
||||||
// remove any extra fields that may not be related to this type
|
// remove any extra fields that may not be related to this type
|
||||||
delete editableColumn.autocolumn
|
delete editableColumn.autocolumn
|
||||||
delete editableColumn.subtype
|
delete editableColumn.subtype
|
||||||
|
@ -335,7 +345,7 @@
|
||||||
delete editableColumn.formulaType
|
delete editableColumn.formulaType
|
||||||
|
|
||||||
// Add in defaults and initial definition
|
// Add in defaults and initial definition
|
||||||
const definition = fieldDefinitions[event.detail?.toUpperCase()]
|
const definition = fieldDefinitions[type?.toUpperCase()]
|
||||||
if (definition?.constraints) {
|
if (definition?.constraints) {
|
||||||
editableColumn.constraints = definition.constraints
|
editableColumn.constraints = definition.constraints
|
||||||
}
|
}
|
||||||
|
@ -404,10 +414,7 @@
|
||||||
fieldDefinitions.FORMULA,
|
fieldDefinitions.FORMULA,
|
||||||
fieldDefinitions.JSON,
|
fieldDefinitions.JSON,
|
||||||
fieldDefinitions[
|
fieldDefinitions[
|
||||||
makeFieldId({
|
makeFieldId(FieldType.BB_REFERENCE, FieldSubtype.USER)
|
||||||
type: FieldType.BB_REFERENCE,
|
|
||||||
subtype: FieldSubtype.USER,
|
|
||||||
})
|
|
||||||
],
|
],
|
||||||
{ name: "Auto Column", type: AUTO_TYPE },
|
{ name: "Auto Column", type: AUTO_TYPE },
|
||||||
]
|
]
|
||||||
|
@ -520,7 +527,7 @@
|
||||||
<Select
|
<Select
|
||||||
disabled={!typeEnabled}
|
disabled={!typeEnabled}
|
||||||
bind:value={editableColumn.fieldId}
|
bind:value={editableColumn.fieldId}
|
||||||
on:change={handleTypeChange}
|
on:change={onHandleTypeChange}
|
||||||
options={allowedTypes}
|
options={allowedTypes}
|
||||||
getOptionLabel={field => field.name}
|
getOptionLabel={field => field.name}
|
||||||
getOptionValue={field => field.fieldId}
|
getOptionValue={field => field.fieldId}
|
||||||
|
@ -693,9 +700,12 @@
|
||||||
<Toggle
|
<Toggle
|
||||||
value={editableColumn.subtype === FieldSubtype.USERS}
|
value={editableColumn.subtype === FieldSubtype.USERS}
|
||||||
on:change={e =>
|
on:change={e =>
|
||||||
(editableColumn.subtype = e.detail
|
handleTypeChange(
|
||||||
? FieldSubtype.USERS
|
makeFieldId(
|
||||||
: FieldSubtype.USER)}
|
FieldType.BB_REFERENCE,
|
||||||
|
e.detail ? FieldSubtype.USERS : FieldSubtype.USER
|
||||||
|
)
|
||||||
|
)}
|
||||||
disabled={!isCreating}
|
disabled={!isCreating}
|
||||||
thin
|
thin
|
||||||
text="Allow multiple users"
|
text="Allow multiple users"
|
||||||
|
|
Loading…
Reference in New Issue