How to use @nakedobjects/services - 10 common examples

To help you get started, we’ve selected a few @nakedobjects/services 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 / goto.ts View on Github external
return this.getObject().then((obj: Ro.DomainObjectRepresentation) => {
                if (this.isCollection()) {
                    const itemNo = this.argumentAsNumber(args, 0)!;
                    const openCollIds = this.ciceroRenderer.openCollectionIds(this.routeData());
                    const coll = obj.collectionMember(openCollIds[0]);
                    // Safe to assume always a List (Cicero doesn't support tables as such & must be open)
                    return this.context.getCollectionDetails(coll, CollectionViewState.List, false).then(details => this.attemptGotoLinkNumber(itemNo, details.value()));

                } else {
                    const matchingProps = this.matchingProperties(obj, arg0);
                    const matchingRefProps = filter(matchingProps, p => !p.isScalar());
                    const matchingColls = this.matchingCollections(obj, arg0);

                    switch (matchingRefProps.length + matchingColls.length) {
                        case 0:

                            return this.returnResult('', Usermessages.noRefFieldMatch(arg0));
                        case 1:
                            // TODO: Check for any empty reference
                            if (matchingRefProps.length > 0) {
                                const link = matchingRefProps[0].value().link();
                                if (link) {
                                    this.urlManager.setItem(link);
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / view-models / src / collection-view-model.ts View on Github external
readonly reset = (routeData: PaneRouteData, resetting: boolean) => {

        let state = routeData.collections[this.collectionRep.collectionId()];

        // collections are always shown as summary on transient
        if (routeData.interactionMode === InteractionMode.Transient) {
            state = CollectionViewState.Summary;
        }

        function getDefaultTableState(exts: Ro.Extensions) {
            if (exts.renderEagerly()) {
                return exts.tableViewColumns() || exts.tableViewTitle() ? CollectionViewState.Table : CollectionViewState.List;
            }
            return CollectionViewState.Summary;
        }

        if (state == null) {
            state = getDefaultTableState(this.collectionRep.extensions());
        }

        this.editing = routeData.interactionMode === InteractionMode.Edit;

        if (resetting || state !== this.currentState) {
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / gemini / src / object / object.component.ts View on Github external
get actionHolders() {
        if (this.mode === InteractionMode.View) {
            return this.viewButtons;
        }

        if (this.mode === InteractionMode.Edit || this.mode === InteractionMode.Transient) {
            return this.saveButtons;
        }

        if (this.mode === InteractionMode.Form) {

            // cache because otherwise we will recreate this array of actionHolders everytime page changes !
            if (!this.actionButtons) {

                const menuItems = this.menuItems()!;
                const actions = flatten(map(menuItems, (mi: MenuItemViewModel) => mi.actions!));
                this.actionButtons = map(actions, a => wrapAction(a));
            }

            return this.actionButtons;
        }
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / gemini / src / object / object.component.ts View on Github external
.then((object: Ro.DomainObjectRepresentation) => {

                    // only change the object property if the object has changed
                    if (isChanging || wasDirty) {
                        this.object = this.viewModelFactory.domainObjectViewModel(object, routeData, wasDirty);
                    }

                    if (modeChanging || isChanging || wasDirty) {
                        if (this.mode === InteractionMode.Edit ||
                            this.mode === InteractionMode.Form ||
                            this.mode === InteractionMode.Transient) {
                            this.createForm(this.object!); // will never be null
                        }
                    }
                })
                .catch((reject: ErrorWrapper) => {
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / view-models / src / collection-view-model.ts View on Github external
readonly reset = (routeData: PaneRouteData, resetting: boolean) => {

        let state = routeData.collections[this.collectionRep.collectionId()];

        // collections are always shown as summary on transient
        if (routeData.interactionMode === InteractionMode.Transient) {
            state = CollectionViewState.Summary;
        }

        function getDefaultTableState(exts: Ro.Extensions) {
            if (exts.renderEagerly()) {
                return exts.tableViewColumns() || exts.tableViewTitle() ? CollectionViewState.Table : CollectionViewState.List;
            }
            return CollectionViewState.Summary;
        }

        if (state == null) {
            state = getDefaultTableState(this.collectionRep.extensions());
        }

        this.editing = routeData.interactionMode === InteractionMode.Edit;
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / gemini / src / object / object.component.ts View on Github external
.then((object: Ro.DomainObjectRepresentation) => {

                    // only change the object property if the object has changed
                    if (isChanging || wasDirty) {
                        this.object = this.viewModelFactory.domainObjectViewModel(object, routeData, wasDirty);
                    }

                    if (modeChanging || isChanging || wasDirty) {
                        if (this.mode === InteractionMode.Edit ||
                            this.mode === InteractionMode.Form ||
                            this.mode === InteractionMode.Transient) {
                            this.createForm(this.object!); // will never be null
                        }
                    }
                })
                .catch((reject: ErrorWrapper) => {
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / view-models / src / domain-object-view-model.ts View on Github external
this.domainObject = obj;
        this.onPaneId = routeData.paneId;
        this.routeData = routeData;
        const iMode = this.domainObject.extensions().interactionMode();
        this.isInEdit = routeData.interactionMode !== InteractionMode.View || iMode === 'form' || iMode === 'transient';
        this.props = routeData.interactionMode !== InteractionMode.View ? this.contextService.getObjectCachedValues(this.domainObject.id(), routeData.paneId) : {};

        const actions = values(this.domainObject.actionMembers()) as Ro.ActionMember[];
        this.actions = map(actions, action => this.viewModelFactory.actionViewModel(action, this, this.routeData)).filter(avm => !avm.returnsScalar());

        this.menuItems = Helpers.createMenuItems(this.actions);

        this.properties = map(this.domainObject.propertyMembers(), (property, id) => this.viewModelFactory.propertyViewModel(property, id!, this.props[id!], this.onPaneId, this.propertyMap));
        this.collections = map(this.domainObject.collectionMembers(), collection => this.viewModelFactory.collectionViewModel(collection, this.routeData, resetting));

        this.unsaved = routeData.interactionMode === InteractionMode.Transient;

        this.title = this.unsaved ? `Unsaved ${this.domainObject.extensions().friendlyName()}` : this.domainObject.title();

        this.title = this.title + Helpers.dirtyMarker(this.contextService, this.configService, obj.getOid());

        this.friendlyName = this.domainObject.extensions().friendlyName();
        this.presentationHint = this.domainObject.extensions().presentationHint();
        this.domainType = this.domainObject.domainType()!;
        this.instanceId = this.domainObject.instanceId()!;
        this.draggableType = this.domainObject.domainType()!;

        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);
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / gemini / src / dynamic-list / dynamic-list.component.ts View on Github external
protected setup(routeData: PaneRouteData) {
        this.cachedRouteData = routeData;
        const cachedList = this.context.getCachedList(routeData.paneId, routeData.page, routeData.pageSize);

        if (cachedList) {
            this.showPlaceholder = false;
            const et = cachedList.extensions().elementType();

            if (et && et !== this.lastOid) {
                this.lastOid = et;
                this.parent.clear();
                this.customComponentService.getCustomComponent(et, ViewType.List).then((c: Type) => {
                    const childComponent = this.componentFactoryResolver.resolveComponentFactory(c);
                    this.parent.createComponent(childComponent);
                });
            }

        } else {
            this.showPlaceholder = true;
            this.title = 'List';
            this.parent.clear();
            this.lastOid = null; // so we recreate child after reload
            this.getActionExtensions(routeData)
                .then((ext: Ro.Extensions) =>
                    this.title = ext.friendlyName())
                .catch((reject: ErrorWrapper) => this.error.handleError(reject));

        }
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / gemini / src / custom-component-config.service.ts View on Github external
configureCustomErrors(custom: ICustomErrorComponentConfigurator) {
        // by default configure page for 404 errors
        custom.addError(ErrorCategory.HttpClientError, HttpStatusCode.NotFound, ObjectNotFoundErrorComponent);
    }
}
github NakedObjectsGroup / NakedObjectsFramework / Spa2 / nakedobjectsspa / view-models / src / list-view-model.ts View on Github external
readonly reset = (list: Ro.ListRepresentation, routeData: PaneRouteData) => {
        this.listRep = list;
        this.routeData = routeData;

        this.id = this.urlManager.getListCacheIndex(routeData.paneId, routeData.page, routeData.pageSize);

        this.page = this.listRep.pagination()!.page;
        this.pageSize = this.listRep.pagination()!.pageSize;
        this.numPages = this.listRep.pagination()!.numPages;

        this.state = this.listRep.hasTableData() ? CollectionViewState.Table : CollectionViewState.List;
        this.updateItems(list.value());
    }