|
|
@ -558,6 +558,13 @@ export async function columnAdd(req: Request, res: Response<TableType>) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Trim end of enum/set
|
|
|
|
|
|
|
|
if (colBody.dt === 'enum' || colBody.dt === 'set') { |
|
|
|
|
|
|
|
for (const opt of colBody.colOptions.options) { |
|
|
|
|
|
|
|
opt.title = opt.title.trimEnd() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (colBody.uidt === UITypes.SingleSelect) { |
|
|
|
if (colBody.uidt === UITypes.SingleSelect) { |
|
|
|
colBody.dtxp = (colBody.colOptions?.options.length) |
|
|
|
colBody.dtxp = (colBody.colOptions?.options.length) |
|
|
|
? `${colBody.colOptions.options.map(o => `'${o.title.replace(/'/gi, '\'\'')}'`).join(',')}` |
|
|
|
? `${colBody.colOptions.options.map(o => `'${o.title.replace(/'/gi, '\'\'')}'`).join(',')}` |
|
|
@ -720,21 +727,6 @@ export async function columnUpdate(req: Request, res: Response<TableType>) { |
|
|
|
) { |
|
|
|
) { |
|
|
|
colBody = getColumnPropsFromUIDT(colBody, base); |
|
|
|
colBody = getColumnPropsFromUIDT(colBody, base); |
|
|
|
|
|
|
|
|
|
|
|
if (colBody.uidt === UITypes.SingleSelect) { |
|
|
|
|
|
|
|
colBody.dtxp = (colBody.colOptions?.options.length) |
|
|
|
|
|
|
|
? `${colBody.colOptions.options.map(o => `'${o.title.replace(/'/gi, '\'\'')}'`).join(',')}` |
|
|
|
|
|
|
|
: ''; |
|
|
|
|
|
|
|
} else if (colBody.uidt === UITypes.MultiSelect){ |
|
|
|
|
|
|
|
colBody.dtxp = (colBody.colOptions?.options.length) |
|
|
|
|
|
|
|
? `${colBody.colOptions.options.map((o) => { |
|
|
|
|
|
|
|
if(o.title.includes(',')) { |
|
|
|
|
|
|
|
NcError.badRequest('Illegal char(\',\') for MultiSelect'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return `'${o.title.replace(/'/gi, '\'\'')}'`; |
|
|
|
|
|
|
|
}).join(',')}` |
|
|
|
|
|
|
|
: ''; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const baseModel = await Model.getBaseModelSQL({ |
|
|
|
const baseModel = await Model.getBaseModelSQL({ |
|
|
|
id: table.id, |
|
|
|
id: table.id, |
|
|
|
dbDriver: NcConnectionMgrv2.get(base) |
|
|
|
dbDriver: NcConnectionMgrv2.get(base) |
|
|
@ -809,6 +801,28 @@ export async function columnUpdate(req: Request, res: Response<TableType>) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Trim end of enum/set
|
|
|
|
|
|
|
|
if (colBody.dt === 'enum' || colBody.dt === 'set') { |
|
|
|
|
|
|
|
for (const opt of colBody.colOptions.options) { |
|
|
|
|
|
|
|
opt.title = opt.title.trimEnd() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (colBody.uidt === UITypes.SingleSelect) { |
|
|
|
|
|
|
|
colBody.dtxp = (colBody.colOptions?.options.length) |
|
|
|
|
|
|
|
? `${colBody.colOptions.options.map(o => `'${o.title.replace(/'/gi, '\'\'')}'`).join(',')}` |
|
|
|
|
|
|
|
: ''; |
|
|
|
|
|
|
|
} else if (colBody.uidt === UITypes.MultiSelect){ |
|
|
|
|
|
|
|
colBody.dtxp = (colBody.colOptions?.options.length) |
|
|
|
|
|
|
|
? `${colBody.colOptions.options.map((o) => { |
|
|
|
|
|
|
|
if(o.title.includes(',')) { |
|
|
|
|
|
|
|
NcError.badRequest('Illegal char(\',\') for MultiSelect'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return `'${o.title.replace(/'/gi, '\'\'')}'`; |
|
|
|
|
|
|
|
}).join(',')}` |
|
|
|
|
|
|
|
: ''; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 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 (!supportedDrivers.includes(driverType) && column.uidt === UITypes.MultiSelect) { |
|
|
|
if (!supportedDrivers.includes(driverType) && column.uidt === UITypes.MultiSelect) { |
|
|
|