mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 14:03:06 +00:00
[CST-5674] Fix; enable policy and action type editing; test
This commit is contained in:
@@ -222,8 +222,6 @@ describe('ResourcePolicyFormComponent test suite', () => {
|
||||
|
||||
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
|
||||
testComp = testFixture.componentInstance;
|
||||
testComp.resourcePolicy = resourcePolicy;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
@@ -161,27 +161,31 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
this.formId = this.formService.getUniqueId('resource-policy-form');
|
||||
this.formModel = this.buildResourcePolicyForm();
|
||||
|
||||
const epersonRD$ = this.ePersonService.findByHref(this.resourcePolicy._links.eperson.href, false).pipe(
|
||||
getFirstSucceededRemoteData()
|
||||
);
|
||||
const groupRD$ = this.groupService.findByHref(this.resourcePolicy._links.group.href, false).pipe(
|
||||
getFirstSucceededRemoteData()
|
||||
);
|
||||
const dsoRD$: Observable<RemoteData<DSpaceObject>> = observableCombineLatest([epersonRD$, groupRD$]).pipe(
|
||||
map((rdArr: RemoteData<DSpaceObject>[]) => {
|
||||
return rdArr.find((rd: RemoteData<DSpaceObject>) => isNotEmpty(rd.payload));
|
||||
}),
|
||||
hasValueOperator(),
|
||||
);
|
||||
this.subs.push(
|
||||
dsoRD$.pipe(
|
||||
filter(() => this.isActive),
|
||||
).subscribe((dsoRD: RemoteData<DSpaceObject>) => {
|
||||
this.resourcePolicyGrant = dsoRD.payload;
|
||||
this.navActiveId = String(dsoRD.payload.type);
|
||||
this.resourcePolicyTargetName$.next(this.getResourcePolicyTargetName());
|
||||
})
|
||||
);
|
||||
if (this.isBeingEdited()) {
|
||||
const epersonRD$ = this.ePersonService.findByHref(this.resourcePolicy._links.eperson.href, false).pipe(
|
||||
getFirstSucceededRemoteData()
|
||||
);
|
||||
const groupRD$ = this.groupService.findByHref(this.resourcePolicy._links.group.href, false).pipe(
|
||||
getFirstSucceededRemoteData()
|
||||
);
|
||||
const dsoRD$: Observable<RemoteData<DSpaceObject>> = observableCombineLatest([epersonRD$, groupRD$]).pipe(
|
||||
map((rdArr: RemoteData<DSpaceObject>[]) => {
|
||||
return rdArr.find((rd: RemoteData<DSpaceObject>) => isNotEmpty(rd.payload));
|
||||
}),
|
||||
hasValueOperator(),
|
||||
);
|
||||
this.subs.push(
|
||||
dsoRD$.pipe(
|
||||
filter(() => this.isActive),
|
||||
).subscribe((dsoRD: RemoteData<DSpaceObject>) => {
|
||||
this.resourcePolicyGrant = dsoRD.payload;
|
||||
this.navActiveId = String(dsoRD.payload.type);
|
||||
this.resourcePolicyTargetName$.next(this.getResourcePolicyTargetName());
|
||||
})
|
||||
)
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,19 +206,12 @@ export class ResourcePolicyFormComponent implements OnInit, OnDestroy {
|
||||
*/
|
||||
private buildResourcePolicyForm(): DynamicFormControlModel[] {
|
||||
const formModel: DynamicFormControlModel[] = [];
|
||||
// TODO to be removed when https://github.com/DSpace/DSpace/issues/7812 will be implemented
|
||||
const policyTypeConf = Object.assign({}, RESOURCE_POLICY_FORM_POLICY_TYPE_CONFIG, {
|
||||
disabled: isNotEmpty(this.resourcePolicy)
|
||||
});
|
||||
// TODO to be removed when https://github.com/DSpace/DSpace/issues/7812 will be implemented
|
||||
const actionConf = Object.assign({}, RESOURCE_POLICY_FORM_ACTION_TYPE_CONFIG, {
|
||||
disabled: isNotEmpty(this.resourcePolicy)
|
||||
});
|
||||
|
||||
formModel.push(
|
||||
new DsDynamicInputModel(RESOURCE_POLICY_FORM_NAME_CONFIG),
|
||||
new DsDynamicTextAreaModel(RESOURCE_POLICY_FORM_DESCRIPTION_CONFIG),
|
||||
new DynamicSelectModel(policyTypeConf),
|
||||
new DynamicSelectModel(actionConf)
|
||||
new DynamicSelectModel(RESOURCE_POLICY_FORM_POLICY_TYPE_CONFIG),
|
||||
new DynamicSelectModel(RESOURCE_POLICY_FORM_ACTION_TYPE_CONFIG)
|
||||
);
|
||||
|
||||
const startDateModel = new DynamicDatePickerModel(
|
||||
|
Reference in New Issue
Block a user