Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private updateOnMatches(field: Ro.IField, allFields: Ro.IField[], fieldEntry: string, matches: Ro.Value[]) {
switch (matches.length) {
case 0:
case 1:
const match = matches.length === 0 ? new Ro.Value(null) : matches[0];
// TODO fix "!""
return this.setFieldAndCheckDependencies(field, allFields, match).then((crs: CommandResult[]) => last(crs)!);
default:
// shouldn't happen - ignore
return this.returnResult('', '');
}
}
private handleFreeForm(field: Ro.IField, fieldEntry: string) {
if (field.isScalar()) {
const mandatoryError = validateMandatory(field, fieldEntry);
if (mandatoryError) {
return this.returnResult('', this.validationMessage(mandatoryError, new Ro.Value(''), field.extensions().friendlyName()));
}
let value = new Ro.Value(fieldEntry);
if (Ro.isDateOrDateTime(field)) {
const dt = validateDate(fieldEntry, supportedDateFormats);
if (dt) {
value = new Ro.Value(Ro.toDateString(dt.toDate()));
}
}
// if optional but empty always valid
if (fieldEntry != null && fieldEntry !== '') {
const remoteMask = field.extensions().mask();
const localFilter = this.mask.toLocalFilter(remoteMask, field.extensions().format()!);
const validateError = validateMandatoryAgainstType(field, fieldEntry, localFilter);
const selfAsValue = (): Ro.Value | null => {
const link = this.domainObject.selfLink();
if (link) {
// not transient - can't drag transients so no need to set up IDraggable members on transients
link.setTitle(this.title);
return new Ro.Value(link);
}
return null;
};
const sav = selfAsValue();
private handleFreeForm(field: Ro.IField, fieldEntry: string) {
if (field.isScalar()) {
const mandatoryError = validateMandatory(field, fieldEntry);
if (mandatoryError) {
return this.returnResult('', this.validationMessage(mandatoryError, new Ro.Value(''), field.extensions().friendlyName()));
}
let value = new Ro.Value(fieldEntry);
if (Ro.isDateOrDateTime(field)) {
const dt = validateDate(fieldEntry, supportedDateFormats);
if (dt) {
value = new Ro.Value(Ro.toDateString(dt.toDate()));
}
}
// if optional but empty always valid
if (fieldEntry != null && fieldEntry !== '') {
const remoteMask = field.extensions().mask();
const localFilter = this.mask.toLocalFilter(remoteMask, field.extensions().format()!);
private clearField(field: Ro.IField): void {
this.context.cacheFieldValue(this.routeData().dialogId, field.id(), new Ro.Value(null));
if (field instanceof Ro.Parameter) {
this.context.cacheFieldValue(this.routeData().dialogId, field.id(), new Ro.Value(null));
} else if (field instanceof Ro.PropertyMember) {
const parent = field.parent as Ro.DomainObjectRepresentation;
this.context.cachePropertyValue(parent, field, new Ro.Value(null));
}
}
(propMember, propId) => {
if (!propMember.disabledReason()) {
propIds.push(propId);
const newVal = newValsFromUrl[propId];
if (newVal) {
values.push(newVal);
} else if (propMember.value().isNull() &&
propMember.isScalar()) {
values.push(new Ro.Value(''));
} else {
values.push(propMember.value());
}
}
});
const propMap = zipObject(propIds, values) as Dictionary;
private clearField(field: Ro.IField): void {
this.context.cacheFieldValue(this.routeData().dialogId, field.id(), new Ro.Value(null));
if (field instanceof Ro.Parameter) {
this.context.cacheFieldValue(this.routeData().dialogId, field.id(), new Ro.Value(null));
} else if (field instanceof Ro.PropertyMember) {
const parent = field.parent as Ro.DomainObjectRepresentation;
this.context.cachePropertyValue(parent, field, new Ro.Value(null));
}
}
addValue(id: string, valueId: string, value: Ro.Value, paneId: Pane) {
if (this.currentId[paneId] !== id) {
this.currentId[paneId] = id;
this.currentValues[paneId] = {};
}
this.currentValues[paneId]![valueId] = new Ro.Value(value);
}