Allow Organization Creator to be visible by configuration (ref #255)

This commit is contained in:
George Kalampokis 2020-04-23 10:48:14 +03:00
parent 05e2374f97
commit 8ae58c9ef3
4 changed files with 16 additions and 3 deletions

View File

@ -57,6 +57,11 @@ export class ConfigurationService extends BaseComponent {
return this._guideAssets; return this._guideAssets;
} }
private _allowOrganizationCreator: boolean;
get allowOrganizationCreator():boolean {
return this._allowOrganizationCreator;
}
public loadConfiguration(): Promise<any> { public loadConfiguration(): Promise<any> {
return new Promise((r, e) => { return new Promise((r, e) => {
@ -92,6 +97,7 @@ export class ConfigurationService extends BaseComponent {
this._logging = Logging.parseValue(config.logging); this._logging = Logging.parseValue(config.logging);
this._lockInterval = config.lockInterval; this._lockInterval = config.lockInterval;
this._guideAssets = config.guideAssets; this._guideAssets = config.guideAssets;
this._allowOrganizationCreator = config.allowOrganizationCreator;
} }
} }

View File

@ -46,7 +46,7 @@
<mat-error *ngIf="formGroup.get('organisations').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | <mat-error *ngIf="formGroup.get('organisations').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |
translate}}</mat-error> translate}}</mat-error>
<mat-hint>{{'DMP-EDITOR.FIELDS.ORGANISATIONS-HINT' | translate}}</mat-hint> <mat-hint>{{'DMP-EDITOR.FIELDS.ORGANISATIONS-HINT' | translate}}</mat-hint>
<button matSuffix class="input-btn" [disabled]="canAddOrganizations()" type="button" (click)="addOrganization($event)"> <button *ngIf="showOrganizationCreator()" matSuffix class="input-btn" [disabled]="canAddOrganizations()" type="button" (click)="addOrganization($event)">
<mat-icon class="icon-btn">add_circle</mat-icon> <mat-icon class="icon-btn">add_circle</mat-icon>
</button> </button>
</mat-form-field> </mat-form-field>

View File

@ -22,6 +22,7 @@ import { Observable } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators'; import { map, takeUntil } from 'rxjs/operators';
import { AddOrganizationComponent } from '../add-organization/add-organization.component'; import { AddOrganizationComponent } from '../add-organization/add-organization.component';
import { isNullOrUndefined } from 'util'; import { isNullOrUndefined } from 'util';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
@Component({ @Component({
selector: 'app-general-tab', selector: 'app-general-tab',
@ -71,7 +72,8 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
private externalSourcesService: ExternalSourcesService, private externalSourcesService: ExternalSourcesService,
private _service: DmpService, private _service: DmpService,
private dialog: MatDialog, private dialog: MatDialog,
private language: TranslateService private language: TranslateService,
private configurationService: ConfigurationService
) { ) {
super(); super();
} }
@ -194,6 +196,10 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
}); });
} }
showOrganizationCreator(): boolean {
return this.configurationService.allowOrganizationCreator;
}
canAddOrganizations(): boolean { canAddOrganizations(): boolean {
if (!isNullOrUndefined(this.formGroup.get('organizations'))) { if (!isNullOrUndefined(this.formGroup.get('organizations'))) {
return this.formGroup.get('organiztions').disabled; return this.formGroup.get('organiztions').disabled;

View File

@ -49,5 +49,6 @@
"logLevels": ["debug", "info", "warning", "error"] "logLevels": ["debug", "info", "warning", "error"]
}, },
"lockInterval": 60000, "lockInterval": 60000,
"guideAssets": "assets/images/guide" "guideAssets": "assets/images/guide",
"allowOrganizationCreator": true
} }