Esempio n. 1
0
    def render_fields(self, fields, form_info=None):
        tb = ClientSideTabbar()
        f = fields
        for i in self.parts:
            of, f = i.filter_own_fields(f)

            t = i.title

            if any((i.errors for i in of)):
                t = Markup(
                    '<span class="text-danger"><span class="glyphicon glyphicon-warning-sign"> {}</span>'
                ).format(t)

            tb.add_tab(t,
                       element("div", i.view.form_attrs,
                               i.view.render_fields(of, form_info=form_info)),
                       name=i.name)
        rest = ""
        if f:
            if not self.rest_view:
                raise ValueError("Not all fields assigned to parts")

            rest = element(
                "div", self.rest_view.form_attrs,
                self.rest_view.render_fields(f, form_info=form_info))

        return Markup("{}{}").format(rest, tb)
Esempio n. 2
0
    def render_fields(self, fields, form_info=None):
        f = fields
        output = []
        to_wrap = []
        wrapped = False
        for i in self.parts:
            of, f = i.filter_own_fields(f)

            t = i.title

            fm = element("div", i.view.form_attrs,
                         i.view.render_fields(of, form_info=form_info))

            if i.should_be_wrapped_in_row():
                to_wrap.append(i.panel_wrapper(fm))

            else:
                if to_wrap:
                    output.append(
                        element("div", {"class": "row"},
                                Markup("").join(to_wrap)))
                to_wrap = []

                output.append(i.panel_wrapper(fm))

        if to_wrap:
            output.append(
                element("div", {"class": "row"},
                        Markup("").join(to_wrap)))

        return Markup("").join(output)
Esempio n. 3
0
    def render_fields(self, fields, form_info=None):
        f = fields
        output = []
        to_wrap = []
        wrapped = False
        for i in self.parts:
            of, f = i.filter_own_fields(f)

            t = i.title

            fm = element("div",
                         i.view.form_attrs,
                         i.view.render_fields(of,
                                              form_info=form_info))

            if i.should_be_wrapped_in_row():
                to_wrap.append(i.panel_wrapper(fm))
                
            else:
                if to_wrap:
                    output.append(element("div",
                                         {"class": "row"},
                                         Markup("").join(to_wrap)))
                to_wrap = []

                output.append(i.panel_wrapper(fm))

        if to_wrap:
            output.append(element("div",
                                  {"class": "row"},
                                  Markup("").join(to_wrap)))
                
        return Markup("").join(output)
Esempio n. 4
0
    def render_fields(self, fields, form_info=None):
        tb = ClientSideTabbar()
        f = fields
        for i in self.parts:
            of, f = i.filter_own_fields(f)

            t = i.title

            if any((i.errors for i in of)):
                t = Markup('<span class="text-danger"><span class="glyphicon glyphicon-warning-sign"> {}</span>').format(t) 
            
            tb.add_tab(t,
                       element("div",
                               i.view.form_attrs,
                               i.view.render_fields(of, form_info=form_info)),
                       name=i.name)
        rest = ""
        if f:
            if not self.rest_view:
                raise ValueError("Not all fields assigned to parts")
            
            rest = element("div",
                           self.rest_view.form_attrs,
                           self.rest_view.render_fields(f,
                                                        form_info=form_info))

        return Markup("{}{}").format(rest, tb)
Esempio n. 5
0
    def __html__(self):
        params = request.view_args
        if not current_appshell.endpoint_accessible(self.target, params):
            return ''
        attrs = {"role": "presentation"}

        if request.endpoint == self.target:
            attrs["class"] = "active"

        url = url_for(self.target, **params)
        link = element('a', {'href': url}, self.text)
        return element('li', attrs, link)
Esempio n. 6
0
    def html_tab(self, first=False):
        attrs = {"role": "presentation"}

        if (first and self.is_active() is None) or self.is_active():
            attrs["class"] = "active"

        link = element('a',
                       {'href': "#" + self.name,
                        "aria-controls": self.name,
                        "role": "tab",
                        "data-toggle": "tab"},
                       self.title)
    
        return element('li', attrs, link)
Esempio n. 7
0
    def __html__(self):
        l = ""
        if self.view.label_args:
            l = element("div", self.view.label_args, "")

        i = Markup('<div class="checkbox"><label>{} {}</label>{}{}</div>')\
            .format(self.render_input(),
                    self.field.label.text,
                    self.render_description(),
                    self.render_errors())

        if self.view.field_div_attrs:
            i = element("div", self.view.field_div_attrs, i)

        return l + i
Esempio n. 8
0
    def __html__(self):
        l = ""
        if self.view.label_args:
            l = element("div", self.view.label_args, "")

        i = Markup('<div class="checkbox"><label>{} {}</label>{}{}</div>')\
            .format(self.render_input(),
                    self.field.label.text,
                    self.render_description(),
                    self.render_errors())
        
        if self.view.field_div_attrs:
            i = element("div", self.view.field_div_attrs, i)

        return l+i
Esempio n. 9
0
    def render(self, view, **kwargs):
        if not self.content:
            return ""

        c = Markup("").join((i.render(self) if isinstance(i, FormButton) else i
                             for i in self.content))
        return element("div", self.get_div_attrs(), c)
Esempio n. 10
0
    def render_footer(self, form_info=None):
        if not self.buttons:
            return ""

        c = Markup("").join((i.render(self, form_info=form_info) if isinstance(
            i, FormButton) else i for i in self.buttons))
        return element("div", self.button_bar_attrs, c)
Esempio n. 11
0
    def panel_wrapper(self, content):
        if self.border is not None:
            content = element("div", {"class": "panel-body"}, content)

            if self.title is not None:
                content = element("div", {"class": "panel-heading"},
                                  self.title) + content

            content = element("div",
                              {"class": "panel panel-{}".format(self.border)},
                              content)

        if self.column:
            content = self.column.render(content)

        return content
Esempio n. 12
0
 def render(self, view, **kwargs):
     if not self.content:
         return ""
     
     c = Markup("").join((i.render(self) if isinstance(i, FormButton) else i
                          for i in self.content))
     return element("div", self.get_div_attrs(), c)
Esempio n. 13
0
 def render_footer(self, form_info=None):
     if not self.buttons:
         return ""
     
     c = Markup("").join((i.render(self, form_info=form_info)
                          if isinstance(i, FormButton) else i
                          for i in self.buttons))
     return element("div", self.button_bar_attrs, c)
Esempio n. 14
0
 def render_field(self, field, **kwargs):
     cls = "form-group"
     if field.errors:
         cls += " has-error"
     if field.flags.required:
         cls += " required"
         
     return element("div", {"class": cls},
                    super(VerticalFormView, self).render_field(field,
                                                               **kwargs)) 
Esempio n. 15
0
    def html_content(self, first=False):
        cls = "tab-pane"
        if (first and self.is_active() is None) or self.is_active():
            cls += " active"

        return element("div",
                       {"class": cls,
                        "id": self.name,
                        "role": "tabpanel"},
                       self.content)
Esempio n. 16
0
    def render_field(self, field, **kwargs):
        cls = "form-group"
        if field.errors:
            cls += " has-error"
        if field.flags.required:
            cls += " required"

        return element(
            "div", {"class": cls},
            super(VerticalFormView, self).render_field(field, **kwargs))
Esempio n. 17
0
    def panel_wrapper(self, content):
        if self.border is not None:
            content = element("div",
                              {"class": "panel-body"},
                              content)

            if self.title is not None:
                content = element("div",
                                  {"class": "panel-heading"},
                                  self.title) + content
            
            content = element("div",
                              {"class": "panel panel-{}".format(self.border)},
                              content)


        if self.column:
            content = self.column.render(content)
            
        return content
Esempio n. 18
0
    def __html__(self):
        l = self.render_label()

        i = Markup("{}{}{}").format(self.render_input(),
                                    self.render_description(),
                                    self.render_errors())

        if self.view.field_div_attrs:
            i = element("div", self.view.field_div_attrs, i)

        return l + i
Esempio n. 19
0
    def __html__(self):
        l = self.render_label()

        i = Markup("{}{}{}").format(self.render_input(),
                                    self.render_description(),
                                    self.render_errors())
        
        if self.view.field_div_attrs:
            i = element("div", self.view.field_div_attrs, i)

        return l+i
Esempio n. 20
0
    def render(self, form, form_info=None):
        contents = Markup("{}{}{}{}").format(
            form.hidden_tag(), self.hidden_errors(form),
            self.render_fields(form, form_info=form_info),
            self.render_footer(form_info=form_info))

        attrs = dict(self.form_attrs)
        if any((isinstance(i, FileField) for i in form)):
            attrs["enctype"] = "multipart/form-data"

        attrs["method"] = self.method

        return element("form", attrs, contents)
Esempio n. 21
0
    def render(self, form, form_info=None):
        contents=Markup("{}{}{}{}").format(
            form.hidden_tag(),
            self.hidden_errors(form),
            self.render_fields(form, form_info=form_info),
            self.render_footer(form_info=form_info)
        )
        
        attrs = dict(self.form_attrs)
        if any((isinstance(i, FileField) for i in form)):
            attrs["enctype"] = "multipart/form-data"

        attrs["method"] = self.method
            
        return element("form", attrs, contents)
Esempio n. 22
0
 def render_description(self):
     if self.field.description:
         return element("p", self.view.description_attrs,
                        self.field.description)
     else:
         return ""
Esempio n. 23
0
 def render_errors(self):
     if self.field.errors:
         return Markup("").join((element("p", self.view.error_attrs, i)
                                 for i in self.field.errors))
     else:
         return ""
Esempio n. 24
0
 def render_input(self):
     v = self.view.get_formfield_view()
     c = Markup("{}{}").format(self.field.hidden_tag(),
                                  v.render_fields(self.field,
                                                  form_info=self.form_info))
     return element("div", v.form_attrs, c)
Esempio n. 25
0
 def render_errors(self):
     if self.field.errors:
         return Markup("").join((element("p", self.view.error_attrs, i)
                                 for i in self.field.errors))
     else:
         return ""
Esempio n. 26
0
 def render_input(self):
     v = self.view.get_formfield_view()
     c = Markup("{}{}").format(
         self.field.hidden_tag(),
         v.render_fields(self.field, form_info=self.form_info))
     return element("div", v.form_attrs, c)
Esempio n. 27
0
 def render_description(self):
     if self.field.description:
         return element("p", self.view.description_attrs,
                        self.field.description)
     else:
         return ""
Esempio n. 28
0
 def __html__(self):
     return element('ul', {"class": "appshell-tabs nav nav-"+self.style},
                    Markup(u"").join(self.tabs))
Esempio n. 29
0
 def __html__(self):
     return element("tr", 
                    self.get_element_attrs(), 
                    self.get_row_contents())
Esempio n. 30
0
 def get_cell_html(self, row):
     return element("td", {}, self.get_cell_inner_html(row))
Esempio n. 31
0
 def __html__(self):
     return element("tr", self.get_element_attrs(), self.get_row_contents())
Esempio n. 32
0
 def get_cell_html(self, row):
     return element("td", {}, self.get_cell_inner_html(row))