Skip to content

Commit 57eb6da

Browse files
committed
fixup! Fix change detection issue
1 parent b1d33c8 commit 57eb6da

3 files changed

Lines changed: 26 additions & 19 deletions

File tree

src/app/curation-form/curation-form.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input, OnInit } from '@angular/core';
1+
import { ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
22
import { ScriptDataService } from '../core/data/processes/script-data.service';
33
import { FormControl, FormGroup } from '@angular/forms';
44
import { getFirstCompletedRemoteData } from '../core/shared/operators';
@@ -40,7 +40,8 @@ export class CurationFormComponent implements OnInit {
4040
private notificationsService: NotificationsService,
4141
private translateService: TranslateService,
4242
private handleService: HandleService,
43-
private router: Router
43+
private router: Router,
44+
private cdr: ChangeDetectorRef
4445
) {
4546
}
4647

@@ -59,6 +60,7 @@ export class CurationFormComponent implements OnInit {
5960
.filter((value) => isNotEmpty(value) && value.includes('='))
6061
.map((value) => value.split('=')[1].trim());
6162
this.form.get('task').patchValue(this.tasks[0]);
63+
this.cdr.detectChanges();
6264
});
6365
}
6466

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<div class="container mt-3">
22
<h3>{{'item.edit.curate.title' |translate:{item: (itemName$ |async)} }}</h3>
33
<ds-curation-form
4-
[dsoHandle]="(dsoRD$|async)?.payload.handle"
4+
*ngIf="dsoRD$ | async as dsoRD"
5+
[dsoHandle]="dsoRD?.payload.handle"
56
></ds-curation-form>
67
</div>
Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Component } from '@angular/core';
2-
import { filter, map, shareReplay } from 'rxjs/operators';
1+
import { Component, OnInit } from '@angular/core';
2+
import { filter, map, take } from 'rxjs/operators';
33
import { RemoteData } from '../../../core/data/remote-data';
44
import { Observable } from 'rxjs';
55
import { ActivatedRoute } from '@angular/router';
66
import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
7-
import { Collection } from '../../../core/shared/collection.model';
87
import { hasValue } from '../../../shared/empty.util';
8+
import { Item } from '../../../core/shared/item.model';
99

1010
/**
1111
* Component for managing a collection's curation tasks
@@ -14,22 +14,26 @@ import { hasValue } from '../../../shared/empty.util';
1414
selector: 'ds-item-curate',
1515
templateUrl: './item-curate.component.html',
1616
})
17-
export class ItemCurateComponent {
18-
dsoRD$: Observable<RemoteData<Collection>> = this.route.parent.data.pipe(
19-
map((data) => data.dso),
20-
shareReplay(1)
21-
);
22-
23-
itemName$: Observable<string> = this.dsoRD$.pipe(
24-
filter((rd: RemoteData<Collection>) => hasValue(rd)),
25-
map((rd: RemoteData<Collection>) => {
26-
console.log(rd);
27-
return this.dsoNameService.getName(rd.payload);
28-
})
29-
);
17+
export class ItemCurateComponent implements OnInit {
18+
dsoRD$: Observable<RemoteData<Item>>;
19+
itemName$: Observable<string>;
3020

3121
constructor(
3222
private route: ActivatedRoute,
3323
private dsoNameService: DSONameService,
3424
) {}
25+
26+
ngOnInit(): void {
27+
this.dsoRD$ = this.route.parent.data.pipe(
28+
take(1),
29+
map((data) => data.dso),
30+
);
31+
32+
this.itemName$ = this.dsoRD$.pipe(
33+
filter((rd: RemoteData<Item>) => hasValue(rd)),
34+
map((rd: RemoteData<Item>) => {
35+
return this.dsoNameService.getName(rd.payload);
36+
})
37+
);
38+
}
3539
}

0 commit comments

Comments
 (0)