mirror of https://github.com/Squidex/squidex.git
Browse Source
* Enable multi-select of roles for workflow transitions. * Applied dash via parameter. Handled UI for multi-select. Applied no-duplicates. * Fixed conflicts due to ReadOnlyArray changes. * Build fixes. * Fixed review comments.pull/432/head
committed by
Sebastian Stehle
18 changed files with 181 additions and 47 deletions
@ -0,0 +1,55 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschränkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System.Collections.Generic; |
||||
|
using System.Collections.ObjectModel; |
||||
|
using Newtonsoft.Json; |
||||
|
using Squidex.Infrastructure.Collections; |
||||
|
using Squidex.Infrastructure.Reflection; |
||||
|
|
||||
|
namespace Squidex.Domain.Apps.Core.Contents.Json |
||||
|
{ |
||||
|
public class JsonWorkflowTransition |
||||
|
{ |
||||
|
[JsonProperty] |
||||
|
public string Expression { get; set; } |
||||
|
|
||||
|
[JsonProperty] |
||||
|
public string Role { get; set; } |
||||
|
|
||||
|
[JsonProperty] |
||||
|
public List<string> Roles { get; } |
||||
|
|
||||
|
public JsonWorkflowTransition() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public JsonWorkflowTransition(WorkflowTransition client) |
||||
|
{ |
||||
|
SimpleMapper.Map(client, this); |
||||
|
} |
||||
|
|
||||
|
public WorkflowTransition ToTransition() |
||||
|
{ |
||||
|
var rolesList = Roles; |
||||
|
|
||||
|
if (!string.IsNullOrEmpty(Role)) |
||||
|
{ |
||||
|
rolesList = new List<string> { Role }; |
||||
|
} |
||||
|
|
||||
|
ReadOnlyCollection<string> roles = null; |
||||
|
|
||||
|
if (rolesList != null && rolesList.Count > 0) |
||||
|
{ |
||||
|
roles = ReadOnlyCollection.Create(rolesList.ToArray()); |
||||
|
} |
||||
|
|
||||
|
return new WorkflowTransition(Expression, roles); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using System; |
||||
|
using Newtonsoft.Json; |
||||
|
using Squidex.Infrastructure.Json.Newtonsoft; |
||||
|
|
||||
|
namespace Squidex.Domain.Apps.Core.Contents.Json |
||||
|
{ |
||||
|
public sealed class WorkflowTransitionConverter : JsonClassConverter<WorkflowTransition> |
||||
|
{ |
||||
|
protected override void WriteValue(JsonWriter writer, WorkflowTransition value, JsonSerializer serializer) |
||||
|
{ |
||||
|
var json = new JsonWorkflowTransition(value); |
||||
|
|
||||
|
serializer.Serialize(writer, json); |
||||
|
} |
||||
|
|
||||
|
protected override WorkflowTransition ReadValue(JsonReader reader, Type objectType, JsonSerializer serializer) |
||||
|
{ |
||||
|
var json = serializer.Deserialize<JsonWorkflowTransition>(reader); |
||||
|
|
||||
|
return json.ToTransition(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue