mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-11 12:03:03 +00:00
Created abstract methods to section model
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { Inject } from '@angular/core';
|
||||
import { Inject, OnInit } from '@angular/core';
|
||||
import { SectionDataObject } from './section-data.model';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { SectionsService } from '../sections.service';
|
||||
import { isNotUndefined } from '../../../shared/empty.util';
|
||||
|
||||
export interface SectionDataModel {
|
||||
sectionData: SectionDataObject
|
||||
@@ -8,7 +11,8 @@ export interface SectionDataModel {
|
||||
/**
|
||||
* An abstract model class for a submission edit form section.
|
||||
*/
|
||||
export abstract class SectionModelComponent implements SectionDataModel {
|
||||
export abstract class SectionModelComponent implements OnInit, SectionDataModel {
|
||||
protected abstract sectionService: SectionsService;
|
||||
collectionId: string;
|
||||
sectionData: SectionDataObject;
|
||||
submissionId: string;
|
||||
@@ -21,4 +25,21 @@ export abstract class SectionModelComponent implements SectionDataModel {
|
||||
this.sectionData = injectedSectionData;
|
||||
this.submissionId = injectedSubmissionId;
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.onSectionInit();
|
||||
this.updateSectionStatus();
|
||||
}
|
||||
|
||||
protected abstract getSectionStatus(): Observable<boolean>;
|
||||
protected abstract onSectionInit(): void;
|
||||
|
||||
protected updateSectionStatus(): void {
|
||||
this.getSectionStatus()
|
||||
.filter((sectionStatus: boolean) => isNotUndefined(sectionStatus))
|
||||
.startWith(true)
|
||||
.subscribe((sectionStatus: boolean) => {
|
||||
this.sectionService.setSectionStatus(this.submissionId, this.sectionData.id, sectionStatus);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user