Skip to content

Commit d3de28d

Browse files
Merge branch 'w2p-117573_remove-observable-function-calls-from-template-7.6' into w2p-117573_remove-observable-function-calls_contribute-main
# Conflicts: # src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html # src/app/access-control/group-registry/group-form/group-form.component.ts
2 parents 2581b66 + 59e5f71 commit d3de28d

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

src/app/access-control/epeople-registry/eperson-form/eperson-form.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ <h2>{{messagePrefix + '.groupsEPersonIsMemberOf' | translate}}</h2>
7575
{{ dsoNameService.getName(group) }}
7676
</a>
7777
</td>
78-
<td class="align-middle">{{ dsoNameService.getName(undefined) }}</td>
78+
<td class="align-middle">
79+
{{ dsoNameService.getName((group.object | async)?.payload) }}
80+
</td>
7981
</tr>
8082
</tbody>
8183
</table>

src/app/access-control/group-registry/group-form/group-form.component.ts

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ import {
3838
} from 'rxjs';
3939
import {
4040
debounceTime,
41-
filter,
4241
map,
43-
startWith,
4442
switchMap,
4543
take,
4644
} from 'rxjs/operators';
@@ -72,7 +70,6 @@ import { AlertType } from '../../../shared/alert/alert-type';
7270
import { ConfirmationModalComponent } from '../../../shared/confirmation-modal/confirmation-modal.component';
7371
import { ContextHelpDirective } from '../../../shared/context-help.directive';
7472
import {
75-
hasNoValue,
7673
hasValue,
7774
hasValueOperator,
7875
isNotEmpty,
@@ -219,11 +216,16 @@ export class GroupFormComponent implements OnInit, OnDestroy {
219216
this.activeGroupLinkedDSO$ = this.getActiveGroupLinkedDSO();
220217
this.linkedEditRolesRoute$ = this.getLinkedEditRolesRoute();
221218
this.canEdit$ = this.activeGroupLinkedDSO$.pipe(
222-
filter((dso: DSpaceObject) => hasNoValue(dso)),
223-
switchMap(() => this.activeGroup$),
224-
hasValueOperator(),
225-
switchMap((group: Group) => this.authorizationService.isAuthorized(FeatureID.CanDelete, group.self)),
226-
startWith(false),
219+
switchMap((dso: DSpaceObject) => {
220+
if (hasValue(dso)) {
221+
return [false];
222+
} else {
223+
return this.activeGroup$.pipe(
224+
hasValueOperator(),
225+
switchMap((group: Group) => this.authorizationService.isAuthorized(FeatureID.CanDelete, group.self)),
226+
);
227+
}
228+
}),
227229
);
228230
this.initialisePage();
229231
}
@@ -271,34 +273,39 @@ export class GroupFormComponent implements OnInit, OnDestroy {
271273
observableCombineLatest([
272274
this.activeGroup$,
273275
this.canEdit$,
274-
this.activeGroupLinkedDSO$.pipe(take(1)),
276+
this.activeGroupLinkedDSO$,
275277
]).subscribe(([activeGroup, canEdit, linkedObject]) => {
276278

277279
if (activeGroup != null) {
278280

279281
// Disable group name exists validator
280282
this.formGroup.controls.groupName.clearAsyncValidators();
281-
if (linkedObject?.name) {
283+
284+
if (isNotEmpty(linkedObject?.name)) {
282285
if (!this.formGroup.controls.groupCommunity) {
283286
this.formBuilderService.insertFormGroupControl(1, this.formGroup, this.formModel, groupCommunityModel);
284287
this.groupDescription = this.formGroup.get('groupCommunity');
285-
this.formGroup.patchValue({
286-
groupName: activeGroup.name,
287-
groupCommunity: linkedObject?.name ?? '',
288-
groupDescription: activeGroup.firstMetadataValue('dc.description'),
289-
});
290288
}
289+
this.formGroup.patchValue({
290+
groupName: activeGroup.name,
291+
groupCommunity: linkedObject?.name ?? '',
292+
groupDescription: activeGroup.firstMetadataValue('dc.description'),
293+
});
291294
} else {
295+
this.formModel = [
296+
groupNameModel,
297+
groupDescriptionModel,
298+
];
292299
this.formGroup.patchValue({
293300
groupName: activeGroup.name,
294301
groupDescription: activeGroup.firstMetadataValue('dc.description'),
295302
});
296303
}
297-
setTimeout(() => {
298-
if (!canEdit || activeGroup.permanent) {
299-
this.formGroup.disable();
300-
}
301-
}, 200);
304+
if (!canEdit || activeGroup.permanent) {
305+
this.formGroup.disable();
306+
} else {
307+
this.formGroup.enable();
308+
}
302309
}
303310
}),
304311
);
@@ -527,6 +534,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
527534
*/
528535
getLinkedEditRolesRoute(): Observable<string> {
529536
return this.activeGroupLinkedDSO$.pipe(
537+
hasValueOperator(),
530538
map((dso: DSpaceObject) => {
531539
switch ((dso as any).type) {
532540
case Community.type.value:

0 commit comments

Comments
 (0)