WhakerKit 2.0

https://sourceforge.net/projects/whakerkit/

Module whakerkit.nodes

Class ToggleColumnsNode

Description

A node to select which columns of the DocumentsNode is displayed.

Requires a global JS "docManager" which is an instance of "DocumentsManager()".

Constructor

Create the node instance.

Parameters
  • parent: (str) The parent node identifier
View Source
def __init__(self, parent: str):
    """Create the node instance.

    :param parent: (str) The parent node identifier

    """
    super(ToggleColumnsNode, self).__init__(parent, 'toggleselect_div', 'div')
    details = HTMLNode(self.identifier, 'toggable_details', 'details')
    details.add_attribute('id', 'toggable_details')
    self.append_child(details)
    self.__add_summary(details)
    self.__add_main(details)
    button = HTMLNode(self.identifier, None, 'button', value=get_msg(MSG_APPLY))
    button.add_attribute('class', 'apply-button')
    button.add_attribute('onclick', 'docManager.updateColumns();')
    self.append_child(button)

Protected functions

__add_summary

View Source
def __add_summary(self, parent: HTMLNode):
    value = f'\n                <span>{get_msg(MSG_VISIBILITY)}</span>\n                <button class="accordion-action" data-toggle\n                        onclick="docManager.getToggleSelector().toggleSelection(event);"\n                        onkeydown="docManager.getToggleSelector().toggleSelection(event);">\n                    <img src="" alt="" />\n                </button>\n        '
    summary = HTMLNode(parent.identifier, None, 'summary', value=value)
    summary.add_attribute('class', 'summary-choice')
    parent.append_child(summary)

__add_main

View Source
def __add_main(self, parent: HTMLNode):
    main = HTMLNode(parent.identifier, None, 'main')
    parent.append_child(main)
    ul = HTMLNode(main.identifier, None, 'ul')
    main.append_child(ul)
    for field in DOC_FIELDS:
        field_property = DOC_FIELDS[field]
        if field_property.is_toggable is False:
            continue
        li = HTMLNode(ul.identifier, None, 'li', attributes={'class': 'check-item'})
        ul.append_child(li)
        inp = HTMLNode(li.identifier, field + '_input', 'input')
        li.append_child(inp)
        inp.add_attribute('id', field + '_input')
        inp.add_attribute('type', 'checkbox')
        inp.add_attribute('aria-labelledby', field + '_label')
        inp.add_attribute('data-toggle', field)
        if field_property.is_hidden is False:
            inp.add_attribute('checked', 'checked')
        label = HTMLNode(li.identifier, field + '_label', 'label', value=field_property.label)
        li.append_child(label)
        label.add_attribute('id', field + '_label')
        label.add_attribute('for', field + '_input')