Skip to content

Commit 930ca36

Browse files
authored
Dev layer categories (#93)
2 parents 4ef8828 + 35a15e0 commit 930ca36

File tree

16 files changed

+588
-44
lines changed

16 files changed

+588
-44
lines changed

Tekst-API/openapi.json

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4101,6 +4101,19 @@
41014101
"title": "Ownerid",
41024102
"description": "User owning this layer"
41034103
},
4104+
"category": {
4105+
"anyOf": [
4106+
{
4107+
"type": "string",
4108+
"maxLength": 16
4109+
},
4110+
{
4111+
"type": "null"
4112+
}
4113+
],
4114+
"title": "Category",
4115+
"description": "Data layer category key"
4116+
},
41044117
"sharedRead": {
41054118
"items": {
41064119
"type": "string",
@@ -4285,6 +4298,19 @@
42854298
"title": "Ownerid",
42864299
"description": "User owning this layer"
42874300
},
4301+
"category": {
4302+
"anyOf": [
4303+
{
4304+
"type": "string",
4305+
"maxLength": 16
4306+
},
4307+
{
4308+
"type": "null"
4309+
}
4310+
],
4311+
"title": "Category",
4312+
"description": "Data layer category key"
4313+
},
42884314
"sharedRead": {
42894315
"items": {
42904316
"type": "string",
@@ -4429,6 +4455,19 @@
44294455
"title": "Ownerid",
44304456
"description": "User owning this layer"
44314457
},
4458+
"category": {
4459+
"anyOf": [
4460+
{
4461+
"type": "string",
4462+
"maxLength": 16
4463+
},
4464+
{
4465+
"type": "null"
4466+
}
4467+
],
4468+
"title": "Category",
4469+
"description": "Data layer category key"
4470+
},
44324471
"sharedRead": {
44334472
"items": {
44344473
"type": "string",
@@ -4827,6 +4866,73 @@
48274866
"type": "object",
48284867
"title": "HTTPValidationError"
48294868
},
4869+
"LayerCategory-Input": {
4870+
"properties": {
4871+
"key": {
4872+
"type": "string",
4873+
"maxLength": 16,
4874+
"minLength": 1,
4875+
"title": "Key"
4876+
},
4877+
"translations": {
4878+
"items": {
4879+
"$ref": "#/components/schemas/LayerCategoryTranslation"
4880+
},
4881+
"type": "array",
4882+
"maxItems": 3,
4883+
"title": "Translations"
4884+
}
4885+
},
4886+
"type": "object",
4887+
"required": [
4888+
"key",
4889+
"translations"
4890+
],
4891+
"title": "LayerCategory"
4892+
},
4893+
"LayerCategory-Output": {
4894+
"properties": {
4895+
"key": {
4896+
"type": "string",
4897+
"maxLength": 16,
4898+
"minLength": 1,
4899+
"title": "Key"
4900+
},
4901+
"translations": {
4902+
"items": {
4903+
"$ref": "#/components/schemas/LayerCategoryTranslation"
4904+
},
4905+
"type": "array",
4906+
"maxItems": 3,
4907+
"title": "Translations"
4908+
}
4909+
},
4910+
"type": "object",
4911+
"required": [
4912+
"key",
4913+
"translations"
4914+
],
4915+
"title": "LayerCategory"
4916+
},
4917+
"LayerCategoryTranslation": {
4918+
"properties": {
4919+
"locale": {
4920+
"$ref": "#/components/schemas/Locale"
4921+
},
4922+
"translation": {
4923+
"type": "string",
4924+
"maxLength": 32,
4925+
"minLength": 1,
4926+
"title": "Translation"
4927+
}
4928+
},
4929+
"type": "object",
4930+
"required": [
4931+
"locale",
4932+
"translation"
4933+
],
4934+
"title": "LayerCategoryTranslation"
4935+
},
48304936
"LayerCommentTranslation": {
48314937
"properties": {
48324938
"locale": {
@@ -5178,6 +5284,19 @@
51785284
"title": "Ownerid",
51795285
"description": "User owning this layer"
51805286
},
5287+
"category": {
5288+
"anyOf": [
5289+
{
5290+
"type": "string",
5291+
"maxLength": 16
5292+
},
5293+
{
5294+
"type": "null"
5295+
}
5296+
],
5297+
"title": "Category",
5298+
"description": "Data layer category key"
5299+
},
51815300
"sharedRead": {
51825301
"items": {
51835302
"type": "string",
@@ -5362,6 +5481,19 @@
53625481
"title": "Ownerid",
53635482
"description": "User owning this layer"
53645483
},
5484+
"category": {
5485+
"anyOf": [
5486+
{
5487+
"type": "string",
5488+
"maxLength": 16
5489+
},
5490+
{
5491+
"type": "null"
5492+
}
5493+
],
5494+
"title": "Category",
5495+
"description": "Data layer category key"
5496+
},
53655497
"sharedRead": {
53665498
"items": {
53675499
"type": "string",
@@ -5506,6 +5638,19 @@
55065638
"title": "Ownerid",
55075639
"description": "User owning this layer"
55085640
},
5641+
"category": {
5642+
"anyOf": [
5643+
{
5644+
"type": "string",
5645+
"maxLength": 16
5646+
},
5647+
{
5648+
"type": "null"
5649+
}
5650+
],
5651+
"title": "Category",
5652+
"description": "Data layer category key"
5653+
},
55095654
"sharedRead": {
55105655
"items": {
55115656
"type": "string",
@@ -5993,6 +6138,21 @@
59936138
"description": "Custom label for main navigation info entry",
59946139
"default": []
59956140
},
6141+
"layerCategories": {
6142+
"items": {
6143+
"$ref": "#/components/schemas/LayerCategory-Output"
6144+
},
6145+
"type": "array",
6146+
"title": "Layercategories",
6147+
"description": "Layer categories to categorize layers in",
6148+
"default": []
6149+
},
6150+
"showLayerCategoryHeadings": {
6151+
"type": "boolean",
6152+
"title": "Showlayercategoryheadings",
6153+
"description": "Show layer category headings in browse view",
6154+
"default": true
6155+
},
59966156
"alwaysShowTextInfo": {
59976157
"type": "boolean",
59986158
"title": "Alwaysshowtextinfo",
@@ -6126,6 +6286,21 @@
61266286
"description": "Custom label for main navigation info entry",
61276287
"default": []
61286288
},
6289+
"layerCategories": {
6290+
"items": {
6291+
"$ref": "#/components/schemas/LayerCategory-Input"
6292+
},
6293+
"type": "array",
6294+
"title": "Layercategories",
6295+
"description": "Layer categories to categorize layers in",
6296+
"default": []
6297+
},
6298+
"showLayerCategoryHeadings": {
6299+
"type": "boolean",
6300+
"title": "Showlayercategoryheadings",
6301+
"description": "Show layer category headings in browse view",
6302+
"default": true
6303+
},
61296304
"alwaysShowTextInfo": {
61306305
"type": "boolean",
61316306
"title": "Alwaysshowtextinfo",

Tekst-API/tekst/models/layer.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ class LayerBase(ModelBase, ModelFactoryMixin):
5959
owner_id: Annotated[
6060
PydanticObjectId | None, Field(description="User owning this layer")
6161
] = None
62+
category: Annotated[
63+
str | None,
64+
Field(description="Data layer category key", max_length=16),
65+
] = None
6266
shared_read: Annotated[
6367
list[PydanticObjectId],
6468
Field(description="Users with shared read access to this layer"),

Tekst-API/tekst/models/settings.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from beanie import PydanticObjectId
44
from pydantic import EmailStr, Field, StringConstraints
5+
from typing_extensions import TypedDict
56

67
from tekst.config import TekstConfig, get_config
78
from tekst.models.common import (
@@ -29,9 +30,24 @@ class PlatformNavInfoEntryTranslation(TranslationBase):
2930
]
3031

3132

33+
class LayerCategoryTranslation(TranslationBase):
34+
translation: Annotated[
35+
str, StringConstraints(strip_whitespace=True, min_length=1, max_length=32)
36+
]
37+
38+
39+
class LayerCategory(TypedDict):
40+
key: Annotated[
41+
str, StringConstraints(strip_whitespace=True, min_length=1, max_length=16)
42+
]
43+
translations: Translations[LayerCategoryTranslation]
44+
45+
3246
class PlatformSettings(ModelBase, ModelFactoryMixin):
3347
"""Settings defining platform behavior configured by admins"""
3448

49+
# INFO
50+
3551
info_platform_name: Annotated[
3652
str,
3753
StringConstraints(min_length=1, max_length=32),
@@ -62,13 +78,21 @@ class PlatformSettings(ModelBase, ModelFactoryMixin):
6278
Field(description="URL to page with contact info"),
6379
] = None
6480

81+
# OPTIONS
6582
default_text_id: Annotated[
6683
PydanticObjectId | None, Field(description="Default text to load in UI")
6784
] = None
6885
nav_info_entry: Annotated[
6986
Translations[PlatformNavInfoEntryTranslation],
7087
Field(description="Custom label for main navigation info entry"),
7188
] = []
89+
layer_categories: Annotated[
90+
list[LayerCategory],
91+
Field(description="Layer categories to categorize layers in"),
92+
] = []
93+
show_layer_category_headings: Annotated[
94+
bool, Field(description="Show layer category headings in browse view")
95+
] = True
7296
always_show_text_info: Annotated[
7397
bool,
7498
Field(

0 commit comments

Comments
 (0)