Ejemplo n.º 1
0
 def render_pyroes(self, pyroes):
     for pyro in pyroes:
         with html.li() as li:  # per-pyro list item
             # per-pyro anchor routing path with parameter pyd
             with html.a(routerlink=('/detail', {'pyd': pyro.pyd})):
                 html.span(pyro.pyd, Class='badge')  # show pyd as badge
                 html.txt(' {name}')._fmt(name=pyro.name_)  # obs name_
Ejemplo n.º 2
0
 def li_pyroes(self, pyroes):
     for pyro in pyroes:
         with html.li() as li:
             # li._class.selected(self.selected_.pyd_ == pyro.pyd)
             li._class.selected(self.pyd == pyro.pyd)
             li._bindx.click(self.pyd_, pyro)
             with html.a(routerlink=('/pyro', {'pyd': pyro.pyd})):
                 html.span(pyro.pyd, Class='badge')
                 html.txt(' {name}')._fmt(name=pyro.name_)
    def li_disasters(self, disasters):
        for disaster in disasters:
            with html.li() as li:
                li._class.selected(self.selected_.did_ == disaster.did)

                with html.a(routerlink=('', {'did': disaster.did})):
                    html.span(disaster.did, Class='badge')
                    html.txt()._fmt(disaster.name_)

            li._bindx.click(lambda d=disaster: self.selected_(d))
Ejemplo n.º 4
0
 def render(self, node):
     with node.select('ul'):  # find the node where to display the list
         for pyro in Pyroes:
             with html.li() as li:  # create a list item per Pyro
                 # if the selected pyro is this pyro ... set a class attr
                 li._class.selected(self.selected_.pyd_ == pyro.pyd)
                 # bind a click to do self.selected_(pyro)
                 li._bindx.click(self.selected_, pyro)
                 # show the pyd in a <apan> as a badge (child of list item)
                 html.span(pyro.pyd, Class='badge')
                 # show the name as text inside the list item
                 html.txt(' {name}')._fmt(name=pyro.name_)
Ejemplo n.º 5
0
 def render_pyroes(self, pyroes):
     # Because this was registered with ul._render, any rendering action
     # takes place under ul, which is empty when entering here
     for pyro in pyroes:
         with html.li() as li:  # create a list item per Pyro
             # if the selected pyro is this pyro ... set a class attr
             li._class.selected(self.selected_.pyd_ == pyro.pyd)
             # bind a click to do self.selected_(pyro)
             li._bindx.click(self.selected_, pyro)
             # show the pyd in a <apan> as a badge (child of list item)
             html.span(pyro.pyd, Class='badge')
             # show the name as text inside the list item
             html.txt(' {name}')._fmt(name=pyro.name_)
Ejemplo n.º 6
0
    def render_pyroes(self, pyroes):
        for pyro in pyroes:
            with html.li() as li:  # per-pyro list item
                # per-pyro anchor routing path with parameter pyd
                with html.a(routerlink=('/detail', {'pyd': pyro.pyd})):
                    html.span(pyro.pyd, Class='badge')  # show pyd as badge
                    html.txt(' {name}')._fmt(name=pyro.name_)  # obs name_

                with html.button('x', Class='delete') as b:
                    # def param avoids closure using last pyro.pyd
                    def pyro_delete(evt, pyd=pyro.pyd):
                        evt.stopPropagation()  # avoid evt clicking on "a"
                        self.pyro_delete(pyd)

                    b._bind.click(pyro_delete)  # use "bind" to get event
Ejemplo n.º 7
0
    def li_pyroes(self, pyroes):
        print('li_pyroes called with:', pyroes)
        for pyro in pyroes:
            with html.li() as li:
                # li._class.selected(self.selected_.pyd_ == pyro.pyd)
                li._class.selected(self.pyd == pyro.pyd)

                # self.pyd_
                # .map(lambda x: x == pyro.pyd)
                # .do_action(lambda x: print('HERE IS THE PROBLEM:', x))
                # )
                li._bindx.click(self.pyd_, pyro.pyd)
                with html.a(routerlink=('/pyro', {'pyd': pyro.pyd})):
                    html.span(pyro.pyd, Class='badge')
                    html.txt(' {name}')._fmt(
                        name=pyro.name_.do_action(lambda x: print('NAME:', x)))
Ejemplo n.º 8
0
 def sought_pyroes(pyroes):
     for p in pyroes:
         with html.li() as li:  # per-pyro list item
             # per-pyro anchor routing path with parameter pyd
             html.a(p.name, routerlink=('/detail', {'pyd': p.pyd}))
Ejemplo n.º 9
0
 def ul_pyroes(pyroes):
     print
     for p in pyroes:
         h.li('{pyd}: {name}'.format(**p))