Skip to content

Commit

Permalink
Updated reload behavior for guid route, reverted changes for overview…
Browse files Browse the repository at this point in the history
… index.
  • Loading branch information
chth0n1x committed Oct 5, 2023
1 parent c849e64 commit 1104099
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
20 changes: 12 additions & 8 deletions app/resolve-guid/guid-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,30 @@ export default abstract class GuidRoute extends Route {
@service ready!: Ready;
@service store!: Store;

abstract modelName(): keyof ModelRegistry;

@task
@waitFor
async getModel(guid: string) {
const blocker = this.ready.getBlocker();

let model;
try {
const blocker = this.ready.getBlocker();
const model = await this.store.findRecord(this.modelName(), guid, {
model = await this.store.findRecord(this.modelName(), guid, {
include: this.include(),
adapterOptions: this.adapterOptions(),
reload: true,
});
blocker.done();
return model;
} catch (e) {
// To do custom error handling, add an error() action to the route that subclasses GuidRoute.
this.send('error', e);
}

blocker.done();

return model;
}

abstract modelName(): keyof ModelRegistry;

adapterOptions(): {} {
return {};
}
Expand All @@ -48,9 +53,8 @@ export default abstract class GuidRoute extends Route {
}

model(params: { guid: string }) {
const paramsGuid = params.guid;
return {
guid: paramsGuid,
guid: params.guid,
taskInstance: taskFor(this.getModel).perform(params.guid),
task: this.getModel,
};
Expand Down
13 changes: 2 additions & 11 deletions lib/registries/addon/overview/index/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,11 @@ export default class Overview extends Controller {
registration?: Registration;

@computed('registration.{root,isRoot}')
get rootTitle() {
get root() {
if (!this.registration || this.registration.isRoot) {
return undefined;
}
const rootTitle = this.registration.root.get('title');
return rootTitle;
}

@computed('registration.{root,isRoot}')
get rootId() {
if (!this.registration || this.registration.isRoot) {
return undefined;
}
const rootId = this.registration.root.get('id');
return rootId;
return this.registration.belongsTo('root').value() as Registration;
}
}
4 changes: 2 additions & 2 deletions lib/registries/addon/overview/index/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
{{t 'registries.overview.component_of'}}
<OsfLink
@route='resolve-guid'
@models={{array this.rootId}}
@models={{array this.root.id}}
>
{{this.rootTitle}}
{{this.root.title}}
</OsfLink>
</div>
{{/unless}}
Expand Down

0 comments on commit 1104099

Please sign in to comment.