当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript services.ContextService类代码示例

本文整理汇总了TypeScript中@nakedobjects/services.ContextService的典型用法代码示例。如果您正苦于以下问题:TypeScript ContextService类的具体用法?TypeScript ContextService怎么用?TypeScript ContextService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ContextService类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: drop

export function drop(context: ContextService, error: ErrorService, vm: FieldViewModel, newValue: IDraggableViewModel) {
    return context.isSubTypeOf(newValue.draggableType, vm.returnType).
        then((canDrop: boolean) => {
            if (canDrop) {
                vm.setNewValue(newValue);
                return true;
            }
            return false;
        }).
        catch((reject: ErrorWrapper) => error.handleError(reject));
}
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:11,代码来源:helpers-view-models.ts

示例2:

                        .subscribe((paneRouteData: PaneRouteData) => {
                            if (!paneRouteData.isEqualIgnoringReload(this.lastPaneRouteData)) {
                                // only remove messages if something more than reload flag has changed
                                this.context.clearMessages();
                                this.context.clearWarnings();
                            }

                            if (this.doSetup(paneRouteData)) {
                                this.lastPaneRouteData = paneRouteData;
                                this.setup(paneRouteData);
                            }
                        });
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:12,代码来源:pane.ts

示例3: setUp

    private setUp() {
        this.context.getUser().
            then((u: Ro.UserRepresentation) => this.user = u.wrapped()).
            catch((reject: ErrorWrapper) => this.error.handleError(reject));

        this.context.getVersion().
            then((v: Ro.VersionRepresentation) => this.serverVersion = v.wrapped()).
            catch((reject: ErrorWrapper) => this.error.handleError(reject));

        this.serverUrl = this.configService.config.appPath;

        this.applicationName = this.configService.config.applicationName;
    }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:13,代码来源:application-properties-view-model.ts

示例4:

 return this.context.getObject(1, oid, this.routeData().interactionMode).then((obj: Ro.DomainObjectRepresentation) => {
     if (this.routeData().interactionMode === InteractionMode.Edit) {
         return this.context.getObjectForEdit(1, obj);
     } else {
         return obj; // To wrap a known object as a promise
     }
 });
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:7,代码来源:command.ts

示例5: valueForUrl

    protected valueForUrl(val: Ro.Value, field: Ro.IField): Ro.Value | null {
        if (val.isNull()) { return val; }
        const fieldEntryType = field.entryType();

        if (fieldEntryType !== Ro.EntryType.FreeForm || field.isCollectionContributed()) {

            if (this.isMultiChoiceField(field) || field.isCollectionContributed()) {
                let valuesFromRouteData: Ro.Value[] | null = new Array<Ro.Value>();
                if (field instanceof Ro.Parameter) {
                    const rd = Commandresult.getParametersAndCurrentValue(field.parent, this.context)[field.id()];
                    if (rd) { valuesFromRouteData = rd.list(); } // TODO: what if only one?
                } else if (field instanceof Ro.PropertyMember) {
                    const obj = field.parent as Ro.DomainObjectRepresentation;
                    const props = this.context.getObjectCachedValues(obj.id());
                    const rd = props[field.id()];
                    if (rd) { valuesFromRouteData = rd.list(); } // TODO: what if only one?
                }
                let vals: Ro.Value[] = [];
                if (val.isReference() || val.isScalar()) {
                    vals = new Array<Ro.Value>(val);
                } else if (val.isList()) { // Should be!
                    vals = val.list()!;
                }
                valuesFromRouteData = valuesFromRouteData || [];

                forEach(vals, v => this.addOrRemoveValue(valuesFromRouteData!, v));

                if (vals[0].isScalar()) { // then all must be scalar
                    const scalars = map(valuesFromRouteData, v => v.scalar());
                    return new Ro.Value(scalars);
                } else { // assumed to be links
                    const links: Ro.ILink[] = map(valuesFromRouteData, v => ({ href: v.link()!.href(), title: Ro.withUndefined(v.link()!.title()) }));
                    return new Ro.Value(links.length > 0 ? links : null);
                }
            }
            if (val.isScalar()) {
                return val;
            }
            // reference
            return this.leanLink(val);
        }

        if (val.isScalar()) {
            if (val.isNull()) {
                return new Ro.Value('');
            }
            return val;
            // TODO: consider these options:
            //    if (from.value instanceof Date) {
            //        return new Value((from.value as Date).toISOString());
            //    }

            //    return new Value(from.value as number | string | boolean);
        }
        if (val.isReference()) {
            return this.leanLink(val);
        }
        return null;
    }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:59,代码来源:command.ts

示例6: ngOnInit

    ngOnInit(): void {
        // expect dynamic-error to  have checked if the context has an error
        const errorWrapper = this.context.getError();
        const error = this.viewModelFactory.errorViewModel(errorWrapper);

        this.title = error.title;
        this.message = error.message;
        this.errorCode = error.errorCode;
        this.description = error.description;
        this.stackTrace = error.stackTrace;
    }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:11,代码来源:error.component.ts

示例7: getObject

    protected getObject(): Promise<Ro.DomainObjectRepresentation> {
        const oid = Ro.ObjectIdWrapper.fromObjectId(this.routeData().objectId, this.keySeparator);
        // TODO: Consider view model & transient modes?

        return this.context.getObject(1, oid, this.routeData().interactionMode).then((obj: Ro.DomainObjectRepresentation) => {
            if (this.routeData().interactionMode === InteractionMode.Edit) {
                return this.context.getObjectForEdit(1, obj);
            } else {
                return obj; // To wrap a known object as a promise
            }
        });
    }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:12,代码来源:command.ts

示例8: ngOnInit

    ngOnInit() {

        const errorWrapper = this.context.getError();
        if (errorWrapper) {
            this.customComponentService.getCustomErrorComponent(errorWrapper.category, errorWrapper.httpErrorCode || errorWrapper.clientErrorCode).then((c: Type<any>) => {
                const childComponent = this.componentFactoryResolver.resolveComponentFactory(c);
                this.parent.createComponent(childComponent);
            });
        } else {
            this.loggerService.warn('No error found returning to home page');
            this.urlManagerService.setHomeSinglePane();
        }
    }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:13,代码来源:dynamic-error.component.ts

示例9: setPropertyValueinContext

 protected setPropertyValueinContext(obj: Ro.DomainObjectRepresentation, property: Ro.PropertyMember, urlVal: Ro.Value) {
     this.context.cachePropertyValue(obj, property, urlVal);
 }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:3,代码来源:command.ts

示例10: setFieldValueInContext

 protected setFieldValueInContext(field: Ro.Parameter, val: Ro.Value) {
     this.context.cacheFieldValue(this.routeData().dialogId, field.id(), val);
 }
开发者ID:NakedObjectsGroup,项目名称:NakedObjectsFramework,代码行数:3,代码来源:command.ts


注:本文中的@nakedobjects/services.ContextService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。