Skip to content

Commit

Permalink
Merge branch 'w2p-117573_remove-observable-function-calls-from-templa…
Browse files Browse the repository at this point in the history
…te-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
  • Loading branch information
alexandrevryghem committed Oct 29, 2024
2 parents 2581b66 + 59e5f71 commit d3de28d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ <h2>{{messagePrefix + '.groupsEPersonIsMemberOf' | translate}}</h2>
{{ dsoNameService.getName(group) }}
</a>
</td>
<td class="align-middle">{{ dsoNameService.getName(undefined) }}</td>
<td class="align-middle">
{{ dsoNameService.getName((group.object | async)?.payload) }}
</td>
</tr>
</tbody>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ import {
} from 'rxjs';
import {
debounceTime,
filter,
map,
startWith,
switchMap,
take,
} from 'rxjs/operators';
Expand Down Expand Up @@ -72,7 +70,6 @@ import { AlertType } from '../../../shared/alert/alert-type';
import { ConfirmationModalComponent } from '../../../shared/confirmation-modal/confirmation-modal.component';
import { ContextHelpDirective } from '../../../shared/context-help.directive';
import {
hasNoValue,
hasValue,
hasValueOperator,
isNotEmpty,
Expand Down Expand Up @@ -219,11 +216,16 @@ export class GroupFormComponent implements OnInit, OnDestroy {
this.activeGroupLinkedDSO$ = this.getActiveGroupLinkedDSO();
this.linkedEditRolesRoute$ = this.getLinkedEditRolesRoute();
this.canEdit$ = this.activeGroupLinkedDSO$.pipe(
filter((dso: DSpaceObject) => hasNoValue(dso)),
switchMap(() => this.activeGroup$),
hasValueOperator(),
switchMap((group: Group) => this.authorizationService.isAuthorized(FeatureID.CanDelete, group.self)),
startWith(false),
switchMap((dso: DSpaceObject) => {
if (hasValue(dso)) {
return [false];
} else {
return this.activeGroup$.pipe(
hasValueOperator(),
switchMap((group: Group) => this.authorizationService.isAuthorized(FeatureID.CanDelete, group.self)),
);
}
}),
);
this.initialisePage();
}
Expand Down Expand Up @@ -271,34 +273,39 @@ export class GroupFormComponent implements OnInit, OnDestroy {
observableCombineLatest([
this.activeGroup$,
this.canEdit$,
this.activeGroupLinkedDSO$.pipe(take(1)),
this.activeGroupLinkedDSO$,
]).subscribe(([activeGroup, canEdit, linkedObject]) => {

if (activeGroup != null) {

// Disable group name exists validator
this.formGroup.controls.groupName.clearAsyncValidators();
if (linkedObject?.name) {

if (isNotEmpty(linkedObject?.name)) {
if (!this.formGroup.controls.groupCommunity) {
this.formBuilderService.insertFormGroupControl(1, this.formGroup, this.formModel, groupCommunityModel);
this.groupDescription = this.formGroup.get('groupCommunity');
this.formGroup.patchValue({
groupName: activeGroup.name,
groupCommunity: linkedObject?.name ?? '',
groupDescription: activeGroup.firstMetadataValue('dc.description'),
});
}
this.formGroup.patchValue({
groupName: activeGroup.name,
groupCommunity: linkedObject?.name ?? '',
groupDescription: activeGroup.firstMetadataValue('dc.description'),
});
} else {
this.formModel = [
groupNameModel,
groupDescriptionModel,
];
this.formGroup.patchValue({
groupName: activeGroup.name,
groupDescription: activeGroup.firstMetadataValue('dc.description'),
});
}
setTimeout(() => {
if (!canEdit || activeGroup.permanent) {
this.formGroup.disable();
}
}, 200);
if (!canEdit || activeGroup.permanent) {
this.formGroup.disable();
} else {
this.formGroup.enable();
}
}
}),
);
Expand Down Expand Up @@ -527,6 +534,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
*/
getLinkedEditRolesRoute(): Observable<string> {
return this.activeGroupLinkedDSO$.pipe(
hasValueOperator(),
map((dso: DSpaceObject) => {
switch ((dso as any).type) {
case Community.type.value:
Expand Down

0 comments on commit d3de28d

Please sign in to comment.