Browse Source

Introduced tags for schemas and fields for automation processes. (#426)

pull/427/head
Sebastian Stehle 6 years ago
committed by GitHub
parent
commit
9e5a358d64
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      src/Squidex/Areas/Api/Controllers/Schemas/Models/FieldPropertiesDto.cs
  2. 6
      src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaPropertiesDto.cs
  3. 6
      src/Squidex/Areas/Api/Controllers/Schemas/Models/UpdateSchemaDto.cs
  4. 41
      src/Squidex/app/features/schemas/pages/schema/forms/field-form-common.component.ts
  5. 10
      src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.html
  6. 10
      src/Squidex/app/shared/services/schemas.service.spec.ts
  7. 7
      src/Squidex/app/shared/services/schemas.service.ts
  8. 1
      src/Squidex/app/shared/services/schemas.types.ts
  9. 6
      src/Squidex/app/shared/state/schemas.forms.ts

6
src/Squidex/Areas/Api/Controllers/Schemas/Models/FieldPropertiesDto.cs

@ -6,6 +6,7 @@
// ==========================================================================
using System;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
@ -57,6 +58,11 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
/// </summary>
public string EditorUrl { get; set; }
/// <summary>
/// Tags for automation processes.
/// </summary>
public ReadOnlyCollection<string> Tags { get; set; }
public abstract FieldProperties ToProperties();
public static Type[] Subtypes()

6
src/Squidex/Areas/Api/Controllers/Schemas/Models/SchemaPropertiesDto.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
namespace Squidex.Areas.Api.Controllers.Schemas.Models
@ -22,5 +23,10 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
/// </summary>
[StringLength(1000)]
public string Hints { get; set; }
/// <summary>
/// Tags for automation processes.
/// </summary>
public ReadOnlyCollection<string> Tags { get; set; }
}
}

6
src/Squidex/Areas/Api/Controllers/Schemas/Models/UpdateSchemaDto.cs

@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Entities.Schemas.Commands;
@ -26,6 +27,11 @@ namespace Squidex.Areas.Api.Controllers.Schemas.Models
[StringLength(1000)]
public string Hints { get; set; }
/// <summary>
/// Tags for automation processes.
/// </summary>
public ReadOnlyCollection<string> Tags { get; set; }
public UpdateSchema ToCommand()
{
var properties = SimpleMapper.Map(this, new SchemaProperties());

41
src/Squidex/app/features/schemas/pages/schema/forms/field-form-common.component.ts

@ -5,8 +5,8 @@
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { Component, Input, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { Component, Input } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { FieldDto } from '@app/shared';
@ -83,10 +83,22 @@ import { FieldDto } from '@app/shared';
</sqx-form-hint>
</div>
</div>
<div class="form-group row" *ngIf="field.properties.isContentField">
<label class="col-3 col-form-label">Tags</label>
<div class="col-9">
<sqx-tag-editor id="schemaTags" formControlName="tags"></sqx-tag-editor>
<sqx-form-hint>
Tags to annotate your field for automation processes.
</sqx-form-hint>
</div>
</div>
</div>
`
})
export class FieldFormCommonComponent implements OnInit {
export class FieldFormCommonComponent {
public readonly standalone = { standalone: true };
@Input()
@ -97,27 +109,4 @@ export class FieldFormCommonComponent implements OnInit {
@Input()
public field: FieldDto;
public ngOnInit() {
this.editForm.setControl('isRequired',
new FormControl(this.field.properties.isRequired));
this.editForm.setControl('isListField',
new FormControl(this.field.properties.isListField));
this.editForm.setControl('isReferenceField',
new FormControl(this.field.properties.isReferenceField));
this.editForm.setControl('editorUrl',
new FormControl(this.field.properties.editorUrl));
this.editForm.setControl('hints',
new FormControl(this.field.properties.hints));
this.editForm.setControl('placeholder',
new FormControl(this.field.properties.placeholder));
this.editForm.setControl('label',
new FormControl(this.field.properties.label));
}
}

10
src/Squidex/app/features/schemas/pages/schema/schema-edit-form.component.html

@ -26,6 +26,16 @@
<textarea type="text" class="form-control" id="schemaHints" formControlName="hints" rows="4"></textarea>
</div>
<div class="form-group">
<label for="schemaTags">Tags</label>
<sqx-control-errors for="tags" [submitted]="editForm.submitted | async"></sqx-control-errors>
<sqx-tag-editor id="schemaTags" formControlName="tags"></sqx-tag-editor>
<sqx-form-hint>Tags to annotate your schema for automation processes.</sqx-form-hint>
</div>
</ng-container>
<ng-container footer>

10
src/Squidex/app/shared/services/schemas.service.spec.ts

@ -575,7 +575,8 @@ describe('SchemasService', () => {
lastModifiedBy: `modifier${id}`,
properties: {
label: `label${id}${suffix}`,
hints: `hints${id}${suffix}`
hints: `hints${id}${suffix}`,
tags: [`tags${id}${suffix}`]
},
version: `${id}`,
_links: {
@ -598,7 +599,8 @@ describe('SchemasService', () => {
version: `${id}`,
properties: {
label: `label${id}${suffix}`,
hints: `hints${id}${suffix}`
hints: `hints${id}${suffix}`,
tags: [`tags${id}${suffix}`]
},
previewUrls: {
'Default': 'url'
@ -772,7 +774,7 @@ export function createSchema(id: number, suffix = '') {
`schema-id${id}`,
`schema-name${id}${suffix}`,
`category${id}${suffix}`,
new SchemaPropertiesDto(`label${id}${suffix}`, `hints${id}${suffix}`),
new SchemaPropertiesDto(`label${id}${suffix}`, `hints${id}${suffix}`, [`tags${id}${suffix}`]),
id % 2 === 0,
id % 3 === 0,
DateTime.parseISO_UTC(`${id % 1000 + 2000}-12-12T10:10:00`), `creator${id}`,
@ -789,7 +791,7 @@ export function createSchemaDetails(id: number, suffix = '') {
`schema-id${id}`,
`schema-name${id}${suffix}`,
`category${id}${suffix}`,
new SchemaPropertiesDto(`label${id}${suffix}`, `hints${id}${suffix}`),
new SchemaPropertiesDto(`label${id}${suffix}`, `hints${id}${suffix}`, [`tags${id}${suffix}`]),
id % 2 === 0,
id % 3 === 0,
DateTime.parseISO_UTC(`${id % 1000 + 2000}-12-12T10:10:00`), `creator${id}`,

7
src/Squidex/app/shared/services/schemas.service.ts

@ -260,7 +260,8 @@ export class NestedFieldDto extends FieldDto {
export class SchemaPropertiesDto {
constructor(
public readonly label?: string,
public readonly hints?: string
public readonly hints?: string,
public readonly tags?: ReadonlyArray<string>
) {
}
}
@ -599,7 +600,7 @@ function parseSchemas(response: any) {
item.id,
item.name,
item.category,
new SchemaPropertiesDto(item.properties.label, item.properties.hints),
new SchemaPropertiesDto(item.properties.label, item.properties.hints, item.properties.tags),
item.isSingleton,
item.isPublished,
DateTime.parseISO_UTC(item.created), item.createdBy,
@ -614,7 +615,7 @@ function parseSchemas(response: any) {
function parseSchemaWithDetails(response: any) {
const fields = response.fields.map((item: any) => parseField(item));
const properties = new SchemaPropertiesDto(response.properties.label, response.properties.hints);
const properties = new SchemaPropertiesDto(response.properties.label, response.properties.hints, response.properties.tags);
return new SchemaDetailsDto(response._links,
response.id,

1
src/Squidex/app/shared/services/schemas.types.ts

@ -139,6 +139,7 @@ export abstract class FieldPropertiesDto {
public readonly isRequired: boolean = false;
public readonly label?: string;
public readonly placeholder?: string;
public readonly tags?: ReadonlyArray<string>;
public get isTranslateable() {
return false;

6
src/Squidex/app/shared/state/schemas.forms.ts

@ -169,7 +169,8 @@ export class EditFieldForm extends Form<FormGroup, { label?: string, hints?: str
],
editorUrl: null,
isRequired: false,
isListField: false
isListField: false,
tags: []
}));
}
}
@ -186,7 +187,8 @@ export class EditSchemaForm extends Form<FormGroup, { label?: string, hints?: st
[
Validators.maxLength(1000)
]
]
],
tags: []
}));
}
}

Loading…
Cancel
Save