-
Notifications
You must be signed in to change notification settings - Fork 474
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MultipleChoiceFormSpec => DualListChoice/CheckboxListChoice
CMK-19100 Change-Id: I11542f980361f656cd1fefea8e5e2584d5734d13
- Loading branch information
1 parent
dc25d16
commit 2d2199a
Showing
20 changed files
with
1,052 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2024 Checkmk GmbH - License: GNU General Public License v2 | ||
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and | ||
# conditions defined in the file COPYING, which is part of this source code package. | ||
|
||
from dataclasses import dataclass | ||
from enum import Enum | ||
|
||
from cmk.rulesets.v1.form_specs._composed import MultipleChoice | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class AdaptiveMultipleChoiceLayout(str, Enum): | ||
auto = "auto" | ||
dual_list = "dual_list" | ||
checkbox_list = "checkbox_list" | ||
|
||
|
||
@dataclass(frozen=True, kw_only=True) | ||
class AdaptiveMultipleChoice(MultipleChoice): | ||
layout: AdaptiveMultipleChoiceLayout = AdaptiveMultipleChoiceLayout.auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
cmk/gui/form_specs/vue/visitors/recomposers/multiple_choice.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2024 Checkmk GmbH - License: GNU General Public License v2 | ||
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and | ||
# conditions defined in the file COPYING, which is part of this source code package. | ||
from typing import Any | ||
|
||
from cmk.ccc.exceptions import MKGeneralException | ||
|
||
from cmk.gui.form_specs.private import AdaptiveMultipleChoice, AdaptiveMultipleChoiceLayout | ||
|
||
from cmk.rulesets.v1.form_specs import FormSpec, MultipleChoice | ||
|
||
|
||
def recompose(form_spec: FormSpec[Any]) -> AdaptiveMultipleChoice: | ||
if not isinstance(form_spec, MultipleChoice): | ||
raise MKGeneralException( | ||
f"Cannot recompose form spec. Expected a MultipleChoice form spec, got {type(form_spec)}" | ||
) | ||
|
||
return AdaptiveMultipleChoice( | ||
# FormSpec | ||
title=form_spec.title, | ||
help_text=form_spec.help_text, | ||
custom_validate=form_spec.custom_validate, | ||
migrate=form_spec.migrate, | ||
# MultipleChoice | ||
elements=form_spec.elements, | ||
show_toggle_all=form_spec.show_toggle_all, | ||
prefill=form_spec.prefill, | ||
# AdaptiveMultipleChoice | ||
layout=AdaptiveMultipleChoiceLayout.auto, | ||
) |
Oops, something went wrong.