How to use the @nakedobjects/restful-objects.Value 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 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('', '');
        }
    }
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / cicero / src / cicero-commands / enter.ts View on Github external
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);
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / view-models / src / domain-object-view-model.ts View on Github external
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();
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / cicero / src / cicero-commands / enter.ts View on Github external
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()!);
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / cicero / src / cicero-commands / enter.ts View on Github external
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));
        }
    }
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / cicero / src / cicero-commands / save.ts View on Github external
(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;
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / cicero / src / cicero-commands / enter.ts View on Github external
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));
        }
    }
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / services / src / context.service.ts View on Github external
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);
    }