def __init__(self, board, card=None): self._board = board self._card = card # View API self.user_id = var.Var('') self.card_id = var.Var(None)
def render(self, h, comp, *args): self.reset_in_dom(comp) v_event_name = var.Var() v_appcode = var.Var() v_aera = var.Var() v_env = var.Var() v_appcomp = var.Var() with h.form(id='refresh_on_comet_event'): h << h.input(type='submit', class_='submit', style='display: none ;').action( XComponentsUpdates( le_l_knowndiv=lambda: self.dom_storage. get_l_known_div_for_change(v_event_name(), appcode=v_appcode(), aera=v_aera(), env=v_env(), appcomp=v_appcomp()), update_himself=True, )) h << h.input(type='hidden', class_='event_name').action(v_event_name) h << h.input(type='hidden', class_='appcode').action(v_appcode) h << h.input(type='hidden', class_='aera').action(v_aera) h << h.input(type='hidden', class_='env').action(v_env) h << h.input(type='hidden', class_='appcomp').action(v_appcomp) return h.root
def __init__(self, asset, card_component, card_component_id, card_component_model): self.asset = asset self.card_component = card_component self.card_component_id = card_component_id self.card_component_model = card_component_model self.crop_left, self.crop_top, self.crop_width, self.crop_height = var.Var( ), var.Var(), var.Var(), var.Var()
def __init__(self, date): """Initialization In: - ``date`` -- a ``datetime`` object """ self.day = var.Var(str(date.day)) self.month = var.Var(str(date.month)) self.year = var.Var(str(date.year))
def __init__(self, board): """Initialization In: - ``board`` -- the board object we are working on """ self.board = board self.background_position = var.Var( self.board.background_image_position) self._changed = var.Var(False)
def __init__(self, board): """Initialization In: - ``board`` -- the board the new column will belong """ self.board = board self.index = var.Var() self.title = var.Var() self.nb_cards = var.Var() self.nb_cards_comp = component.Component(self, 'nb_cards')
def render_NewMember(self, h, comp, *args): """Render the title of the associated card""" with h.form: members_to_add = var.Var() def get_emails(): emails = [] for email in members_to_add().split(','): try: email = email.strip() email = validator.validate_email(email) emails.append(email) except ValueError: continue return emails h << h.input( type='text', id=self.text_id, ).action(members_to_add) h << h.input(value=_("Add"), type="submit", class_="btn btn-primary").action( remote.Action(lambda: comp.answer(get_emails()))) h << self.autocomplete h << h.script( "document.getElementById(%s).focus()" % ajax.py2js(self.text_id)) return h.root
def __init__(self, id_, board, card_extensions, action_log, search_engine_service, services_service, data=None): """Initialization In: - ``id_`` -- the id of the column """ self.db_id = id_ self._data = data self.id = 'list_' + str(self.db_id) self.board = board self.nb_card = var.Var(self.data.nb_max_cards) self._services = services_service self.action_log = action_log self.search_engine = search_engine_service self.card_extensions = card_extensions self.body = component.Component(self, 'body') self.title = component.Component( title.EditableTitle(self.get_title)).on_answer(self.set_title) self.card_counter = component.Component(CardsCounter(self)) self.cards = [ component.Component( self._services( comp.Card, c.id, self.card_extensions, self.action_log, data=c)) for c in self.data.cards] self.new_card = component.Component( comp.NewCard(self)) self.actions_comp = component.Component(self, 'overlay') self.actions_overlay = component.Component(overlay.Overlay( lambda r: r.i(class_='icon-target2'), self.actions_comp.render, title=_('List actions'), dynamic=False))
def render_AddMembers(self, h, comp, *args): value = var.Var('') submit_id = h.generate_id('form') hidden_id = h.generate_id('hidden') with h.form: h << h.input(type='text', id=self.text_id) h << h.input(type='hidden', id=hidden_id).action(value) h << self.autocomplete h << h.script( u"%(ac_id)s.itemSelectEvent.subscribe(function(sType, aArgs) {" u"var value = aArgs[2][0];" u"YAHOO.util.Dom.setAttribute(%(hidden_id)s, 'value', value);" u"YAHOO.util.Dom.get(%(submit_id)s).click();" u"});" % { 'ac_id': self.autocomplete().var, 'hidden_id': ajax.py2js(hidden_id), 'submit_id': ajax.py2js(submit_id) }) h << h.script( "document.getElementById(%s).focus()" % ajax.py2js(self.text_id)) h << h.button(id=submit_id, style='display:none').action( remote.Action(lambda: comp.answer([] if not value() else [value()]))) return h.root
def render_comments_form(self, h, comp, *args): """Add a comment to the current card""" if security.has_permissions('comment', self): text = var.Var() with h.form: txt_id, buttons_id = h.generate_id(), h.generate_id() sub_id = h.generate_id() kw = { "id": txt_id, "placeholder": _("Add comment."), "onfocus": "YAHOO.kansha.app.show('%s', true);YAHOO.util.Dom.addClass(this, 'expanded'); " % buttons_id, } h << h.textarea(**kw).action(text) h.head.javascript( h.generate_id(), 'YAHOO.kansha.app.addCtrlEnterHandler(%s, %s)' % ( ajax.py2js(txt_id), ajax.py2js(sub_id) ) ) with h.div(id=buttons_id, class_="buttons hidden"): h << h.input(value=_("Save"), id=sub_id, type='submit', class_="btn btn-primary").action(lambda: comp.answer(text())) h << ' ' h << h.input(value=_("Cancel"), type='submit', class_="btn").action(lambda: comp.answer('')) return h.root
def render_CardsCounter_edit(self, h, comp, *args): """Render the title of the associated object""" text = var.Var(self.text) with h.div(class_='list-counter'): with h.div(class_='cardCounter'): with h.form(onsubmit='return false;'): action = h.input(type='submit').action( lambda: self.validate(text(), comp)).get('onclick') id_ = h.generate_id() h << h.input(id=id_, type='text', value=self.column.nb_max_cards or '', onblur=action).action(text) h << h.script( """YAHOO.util.Event.on(%s, 'keyup', function (e) { if (e.keyCode == 13) { e.preventDefault(); this.blur(); } var result = this.value.replace(/[^0-9]/g, '') if (this.value !=result) { this.value = result; } });""" % ajax.py2js(id_)) h << h.script( "YAHOO.kansha.app.selectElement(%s);" % ajax.py2js(id_)) if self.error is not None: with h.div(class_='nagare-error-message'): h << self.error return h.root
def __init__(self, id_, board, search_engine, services_service, data=None): """Initialization In: - ``id_`` -- the id of the column """ self.db_id = id_ self._data = data data = data if data else self.data self.id = 'list_' + str(self.db_id) self.board = board self.nb_card = var.Var(data.nb_max_cards) self._services = services_service self.search_engine = search_engine self.body = component.Component(self, 'body') self.title = component.Component(ColumnTitle(self)) self.title.on_answer(lambda v: self.title.call(model='edit')) self.card_counter = component.Component(CardsCounter(self)) self.cards = [ component.Component(self._services(card.Card, c.id, self, data=c)) for c in data.cards ] self.new_card = component.Component(card.NewCard(self)).on_answer( self.create_card) self.actions_comp = component.Component(self, 'overlay') self.actions_overlay = component.Component( overlay.Overlay(lambda r: r.i(class_='icon-circle-down'), self.actions_comp.render, title=_('List actions'), dynamic=False))
def __init__(self, description): """Initialization In: - ``description`` -- callable that returns the description. """ self.description = var.Var(description)
def __init__(self, data): """Initialization In: - ``data`` -- the label's database object """ self.id = data.id self._changed = var.Var(False)
def __init__(self, board): """Initialization In: - ``board`` -- the board object we are working on """ self.board = board self._changed = var.Var(False)
def __init__(self, parent): event_management._register_listener(parent, self) self.search_pattern = var.Var('') self.search_by = var.Var('') # Tells if opening animation is already done self.form_opened = var.Var(False) # Tells if form opening has been asked self.show_form = var.Var(False) self.options = component.Component(SearchMenu([ (_(u'search_ideas'), u'idea'), (_(u'Profils'), u'profile')])) self.options.on_answer(self.select_option) self.select_option(u'idea')
def __init__(self, project): super(ProjectEditor, self).__init__(project, ("project_id", "name", "users_ids")) self.name.validate(StringValidator) self.users_ids #.validate(ListValidatorMeta(IntValidator)) self.entry_user_id = var.Var() self.new_amount = editor.Property().validate(float) self.new_comment = editor.Property().validate(StringValidator)
def __init__(self, board): """Initialization In: - ``board`` -- the board object we are working on """ self.board = board self._changed = var.Var(False) self._weights_editor = component.Component(WeightsSequenceEditor(self))
def __init__(self, items, items_creator=None): """ Initialize Menu navigation component. Args: items: a list of object """ self.items = items self.items_creator = items_creator self.selected = var.Var(None)
def update(self, other): self.data.update(other.data) self.nb_card = var.Var(self.data.nb_max_cards) cards_to_index = [] for card_comp in other.cards: card = card_comp() new_card = self.create_card(card.get_title()) new_card.update(card) cards_to_index.append(card) self.index_cards(cards_to_index, update=True)
def __init__(self, parent, idea): event_management._register_listener(parent, self) self.id = idea if is_integer(idea) else idea.id self.display_date = 'publication_date' self.comment_pager = component.Component(CommentPager(self)) self.comment_creator = component.Component( CommentCreator(self, self.id)) self.comment_creator.on_answer(lambda a: self.comments_updated()) self.wf_context = component.Component(IdeaWFContext(self.id)) event_management._register_listener(self, self.wf_context()) self.workflow_section = component.Component(WorkflowSection(self.id)) event_management._register_listener(self, self.workflow_section()) self.selected_tab = var.Var('') self.menu_items = [] if self.has_comments(): nb_comments = self.get_nb_comments() self.menu_items.append( (_N(u"Comment (%d)", u"Comments (%d)", nb_comments) % nb_comments, 'comments', None, '', None)) if self.has_challenge(): self.menu_items.append( (_(u"Challenge"), 'challenge', None, '', None)) if self.has_tags(): self.menu_items.append((_(u"Tags"), 'tags', None, '', None)) self.menu = component.Component(Menu(self.menu_items), model='tab_renderer') self.menu.on_answer(self.select_tab) self.select_default_tab() self._navigate_to_element = None self._comment_submit_id = generate_id('comment-submit') self.display_full_description = var.Var(False)
def __init__(self, idea, event): self.idea_id = idea if is_integer(idea) else idea.id self.event = event self.comment = editor.Property('') # for some workflow events, we must choose a new developer self.di = editor.Property('') refuse_event = get_workflow().WFEvents.REFUSE_EVENT if event in (refuse_event, ): self.comment.validate(validators.non_empty_string) self.show_all = var.Var(False)
def render_Label_edit_color_overlay(self, h, comp, *args): """Color chooser contained in the overlay body""" v = var.Var(self.data.color) i = h.generate_id() h << h.div(id=i, class_='label-color-picker clearfix') with h.form: h << h.input(type='hidden', value=v(), id='%s-hex-value' % i).action(v) h << h.button(_('Save'), class_='btn btn-primary').action( ajax.Update(action=lambda v=v: self.set_color(v()))) h << ' ' h << h.button(_('Cancel'), class_='btn').action(lambda: None) h << h.script("YAHOO.kansha.app.addColorPicker(%s)" % ajax.py2js(i)) return h.root
def render_Board_save_template(self, h, comp, *args): shared = var.Var('me') with h.form(class_='description-form'): h << h.label(_(u'Save this board as a template')) with h.select.action(shared): h << h.option(_(u'For me only'), value='me').selected(shared) h << h.option(_(u'For all users'), value='shared').selected(shared) with h.div(class_='buttons'): action = remote.Action(lambda: self.save_as_template(shared() == 'shared')) h << h.button(_(u'Save'), class_='btn btn-primary', type='submit').action(action) h << ' ' h << h.button(_('Cancel'), class_='btn', onclick='YAHOO.kansha.app.hideOverlay();') return h.root
def render_NewChecklistItem_edit(self, h, comp, model): """Render the title of the associated object""" text = var.Var(u'') with h.form(class_='new-item-form'): id_ = h.generate_id() h << h.input(type='text', value=text, id_=id_, placeholder=_(u'Add item')).action(text) h << h.button(_(u'Add'), class_='btn btn-primary').action(lambda: comp.answer(text())) if self.focus: h << h.script("YAHOO.util.Dom.get(%s).focus()" % ajax.py2js(id_)) self.focus = False return h.root
def render(self, h, comp, *args): with h.div(class_='login LDAPLogin'): with h.form: # if self.error_message: # h << h.br << h.div(self.error_message, class_="error") uid = var.Var() h << h.input(type='text', name='__ac_name', id='ldap_username', placeholder=_('Enter username')).action(uid) passwd = var.Var() h << h.input(type='password', name='__ac_password', id='ldap_password', placeholder=_('Enter password')).action(passwd) with h.div(class_='actions'): h << h.input(type='submit', value=_(u'Sign in with LDAP'), class_='btn btn-primary').action( lambda: self.connect(uid(), passwd(), comp)) return h.root
def render(self, h, comp, *args): content = var.Var() page = PageData.get_by(pagename=self.page.title) with h.form: with h.textarea(rows='10', cols='40').action(content): h << page.data h << h.br h << h.input(type='submit', value='Save').action(self.answer, comp, content) h << ' ' h << h.input(type='submit', value='Cancel').action(comp.answer) return h.root
def render_comment_label_form(self, h, comp, *args): """edit a comment """ text = var.Var(self.text) with h.form: txt_id, buttons_id = h.generate_id(), h.generate_id() sub_id = h.generate_id() h << h.textarea(text(), class_='expanded', id_=txt_id).action(text) with h.div(class_='buttons', id=buttons_id): h << h.input(value=_("Save"), id=sub_id, type='submit', class_="btn btn-primary").action(lambda: comp.answer(self.change_text(text()))) h << ' ' h << h.input(value=_("Cancel"), type='submit', class_="btn").action(lambda: comp.answer('')) return h.root
def render(self, h, comp, *args): title = var.Var(self.title() or '') id_ = h.generate_id('id') with h.form(class_=self.class_ + '-form'): input = (h.textarea(title, style='height: %dpx' % self.height) if self.height else h.input(value=title)) h << input(id=id_, placeholder=self.placeholder).action(title) h << h.button(_('Save'), class_='btn btn-primary').action(self.set_title, comp, title) h << ' ' h << h.button(_('Cancel'), class_='btn').action(comp.answer) h << h.script('YAHOO.kansha.app.selectElement(%s);' % id_) return h.root
def __init__(self, query, ac_class=u"", max_cache_entries=10, delim_char=u"", min_query_length=2, max_results_displayed=10, query_delay=0.5, query_question_mark=False, action=None, error=None, id=None, **kwds): self._query = query self.input_params = kwds self._action = action self._error = error self.value = var.Var(u'') self.ac_class = ac_class self.max_cache_entries = max_cache_entries self.query_delay = query_delay self.delim_char = delim_char self.min_query_length = min_query_length self.max_results_displayed = max_results_displayed self.id = id