Bug 57068 - Add a proper (sub)syntax for UDM_PropertySelect
Add a proper (sub)syntax for UDM_PropertySelect
Status: NEW
Product: UCS
Classification: Unclassified
Component: UDM (Generic)
UCS 5.0
Other Linux
: P5 normal (vote)
: ---
Assigned To: UMC maintainers
UMC maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2024-02-19 11:52 CET by Felix Botner
Modified: 2024-02-19 13:16 CET (History)
1 user (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Botner univentionstaff 2024-02-19 11:52:58 CET
For blocklist blockingProperties we use the complex syntax UDM_PropertySelect, currently with "string".

Better to have a correct sub syntax for modules and properties.

Florian's Idea:

class UDM_PropertySelect(complex):
    """Syntax to enter |UDM| module and property name."""

    subsyntaxes = ((_('UDM module'), univentionAdminModules), (_('property'), allModuleProperties))
    subsyntax_names = ('module', 'property')


class allModuleProperties(combobox):
    """Syntax to select properties for |UDM| modules."""

    depends = 'module'

    @classmethod
    def update_choices(cls):
        cls.choices = cls.get_choices(None, {'dependencies': {cls.depends: list(univention.admin.modules.modules)}})

    @classmethod
    def get_choices(cls, lo, options):
        if cls.depends not in options.get('dependencies', {}):  # pragma: no cover
            return cls.choices
        modules = options['dependencies'][cls.depends]
        return cls.sort_choices([
            (key, opt.short_description)
            for module in modules
            for key, opt in getattr(univention.admin.modules.get(module), 'property_descriptions', {}).items()
        ])
Comment 1 Florian Best univentionstaff 2024-02-19 13:16:04 CET
That sketch probably doesn't work yet, as it specifies "module" as dependency while "module" is not a property but a sub-syntax.
Therefore the "depends" should be the name of the property. Then the given dependency is probably given as list [module, property]. and we have to take the first entry there to get the selected module and choose the available properties for it.
I don't know if the javascript frontend already supports dependencies for sub-syntaxes (i.e. detect to reload values when the value of the same property changes).