|
|
@ -519,7 +519,6 @@ export async function columnAdd(req: Request, res: Response<TableType>) { |
|
|
|
? `${colBody.colOptions.options.map((o) => { |
|
|
|
? `${colBody.colOptions.options.map((o) => { |
|
|
|
if(o.title.includes(',')) { |
|
|
|
if(o.title.includes(',')) { |
|
|
|
NcError.badRequest('Illegal char(\',\') for MultiSelect'); |
|
|
|
NcError.badRequest('Illegal char(\',\') for MultiSelect'); |
|
|
|
throw new Error(''); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return `'${o.title.replace(/'/gi, '\'\'')}'`; |
|
|
|
return `'${o.title.replace(/'/gi, '\'\'')}'`; |
|
|
|
}).join(',')}` |
|
|
|
}).join(',')}` |
|
|
@ -680,7 +679,6 @@ export async function columnUpdate(req: Request, res: Response<TableType>) { |
|
|
|
? `${colBody.colOptions.options.map((o) => { |
|
|
|
? `${colBody.colOptions.options.map((o) => { |
|
|
|
if(o.title.includes(',')) { |
|
|
|
if(o.title.includes(',')) { |
|
|
|
NcError.badRequest('Illegal char(\',\') for MultiSelect'); |
|
|
|
NcError.badRequest('Illegal char(\',\') for MultiSelect'); |
|
|
|
throw new Error(''); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return `'${o.title.replace(/'/gi, '\'\'')}'`; |
|
|
|
return `'${o.title.replace(/'/gi, '\'\'')}'`; |
|
|
|
}).join(',')}` |
|
|
|
}).join(',')}` |
|
|
@ -698,6 +696,16 @@ export async function columnUpdate(req: Request, res: Response<TableType>) { |
|
|
|
op.title = op.title.replace(/^'/, '').replace(/'$/, '') |
|
|
|
op.title = op.title.replace(/^'/, '').replace(/'$/, '') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Restrict duplicates
|
|
|
|
|
|
|
|
const titles = colBody.colOptions.options.map(el => el.title) |
|
|
|
|
|
|
|
if (titles |
|
|
|
|
|
|
|
.some( function(item) { |
|
|
|
|
|
|
|
return titles.indexOf(item) !== titles.lastIndexOf(item); |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
NcError.badRequest('Duplicates are not allowed!'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Handle option delete
|
|
|
|
// Handle option delete
|
|
|
|
for (const option of column.colOptions.options.filter(oldOp => colBody.colOptions.options.find(newOp => newOp.id === oldOp.id) ? false : true)) { |
|
|
|
for (const option of column.colOptions.options.filter(oldOp => colBody.colOptions.options.find(newOp => newOp.id === oldOp.id) ? false : true)) { |
|
|
|
if (column.uidt === UITypes.SingleSelect) {
|
|
|
|
if (column.uidt === UITypes.SingleSelect) {
|
|
|
|