Example #1
0
def render(self, h, comp, *args):
    """Render the overlay"""
    link_id = h.generate_id()
    overlay_id = h.generate_id()
    body_id = h.generate_id('BODY_')

    self.render_a(h, link_id)

    # TODO: find a cleaner solution
    if self.dynamic:
        # Load overlay body dynamically
        load = ajax.js(
            "YAHOO.util.Dom.get(%(body_id)s).innerHTML = '';"
            "%(load_body)s" %
            {
                'body_id': ajax.py2js(body_id),
                'load_body': h.a.action(
                    ajax.Update(render=self.content, component_to_update=body_id)
                ).get('onclick').replace('return', '')
            }
        )
    else:
        # The overlay body is already present in the DOM tree
        load = ajax.js('')

    js = ajax.js(
        "%(load)s;"
        "YAHOO.kansha.app.showOverlay(%(overlay_id)s, %(link_id)s, %(centered)s)" %
        {
            'load': ajax.py2js(load),
            'link_id': ajax.py2js(link_id),
            'overlay_id': ajax.py2js(overlay_id),
            'centered': ajax.py2js(self.centered, h)
        }
    )

    h.head.javascript(
        h.generate_id(),
        "YAHOO.util.Event.addListener(%(link_id)s, 'click', "
        "function(){%(js)s;}"
        ")" % {'link_id': ajax.py2js(link_id), "js": ajax.py2js(js)}
    )

    cls = [u'overlay']
    if not self.centered:
        cls.append(u'overlay_arrow')
    if self.cls:
        cls.append(self.cls)
    with h.div(class_=u' '.join(cls), id=overlay_id, onclick="YAHOO.kansha.app.stopEvent()"):
        with h.div(class_='overlay-header'):
            with h.div(class_='overlay-title'):
                h << h.div(self.title or self.text(h))
            h << h.a(title=_('Close this dialog window.'), href='#', class_='icon-remove icon-grey action-close', onclick='YAHOO.kansha.app.hideOverlay();return false')
        h << h.div(' ' if self.dynamic else self.content(h), class_='overlay-body', id=body_id)

    return h.root
Example #2
0
def render(self, h, comp, *args):
    """Render the overlay"""
    link_id = h.generate_id()
    overlay_id = h.generate_id()
    body_id = h.generate_id('BODY_')

    self.render_a(h, link_id)

    # TODO: find a cleaner solution
    if self.dynamic:
        # Load overlay body dynamically
        load = ajax.js(
            "YAHOO.util.Dom.get(%(body_id)s).innerHTML = '';"
            "%(load_body)s" %
            {
                'body_id': ajax.py2js(body_id),
                'load_body': h.a.action(
                    ajax.Update(render=self.content, component_to_update=body_id)
                ).get('onclick').replace('return', '')
            }
        )
    else:
        # The overlay body is already present in the DOM tree
        load = ajax.js('')

    js = ajax.js(
        "%(load)s;"
        "YAHOO.kansha.app.showOverlay(%(overlay_id)s, %(link_id)s, %(centered)s)" %
        {
            'load': ajax.py2js(load),
            'link_id': ajax.py2js(link_id),
            'overlay_id': ajax.py2js(overlay_id),
            'centered': ajax.py2js(self.centered, h)
        }
    )

    h.head.javascript(
        h.generate_id(),
        "YAHOO.util.Event.addListener(%(link_id)s, 'click', "
        "function(){%(js)s;}"
        ")" % {'link_id': ajax.py2js(link_id), "js": ajax.py2js(js)}
    )

    cls = [u'overlay']
    if self.cls:
        cls.append(self.cls)
    with h.div(class_=u' '.join(cls), id=overlay_id, onclick="YAHOO.kansha.app.stopEvent()"):
        if not self.centered:
            h << h.span(class_='overlay_arrow')
        with h.div(class_='overlay-header'):
            with h.div(class_='overlay-title'):
                h << h.div(self.title or self.text(h))
        h << h.div(' ' if self.dynamic else self.content(h), class_='overlay-body', id=body_id)

    return h.root
Example #3
0
def render_card_delete(self, h, comp, model):
    if security.has_permissions('edit', self) and not self.archived:
        with h.form:
            close_func = ajax.js(
                'function (){%s;}' %
                h.a.action(self.emit_event, comp, events.CardArchived).get('onclick')
            )
            h << h.button(
                h.i(class_='icon-trashcan'),
                _('Delete'),
                class_='btn delete',
                onclick=(
                    "if (confirm(%(confirm_msg)s)) {"
                    "   YAHOO.kansha.app.archiveCard(%(close_func)s);"
                    "   reload_columns();"
                    "}"
                    "return false" %
                    {
                        'close_func': ajax.py2js(close_func),
                        'confirm_msg': ajax.py2js(
                            _(u'This card will be deleted. Are you sure?')
                        ).decode('UTF-8')
                    }
                )
            )
    return h.root
Example #4
0
def render_user_filter(self, h, comp, *args):
    id = h.generate_id('filterline')
    on_change = ajax.js('this.form.submit();')

    with h.div(id=id, class_='filterline'):
        with h.form.post_action(self.post_action):
            with h.div(class_='cell'):
                h << h.input(type='text',
                             class_="text",
                             title=_(u'Login'),
                             value=self.uid()).action(self.uid)

            with h.div(class_='cell select-box'):
                with h.select(onchange=on_change).action(self.corporation_id) as s:
                    for v in self.get_corporations():
                        h << h.option(u'%s' % (v[0]), value=v[1]).selected(self.corporation_id())
                h << s.error(self.corporation_id.error)

            with h.div(class_='cell select-box'):
                with h.select(onchange=on_change).action(self.direction_id) as s:
                    for v in self.get_directions():
                        h << h.option(u'%s' % (v[0]),
                                      value=v[1]).selected(self.direction_id())
                h << s.error(self.direction_id.error)

            with h.div(class_='cell select-box'):
                with h.select(onchange=on_change).action(self.service_id) as s:
                    for v in self.get_services():
                        h << h.option(u'%s' % (v[0]), value=v[1]).selected(self.service_id())
                h << s.error(self.service_id.error)

            with h.div(class_='cell select-box'):
                with h.select(onchange=on_change).action(self.site_id) as s:
                    for v in self.get_sites():
                        h << h.option(u'%s' % (v[0]), value=v[1]).selected(self.site_id())
                h << s.error(self.site_id.error)

            with h.div(class_='cell select-box'):
                with h.select(onchange=on_change).action(self.fi_uid) as s:
                    h << h.option(_(u'All the facilitators'), value='-1').selected(self.fi_uid())
                    for user in self.get_facilitators():
                        h << h.option(user.fullname, value=user.uid).selected(self.fi_uid())
                h << s.error(self.fi_uid.error)

            with h.div(class_='cell select-box'):
                with h.select(onchange=on_change).action(self.enabled):
                    h << h.option(_(u'By state'), value='-1').selected(self.enabled())
                    h << h.option(_(u'Enabled'), value=_(u'Enabled')).selected(self.enabled())
                    h << h.option(_(u'Disabled'), value=_(u'Disabled')).selected(self.enabled())

            with h.div(class_='cell'):
                h << h.input(type="submit", class_="action", value=_(u'Filter'))

    return h.root
Example #5
0
def render_card_actions(self, h, comp, *args):
    with h.div(class_='card-actions'):
        with h.form:
            with h.ul():
                with h.li(class_="buttonAddChecklist"):
                    h << self.checklists.render(h, 'button')
                with h.li(class_="buttonAddFile"):
                    h << self.gallery.render(h, 'download')
                with h.li(class_="buttonVote"):
                    h << self.votes.render(h.AsyncRenderer(), 'edit')
                with h.li(class_="buttonDueDate"):
                    h << self.due_date.render(h.AsyncRenderer(), 'button')
                if self.board.weighting_cards:
                    with h.li(class_="actionWeight"):
                        h << self._weight.on_answer(
                            lambda v: self._weight.call(model='edit_weight'
                                                        if v else None))
                with h.li(class_="buttonDeleteCard"):
                    if security.has_permissions(
                            'edit', self) and not self.column.is_archive:
                        close_func = ajax.js(
                            'function (){%s;}' %
                            h.a.action(comp.answer, 'delete').get('onclick'))
                        h << h.button(
                            h.i(class_='icon-bin'),
                            _('Delete'),
                            class_='btn delete',
                            onclick=
                            ("if (confirm(%(confirm_msg)s)) {"
                             "   YAHOO.kansha.app.archiveCard(%(close_func)s, %(id)s, %(col_id)s, %(archive_col_id)s);"
                             "   reload_columns();"
                             "}"
                             "return false" % {
                                 'close_func':
                                 ajax.py2js(close_func),
                                 'id':
                                 ajax.py2js(self.id),
                                 'col_id':
                                 ajax.py2js(self.column.id),
                                 'archive_col_id':
                                 ajax.py2js(
                                     self.column.board.archive_column.id),
                                 'confirm_msg':
                                 ajax.py2js(
                                     _(u'This card will be deleted. Are you sure?'
                                       )).decode('UTF-8')
                             }))
                h << comp.render(h, 'members')

    return h.root
Example #6
0
def render_card_actions(self, h, comp, *args):
    with h.div(class_='card-actions'):
        with h.form:
            with h.ul():
                with h.li(class_="buttonAddChecklist"):
                    h << self.checklists.render(h, 'button')
                with h.li(class_="buttonAddFile"):
                    h << self.gallery.render(h, 'download')
                with h.li(class_="buttonVote"):
                    h << self.votes.render(h.AsyncRenderer(), 'edit')
                with h.li(class_="buttonDueDate"):
                    h << self.due_date.render(h.AsyncRenderer(), 'button')
                if self.board.weighting_cards:
                    with h.li(class_="actionWeight"):
                        h << self._weight.on_answer(lambda v: self._weight.call(model='edit_weight' if v else None))
                with h.li(class_="buttonDeleteCard"):
                    if security.has_permissions('edit', self) and not self.column.is_archive:
                        close_func = ajax.js(
                            'function (){%s;}' %
                            h.a.action(comp.answer, 'delete').get('onclick')
                        )
                        h << h.button(
                            h.i(class_='icon-bin'),
                            _('Delete'),
                            class_='btn delete',
                            onclick=(
                                "if (confirm(%(confirm_msg)s)) {"
                                "   YAHOO.kansha.app.archiveCard(%(close_func)s, %(id)s, %(col_id)s, %(archive_col_id)s);"
                                "   reload_columns();"
                                "}"
                                "return false" %
                                {
                                    'close_func': ajax.py2js(close_func),
                                    'id': ajax.py2js(self.id),
                                    'col_id': ajax.py2js(self.column.id),
                                    'archive_col_id': ajax.py2js(
                                        self.column.board.archive_column.id
                                    ),
                                    'confirm_msg': ajax.py2js(
                                        _(u'This card will be deleted. Are you sure?')
                                    ).decode('UTF-8')
                                }
                            )
                        )
                h << comp.render(h, 'members')

    return h.root
Example #7
0
def render_card_delete(self, h, comp, model):
    if security.has_permissions('edit', self) and not self.archived:
        with h.form:
            close_func = ajax.js('function (){%s;}' % h.a.action(
                self.emit_event, comp, events.CardArchived).get('onclick'))
            h << h.button(
                h.i(class_='icon-trashcan'),
                _('Delete'),
                class_='btn delete',
                onclick=("if (confirm(%(confirm_msg)s)) {"
                         "   YAHOO.kansha.app.archiveCard(%(close_func)s);"
                         "   reload_columns();"
                         "}"
                         "return false" % {
                             'close_func':
                             ajax.py2js(close_func),
                             'confirm_msg':
                             ajax.py2js(
                                 _(u'This card will be deleted. Are you sure?')
                             ).decode('UTF-8')
                         }))
    return h.root