Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getFields(field: Ro.IField): Ro.IField[] {
if (field instanceof Ro.Parameter) {
const action = field.parent;
if (action instanceof Ro.InvokableActionMember || action instanceof Ro.ActionRepresentation) {
const parms = action.parameters();
return map(parms, p => p as Ro.IField);
}
}
if (field instanceof Ro.PropertyMember) {
// todo
return [];
}
return [];
}
private handleConditionalChoices(field: Ro.IField, updating: boolean, fieldEntry?: string, ) {
let enteredFields: Dictionary;
const allFields = Commandresult.getFields(field);
if (field instanceof Ro.Parameter) {
enteredFields = Commandresult.getParametersAndCurrentValue(field.parent, this.context);
}
if (field instanceof Ro.PropertyMember) {
enteredFields = this.getPropertiesAndCurrentValue(field.parent as Ro.DomainObjectRepresentation);
}
// TODO fix this any cast
const args = fromPairs(map(field.promptLink()!.arguments()! as any, (v: any, key: string) => [key, new Ro.Value(v.value)])) as Dictionary;
forEach(keys(args), key => args[key] = enteredFields[key]);
let fieldEntryOrExistingValue: string;
if (fieldEntry === undefined) {
const def = args[field.id()];
fieldEntryOrExistingValue = def ? def.toValueString() : '';
} else {
fieldEntryOrExistingValue = fieldEntry;
}
private renderFieldDetails(field: Ro.IField, value: Ro.Value): string {
const fieldName = Usermessages.fieldName(field.extensions().friendlyName());
const desc = field.extensions().description();
const descAndPrefix = desc ? `\n${Usermessages.descriptionFieldPrefix} ${desc}` : '';
const types = `\n${Usermessages.typePrefix} ${Ro.friendlyTypeName(field.extensions().returnType()!)}`;
let postFix = '';
if (field instanceof Ro.PropertyMember && field.disabledReason()) {
postFix = `\n${Usermessages.unModifiablePrefix(field.disabledReason())}`;
} else {
postFix = field.extensions().optional() ? `\n${Usermessages.optional}` : `\n${Usermessages.mandatory}`;
const choices = field.choices();
if (choices) {
const label = `\n${Usermessages.choices}: `;
const labelAndChoices = reduce(choices, (ss, cho) => ss + cho + ' ', label);
postFix = `${postFix}${labelAndChoices}`;
}
}
return `${fieldName}${descAndPrefix}${types}${postFix}`;
}
}
) {
if (propertyRep && mask) {
this.title = propertyRep.extensions().friendlyName();
if (propertyRep instanceof Ro.CollectionMember) {
const size = propertyRep.size();
this.formattedValue = Helpers.getCollectionDetails(size);
this.value = '';
this.type = 'scalar';
this.returnType = 'string';
}
if (propertyRep instanceof Ro.PropertyMember) {
const isPassword = propertyRep.extensions().dataType() === 'password';
const value = propertyRep.value();
this.returnType = propertyRep.extensions().returnType()!;
if (propertyRep.isScalar()) {
this.type = 'scalar';
Helpers.setScalarValueInView(this, propertyRep, value);
const remoteMask = propertyRep.extensions().mask();
const localFilter = mask.toLocalFilter(remoteMask, propertyRep.extensions().format()!);
if (propertyRep.entryType() === Ro.EntryType.Choices) {
const currentChoice = new ChoiceViewModel(value, id);
const choicesMap = propertyRep.choices()!;
const choices = map(choicesMap, (v, n) => new ChoiceViewModel(v, id, n));
const choice = find(choices, c => c.valuesEqual(currentChoice));