本文整理匯總了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));
}
示例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);
}
});
示例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
}
});
示例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;
}
示例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;
}
示例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
}
});
}
示例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();
}
}
示例9: setPropertyValueinContext
protected setPropertyValueinContext(obj: Ro.DomainObjectRepresentation, property: Ro.PropertyMember, urlVal: Ro.Value) {
this.context.cachePropertyValue(obj, property, urlVal);
}
示例10: setFieldValueInContext
protected setFieldValueInContext(field: Ro.Parameter, val: Ro.Value) {
this.context.cacheFieldValue(this.routeData().dialogId, field.id(), val);
}