Browse Source

Fixed deep equals.

pull/469/head
Sebastian 7 years ago
parent
commit
45639f6ec9
  1. 9
      backend/src/Squidex.Domain.Apps.Core.Model/Schemas/ReferencesFieldProperties.cs
  2. 15
      backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs
  3. 4
      frontend/app/features/rules/pages/rules/rule-wizard.component.ts
  4. 2
      frontend/app/features/schemas/pages/schema/field.component.ts
  5. 13
      frontend/app/features/schemas/pages/schema/types/assets-validation.component.html
  6. 2
      frontend/app/features/settings/pages/languages/language.component.ts
  7. 4
      frontend/app/features/settings/pages/patterns/pattern.component.ts

9
backend/src/Squidex.Domain.Apps.Core.Model/Schemas/ReferencesFieldProperties.cs

@ -8,6 +8,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq;
namespace Squidex.Domain.Apps.Core.Schemas namespace Squidex.Domain.Apps.Core.Schemas
{ {
@ -23,10 +24,12 @@ namespace Squidex.Domain.Apps.Core.Schemas
public ReferencesFieldEditor Editor { get; set; } public ReferencesFieldEditor Editor { get; set; }
public ReadOnlyCollection<Guid>? SchemaIds { get; set; }
public Guid SchemaId public Guid SchemaId
{ {
get
{
return SchemaIds?.FirstOrDefault() ?? Guid.Empty;
}
set set
{ {
if (value != default) if (value != default)
@ -40,6 +43,8 @@ namespace Squidex.Domain.Apps.Core.Schemas
} }
} }
public ReadOnlyCollection<Guid>? SchemaIds { get; set; }
public override T Accept<T>(IFieldPropertiesVisitor<T> visitor) public override T Accept<T>(IFieldPropertiesVisitor<T> visitor)
{ {
return visitor.Visit(this); return visitor.Visit(this);

15
backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Schemas/SchemaTests.cs

@ -20,6 +20,21 @@ namespace Squidex.Domain.Apps.Core.Model.Schemas
{ {
private readonly Schema schema_0 = new Schema("my-schema"); private readonly Schema schema_0 = new Schema("my-schema");
public static IEnumerable<object[]> FieldProperyTypes()
{
return typeof(Schema).Assembly.GetTypes().Where(x => x.BaseType == typeof(FieldProperties)).Select(x => new object[] { x });
}
[Theory]
[MemberData(nameof(FieldProperyTypes))]
public void Should_make_deep_equal_test(Type type)
{
var lhs = (FieldProperties)Activator.CreateInstance(type)!;
var rhs = (FieldProperties)Activator.CreateInstance(type)!;
Assert.True(lhs.DeepEquals(rhs));
}
[Fact] [Fact]
public void Should_instantiate_schema() public void Should_instantiate_schema()
{ {

4
frontend/app/features/rules/pages/rules/rule-wizard.component.ts

@ -168,7 +168,7 @@ export class RuleWizardComponent implements AfterViewInit, OnInit {
.subscribe(() => { .subscribe(() => {
this.emitComplete(); this.emitComplete();
this.triggerForm.submitCompleted(); this.triggerForm.submitCompleted({ noReset: true });
}, error => { }, error => {
this.triggerForm.submitFailed(error); this.triggerForm.submitFailed(error);
}); });
@ -183,7 +183,7 @@ export class RuleWizardComponent implements AfterViewInit, OnInit {
.subscribe(() => { .subscribe(() => {
this.emitComplete(); this.emitComplete();
this.actionForm.submitCompleted(); this.actionForm.submitCompleted({ noReset: true });
}, error => { }, error => {
this.actionForm.submitFailed(error); this.actionForm.submitFailed(error);
}); });

2
frontend/app/features/schemas/pages/schema/field.component.ts

@ -118,7 +118,7 @@ export class FieldComponent implements OnChanges {
this.schemasState.updateField(this.schema, this.field, { properties }) this.schemasState.updateField(this.schema, this.field, { properties })
.subscribe(() => { .subscribe(() => {
this.editForm.submitCompleted(); this.editForm.submitCompleted({ noReset: true });
}, error => { }, error => {
this.editForm.submitFailed(error); this.editForm.submitFailed(error);
}); });

13
frontend/app/features/schemas/pages/schema/types/assets-validation.component.html

@ -38,12 +38,15 @@
<label class="col-form-label">bytes</label> <label class="col-form-label">bytes</label>
</div> </div>
</div> </div>
<div class="form-group2 row">
<label class="col-3 col-form-checkbox-label" for="{{field.fieldId}}_fieldMustBeImage">Must be Image</label>
<div class="col-6"> <div class="form-group row">
<input class="form-check-input" type="checkbox" id="{{field.fieldId}}_fieldMustBeImage" formControlName="mustBeImage" /> <div class="col-9 offset-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" id="{{field.fieldId}}_fieldMustBeImage" formControlName="mustBeImage" />
<label class="form-check-label" for="{{field.fieldId}}_fieldMustBeImage">
Must be Image
</label>
</div>
</div> </div>
</div> </div>

2
frontend/app/features/settings/pages/languages/language.component.ts

@ -78,7 +78,7 @@ export class LanguageComponent implements OnChanges {
this.languagesState.update(this.language, request) this.languagesState.update(this.language, request)
.subscribe(() => { .subscribe(() => {
this.editForm.submitCompleted(); this.editForm.submitCompleted({ noReset: true });
this.toggleEditing(); this.toggleEditing();
}, error => { }, error => {

4
frontend/app/features/settings/pages/patterns/pattern.component.ts

@ -63,8 +63,8 @@ export class PatternComponent implements OnChanges {
if (value) { if (value) {
if (this.pattern) { if (this.pattern) {
this.patternsState.update(this.pattern, value) this.patternsState.update(this.pattern, value)
.subscribe(newPattern => { .subscribe(() => {
this.editForm.submitCompleted(newPattern); this.editForm.submitCompleted({ noReset: true });
}, error => { }, error => {
this.editForm.submitFailed(error); this.editForm.submitFailed(error);
}); });

Loading…
Cancel
Save