Browse Source

Made stars inline editable.

pull/425/head
Sebastian Stehle 7 years ago
parent
commit
df5084e3a8
  1. 4
      src/Squidex.Domain.Apps.Entities/Schemas/Guards/FieldPropertiesValidator.cs
  2. 3
      src/Squidex/app/features/content/shared/content-value-editor.component.ts
  3. 2
      src/Squidex/app/features/schemas/pages/schema/types/number-ui.component.ts
  4. 2
      src/Squidex/app/framework/angular/forms/stars.component.scss
  5. 4
      tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Guards/FieldProperties/NumberFieldPropertiesTests.cs

4
src/Squidex.Domain.Apps.Entities/Schemas/Guards/FieldPropertiesValidator.cs

@ -196,9 +196,9 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards
nameof(properties.MaxValue));
}
if (properties.InlineEditable && properties.Editor != NumberFieldEditor.Input && properties.Editor != NumberFieldEditor.Dropdown)
if (properties.InlineEditable && properties.Editor == NumberFieldEditor.Radio)
{
yield return new ValidationError("Inline editing is only allowed for dropdowns and input fields.",
yield return new ValidationError("Inline editing is not allowed for Radio editor.",
nameof(properties.InlineEditable),
nameof(properties.Editor));
}

3
src/Squidex/app/features/content/shared/content-value-editor.component.ts

@ -20,6 +20,9 @@ import { FieldDto } from '@app/shared';
<ng-container *ngSwitchCase="'Input'">
<input class="form-control" type="number" [formControlName]="field.name" [placeholder]="field.displayPlaceholder" />
</ng-container>
<ng-container *ngSwitchCase="'Stars'">
<sqx-stars [formControlName]="field.name" [maximumStars]="field.rawProperties.maxValue"></sqx-stars>
</ng-container>
<ng-container *ngSwitchCase="'Dropdown'">
<select class="form-control" [formControlName]="field.name">
<option [ngValue]="null"></option>

2
src/Squidex/app/features/schemas/pages/schema/types/number-ui.component.ts

@ -54,7 +54,7 @@ export class NumberUIComponent extends ResourceOwner implements OnInit {
value$<string>(this.editForm.controls['editor']).pipe(map(x => !(x && (x === 'Radio' || x === 'Dropdown'))));
this.hideInlineEditable =
value$<string>(this.editForm.controls['editor']).pipe(map(x => !(x === 'Input' || x === 'Dropdown')));
value$<string>(this.editForm.controls['editor']).pipe(map(x => x === 'Radio'));
this.own(
this.hideAllowedValues.subscribe(isSelection => {

2
src/Squidex/app/framework/angular/forms/stars.component.scss

@ -13,7 +13,6 @@ $color-gold: #ffd700;
border: 0;
height: 2.4rem;
line-height: 2.4rem;
vertical-align: middle;
}
&.disabled {
@ -30,6 +29,7 @@ $color-gold: #ffd700;
background: transparent;
border: 0;
line-height: 1px;
vertical-align: middle;
}
&::before {

4
tests/Squidex.Domain.Apps.Entities.Tests/Schemas/Guards/FieldProperties/NumberFieldPropertiesTests.cs

@ -132,7 +132,6 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards.FieldProperties
[Theory]
[InlineData(NumberFieldEditor.Radio)]
[InlineData(NumberFieldEditor.Stars)]
public void Should_add_error_if_inline_editing_is_not_allowed_for_editor(NumberFieldEditor editor)
{
var sut = new NumberFieldProperties { InlineEditable = true, Editor = editor, AllowedValues = ReadOnlyCollection.Create(1.0) };
@ -142,13 +141,14 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards.FieldProperties
errors.Should().BeEquivalentTo(
new List<ValidationError>
{
new ValidationError("Inline editing is only allowed for dropdowns and input fields.", "InlineEditable", "Editor")
new ValidationError("Inline editing is not allowed for Radio editor.", "InlineEditable", "Editor")
});
}
[Theory]
[InlineData(NumberFieldEditor.Input)]
[InlineData(NumberFieldEditor.Dropdown)]
[InlineData(NumberFieldEditor.Stars)]
public void Should_not_add_error_if_inline_editing_is_allowed_for_editor(NumberFieldEditor editor)
{
var sut = new NumberFieldProperties { InlineEditable = true, Editor = editor, AllowedValues = ReadOnlyCollection.Create(1.0) };

Loading…
Cancel
Save