RED-5741: Fixed ui sending empty string when technical name is _.

This commit is contained in:
Nicoleta Panaghiu 2022-12-16 15:40:56 +02:00
parent 484704683c
commit 1b3676cc93

View File

@ -201,9 +201,12 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit
const existingTechnicalNames = this._dictionariesMapService.get(this.dossierTemplateId).map(dict => dict.type);
const baseTechnicalName = toSnakeCase(value.trim());
let technicalName = baseTechnicalName.replaceAll(/[^A-Za-z0-9_-]/g, '');
if (!technicalName.length && baseTechnicalName.length) {
technicalName = '_';
}
let suffix = 1;
while (existingTechnicalNames.includes(technicalName)) {
technicalName = [technicalName, suffix++].join('_');
technicalName = technicalName === '_' ? `${technicalName}${suffix++}` : [technicalName, suffix++].join('_');
}
return technicalName;
}