Esempio n. 1
0
 def render(self):
     if not self.get_arg('readonly', False):
         return (BaseJS.render(self) + 
             '''<input type="button" value="..." onclick="return showCalendar('%s', '%%d/%%m/%%Y');"/>''' %
                 self.get_html_id())
     else:
         return BaseJS.render(self)
 def get_value(self):
     f = BaseJS.get_value(self)
     if f is None:
         f = self.get_arg('initial_selection')
     if not isinstance(f, list):
         f = [f]
     return f
Esempio n. 3
0
 def get_calc_html_attrs(self):
     return self._merge_dicts (
         BaseJS.get_calc_html_attrs(self), 
         {
             'type' : 'hidden', 
             'value': json.write(self.get_value()),
         })
Esempio n. 4
0
 def get_value(self):
     f = BaseJS.get_value(self)
     if f is None:
         f = self.get_arg('initial_selection')
     if not isinstance(f, list):
         f = [f]
     return f
Esempio n. 5
0
    def get_diffs(self):
        added = []
        removed = []
        old = []

        initial = self.get_arg('initial_selection')
        sent = BaseJS.get_value(self)

        if sent is None:
            # No se ha recibido ningún valor. Entendemos que se
            # borraron todos
            return {'added': [], 'old': [], 'removed': initial}

        if not isinstance(sent, list):
            # Se ha recibido un solo valor
            sent = [sent]

        for i in initial:
            if i not in sent:
                removed.append(i)
            else:
                old.append(i)

        for i in sent:
            if i not in initial:
                added.append(i)

        return {'added': added, 'old': old, 'removed': removed}
Esempio n. 6
0
 def render(self):
     html = "<input type='hidden' name='%s' value='sent' />" % self._get_checker_name()
     if self.get_arg('readonly', False):
         html += "<input type='hidden' name='%s' value='%s' />" % (
             self._get_force_name(),
             int(bool(self.get_arg('initial_value', 0))))
     return BaseJS.render(self) + html
Esempio n. 7
0
    def get_calc_html_attrs(self):
        calcdict = self._merge_dicts(
            BaseJS.get_calc_html_attrs(self),
            {"type": self.get_html_type(), "value": self.get_arg("label", self.get_name())},
        )

        return calcdict
    def get_diffs(self):
        added = []
        removed = []
        old = []

        initial = self.get_arg('initial_selection')
        sent = BaseJS.get_value(self)

        if sent is None:
            # No se ha recibido ningún valor. Entendemos que se 
            # borraron todos
            return {'added': [], 'old': [], 'removed': initial}

        if not isinstance(sent, list):
            # Se ha recibido un solo valor
            sent = [sent]

        for i in initial:
            if i not in sent:
                removed.append(i)
            else:
                old.append(i)

        for i in sent:
            if i not in initial:
                added.append(i)

        return {'added': added, 'old': old, 'removed': removed}
Esempio n. 9
0
    def get_calc_html_attrs(self):
        calcdict = self._merge_dicts(
            BaseJS.get_calc_html_attrs(self), {
                'type': self.get_html_type(),
                'value': self.get_arg('label', self.get_name())
            })

        return calcdict
Esempio n. 10
0
 def render(self):
     html = "<input type='hidden' name='%s' value='sent' />" % self._get_checker_name(
     )
     if self.get_arg('readonly', False):
         html += "<input type='hidden' name='%s' value='%s' />" % (
             self._get_force_name(),
             int(bool(self.get_arg('initial_value', 0))))
     return BaseJS.render(self) + html
Esempio n. 11
0
    def get_value(self):
        v = BaseJS.get_value(self)
        if v is None:
            return self.get_arg('selected', [])

        if not isinstance(v, list):
            v = [v]

        return v
Esempio n. 12
0
    def get_value(self):
        import time
        raw_value = BaseJS.get_value(self)
        if raw_value:
            for fmt in self.get_formats():
                try:
                    return time.strptime(raw_value, fmt)
                except ValueError:
                    pass

        return self.get_initial_value() or time.localtime()
Esempio n. 13
0
    def get_calc_html_attrs(self):
        calcdict = BaseJS.get_calc_html_attrs(self)

        for at in ('size', 'multiple', 'readonly'):
            a = self.get_arg(at, None)
            if a is not None: 
                calcdict[at] = str(a)

        if 'readonly' in calcdict:
            calcdict['readonly'] = None

        return calcdict
Esempio n. 14
0
    def get_validation_js_info(self):
        r = BaseJS.get_validation_js_info(self)

        if self.get_arg('nonempty', False):
            me = 'document.getElementById("%s")' % self.get_html_id()
            r.append({
                'validate': me + '.value != ""',
                'onselect': me + '.focus()',
                'msg': 'Can not be empty'
            })

        return r
Esempio n. 15
0
    def get_validation_js_info(self):
        r = BaseJS.get_validation_js_info(self)

        if self.get_arg('nonempty', False):
            me = 'document.getElementById("%s")' % self.get_html_id()
            r.append({
                'validate': me + '.value != ""',
                'onselect': me + '.focus()',
                'msg': 'Can not be empty'
            })

        return r
Esempio n. 16
0
    def validate_widget(self):
        errors = []

        v = self._number_human_to_mac(BaseJS.get_value(self) or '0')
        if v is not None:
            try:
                # Para tomarlo como un valor, debe al menos poder ser convertido a real
                v = float(v)
            except ValueError:
                errors.append('Invalid number')

        return errors
Esempio n. 17
0
    def get_calc_html_attrs(self):
        calcdict = self._merge_dicts(BaseJS.get_calc_html_attrs(self), {
            'type': 'checkbox',
            'value': 'on'
        })

        if self.get_value():
            calcdict['checked'] = "yes"

        if self.get_arg('readonly', False):
            calcdict['disabled'] = None

        return calcdict
Esempio n. 18
0
    def get_calc_html_attrs(self):
        calcdict = self._merge_dicts (
            BaseJS.get_calc_html_attrs(self), 
            {
                'type' : 'checkbox', 
                'value': 'on'
            })

        if self.get_value():
            calcdict['checked'] = "yes"

        if self.get_arg('readonly', False):
            calcdict['disabled'] = None

        return calcdict
Esempio n. 19
0
    def get_value(self):
        v = BaseJS.get_value(self)

        if v is None:
            v = self.get_arg('initial_value', '')

        if v is None:
            v = ''

        if type(v) not in (str, unicode):
            v = str(v)

        if self.get_arg('trim_spaces'):
            v = v.strip()

        return v
Esempio n. 20
0
    def get_value(self):
        v = BaseJS.get_value(self)

        if v is None:
            v = self.get_arg('initial_value', '')

        if v is None:
            v = ''

        if type(v) not in (str, unicode):
            v = str(v)

        if self.get_arg('trim_spaces'):
            v = v.strip()

        return v
Esempio n. 21
0
    def get_calc_html_attrs(self):
        calcdict = self._merge_dicts (
            BaseJS.get_calc_html_attrs(self), 
            {
                'type' : 'text', 
                'value': self.get_value()
            })

        if self.get_arg('trim_spaces'):
            calcdict['onblur'] = 'mcw_tb_trim_spaces(this);' + calcdict.get('onblur', '')

        for at in ('size', 'maxlength', 'class',):
            a = self.get_arg(at, None)
            if a is not None: 
                calcdict[at] = a

        if self.get_arg('password', False):
            calcdict['type'] = 'password'

        return calcdict
Esempio n. 22
0
    def get_value(self):

        # Si viene por el argumento initial_value, lo tomamos como que
        # es formato máquina. Si viene por las variables llegadas
        # por formulario, es formato humano

        v = BaseJS.get_value(self)
        if v is None:
            return self.get_arg('initial_value', '0')

        v = self._number_human_to_mac(v)

        try:
            v = int(v)
        except ValueError:
            try:
                v = float(v)
            except ValueError:
                v = 0

        return v
Esempio n. 23
0
    def get_calc_html_attrs(self):
        calcdict = self._merge_dicts(BaseJS.get_calc_html_attrs(self), {
            'type': 'text',
            'value': self.get_value()
        })

        if self.get_arg('trim_spaces'):
            calcdict['onblur'] = 'mcw_tb_trim_spaces(this);' + calcdict.get(
                'onblur', '')

        for at in (
                'size',
                'maxlength',
                'class',
        ):
            a = self.get_arg(at, None)
            if a is not None:
                calcdict[at] = a

        if self.get_arg('password', False):
            calcdict['type'] = 'password'

        return calcdict
Esempio n. 24
0
 def get_value(self):
     v = BaseJS.get_value(self)
     if v is None:
         v = self.get_arg('initial_value', None)
     return v
Esempio n. 25
0
 def get_value(self):
     v = BaseJS.get_value(self)
     if v is None:
         v = self.get_arg('initial_value', None)
     return v
Esempio n. 26
0
 def get_value(self):
     # Para el botón, devuelve verdadero o falso si se ha pulsado este botón.
     return BaseJS.get_value(self) is not None
Esempio n. 27
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return [
         req + ['columns', 'initial_selection', 'key', 'source'],
         opt + ['label_button', 'table_class']
     ]
Esempio n. 28
0
 def get_value(self):
     # Para el botón, devuelve verdadero o falso si se ha pulsado este botón.
     return BaseJS.get_value(self) is not None
Esempio n. 29
0
 def get_calc_html_attrs(self):
     return self._merge_dicts(BaseJS.get_calc_html_attrs(self), {
         'type': 'hidden',
         'value': json.write(self.get_value()),
     })
Esempio n. 30
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return [
         req + ['columns', 'initial_selection', 'key', 'source'],
         opt + ['label_button', 'table_class']
     ]
Esempio n. 31
0
 def get_calc_html_attrs(self):
     return self._merge_dicts (
         BaseJS.get_calc_html_attrs(self),
         {
             'value': self.get_value_as_string(),
         })
Esempio n. 32
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return req, opt + [
         'size', 'nonempty', 'maxlength', 'class', 'initial_value',
         'sync_with', 'sync_map', 'trim_spaces', 'password'
     ]
Esempio n. 33
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return req, opt + ['formats', 'initial_value']
Esempio n. 34
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return (req + ['options']), (opt + ['initial_value', 'separator'])
Esempio n. 35
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return (req + ['options']), (opt + ['initial_value', 'separator'])
Esempio n. 36
0
 def get_calc_html_attrs(self):
     return self._merge_dicts (
         BaseJS.get_calc_html_attrs(self),  { 'type' : 'radio',  })
Esempio n. 37
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return req, opt + [
         'size', 'nonempty', 'maxlength', 'class', 'initial_value', 
         'sync_with', 'sync_map', 'trim_spaces', 'password']
Esempio n. 38
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return req, (opt + ['initial_value'])
Esempio n. 39
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return (req + ['options'], 
             opt + ['selected', 'sync_with', 'ajax_url', 
                    'headoption', 'multiple', 'size'])
Esempio n. 40
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return req + ['columns', 'data'], \
            opt + ['header_style', 'orderable', 'on_rows_change', 'order', 'rows_per_page']
Esempio n. 41
0
 def get_value(self):
     val = BaseJS.get_value(self)
     if val is None: val = str(self.get_arg('initial_value', ''))
     return val
Esempio n. 42
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return req, opt + ['label', 'submit']
Esempio n. 43
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return req, (opt + ['initial_value'])
Esempio n. 44
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return req + ['columns', 'data'], \
            opt + ['header_style', 'orderable', 'on_rows_change', 'order', 'rows_per_page']
Esempio n. 45
0
 def get_calc_html_attrs(self):
     return self._merge_dicts(BaseJS.get_calc_html_attrs(self), {
         'type': 'radio',
     })
Esempio n. 46
0
 def get_value(self):
     val = BaseJS.get_value(self)
     if val is None: val = str(self.get_arg('initial_value', ''))
     return val
Esempio n. 47
0
 def get_args_spec(self):
     req, opt = BaseJS.get_args_spec(self)
     return req, opt + ["label", "submit"]