How to use the @nakedobjects/restful-objects.PropertyMember 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() : '';
        } else {
            fieldEntryOrExistingValue = fieldEntry;
        }
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / cicero / src / cicero-commands / enter.ts View on Github external
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}`;
    }
}
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / view-models / src / table-row-column-view-model.ts View on Github external
) {

        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));