|
|
|
@ -9,7 +9,6 @@ |
|
|
|
using System; |
|
|
|
using Squidex.Domain.Apps.Core; |
|
|
|
using Squidex.Domain.Apps.Core.Schemas; |
|
|
|
using Squidex.Infrastructure.Reflection; |
|
|
|
|
|
|
|
namespace Squidex.Domain.Apps.Events.Schemas.Utils |
|
|
|
{ |
|
|
|
@ -61,7 +60,7 @@ namespace Squidex.Domain.Apps.Events.Schemas.Utils |
|
|
|
return schema; |
|
|
|
} |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, FieldAdded @event, FieldRegistry registry) |
|
|
|
public static Schema Apply(this Schema schema, FieldAdded @event, FieldRegistry registry) |
|
|
|
{ |
|
|
|
var partitioning = |
|
|
|
string.Equals(@event.Partitioning, Partitioning.Language.Key, StringComparison.OrdinalIgnoreCase) ? |
|
|
|
@ -71,86 +70,65 @@ namespace Squidex.Domain.Apps.Events.Schemas.Utils |
|
|
|
var fieldId = @event.FieldId.Id; |
|
|
|
var field = registry.CreateField(fieldId, @event.Name, partitioning, @event.Properties); |
|
|
|
|
|
|
|
schema.DeleteField(fieldId); |
|
|
|
schema.AddField(field); |
|
|
|
} |
|
|
|
schema = schema.DeleteField(fieldId); |
|
|
|
schema = schema.AddField(field); |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, FieldUpdated @event) |
|
|
|
{ |
|
|
|
if (schema.FieldsById.TryGetValue(@event.FieldId.Id, out var field)) |
|
|
|
{ |
|
|
|
field.Update(@event.Properties); |
|
|
|
} |
|
|
|
return schema; |
|
|
|
} |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, FieldLocked @event) |
|
|
|
public static Schema Apply(this Schema schema, FieldUpdated @event) |
|
|
|
{ |
|
|
|
if (schema.FieldsById.TryGetValue(@event.FieldId.Id, out var field)) |
|
|
|
{ |
|
|
|
field.Lock(); |
|
|
|
} |
|
|
|
return schema.UpdateField(@event.FieldId.Id, @event.Properties); |
|
|
|
} |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, FieldHidden @event) |
|
|
|
public static Schema Apply(this Schema schema, FieldLocked @event) |
|
|
|
{ |
|
|
|
if (schema.FieldsById.TryGetValue(@event.FieldId.Id, out var field)) |
|
|
|
{ |
|
|
|
field.Hide(); |
|
|
|
} |
|
|
|
return schema.LockField(@event.FieldId.Id); |
|
|
|
} |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, FieldShown @event) |
|
|
|
public static Schema Apply(this Schema schema, FieldHidden @event) |
|
|
|
{ |
|
|
|
if (schema.FieldsById.TryGetValue(@event.FieldId.Id, out var field)) |
|
|
|
{ |
|
|
|
field.Show(); |
|
|
|
} |
|
|
|
return schema.HideField(@event.FieldId.Id); |
|
|
|
} |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, FieldDisabled @event) |
|
|
|
public static Schema Apply(this Schema schema, FieldShown @event) |
|
|
|
{ |
|
|
|
if (schema.FieldsById.TryGetValue(@event.FieldId.Id, out var field)) |
|
|
|
{ |
|
|
|
field.Disable(); |
|
|
|
} |
|
|
|
return schema.ShowField(@event.FieldId.Id); |
|
|
|
} |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, FieldEnabled @event) |
|
|
|
public static Schema Apply(this Schema schema, FieldDisabled @event) |
|
|
|
{ |
|
|
|
if (schema.FieldsById.TryGetValue(@event.FieldId.Id, out var field)) |
|
|
|
{ |
|
|
|
field.Enable(); |
|
|
|
} |
|
|
|
return schema.DisableField(@event.FieldId.Id); |
|
|
|
} |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, SchemaUpdated @event) |
|
|
|
public static Schema Apply(this Schema schema, FieldEnabled @event) |
|
|
|
{ |
|
|
|
schema.Update(@event.Properties); |
|
|
|
return schema.EnableField(@event.FieldId.Id); |
|
|
|
} |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, SchemaFieldsReordered @event) |
|
|
|
public static Schema Apply(this Schema schema, SchemaUpdated @event) |
|
|
|
{ |
|
|
|
schema.ReorderFields(@event.FieldIds); |
|
|
|
return schema.Update(@event.Properties); |
|
|
|
} |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, FieldDeleted @event) |
|
|
|
public static Schema Apply(this Schema schema, SchemaFieldsReordered @event) |
|
|
|
{ |
|
|
|
schema.DeleteField(@event.FieldId.Id); |
|
|
|
return schema.ReorderFields(@event.FieldIds); |
|
|
|
} |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, SchemaPublished @event) |
|
|
|
public static Schema Apply(this Schema schema, FieldDeleted @event) |
|
|
|
{ |
|
|
|
schema.Publish(); |
|
|
|
return schema.DeleteField(@event.FieldId.Id); |
|
|
|
} |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, SchemaUnpublished @event) |
|
|
|
public static Schema Apply(this Schema schema, SchemaPublished @event) |
|
|
|
{ |
|
|
|
schema.Unpublish(); |
|
|
|
return schema.Publish(); |
|
|
|
} |
|
|
|
|
|
|
|
public static void Apply(this Schema schema, ScriptsConfigured @event) |
|
|
|
public static Schema Apply(this Schema schema, SchemaUnpublished @event) |
|
|
|
{ |
|
|
|
SimpleMapper.Map(@event, schema); |
|
|
|
return schema.Unpublish(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|