Skip to content

Commit

Permalink
vue: introduced layout options for Dictionary and CascadingDropdown
Browse files Browse the repository at this point in the history
Change-Id: I2d76df9dd76cd7f9a9e64695e50e291ec863b6b2
  • Loading branch information
schnetzzz committed Aug 23, 2024
1 parent f1feab0 commit 2facba3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
13 changes: 13 additions & 0 deletions cmk/gui/form_specs/vue/shared_type_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import annotations

from dataclasses import dataclass, field
from enum import Enum
from typing import Any, Optional, Union


Expand Down Expand Up @@ -50,6 +51,11 @@ class DictionaryGroup:
help: Optional[str] = None


class Layout(str, Enum):
default = "default"
two_columns = "two_columns"


@dataclass(kw_only=True)
class SingleChoiceElement:
name: Any
Expand All @@ -62,6 +68,11 @@ class MultipleChoiceElement:
title: str


class Layout1(str, Enum):
default = "default"
horizontal = "horizontal"


@dataclass(kw_only=True)
class ValidationMessage:
location: list[str]
Expand Down Expand Up @@ -135,6 +146,7 @@ class Dictionary(FormSpec):
elements: list[DictionaryElement] = field(default_factory=lambda: [])
no_elements_text: Optional[str] = None
additional_static_elements: Optional[dict[str, Any]] = None
layout: Layout = Layout.default


@dataclass(kw_only=True)
Expand Down Expand Up @@ -169,6 +181,7 @@ class CascadingSingleChoice(FormSpec):
elements: list[CascadingSingleChoiceElement] = field(default_factory=lambda: [])
no_elements_text: Optional[str] = None
label: Optional[str] = None
layout: Layout1 = Layout1.default


@dataclass(kw_only=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type Dictionary = FormSpec & {
groups: DictionaryGroup[];
no_elements_text?: string;
additional_static_elements?: {};
layout: "default" | "two_columns";
};
export type List = FormSpec & {
type: "list";
Expand Down Expand Up @@ -74,6 +75,7 @@ export type CascadingSingleChoice = FormSpec & {
no_elements_text?: string;
label?: string;
input_hint: unknown;
layout: "default" | "horizontal";
};
export type FixedValue = FormSpec & {
type: "fixed_value";
Expand Down
17 changes: 14 additions & 3 deletions packages/cmk-shared-typing/source/vue_formspec/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,19 @@
},
"additional_static_elements": {
"type": "object"
},
"layout": {
"enum": ["default", "two_columns"],
"default": "default"
}
},
"required": [
"type",
"elements",
"static_elements_key",
"groups"
"groups",
"layout"

],
"allOf": [
{
Expand Down Expand Up @@ -389,12 +395,17 @@
"label": {
"type": "string"
},
"input_hint": {}
"input_hint": {},
"layout": {
"enum": ["default", "horizontal"],
"default": "default"
}
},
"required": [
"type",
"elements",
"input_hint"
"input_hint",
"layout"
],
"allOf": [
{
Expand Down
2 changes: 2 additions & 0 deletions packages/cmk-shared-typing/source/vue_formspec/postprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
STRIP_OPTIONAL = [
("FormSpec", "validators"),
("Dictionary", "elements"),
("Dictionary", "layout"),
("SingleChoice", "elements"),
("MultipleChoice", "elements"),
("MultipleChoice", "show_toggle_all"),
("CascadingSingleChoice", "elements"),
("CascadingSingleChoice", "layout"),
]


Expand Down

0 comments on commit 2facba3

Please sign in to comment.