diff --git a/extensions/Squidex.Extensions/Squidex.Extensions.csproj b/extensions/Squidex.Extensions/Squidex.Extensions.csproj index 4f8e9fcb0..0ad8a8925 100644 --- a/extensions/Squidex.Extensions/Squidex.Extensions.csproj +++ b/extensions/Squidex.Extensions/Squidex.Extensions.csproj @@ -13,7 +13,7 @@ - + diff --git a/src/Squidex.Domain.Apps.Core.Operations/Scripting/DefaultConverter.cs b/src/Squidex.Domain.Apps.Core.Operations/Scripting/DefaultConverter.cs new file mode 100644 index 000000000..5959acc30 --- /dev/null +++ b/src/Squidex.Domain.Apps.Core.Operations/Scripting/DefaultConverter.cs @@ -0,0 +1,57 @@ +// ========================================================================== +// Squidex Headless CMS +// ========================================================================== +// Copyright (c) Squidex UG (haftungsbeschraenkt) +// All rights reserved. Licensed under the MIT license. +// ========================================================================== + +using System; +using System.Security.Claims; +using Jint; +using Jint.Native; +using Jint.Runtime.Interop; +using NodaTime; +using Squidex.Domain.Apps.Core.Contents; +using Squidex.Domain.Apps.Core.Scripting.ContentWrapper; +using Squidex.Shared.Users; + +namespace Squidex.Domain.Apps.Core.Scripting +{ + public sealed class DefaultConverter : IObjectConverter + { + public static readonly DefaultConverter Instance = new DefaultConverter(); + + private DefaultConverter() + { + } + + public bool TryConvert(Engine engine, object value, out JsValue result) + { + result = null; + + if (value is Enum) + { + result = value.ToString(); + return true; + } + + switch (value) + { + case IUser user: + result = JintUser.Create(engine, user); + return true; + case ClaimsPrincipal principal: + result = JintUser.Create(engine, principal); + return true; + case Instant instant: + result = JsValue.FromObject(engine, instant.ToDateTimeUtc()); + return true; + case NamedContentData content: + result = new ContentDataObject(engine, content); + return true; + } + + return false; + } + } +} diff --git a/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs b/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs index 3b3aa4b5b..8512ce30b 100644 --- a/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs +++ b/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs @@ -8,18 +8,15 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Security.Claims; using Jint; using Jint.Native; using Jint.Native.Date; using Jint.Native.Object; using Jint.Runtime; using Jint.Runtime.Interop; -using NodaTime; using Squidex.Domain.Apps.Core.Contents; using Squidex.Domain.Apps.Core.Scripting.ContentWrapper; using Squidex.Infrastructure; -using Squidex.Shared.Users; namespace Squidex.Domain.Apps.Core.Scripting { @@ -27,40 +24,6 @@ namespace Squidex.Domain.Apps.Core.Scripting { public TimeSpan Timeout { get; set; } = TimeSpan.FromMilliseconds(200); - public sealed class Converter : IObjectConverter - { - public Engine Engine { get; set; } - - public bool TryConvert(object value, out JsValue result) - { - result = null; - - if (value is Enum) - { - result = value.ToString(); - return true; - } - - switch (value) - { - case IUser user: - result = JintUser.Create(Engine, user); - return true; - case ClaimsPrincipal principal: - result = JintUser.Create(Engine, principal); - return true; - case Instant instant: - result = JsValue.FromObject(Engine, instant.ToDateTimeUtc()); - return true; - case NamedContentData content: - result = new ContentDataObject(Engine, content); - return true; - } - - return false; - } - } - public void Execute(ScriptContext context, string script) { Guard.NotNull(context, nameof(context)); @@ -198,8 +161,6 @@ namespace Squidex.Domain.Apps.Core.Scripting private Engine CreateScriptEngine(IReferenceResolver resolver = null, Dictionary> customFormatters = null) { - var converter = new Converter(); - var engine = new Engine(options => { if (resolver != null) @@ -207,7 +168,7 @@ namespace Squidex.Domain.Apps.Core.Scripting options.SetReferencesResolver(resolver); } - options.TimeoutInterval(Timeout).Strict().AddObjectConverter(converter); + options.TimeoutInterval(Timeout).Strict().AddObjectConverter(DefaultConverter.Instance); }); if (customFormatters != null) @@ -218,8 +179,6 @@ namespace Squidex.Domain.Apps.Core.Scripting } } - converter.Engine = engine; - engine.SetValue("slugify", new ClrFunctionInstance(engine, "slugify", Slugify)); engine.SetValue("formatTime", new ClrFunctionInstance(engine, "formatTime", FormatDate)); engine.SetValue("formatDate", new ClrFunctionInstance(engine, "formatDate", FormatDate)); diff --git a/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj b/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj index a2f8491f7..f22143521 100644 --- a/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj +++ b/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/Squidex.Infrastructure/Log/LockingLogStore.cs b/src/Squidex.Infrastructure/Log/LockingLogStore.cs index 7b7ae2968..bafce0bd2 100644 --- a/src/Squidex.Infrastructure/Log/LockingLogStore.cs +++ b/src/Squidex.Infrastructure/Log/LockingLogStore.cs @@ -68,7 +68,7 @@ namespace Squidex.Infrastructure.Log } else { - await stream.WriteAsync(LockedText, 0, LockedText.Length, cts.Token); + await stream.WriteAsync(LockedText, 0, LockedText.Length); } } } diff --git a/src/Squidex/Squidex.csproj b/src/Squidex/Squidex.csproj index cebe95677..cda49b8ed 100644 --- a/src/Squidex/Squidex.csproj +++ b/src/Squidex/Squidex.csproj @@ -91,7 +91,7 @@ - + diff --git a/src/Squidex/app/features/administration/pages/event-consumers/event-consumers-page.component.html b/src/Squidex/app/features/administration/pages/event-consumers/event-consumers-page.component.html index ce58ed3e2..59a73c5e1 100644 --- a/src/Squidex/app/features/administration/pages/event-consumers/event-consumers-page.component.html +++ b/src/Squidex/app/features/administration/pages/event-consumers/event-consumers-page.component.html @@ -6,7 +6,7 @@ - @@ -42,13 +42,13 @@ {{eventConsumer.position}} - - - diff --git a/src/Squidex/app/features/administration/pages/users/users-page.component.html b/src/Squidex/app/features/administration/pages/users/users-page.component.html index 3270262c4..0c51c3304 100644 --- a/src/Squidex/app/features/administration/pages/users/users-page.component.html +++ b/src/Squidex/app/features/administration/pages/users/users-page.component.html @@ -6,7 +6,7 @@ - @@ -18,7 +18,7 @@ - @@ -61,10 +61,10 @@ - - diff --git a/src/Squidex/app/features/assets/pages/assets-page.component.html b/src/Squidex/app/features/assets/pages/assets-page.component.html index 675175803..8c27b3e4c 100644 --- a/src/Squidex/app/features/assets/pages/assets-page.component.html +++ b/src/Squidex/app/features/assets/pages/assets-page.component.html @@ -10,7 +10,7 @@
-
diff --git a/src/Squidex/app/features/content/declarations.ts b/src/Squidex/app/features/content/declarations.ts index 2ebc03da9..759513526 100644 --- a/src/Squidex/app/features/content/declarations.ts +++ b/src/Squidex/app/features/content/declarations.ts @@ -18,6 +18,7 @@ export * from './shared/array-editor.component'; export * from './shared/assets-editor.component'; export * from './shared/array-item.component'; export * from './shared/content-item.component'; +export * from './shared/content-item-editor.component'; export * from './shared/content-status.component'; export * from './shared/contents-selector.component'; export * from './shared/due-time-selector.component'; diff --git a/src/Squidex/app/features/content/module.ts b/src/Squidex/app/features/content/module.ts index a2f9b17b6..d47cb229a 100644 --- a/src/Squidex/app/features/content/module.ts +++ b/src/Squidex/app/features/content/module.ts @@ -29,6 +29,7 @@ import { ContentFieldComponent, ContentHistoryPageComponent, ContentItemComponent, + ContentItemEditorComponent, ContentPageComponent, ContentsFiltersPageComponent, ContentsPageComponent, @@ -113,6 +114,7 @@ const routes: Routes = [ ContentFieldComponent, ContentHistoryPageComponent, ContentItemComponent, + ContentItemEditorComponent, ContentPageComponent, ContentsFiltersPageComponent, ContentStatusComponent, diff --git a/src/Squidex/app/features/content/pages/content/field-languages.component.ts b/src/Squidex/app/features/content/pages/content/field-languages.component.ts index aac427c15..08d6651d2 100644 --- a/src/Squidex/app/features/content/pages/content/field-languages.component.ts +++ b/src/Squidex/app/features/content/pages/content/field-languages.component.ts @@ -5,7 +5,7 @@ * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. */ -import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; import { AppLanguageDto, RootFieldDto } from '@app/shared'; @@ -28,7 +28,8 @@ import { AppLanguageDto, RootFieldDto } from '@app/shared'; Please remember to check all languages when you see validation errors. - ` + `, + changeDetection: ChangeDetectionStrategy.OnPush }) export class FieldLanguagesComponent { @Input() diff --git a/src/Squidex/app/features/content/pages/contents/contents-page.component.html b/src/Squidex/app/features/content/pages/contents/contents-page.component.html index fbeff8b1d..26f70f2c6 100644 --- a/src/Squidex/app/features/content/pages/contents/contents-page.component.html +++ b/src/Squidex/app/features/content/pages/contents/contents-page.component.html @@ -16,7 +16,7 @@
-
@@ -36,7 +36,7 @@
- @@ -73,23 +73,23 @@
{{selectionCount}} items selected:   - - - - -
- diff --git a/src/Squidex/app/features/content/shared/array-item.component.html b/src/Squidex/app/features/content/shared/array-item.component.html index ad3b3a507..2283e2e54 100644 --- a/src/Squidex/app/features/content/shared/array-item.component.html +++ b/src/Squidex/app/features/content/shared/array-item.component.html @@ -5,32 +5,32 @@ Item #{{index + 1}} - - - - - - - - diff --git a/src/Squidex/app/features/content/shared/content-item-editor.component.ts b/src/Squidex/app/features/content/shared/content-item-editor.component.ts new file mode 100644 index 000000000..8e8a95e93 --- /dev/null +++ b/src/Squidex/app/features/content/shared/content-item-editor.component.ts @@ -0,0 +1,69 @@ +/* + * Squidex Headless CMS + * + * @license + * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. + */ + +import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { FormGroup } from '@angular/forms'; + +import { FieldDto } from '@app/shared'; + +@Component({ + selector: 'sqx-content-item-editor', + template: ` +
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+ +
+
+
+
+
+
`, + changeDetection: ChangeDetectionStrategy.OnPush +}) +export class ContentItemEditorComponent { + @Input() + public field: FieldDto; + + @Input() + public form: FormGroup; +} \ No newline at end of file diff --git a/src/Squidex/app/features/content/shared/content-item.component.html b/src/Squidex/app/features/content/shared/content-item.component.html index c00c410c7..ff79e23d8 100644 --- a/src/Squidex/app/features/content/shared/content-item.component.html +++ b/src/Squidex/app/features/content/shared/content-item.component.html @@ -1,64 +1,25 @@ - - + + + + + + + + - - - + + + + - -
-
-
-
-
- -
-
- -
-
-
-
-
-
- -
-
- -
-
- -
-
-
-
-
-
- -
-
-
- -
-
-
-
-
-
-
+ {{values[i]}} -
+ + - - - - - - + + + + + + + + - + - + {{patternName}} diff --git a/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.html b/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.html index f13edf18f..d3ee7d5b5 100644 --- a/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.html +++ b/src/Squidex/app/features/schemas/pages/schemas/schemas-page.component.html @@ -9,7 +9,7 @@ - diff --git a/src/Squidex/app/features/settings/pages/backups/backups-page.component.html b/src/Squidex/app/features/settings/pages/backups/backups-page.component.html index 7e9ef4470..5906e2444 100644 --- a/src/Squidex/app/features/settings/pages/backups/backups-page.component.html +++ b/src/Squidex/app/features/settings/pages/backups/backups-page.component.html @@ -6,13 +6,13 @@ - - @@ -27,7 +27,7 @@
No backups created yet. -
diff --git a/src/Squidex/app/features/settings/pages/clients/client.component.html b/src/Squidex/app/features/settings/pages/clients/client.component.html index 8d0ac010c..748772511 100644 --- a/src/Squidex/app/features/settings/pages/clients/client.component.html +++ b/src/Squidex/app/features/settings/pages/clients/client.component.html @@ -11,7 +11,7 @@ - @@ -25,7 +25,7 @@
- +
diff --git a/src/Squidex/app/features/settings/pages/contributors/contributors-page.component.html b/src/Squidex/app/features/settings/pages/contributors/contributors-page.component.html index 4fcace09b..f4f9a428c 100644 --- a/src/Squidex/app/features/settings/pages/contributors/contributors-page.component.html +++ b/src/Squidex/app/features/settings/pages/contributors/contributors-page.component.html @@ -6,7 +6,7 @@ - diff --git a/src/Squidex/app/features/settings/pages/languages/languages-page.component.html b/src/Squidex/app/features/settings/pages/languages/languages-page.component.html index d7d9981e9..25d942fc8 100644 --- a/src/Squidex/app/features/settings/pages/languages/languages-page.component.html +++ b/src/Squidex/app/features/settings/pages/languages/languages-page.component.html @@ -6,7 +6,7 @@ - diff --git a/src/Squidex/app/features/settings/pages/more/more-page.component.html b/src/Squidex/app/features/settings/pages/more/more-page.component.html index 43a4fb990..64ff6c060 100644 --- a/src/Squidex/app/features/settings/pages/more/more-page.component.html +++ b/src/Squidex/app/features/settings/pages/more/more-page.component.html @@ -17,7 +17,7 @@
Once you archive an app, there is no going back. Please be certain.
- diff --git a/src/Squidex/app/features/settings/pages/plans/plans-page.component.html b/src/Squidex/app/features/settings/pages/plans/plans-page.component.html index 34f456c26..c4849ea5f 100644 --- a/src/Squidex/app/features/settings/pages/plans/plans-page.component.html +++ b/src/Squidex/app/features/settings/pages/plans/plans-page.component.html @@ -6,7 +6,7 @@ - diff --git a/src/Squidex/app/features/settings/pages/roles/roles-page.component.html b/src/Squidex/app/features/settings/pages/roles/roles-page.component.html index 1a0e1a884..1d44a7fd6 100644 --- a/src/Squidex/app/features/settings/pages/roles/roles-page.component.html +++ b/src/Squidex/app/features/settings/pages/roles/roles-page.component.html @@ -6,7 +6,7 @@ - diff --git a/src/Squidex/app/framework/angular/forms/autocomplete.component.html b/src/Squidex/app/framework/angular/forms/autocomplete.component.html index 9f4a662c3..ea2df131d 100644 --- a/src/Squidex/app/framework/angular/forms/autocomplete.component.html +++ b/src/Squidex/app/framework/angular/forms/autocomplete.component.html @@ -6,7 +6,7 @@ autocapitalize="off">
-
- +
- +
- +
diff --git a/src/Squidex/app/framework/angular/forms/stars.component.html b/src/Squidex/app/framework/angular/forms/stars.component.html index 4cf2ca64f..af4d6d7c9 100644 --- a/src/Squidex/app/framework/angular/forms/stars.component.html +++ b/src/Squidex/app/framework/angular/forms/stars.component.html @@ -8,6 +8,6 @@
- + \ No newline at end of file diff --git a/src/Squidex/app/framework/angular/forms/tag-editor.component.html b/src/Squidex/app/framework/angular/forms/tag-editor.component.html index a49056221..1877ad601 100644 --- a/src/Squidex/app/framework/angular/forms/tag-editor.component.html +++ b/src/Squidex/app/framework/angular/forms/tag-editor.component.html @@ -24,7 +24,7 @@
-
{{pager.itemFirst}}-{{pager.itemLast}} of {{pager.numberOfItems}} - -
diff --git a/src/Squidex/app/shared/components/asset.component.html b/src/Squidex/app/shared/components/asset.component.html index 2e822d47e..9e8563704 100644 --- a/src/Squidex/app/shared/components/asset.component.html +++ b/src/Squidex/app/shared/components/asset.component.html @@ -21,10 +21,10 @@ - + - +
@@ -121,10 +121,10 @@ - - diff --git a/src/Squidex/app/shared/components/assets-selector.component.html b/src/Squidex/app/shared/components/assets-selector.component.html index 3462a13ea..237f4cab2 100644 --- a/src/Squidex/app/shared/components/assets-selector.component.html +++ b/src/Squidex/app/shared/components/assets-selector.component.html @@ -6,7 +6,7 @@
-
diff --git a/src/Squidex/app/shared/components/geolocation-editor.component.html b/src/Squidex/app/shared/components/geolocation-editor.component.html index 768fe3b9e..6372c12ed 100644 --- a/src/Squidex/app/shared/components/geolocation-editor.component.html +++ b/src/Squidex/app/shared/components/geolocation-editor.component.html @@ -9,7 +9,7 @@
- +
@@ -18,7 +18,7 @@
- +
diff --git a/src/Squidex/app/shared/components/language-selector.component.html b/src/Squidex/app/shared/components/language-selector.component.html index 4215489e6..ef39cfd30 100644 --- a/src/Squidex/app/shared/components/language-selector.component.html +++ b/src/Squidex/app/shared/components/language-selector.component.html @@ -5,7 +5,7 @@