Skip to content

Commit

Permalink
Make "Browse" main nav link text configurable in platform settings
Browse files Browse the repository at this point in the history
Closes #234
  • Loading branch information
bkis committed Jul 9, 2024
1 parent 94f3157 commit fe817a8
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 40 deletions.
62 changes: 41 additions & 21 deletions Tekst-API/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10816,6 +10816,25 @@
"type": "object",
"title": "LocationUpdate"
},
"MainNavEntryTranslation": {
"properties": {
"locale": {
"$ref": "#/components/schemas/TranslationLocaleKey"
},
"translation": {
"type": "string",
"maxLength": 16,
"minLength": 1,
"title": "Translation"
}
},
"type": "object",
"required": [
"locale",
"translation"
],
"title": "MainNavEntryTranslation"
},
"MaybePrivateUserField": {
"type": "string",
"enum": [
Expand Down Expand Up @@ -11926,25 +11945,6 @@
],
"title": "PlatformDescriptionTranslation"
},
"PlatformNavInfoEntryTranslation": {
"properties": {
"locale": {
"$ref": "#/components/schemas/TranslationLocaleKey"
},
"translation": {
"type": "string",
"maxLength": 16,
"minLength": 1,
"title": "Translation"
}
},
"type": "object",
"required": [
"locale",
"translation"
],
"title": "PlatformNavInfoEntryTranslation"
},
"PlatformSecurityInfo": {
"properties": {
"closedMode": {
Expand Down Expand Up @@ -12019,9 +12019,19 @@
"title": "Defaulttextid",
"description": "Default text to load in UI"
},
"navBrowseEntry": {
"items": {
"$ref": "#/components/schemas/MainNavEntryTranslation"
},
"type": "array",
"maxItems": 3,
"title": "Navbrowseentry",
"description": "Custom label for main navigation browse entry",
"default": []
},
"navInfoEntry": {
"items": {
"$ref": "#/components/schemas/PlatformNavInfoEntryTranslation"
"$ref": "#/components/schemas/MainNavEntryTranslation"
},
"type": "array",
"maxItems": 3,
Expand Down Expand Up @@ -12134,9 +12144,19 @@
"title": "Defaulttextid",
"description": "Default text to load in UI"
},
"navBrowseEntry": {
"items": {
"$ref": "#/components/schemas/MainNavEntryTranslation"
},
"type": "array",
"maxItems": 3,
"title": "Navbrowseentry",
"description": "Custom label for main navigation browse entry",
"default": []
},
"navInfoEntry": {
"items": {
"$ref": "#/components/schemas/PlatformNavInfoEntryTranslation"
"$ref": "#/components/schemas/MainNavEntryTranslation"
},
"type": "array",
"maxItems": 3,
Expand Down
10 changes: 8 additions & 2 deletions Tekst-API/tekst/models/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PlatformDescriptionTranslation(TranslationBase):
]


class PlatformNavInfoEntryTranslation(TranslationBase):
class MainNavEntryTranslation(TranslationBase):
translation: Annotated[
str,
StringConstraints(
Expand Down Expand Up @@ -102,8 +102,14 @@ class PlatformSettings(ModelBase, ModelFactoryMixin):
description="Default text to load in UI",
),
] = None
nav_browse_entry: Annotated[
Translations[MainNavEntryTranslation],
Field(
description="Custom label for main navigation browse entry",
),
] = []
nav_info_entry: Annotated[
Translations[PlatformNavInfoEntryTranslation],
Translations[MainNavEntryTranslation],
Field(
description="Custom label for main navigation info entry",
),
Expand Down
28 changes: 20 additions & 8 deletions Tekst-Web/src/api/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2524,6 +2524,12 @@ export interface components {
/** Label */
label?: string | null;
};
/** MainNavEntryTranslation */
MainNavEntryTranslation: {
locale: components['schemas']['TranslationLocaleKey'];
/** Translation */
translation: string;
};
/** @enum {string} */
MaybePrivateUserField: 'name' | 'affiliation' | 'bio';
MaybePrivateUserFields: components['schemas']['MaybePrivateUserField'][];
Expand Down Expand Up @@ -3107,12 +3113,6 @@ export interface components {
/** Translation */
translation: string;
};
/** PlatformNavInfoEntryTranslation */
PlatformNavInfoEntryTranslation: {
locale: components['schemas']['TranslationLocaleKey'];
/** Translation */
translation: string;
};
/** PlatformSecurityInfo */
PlatformSecurityInfo: {
/**
Expand Down Expand Up @@ -3170,12 +3170,18 @@ export interface components {
* @description Default text to load in UI
*/
defaultTextId?: string | null;
/**
* Navbrowseentry
* @description Custom label for main navigation browse entry
* @default []
*/
navBrowseEntry?: components['schemas']['MainNavEntryTranslation'][];
/**
* Navinfoentry
* @description Custom label for main navigation info entry
* @default []
*/
navInfoEntry?: components['schemas']['PlatformNavInfoEntryTranslation'][];
navInfoEntry?: components['schemas']['MainNavEntryTranslation'][];
/**
* Customfonts
* @description CSS font family names for use in resources
Expand Down Expand Up @@ -3246,12 +3252,18 @@ export interface components {
* @description Default text to load in UI
*/
defaultTextId?: string | null;
/**
* Navbrowseentry
* @description Custom label for main navigation browse entry
* @default []
*/
navBrowseEntry?: components['schemas']['MainNavEntryTranslation'][];
/**
* Navinfoentry
* @description Custom label for main navigation info entry
* @default []
*/
navInfoEntry?: components['schemas']['PlatformNavInfoEntryTranslation'][];
navInfoEntry?: components['schemas']['MainNavEntryTranslation'][];
/**
* Customfonts
* @description CSS font family names for use in resources
Expand Down
14 changes: 9 additions & 5 deletions Tekst-Web/src/components/navigation/navMenuOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@ export function useMainMenuOptions(showIcons: boolean = true) {

const menuOptions = computed<MenuOption[]>(() => [
{
label: renderLink(() => $t('nav.browse'), {
name: 'browse',
params: { text: state.text?.slug },
query: { lvl: browse.level, pos: browse.position },
}),
label: renderLink(
() =>
pickTranslation(pfData.value?.settings.navBrowseEntry, state.locale) || $t('nav.browse'),
{
name: 'browse',
params: { text: state.text?.slug },
query: { lvl: browse.level, pos: browse.position },
}
),
key: 'browse',
icon: (showIcons && renderIcon(BookIcon)) || undefined,
},
Expand Down
2 changes: 1 addition & 1 deletion Tekst-Web/src/forms/formRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export const platformSettingsFormRules: Record<string, FormItemRule[]> = {
trigger: 'blur',
},
],
navInfoEntryTranslation: [minMaxCharsRule(1, 42, 'blur')],
navEntryTranslation: [minMaxCharsRule(1, 42, 'blur')],
oskModeKey: [
requiredRule(() => $t('models.platformSettings.oskModeKey'), 'blur'),
minMaxCharsRule(1, 32, 'blur'),
Expand Down
12 changes: 11 additions & 1 deletion Tekst-Web/src/views/admin/AdminSystemSettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,24 @@ function resetForm() {
/>
</n-form-item>

<!-- TRANSLATE MAIN NAV BROWSE ENTRY -->
<translation-form-item
v-model="formModel.navBrowseEntry"
parent-form-path-prefix="navBrowseEntry"
:loading="loading"
:main-form-label="$t('models.platformSettings.navBrowseEntry')"
:translation-form-label="$t('models.platformSettings.navBrowseEntry')"
:translation-form-rule="platformSettingsFormRules.navEntryTranslation"
/>

<!-- TRANSLATE MAIN NAV INFO ENTRY -->
<translation-form-item
v-model="formModel.navInfoEntry"
parent-form-path-prefix="navInfoEntry"
:loading="loading"
:main-form-label="$t('models.platformSettings.navInfoEntry')"
:translation-form-label="$t('models.platformSettings.navInfoEntry')"
:translation-form-rule="platformSettingsFormRules.navInfoEntryTranslation"
:translation-form-rule="platformSettingsFormRules.navEntryTranslation"
/>

<!-- DISPLAY OPTIONS -->
Expand Down
3 changes: 2 additions & 1 deletion Tekst-Web/translations/ui/deDE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ models:
infoContactUrl: URL Kontaktperson
defaultText: Standard-Text
availableLocales: Verfügbare Sprachen
navInfoEntry: Eigene Beschriftung für Info-Eintrag in Hauptnavigation
navBrowseEntry: Eigene Beschriftung für "Lesen" in Hauptnavigation
navInfoEntry: Eigene Beschriftung für "Info" in Hauptnavigation
alwaysShowTextInfo: Zeige Textinformationen und -auswahl auch auf nicht-textspezifischen Seiten
showTekstFooterHint: Zeige einen kleinen Hinweis auf die Tekst-Software in der Fußzeile (Danke!)
oskModes: Bildschirmtastatur-Modi
Expand Down
3 changes: 2 additions & 1 deletion Tekst-Web/translations/ui/enUS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,8 @@ models:
infoContactUrl: Contact URL
defaultText: Default Text
availableLocales: Available Languages
navInfoEntry: Custom label for info entry in main navigation
navBrowseEntry: Custom label for "Browse" in main navigation
navInfoEntry: Custom label for "Info" in main navigation
alwaysShowTextInfo: Show text info and selector in header even on non-text-specific pages
showTekstFooterHint: Show a small hint to the Tekst software in the footer (Thank you!)
oskModes: On-screen keyboard modes
Expand Down

0 comments on commit fe817a8

Please sign in to comment.