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