How to use the @nakedobjects/restful-objects.friendlyTypeName 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 / 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}`;
    }
}