Commit 73da299aaf9834b1fb108ca988767e2de3880476
1 parent
e0d554c5
Ace based editors disabled state handling
Showing
5 changed files
with
17 additions
and
8 deletions
... | ... | @@ -185,6 +185,9 @@ export class JsFuncComponent implements OnInit, OnDestroy, ControlValueAccessor, |
185 | 185 | |
186 | 186 | setDisabledState(isDisabled: boolean): void { |
187 | 187 | this.disabled = isDisabled; |
188 | + if (this.jsEditor) { | |
189 | + this.jsEditor.setReadOnly(this.disabled); | |
190 | + } | |
188 | 191 | } |
189 | 192 | |
190 | 193 | public validate(c: FormControl) { | ... | ... |
... | ... | @@ -22,11 +22,11 @@ |
22 | 22 | <label class="tb-title no-padding">{{ label }}</label> |
23 | 23 | <span fxFlex></span> |
24 | 24 | <button type="button" |
25 | - mat-button *ngIf="!readonly" class="tidy" (click)="beautifyJSON()"> | |
25 | + mat-button *ngIf="!readonly && !disabled" class="tidy" (click)="beautifyJSON()"> | |
26 | 26 | {{'js-func.tidy' | translate }} |
27 | 27 | </button> |
28 | 28 | <button type="button" |
29 | - mat-button *ngIf="!readonly" class="tidy" (click)="minifyJSON()"> | |
29 | + mat-button *ngIf="!readonly && !disabled" class="tidy" (click)="minifyJSON()"> | |
30 | 30 | {{'js-func.mini' | translate }} |
31 | 31 | </button> |
32 | 32 | <button type='button' mat-button mat-icon-button (click)="fullscreen = !fullscreen" | ... | ... |
... | ... | @@ -118,7 +118,7 @@ export class JsonContentComponent implements OnInit, ControlValueAccessor, Valid |
118 | 118 | mode: `ace/mode/${mode}`, |
119 | 119 | showGutter: true, |
120 | 120 | showPrintMargin: false, |
121 | - readOnly: this.readonly | |
121 | + readOnly: this.disabled || this.readonly | |
122 | 122 | }; |
123 | 123 | |
124 | 124 | const advancedOptions = { |
... | ... | @@ -185,6 +185,9 @@ export class JsonContentComponent implements OnInit, ControlValueAccessor, Valid |
185 | 185 | |
186 | 186 | setDisabledState(isDisabled: boolean): void { |
187 | 187 | this.disabled = isDisabled; |
188 | + if (this.jsonEditor) { | |
189 | + this.jsonEditor.setReadOnly(this.disabled || this.readonly); | |
190 | + } | |
188 | 191 | } |
189 | 192 | |
190 | 193 | public validate(c: FormControl) { |
... | ... | @@ -196,7 +199,7 @@ export class JsonContentComponent implements OnInit, ControlValueAccessor, Valid |
196 | 199 | } |
197 | 200 | |
198 | 201 | validateOnSubmit(): void { |
199 | - if (!this.readonly) { | |
202 | + if (!this.disabled && !this.readonly) { | |
200 | 203 | this.cleanupJsonErrors(); |
201 | 204 | this.contentValid = true; |
202 | 205 | this.propagateChange(this.contentBody); | ... | ... |
... | ... | @@ -25,11 +25,11 @@ |
25 | 25 | 'tb-error': !objectValid}">{{ label }}</label> |
26 | 26 | <span fxFlex></span> |
27 | 27 | <button type="button" |
28 | - mat-button *ngIf="!readonly" class="tidy" (click)="beautifyJSON()"> | |
28 | + mat-button *ngIf="!readonly && !disabled" class="tidy" (click)="beautifyJSON()"> | |
29 | 29 | {{'js-func.tidy' | translate }} |
30 | 30 | </button> |
31 | 31 | <button type="button" |
32 | - mat-button *ngIf="!readonly" class="tidy" (click)="minifyJSON()"> | |
32 | + mat-button *ngIf="!readonly && !disabled" class="tidy" (click)="minifyJSON()"> | |
33 | 33 | {{'js-func.mini' | translate }} |
34 | 34 | </button> |
35 | 35 | <button mat-button mat-icon-button (click)="fullscreen = !fullscreen" | ... | ... |
... | ... | @@ -111,7 +111,7 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va |
111 | 111 | mode: 'ace/mode/json', |
112 | 112 | showGutter: true, |
113 | 113 | showPrintMargin: false, |
114 | - readOnly: this.readonly | |
114 | + readOnly: this.disabled || this.readonly | |
115 | 115 | }; |
116 | 116 | |
117 | 117 | const advancedOptions = { |
... | ... | @@ -161,6 +161,9 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va |
161 | 161 | |
162 | 162 | setDisabledState(isDisabled: boolean): void { |
163 | 163 | this.disabled = isDisabled; |
164 | + if (this.jsonEditor) { | |
165 | + this.jsonEditor.setReadOnly(this.disabled || this.readonly); | |
166 | + } | |
164 | 167 | } |
165 | 168 | |
166 | 169 | public validate(c: FormControl) { |
... | ... | @@ -172,7 +175,7 @@ export class JsonObjectEditComponent implements OnInit, ControlValueAccessor, Va |
172 | 175 | } |
173 | 176 | |
174 | 177 | validateOnSubmit(): void { |
175 | - if (!this.readonly) { | |
178 | + if (!this.disabled && !this.readonly) { | |
176 | 179 | this.cleanupJsonErrors(); |
177 | 180 | if (!this.objectValid) { |
178 | 181 | this.store.dispatch(new ActionNotificationShow( | ... | ... |