|
|
@ -21,7 +21,7 @@ const vModel = useVModel(props, 'value', emit) |
|
|
|
|
|
|
|
|
|
|
|
const { setAdditionalValidations, validateInfos, isPg, isMysql } = useColumnCreateStoreOrThrow() |
|
|
|
const { setAdditionalValidations, validateInfos, isPg, isMysql } = useColumnCreateStoreOrThrow() |
|
|
|
|
|
|
|
|
|
|
|
let options = $ref<Option[]>([]) |
|
|
|
let options = $ref<(Option & { status?: 'remove' })[]>([]) |
|
|
|
let renderedOptions = $ref<(Option & { status?: 'remove' })[]>([]) |
|
|
|
let renderedOptions = $ref<(Option & { status?: 'remove' })[]>([]) |
|
|
|
let savedDefaultOption = $ref<Option | null>(null) |
|
|
|
let savedDefaultOption = $ref<Option | null>(null) |
|
|
|
let savedCdf = $ref<string | null>(null) |
|
|
|
let savedCdf = $ref<string | null>(null) |
|
|
@ -41,13 +41,15 @@ const validators = { |
|
|
|
validator: (_: any, _opt: any) => { |
|
|
|
validator: (_: any, _opt: any) => { |
|
|
|
return new Promise<void>((resolve, reject) => { |
|
|
|
return new Promise<void>((resolve, reject) => { |
|
|
|
for (const opt of options) { |
|
|
|
for (const opt of options) { |
|
|
|
|
|
|
|
if ((opt as any).status === 'remove') continue |
|
|
|
|
|
|
|
|
|
|
|
if (!opt.title.length) { |
|
|
|
if (!opt.title.length) { |
|
|
|
return reject(new Error("Select options can't be null")) |
|
|
|
return reject(new Error("Select options can't be null")) |
|
|
|
} |
|
|
|
} |
|
|
|
if (vModel.value.uidt === UITypes.MultiSelect && opt.title.includes(',')) { |
|
|
|
if (vModel.value.uidt === UITypes.MultiSelect && opt.title.includes(',')) { |
|
|
|
return reject(new Error("MultiSelect columns can't have commas(',')")) |
|
|
|
return reject(new Error("MultiSelect columns can't have commas(',')")) |
|
|
|
} |
|
|
|
} |
|
|
|
if (options.filter((el) => el.title === opt.title).length !== 1) { |
|
|
|
if (options.filter((el) => el.title === opt.title && (el as any).status !== 'remove').length > 1) { |
|
|
|
return reject(new Error("Select options can't have duplicates")) |
|
|
|
return reject(new Error("Select options can't have duplicates")) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|