Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Umbraco.Cms.Api.Management.ViewModels;
using Umbraco.Cms.Api.Management.ViewModels;
using Umbraco.Cms.Core.Mapping;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Api.Management.ViewModels.Dictionary;
Expand Down Expand Up @@ -62,5 +62,10 @@ private void Map(IDictionaryItem source, DictionaryOverviewResponseModel target,
.Where(translation => translation.Value.IsNullOrWhiteSpace() == false)
.Select(translation => translation.LanguageIsoCode)
.ToArray();
target.Translations = source
.Translations
.ToDictionary(
translation => translation.LanguageIsoCode,
translation => translation.Value ?? string.Empty);
}
}
15 changes: 13 additions & 2 deletions src/Umbraco.Cms.Api.Management/OpenApi.json
Comment thread
Nis-Knowit marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -39507,7 +39507,8 @@
"DictionaryOverviewResponseModel": {
"required": [
"id",
"translatedIsoCodes"
"translatedIsoCodes",
"translations"
],
"type": "object",
"properties": {
Expand All @@ -39532,6 +39533,12 @@
"items": {
"type": "string"
}
},
"translations": {
"type": "object",
"additionalProperties": {
"type": "string"
}
}
},
"additionalProperties": false
Expand Down Expand Up @@ -46936,6 +46943,7 @@
"required": [
"allowLocalLogin",
"allowPasswordReset",
"umbracoCssPath",
"versionCheckPeriod"
],
"type": "object",
Expand All @@ -46949,6 +46957,9 @@
},
"allowLocalLogin": {
"type": "boolean"
},
"umbracoCssPath": {
"type": "string"
}
},
"additionalProperties": false
Expand Down Expand Up @@ -50509,4 +50520,4 @@
"name": "Webhook"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Umbraco.Cms.Api.Management.ViewModels.Dictionary;
namespace Umbraco.Cms.Api.Management.ViewModels.Dictionary;

public class DictionaryOverviewResponseModel
{
Expand All @@ -21,4 +21,9 @@ public class DictionaryOverviewResponseModel
/// Sets the translations.
/// </summary>
public IEnumerable<string> TranslatedIsoCodes { get; set; } = Enumerable.Empty<string>();

/// <summary>
/// Gets or sets the translation values by ISO code.
/// </summary>
public Dictionary<string, string> Translations { get; set; } = new();
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public IEnumerable<IDictionaryItem> GetDictionaryItemDescendants(Guid? parentId,

if (filter.IsNullOrWhiteSpace() is false)
{
sql.Where<DictionaryDto>(x => x.Key.StartsWith(filter));
// Search in both dictionary key and translation values
sql.Where($"({QuotedColumn("key")} LIKE @filter OR EXISTS (SELECT 1 FROM {SqlContext.SqlSyntax.GetQuotedTableName(LanguageTextDto.TableName)} lt WHERE lt.{SqlContext.SqlSyntax.GetQuotedColumnName("UniqueId")} = {QuotedColumn("id")} AND lt.{SqlContext.SqlSyntax.GetQuotedColumnName("value")} LIKE @filter))", new { filter = $"%{filter}%" });
}

sql.OrderBy<DictionaryDto>(x => x.UniqueId);
Expand All @@ -130,7 +131,8 @@ public IEnumerable<IDictionaryItem> GetDictionaryItemDescendants(Guid? parentId,

if (filter.IsNullOrWhiteSpace() is false)
{
sql.Where<DictionaryDto>(x => x.Key.StartsWith(filter));
// Search in both dictionary key and translation values
sql.Where($"({QuotedColumn("key")} LIKE @filter OR EXISTS (SELECT 1 FROM {SqlContext.SqlSyntax.GetQuotedTableName(LanguageTextDto.TableName)} lt WHERE lt.{SqlContext.SqlSyntax.GetQuotedColumnName("UniqueId")} = {QuotedColumn("id")} AND lt.{SqlContext.SqlSyntax.GetQuotedColumnName("value")} LIKE @filter))", new { filter = $"%{filter}%" });
}

return Database
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,9 @@ export type DictionaryOverviewResponseModel = {
id: string;
parent?: ReferenceByIdModel | null;
translatedIsoCodes: Array<string>;
translations: {
[key: string]: string;
};
};

export enum DirectionModel {
Expand Down Expand Up @@ -6688,8 +6691,14 @@ export type GetDocumentByIdReferencedByErrors = {
* The authenticated user does not have access to this resource
*/
403: unknown;
/**
* Not Found
*/
404: ProblemDetails;
};

export type GetDocumentByIdReferencedByError = GetDocumentByIdReferencedByErrors[keyof GetDocumentByIdReferencedByErrors];

export type GetDocumentByIdReferencedByResponses = {
/**
* OK
Expand Down Expand Up @@ -6720,8 +6729,14 @@ export type GetDocumentByIdReferencedDescendantsErrors = {
* The authenticated user does not have access to this resource
*/
403: unknown;
/**
* Not Found
*/
404: ProblemDetails;
};

export type GetDocumentByIdReferencedDescendantsError = GetDocumentByIdReferencedDescendantsErrors[keyof GetDocumentByIdReferencedDescendantsErrors];

export type GetDocumentByIdReferencedDescendantsResponses = {
/**
* OK
Expand Down Expand Up @@ -9677,8 +9692,14 @@ export type GetMediaByIdReferencedByErrors = {
* The authenticated user does not have access to this resource
*/
403: unknown;
/**
* Not Found
*/
404: ProblemDetails;
};

export type GetMediaByIdReferencedByError = GetMediaByIdReferencedByErrors[keyof GetMediaByIdReferencedByErrors];

export type GetMediaByIdReferencedByResponses = {
/**
* OK
Expand Down Expand Up @@ -9709,8 +9730,14 @@ export type GetMediaByIdReferencedDescendantsErrors = {
* The authenticated user does not have access to this resource
*/
403: unknown;
/**
* Not Found
*/
404: ProblemDetails;
};

export type GetMediaByIdReferencedDescendantsError = GetMediaByIdReferencedDescendantsErrors[keyof GetMediaByIdReferencedDescendantsErrors];

export type GetMediaByIdReferencedDescendantsResponses = {
/**
* OK
Expand Down Expand Up @@ -11523,8 +11550,14 @@ export type GetMemberByIdReferencedByErrors = {
* The authenticated user does not have access to this resource
*/
403: unknown;
/**
* Not Found
*/
404: ProblemDetails;
};

export type GetMemberByIdReferencedByError = GetMemberByIdReferencedByErrors[keyof GetMemberByIdReferencedByErrors];

export type GetMemberByIdReferencedByResponses = {
/**
* OK
Expand Down Expand Up @@ -11555,8 +11588,14 @@ export type GetMemberByIdReferencedDescendantsErrors = {
* The authenticated user does not have access to this resource
*/
403: unknown;
/**
* Not Found
*/
404: ProblemDetails;
};

export type GetMemberByIdReferencedDescendantsError = GetMemberByIdReferencedDescendantsErrors[keyof GetMemberByIdReferencedDescendantsErrors];

export type GetMemberByIdReferencedDescendantsResponses = {
/**
* OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class UmbDictionaryCollectionServerDataSource implements UmbCollectionDat
name: item.name!,
parentUnique: item.parent ? item.parent.id : null,
translatedIsoCodes: item.translatedIsoCodes,
translations: item.translations || {},
unique: item.id,
};
return model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export interface UmbDictionaryCollectionModel {
name: string;
parentUnique: string | null;
translatedIsoCodes: Array<string>;
translations: Record<string, string>;
unique: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,23 @@ export class UmbDictionaryTableCollectionViewElement extends UmbLitElement {
value: html`<a style="font-weight:bold" href=${editPath}> ${dictionary.name}</a> `,
},
...languages.map((language) => {
const translation = dictionary.translations?.[language.unique];
return {
columnAlias: language.unique,
value: dictionary.translatedIsoCodes?.includes(language.unique)
? this.#renderCheckIcon(language.name)
: this.#renderAlertIcon(language.name),
value: translation ? this.#renderTranslation(translation) : this.#renderMissingTranslation(language.name),
};
}),
],
};
});
}

#renderCheckIcon(name: string) {
return html`<uui-icon
name="check"
title="${this.localize.term('visuallyHiddenTexts_hasTranslation')} (${name})"
style="color:var(--uui-color-positive-standalone);display:inline-block"></uui-icon>`;
#renderTranslation(value: string) {
return html`<span style="color:var(--uui-color-text)" title="${value}">${value}</span>`;
}

#renderAlertIcon(name: string) {
return html`<uui-icon
name="alert"
title="${this.localize.term('visuallyHiddenTexts_noTranslation')} (${name})"
style="color:var(--uui-color-danger-standalone);display:inline-block"></uui-icon>`;
#renderMissingTranslation(languageName: string) {
return html`<span style="color:var(--uui-color-danger-standalone);font-style:italic" title="${this.localize.term('visuallyHiddenTexts_noTranslation')} (${languageName})">—</span>`;
}

override render() {
Expand Down
Loading