diff --git a/src/app/submission/form/collection/submission-form-collection.component.html b/src/app/submission/form/collection/submission-form-collection.component.html
index 4ed14051f4..6547a3cc3c 100644
--- a/src/app/submission/form/collection/submission-form-collection.component.html
+++ b/src/app/submission/form/collection/submission-form-collection.component.html
@@ -13,7 +13,7 @@
[disabled]="(disabled$ | async)"
ngbDropdownToggle>
- {{ (selectedCollectionName) ? selectedCollectionName : '' }}
+ {{ selectedCollectionName$ | async }}
= new EventEmitter
();
+ @Output() collectionChange: EventEmitter = new EventEmitter();
public disabled$ = new BehaviorSubject(true);
public model: any;
@@ -71,14 +68,13 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
public searchListCollection$: Observable;
public selectedCollectionId: string;
public selectedCollectionName: string;
+ public selectedCollectionName$: Observable;
protected pathCombiner: JsonPatchOperationPathCombiner;
private scrollableBottom = false;
private scrollableTop = false;
private subs: Subscription[] = [];
- formatter = (x: { collection: string }) => x.collection;
-
constructor(protected cdr: ChangeDetectorRef,
private communityDataService: CommunityDataService,
private operationsBuilder: JsonPatchOperationsBuilder,
@@ -104,21 +100,19 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
if (hasValue(changes.currentCollectionId)
&& hasValue(changes.currentCollectionId.currentValue)) {
this.selectedCollectionId = this.currentCollectionId;
+
// @TODO replace with search/top browse endpoint
// @TODO implement community/subcommunity hierarchy
- const listCollection$ = this.communityDataService.findAll().pipe(
+ const communities$ = this.communityDataService.findAll().pipe(
find((communities: RemoteData>) => isNotEmpty(communities.payload)),
- mergeMap((communities: RemoteData>) => communities.payload.page),
+ mergeMap((communities: RemoteData>) => communities.payload.page));
+
+ const listCollection$ = communities$.pipe(
flatMap((communityData: Community) => {
return communityData.collections.pipe(
find((collections: RemoteData>) => !collections.isResponsePending && collections.hasSucceeded),
mergeMap((collections: RemoteData>) => collections.payload.page),
filter((collectionData: Collection) => isNotEmpty(collectionData)),
- tap((collectionData: Collection) => {
- if (collectionData.id === this.selectedCollectionId) {
- this.selectedCollectionName = collectionData.name;
- }
- }),
map((collectionData: Collection) => ({
communities: [{id: communityData.id, name: communityData.name}],
collection: {id: collectionData.id, name: collectionData.name}
@@ -129,6 +123,19 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
startWith([])
);
+ this.selectedCollectionName$ = communities$.pipe(
+ flatMap((communityData: Community) => {
+ return communityData.collections.pipe(
+ find((collections: RemoteData>) => !collections.isResponsePending && collections.hasSucceeded),
+ mergeMap((collections: RemoteData>) => collections.payload.page),
+ filter((collectionData: Collection) => isNotEmpty(collectionData)),
+ filter((collectionData: Collection) => collectionData.id === this.selectedCollectionId),
+ map((collectionData: Collection) => collectionData.name)
+ );
+ }),
+ startWith('')
+ );
+
const searchTerm$ = this.searchField.valueChanges.pipe(
debounceTime(200),
distinctUntilChanged(),
@@ -138,7 +145,7 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
this.searchListCollection$ = combineLatest(searchTerm$, listCollection$).pipe(
map(([searchTerm, listCollection]) => {
this.disabled$.next(isEmpty(listCollection));
- if (searchTerm === '' || isNullOrUndefined(searchTerm)) {
+ if (isEmpty(searchTerm)) {
return listCollection;
} else {
return listCollection.filter((v) => v.collection.name.toLowerCase().indexOf(searchTerm.toLowerCase()) > -1).slice(0, 5)
@@ -167,6 +174,7 @@ export class SubmissionFormCollectionComponent implements OnChanges, OnInit {
.subscribe((submissionObject: SubmissionObject[]) => {
this.selectedCollectionId = event.collection.id;
this.selectedCollectionName = event.collection.name;
+ this.selectedCollectionName$ = observableOf(event.collection.name);
this.collectionChange.emit(submissionObject[0]);
this.submissionService.changeSubmissionCollection(this.submissionId, event.collection.id);
this.disabled$.next(false);
diff --git a/src/app/submission/sections/license/section-license.component.html b/src/app/submission/sections/license/section-license.component.html
index 0a432eae7a..7b0faad5e3 100644
--- a/src/app/submission/sections/license/section-license.component.html
+++ b/src/app/submission/sections/license/section-license.component.html
@@ -1,4 +1,4 @@
-{{ licenseText }}
+{{ licenseText$ | async }}
;
protected pathCombiner: JsonPatchOperationPathCombiner;
protected subs: Subscription[] = [];
@@ -68,33 +68,31 @@ export class LicenseSectionComponent extends SectionModelComponent {
this.formModel = this.formBuilderService.fromJSON(SECTION_LICENSE_FORM_MODEL);
const model = this.formBuilderService.findById('granted', this.formModel);
+ // Retrieve license accepted status
+ if ((this.sectionData.data as WorkspaceitemSectionLicenseObject).granted) {
+ (model as DynamicCheckboxModel).valueUpdates.next(true);
+ } else {
+ (model as DynamicCheckboxModel).valueUpdates.next(false);
+ }
+
+ this.licenseText$ = this.collectionDataService.findById(this.collectionId).pipe(
+ filter((collectionData: RemoteData) => isNotUndefined((collectionData.payload))),
+ flatMap((collectionData: RemoteData) => collectionData.payload.license),
+ find((licenseData: RemoteData) => isNotUndefined((licenseData.payload))),
+ map((licenseData: RemoteData) => licenseData.payload.text),
+ startWith(''));
+
this.subs.push(
- this.collectionDataService.findById(this.collectionId).pipe(
- filter((collectionData: RemoteData) => isNotUndefined((collectionData.payload))),
- flatMap((collectionData: RemoteData) => collectionData.payload.license),
- find((licenseData: RemoteData) => isNotUndefined((licenseData.payload))))
- .subscribe((licenseData: RemoteData) => {
- this.licenseText = licenseData.payload.text;
-
- // Retrieve license accepted status
- if ((this.sectionData.data as WorkspaceitemSectionLicenseObject).granted) {
- (model as DynamicCheckboxModel).valueUpdates.next(true);
- } else {
- (model as DynamicCheckboxModel).valueUpdates.next(false);
- }
-
- // Disable checkbox whether it's in workflow or item scope
- this.sectionService.isSectionReadOnly(
- this.submissionId,
- this.sectionData.id,
- this.submissionService.getSubmissionScope()
- ).pipe(
- take(1),
- filter((isReadOnly) => isReadOnly))
- .subscribe(() => {
- model.disabledUpdates.next(true);
- });
- this.changeDetectorRef.detectChanges();
+ // Disable checkbox whether it's in workflow or item scope
+ this.sectionService.isSectionReadOnly(
+ this.submissionId,
+ this.sectionData.id,
+ this.submissionService.getSubmissionScope()
+ ).pipe(
+ take(1),
+ filter((isReadOnly) => isReadOnly))
+ .subscribe(() => {
+ model.disabledUpdates.next(true);
}),
this.sectionService.getSectionErrors(this.submissionId, this.sectionData.id).pipe(
@@ -108,7 +106,7 @@ export class LicenseSectionComponent extends SectionModelComponent {
if (error.path === '/sections/license') {
// check whether license is not accepted
if (!(model as DynamicCheckboxModel).checked) {
- return Object.assign({}, error, {path: '/sections/license/granted'});
+ return Object.assign({}, error, { path: '/sections/license/granted' });
} else {
return null;
}