Example #1
0
    def _get_element(self, **kwargs) -> htmler.Element:
        """Render the widget.
        :param **kwargs:
        """
        lng = self.value['lng']
        lat = self.value['lat']
        address = self.value['address']
        address_components = json.dumps(self.value['address_components'])

        inputs = htmler.TagLessElement()
        inputs.append_child(htmler.Input(type='text', name=self._uid + '[search]', css='form-control', value=address,
                                         placeholder=self._placeholder))
        inputs.append_child(htmler.Input(type='hidden', name=self._uid + '[lng]', value=lng))
        inputs.append_child(htmler.Input(type='hidden', name=self._uid + '[lat]', value=lat))
        inputs.append_child(htmler.Input(type='hidden', name=self._uid + '[address]', value=address))
        inputs.append_child(
            htmler.Input(type='hidden', name=self._uid + '[address_components]', value=address_components))

        if self._autodetect:
            self._data['autodetect'] = self._autodetect

        if self._types:
            self._data['types'] = json.dumps(self._types)

        if self._component_restrictions:
            self._data['component_restrictions'] = json.dumps({'country': self._component_restrictions})

        return inputs
Example #2
0
    def _get_element(self, **kwargs) -> htmler.Element:
        html_input = htmler.Input(
            type='text',
            id=self._uid,
            name=self._name,
            value=','.join(self.get_val()) if self.get_val() else '',
            css=' '.join(('form-control', self._css)),
        )

        return html_input
Example #3
0
    def _get_element(self, **kwargs):
        """Hook
        """
        container = htmler.TagLessElement()
        container.append_child(htmler.Input(
            type='hidden',
            name=self.name))  # It is important to have an empty input!
        for entity in self._get_entities():
            container.append_child(self._item_renderer(entity))

        return container
Example #4
0
    def _get_element(self, **kwargs) -> htmler.Element:
        html_input = htmler.Input(
            type='file',
            id=self._uid,
            name=self._name,
            accept=self._accept,
        )

        if self._multiple:
            html_input.set_attr('multiple', 'true')

        return html_input
Example #5
0
    def _get_element(self, **kwargs) -> htmler.Element:
        """Render the widget
        """
        html_input = htmler.Input(
            type='text',
            id=self._uid,
            name=self._name,
            value=','.join([v.f_get('title') for v in self.get_val()]),
            css=' '.join(('form-control', self._css)),
        )

        return html_input
Example #6
0
    def _get_element(self, **kwargs) -> htmler.Input:
        inp = htmler.Input(
            type='hidden',
            id=self.uid,
            name=self.name,
            value=self.value,
            required=self.required
        )

        for k, v in self._data.items():
            inp.set_attr('data_' + k, v)

        return inp
Example #7
0
    def _get_element(self, **kwargs) -> htmler.Element:
        """Render the widget.
        :param **kwargs:
        """
        container = htmler.TagLessElement()
        container.append_child(
            htmler.Input(type='hidden',
                         uid=self.uid,
                         name=self.name,
                         value=self.value))
        container.append_child(
            htmler.P(self._text, css='form-control-static', title=self._title))

        return container
Example #8
0
    def _get_element(self, **kwargs) -> htmler.Input:
        """Render the widget
        :param **kwargs:
        """
        inp = htmler.Input(
            type=self._type,
            id=self._uid,
            name=self._name,
            css='form-control',
            autocomplete=self._autocomplete,
            placeholder=self._placeholder,
            required=self._required
        )

        value = self.get_val()
        if value:
            inp.set_attr('value', value)

        if not self._enabled:
            inp.set_attr('disabled', 'true')

        if self._min_length:
            inp.set_attr('minlength', self._min_length)

        if self._max_length:
            inp.set_attr('maxlength', self._max_length)

        if self._prepend or self._append:
            group = htmler.Div(css='input-group')
            if self._prepend:
                prepend = group.append_child(htmler.Div(css='input-group-addon input-group-prepend'))
                prepend.append_child(htmler.Div(self._prepend, css='input-group-text'))
            group.append_child(inp)
            if self._append:
                append = group.append_child(htmler.Div(css='input-group-addon input-group-append'))
                append.append_child(htmler.Div(self._append, css='input-group-text'))
            inp = group

        if self._inputmask:
            inp.set_attr('data_inputmask', ','.join(["'{}': '{}'".format(k, v) for k, v in self._inputmask.items()]))

        return inp
Example #9
0
    def _get_element(self, **kwargs) -> htmler.Element:
        """Render the widget.
        :param **kwargs:
        """
        inputs = htmler.TagLessElement()

        inputs.append_child(
            htmler.
            P(f'Longitude: {self.value["lng"]}, latitude: {self.value["lat"]}',
              css='text'))

        self._data['autodetect'] = self._autodetect

        for k in ('lng', 'lat', 'coordinates', 'accuracy', 'alt',
                  'alt_accuracy', 'heading', 'speed'):
            inp_val = self._value[k] if k in self._value else ''
            inputs.append_child(
                htmler.Input(type='hidden',
                             css=k,
                             name=self._uid + '[' + k + ']',
                             value=inp_val))

        return inputs