Browse Source

Improve formatting of action data.

pull/861/head
Sebastian 4 years ago
parent
commit
d26808ae26
  1. 2
      backend/src/Squidex/Areas/Api/Controllers/News/Service/FeaturesService.cs
  2. 2
      frontend/src/app/features/rules/pages/simulator/simulated-rule-event.component.html
  3. 18
      frontend/src/app/framework/angular/forms/editors/code-editor.component.ts

2
backend/src/Squidex/Areas/Api/Controllers/News/Service/FeaturesService.cs

@ -9,6 +9,8 @@ using Microsoft.Extensions.Options;
using Squidex.Areas.Api.Controllers.News.Models; using Squidex.Areas.Api.Controllers.News.Models;
using Squidex.ClientLibrary; using Squidex.ClientLibrary;
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
namespace Squidex.Areas.Api.Controllers.News.Service namespace Squidex.Areas.Api.Controllers.News.Service
{ {
public sealed class FeaturesService public sealed class FeaturesService

2
frontend/src/app/features/rules/pages/simulator/simulated-rule-event.component.html

@ -53,7 +53,7 @@
<div class="history-state"> <div class="history-state">
<label>{{ 'rules.actionData' | sqxTranslate }}</label> <label>{{ 'rules.actionData' | sqxTranslate }}</label>
<sqx-code-editor [ngModel]="event.actionData" valueMode="Json" [disabled]="true" [wordWrap]="true" height="auto" [maxLines]="20"></sqx-code-editor> <sqx-code-editor [ngModel]="event.actionData" valueMode="JsonString" [disabled]="true" [wordWrap]="true" height="auto" [maxLines]="20"></sqx-code-editor>
</div> </div>
<sqx-rule-transition text="i18n:rules.simulation.actionExecuted"></sqx-rule-transition> <sqx-rule-transition text="i18n:rules.simulation.actionExecuted"></sqx-rule-transition>

18
frontend/src/app/framework/angular/forms/editors/code-editor.component.ts

@ -46,7 +46,7 @@ export class CodeEditorComponent extends StatefulControlComponent<{}, string> im
public valueFile = ''; public valueFile = '';
@Input() @Input()
public valueMode: 'String' | 'Json' = 'String'; public valueMode: 'String' | 'Json' | 'JsonString' = 'String';
@Input() @Input()
public maxLines: number | undefined; public maxLines: number | undefined;
@ -92,21 +92,21 @@ export class CodeEditorComponent extends StatefulControlComponent<{}, string> im
} }
public writeValue(obj: string) { public writeValue(obj: string) {
if (this.valueMode === 'Json') {
if (obj === null) {
this.value = '';
} else {
try { try {
this.value = JSON.stringify(obj, undefined, 4); if (Types.isNull(obj) || Types.isUndefined(obj)) {
} catch (e) {
this.value = ''; this.value = '';
} } else if (Types.isString(obj) && this.valueMode === 'JsonString') {
} this.value = JSON.stringify(JSON.parse(obj), undefined, 4);
} else if (Types.isString(obj)) { } else if (Types.isString(obj)) {
this.value = obj; this.value = obj;
} else if (this.valueMode === 'Json') {
this.value = JSON.stringify(obj, undefined, 4);
} else { } else {
this.value = ''; this.value = '';
} }
} catch {
this.value = '';
}
if (this.aceEditor) { if (this.aceEditor) {
this.setValue(this.value); this.setValue(this.value);

Loading…
Cancel
Save