Browse Source

Fixed error handling.

release/5.7
Sebastian 5 years ago
parent
commit
f0d9ac333c
  1. 4
      backend/i18n/frontend_en.json
  2. 2
      backend/i18n/source/backend_en.json
  3. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/Guards/ValidationExtensions.cs
  4. 2
      backend/src/Squidex.Shared/Texts.resx
  5. 16
      frontend/app/shared/services/contents.service.ts

4
backend/i18n/frontend_en.json

@ -399,8 +399,8 @@
"contents.deleteConfirmText": "Do you really want to delete the content?", "contents.deleteConfirmText": "Do you really want to delete the content?",
"contents.deleteConfirmTitle": "Delete content", "contents.deleteConfirmTitle": "Delete content",
"contents.deleteManyConfirmText": "Do you really want to delete the selected content items?", "contents.deleteManyConfirmText": "Do you really want to delete the selected content items?",
"contents.deleteReferrerConfirmText": "The content is referenced by another content item.\n\nDo you really want to delete this content?", "contents.deleteReferrerConfirmText": "The content is referenced by another content item.\n\nDo you really want to delete/unpublish this content?",
"contents.deleteReferrerConfirmTitle": "Delete content", "contents.deleteReferrerConfirmTitle": "Delete/unpublish content",
"contents.deleteVersionConfirmText": "Do you really want to delete this version?", "contents.deleteVersionConfirmText": "Do you really want to delete this version?",
"contents.deleteVersionFailed": "Failed to delete version. Please reload.", "contents.deleteVersionFailed": "Failed to delete version. Please reload.",
"contents.draftNew": "New Draft", "contents.draftNew": "New Draft",

2
backend/i18n/source/backend_en.json

@ -131,7 +131,7 @@
"contents.invalidNumber": "Invalid json type, expected number.", "contents.invalidNumber": "Invalid json type, expected number.",
"contents.invalidString": "Invalid json type, expected string.", "contents.invalidString": "Invalid json type, expected string.",
"contents.listReferences": "{count} Reference(s)", "contents.listReferences": "{count} Reference(s)",
"contents.referenced": "Content is referenced by another content and cannot be deleted.", "contents.referenced": "Content is referenced by another content and cannot be deleted or unpublished.",
"contents.singletonNotChangeable": "Singleton content cannot be updated.", "contents.singletonNotChangeable": "Singleton content cannot be updated.",
"contents.singletonNotCreatable": "Singleton content cannot be created.", "contents.singletonNotCreatable": "Singleton content cannot be created.",
"contents.singletonNotDeletable": "Singleton content cannot be deleted.", "contents.singletonNotDeletable": "Singleton content cannot be deleted.",

2
backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/Guards/ValidationExtensions.cs

@ -98,7 +98,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.DomainObject.Guards
if (hasReferrer) if (hasReferrer)
{ {
throw new DomainException(T.Get("contents.referenced", "OBJECT_REFERENCED")); throw new DomainException(T.Get("contents.referenced"), "OBJECT_REFERENCED");
} }
} }

2
backend/src/Squidex.Shared/Texts.resx

@ -479,7 +479,7 @@
<value>{count} Reference(s)</value> <value>{count} Reference(s)</value>
</data> </data>
<data name="contents.referenced" xml:space="preserve"> <data name="contents.referenced" xml:space="preserve">
<value>Content is referenced by another content and cannot be deleted.</value> <value>Content is referenced by another content and cannot be deleted or unpublished.</value>
</data> </data>
<data name="contents.singletonNotChangeable" xml:space="preserve"> <data name="contents.singletonNotChangeable" xml:space="preserve">
<value>Singleton content cannot be updated.</value> <value>Singleton content cannot be updated.</value>

16
frontend/app/shared/services/contents.service.ts

@ -143,7 +143,7 @@ export class ContentsService {
public getContents(appName: string, schemaName: string, q?: ContentQueryDto): Observable<ContentsDto> { public getContents(appName: string, schemaName: string, q?: ContentQueryDto): Observable<ContentsDto> {
const { ids, maxLength } = q || {}; const { ids, maxLength } = q || {};
const { fullQuery, queryOdataParts, queryObj } = buildQuery(q); const { fullQuery, odataParts: queryOdataParts, queryObj } = buildQuery(q);
if (fullQuery.length > (maxLength || 2000)) { if (fullQuery.length > (maxLength || 2000)) {
const body: any = {}; const body: any = {};
@ -348,7 +348,7 @@ function buildQuery(q?: ContentQueryDto) {
const { ids, query, skip, take } = q || {}; const { ids, query, skip, take } = q || {};
const queryParts: string[] = []; const queryParts: string[] = [];
const queryOdataParts: string[] = []; const odataParts: string[] = [];
let queryObj: Query | undefined; let queryObj: Query | undefined;
@ -357,14 +357,14 @@ function buildQuery(q?: ContentQueryDto) {
} else { } else {
if (query && query.fullText && query.fullText.indexOf('$') >= 0) { if (query && query.fullText && query.fullText.indexOf('$') >= 0) {
queryOdataParts.push(`${query.fullText.trim()}`); odataParts.push(`${query.fullText.trim()}`);
if (take && take > 0) { if (take && take > 0) {
queryOdataParts.push(`$top=${take}`); odataParts.push(`$top=${take}`);
} }
if (skip && skip > 0) { if (skip && skip > 0) {
queryOdataParts.push(`$skip=${skip}`); odataParts.push(`$skip=${skip}`);
} }
} else { } else {
queryObj = { ...query }; queryObj = { ...query };
@ -381,8 +381,9 @@ function buildQuery(q?: ContentQueryDto) {
} }
} }
const fullQuery = [...queryParts, ...queryOdataParts].join('&'); const fullQuery = [...queryParts, ...odataParts].join('&');
return { fullQuery, queryOdataParts, queryObj };
return { fullQuery, odataParts, queryObj };
} }
function parseContent(response: any) { function parseContent(response: any) {
@ -423,5 +424,6 @@ function parseError(response: any) {
return new ErrorDto( return new ErrorDto(
response.statusCode, response.statusCode,
response.message, response.message,
response.errorCode,
response.details); response.details);
} }
Loading…
Cancel
Save