@@ -38,9 +38,7 @@ import {
3838} from 'rxjs' ;
3939import {
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';
7270import { ConfirmationModalComponent } from '../../../shared/confirmation-modal/confirmation-modal.component' ;
7371import { ContextHelpDirective } from '../../../shared/context-help.directive' ;
7472import {
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