How to use the @nakedobjects/restful-objects.Parameter function in @nakedobjects/restful-objects

To help you get started, we’ve selected a few @nakedobjects/restful-objects examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / cicero / src / cicero-commands / command-result.ts View on Github external
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 [];
}
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / cicero / src / cicero-commands / enter.ts View on Github external
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() : '';