Browse Source

UI fix.

pull/935/head
Sebastian 4 years ago
parent
commit
781c5a9a9e
  1. 40
      backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs
  2. 26
      backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/OperationBuilder.cs
  3. 10
      backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs
  4. 3
      frontend/src/app/features/content/pages/content/editor/content-field.component.scss
  5. 20
      frontend/src/app/features/content/pages/content/editor/field-copy-button.component.html

40
backend/src/Squidex/Areas/Api/Controllers/Contents/ContentsController.cs

@ -100,6 +100,7 @@ namespace Squidex.Areas.Api.Controllers.Contents
/// <param name="app">The name of the app.</param>
/// <param name="schema">The name of the schema.</param>
/// <param name="id">The ID of the content to fetch.</param>
/// <param name="version">The optional version.</param>
/// <returns>
/// 200 => Content returned.
/// 404 => Content, schema or app not found.
@ -112,9 +113,9 @@ namespace Squidex.Areas.Api.Controllers.Contents
[ProducesResponseType(typeof(ContentDto), StatusCodes.Status200OK)]
[ApiPermissionOrAnonymous]
[ApiCosts(1)]
public async Task<IActionResult> GetContent(string app, string schema, DomainId id)
public async Task<IActionResult> GetContent(string app, string schema, DomainId id, long version = EtagVersion.Any)
{
var content = await contentQuery.FindAsync(Context, schema, id, ct: HttpContext.RequestAborted);
var content = await contentQuery.FindAsync(Context, schema, id, version, HttpContext.RequestAborted);
if (content == null)
{
@ -218,41 +219,6 @@ namespace Squidex.Areas.Api.Controllers.Contents
return Ok(response);
}
/// <summary>
/// Get a content by version V2.
/// </summary>
/// <param name="app">The name of the app.</param>
/// <param name="schema">The name of the schema.</param>
/// <param name="id">The ID of the content to fetch.</param>
/// <param name="version">The version fo the content to fetch.</param>
/// <returns>
/// 200 => Content version returned.
/// 404 => Content, schema or app not found.
/// </returns>
/// <remarks>
/// You can read the generated documentation for your app at /api/content/{appName}/docs.
/// </remarks>
[HttpGet]
[Route("content/{app}/{schema}/{id}/v/{version}/")]
[ApiPermissionOrAnonymous(PermissionIds.AppContentsReadOwn)]
[ApiCosts(1)]
public async Task<IActionResult> GetContentVersionV2(string app, string schema, DomainId id, int version)
{
var content = await contentQuery.FindAsync(Context, schema, id, version, HttpContext.RequestAborted);
if (content == null)
{
return NotFound();
}
var response = Deferred.Response(() =>
{
return ContentDto.FromDomain(content, Resources);
});
return Ok(response);
}
/// <summary>
/// Get a content by version.
/// </summary>

26
backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/OperationBuilder.cs

@ -10,6 +10,7 @@ using NJsonSchema;
using NSwag;
using Squidex.Areas.Api.Config.OpenApi;
using Squidex.Domain.Apps.Core;
using Squidex.Infrastructure;
using Squidex.Shared;
using Squidex.Web;
@ -94,7 +95,14 @@ namespace Squidex.Areas.Api.Controllers.Contents.Generator
return this;
}
public OperationBuilder HasQuery(string name, JsonObjectType type, string? description = null)
public OperationBuilder Deprecated()
{
operation.IsDeprecated = true;
return this;
}
public OperationBuilder HasQuery(string name, JsonObjectType type, string description)
{
var jsonSchema = new JsonSchema { Type = type };
@ -108,14 +116,26 @@ namespace Squidex.Areas.Api.Controllers.Contents.Generator
return AddParameter(name, jsonSchema, OpenApiParameterKind.Path, description);
}
public OperationBuilder HasBody(string name, JsonSchema jsonSchema, string? description = null)
public OperationBuilder HasBody(string name, JsonSchema schema, string? description = null)
{
var jsonSchema = schema;
return AddParameter(name, jsonSchema, OpenApiParameterKind.Body, description);
}
public OperationBuilder Responds(int statusCode, string description, JsonSchema? schema = null)
{
var response = new OpenApiResponse { Description = description, Schema = schema };
var response = new OpenApiResponse
{
Description = description
};
if (schema != null && statusCode == 204)
{
ThrowHelper.ArgumentException("Invalid status code.", nameof(statusCode));
}
response.Schema = schema;
operation.Responses.Add(statusCode.ToString(CultureInfo.InvariantCulture), response);

10
backend/src/Squidex/Areas/Api/Controllers/Contents/Generator/SchemasOpenApiGenerator.cs

@ -133,25 +133,19 @@ namespace Squidex.Areas.Api.Controllers.Contents.Generator
.RequirePermission(PermissionIds.AppContentsReadOwn)
.Operation("Get")
.OperationSummary("Get a [schema] content item.")
.HasQuery("version", JsonObjectType.Number, FieldDescriptions.EntityVersion)
.HasId()
.Responds(200, "Content item returned.", builder.ContentSchema);
builder.AddOperation(OpenApiOperationMethod.Get, "/{id}/{version}")
.RequirePermission(PermissionIds.AppContentsReadOwn)
.Deprecated()
.Operation("GetVersioned")
.OperationSummary("Get a [schema] content item by id and version.")
.HasPath("version", JsonObjectType.Number, FieldDescriptions.EntityVersion)
.HasId()
.Responds(200, "Content item returned.", builder.DataSchema);
builder.AddOperation(OpenApiOperationMethod.Get, "/{id}/v/{version}")
.RequirePermission(PermissionIds.AppContentsReadOwn)
.Operation("GetVersionedV2")
.OperationSummary("Get a [schema] content item by id and version.")
.HasPath("version", JsonObjectType.Number, FieldDescriptions.EntityVersion)
.HasId()
.Responds(200, "Content item returned.", builder.ContentSchema);
builder.AddOperation(OpenApiOperationMethod.Get, "/{id}/validity")
.RequirePermission(PermissionIds.AppContentsReadOwn)
.Operation("Validate")

3
frontend/src/app/features/content/pages/content/editor/content-field.component.scss

@ -27,7 +27,8 @@
}
&-buttons {
@include absolute(-.75rem, 4.25rem);
@include absolute(-.75rem, 4.25rem, null, 0);
overflow: hidden;
}
&-buttons-compare {

20
frontend/src/app/features/content/pages/content/editor/field-copy-button.component.html

@ -13,15 +13,17 @@
<div class="dropdown-divider"></div>
<div class="section row">
<label class="col-auto col-form-label" for="languageSource">{{ 'common.from' | sqxTranslate }}</label>
<div class="col">
<select class="form-select" id="languagesSource"
[ngModel]="copySource"
(ngModelChange)="setCopySource($event)">
<option *ngFor="let language of languages" [ngValue]="language.iso2Code">{{language.iso2Code}}</option>
</select>
<div class="section">
<div class="row">
<label class="col-auto col-form-label" for="languageSource">{{ 'common.from' | sqxTranslate }}</label>
<div class="col">
<select class="form-select" id="languagesSource"
[ngModel]="copySource"
(ngModelChange)="setCopySource($event)">
<option *ngFor="let language of languages" [ngValue]="language.iso2Code">{{language.iso2Code}}</option>
</select>
</div>
</div>
</div>

Loading…
Cancel
Save