Mercurial > libervia-web
comparison src/browser/sat_browser/blog.py @ 598:ed6d8f7c6026 frontends_multi_profiles
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 06 Feb 2015 19:25:17 +0100 |
parents | be2891462e63 |
children | 7af8f4ab3675 |
comparison
equal
deleted
inserted
replaced
597:be2891462e63 | 598:ed6d8f7c6026 |
---|---|
412 except IndexError: | 412 except IndexError: |
413 return None | 413 return None |
414 assert(first.type == 'main_item') | 414 assert(first.type == 'main_item') |
415 return first if first.empty else None | 415 return first if first.empty else None |
416 | 416 |
417 @classmethod | 417 @staticmethod |
418 def registerClass(cls): | 418 def onGroupDrop(host, item): |
419 base_widget.LiberviaWidget.addDropKey("GROUP", cls.createPanel) | |
420 base_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", cls.createMetaPanel) | |
421 | |
422 @classmethod | |
423 def createPanel(cls, host, item): | |
424 """Generic panel creation for one, several or all groups (meta). | 419 """Generic panel creation for one, several or all groups (meta). |
420 | |
425 @parem host: the SatWebFrontend instance | 421 @parem host: the SatWebFrontend instance |
426 @param item: single group as a string, list of groups | 422 @param item: single group as a string, list of groups |
427 (as an array) or None (for the meta group = "all groups") | 423 (as an array) or None (for the meta group = "all groups") |
428 @return: the created MicroblogPanel | 424 @return: the created MicroblogPanel |
429 """ | 425 """ |
430 items_ = tuple(item) if isinstance(item, list) else (() if item is None else (item,)) | 426 items_ = tuple(item) if isinstance(item, list) else (() if item is None else (item,)) |
431 type_ = 'ALL' if items_ == () else 'GROUP' | 427 type_ = 'ALL' if items_ == () else 'GROUP' |
432 # XXX: pyjamas doesn't support use of cls directly | 428 # XXX: pyjamas doesn't support use of cls directly |
433 _new_panel = MicroblogPanel(host, _items) | 429 widget = host.widgets.getOrCreateWidget(MicroblogPanel, items_, profile=C.PROF_KEY_NONE, on_new_widget=None, on_existing_widget=C.WIDGET_RECREATE) |
434 host.FillMicroblogPanel(_new_panel) | 430 host.FillMicroblogPanel(widget) |
435 host.bridge.call('getMassiveLastMblogs', _new_panel.massiveInsert, _type, _items, 10) | 431 host.bridge.getMassiveLastMblogs(type_, items_, 10, profile=C.PROF_KEY_NONE, callback=widget.massiveInsert) |
436 host.setSelected(_new_panel) | 432 widget.refresh() # FIXME: needed ? |
437 _new_panel.refresh() | 433 return widget |
438 return _new_panel | |
439 | |
440 @classmethod | |
441 def createMetaPanel(cls, host, item): | |
442 """Needed for the drop keys to not be mixed between meta panel and panel for "Contacts" group""" | |
443 return MicroblogPanel.createPanel(host, None) | |
444 | 434 |
445 @property | 435 @property |
446 def accepted_groups(self): | 436 def accepted_groups(self): |
447 return self._accepted_groups | 437 return self._accepted_groups |
448 | 438 |
714 return True | 704 return True |
715 for group in self._accepted_groups: | 705 for group in self._accepted_groups: |
716 if self.host.contact_lists[self.profile].isEntityInGroup(jid_, group): | 706 if self.host.contact_lists[self.profile].isEntityInGroup(jid_, group): |
717 return True | 707 return True |
718 return False | 708 return False |
709 | |
710 | |
711 base_widget.LiberviaWidget.addDropKey("GROUP", MicroblogPanel.onGroupDrop) | |
712 | |
713 # Needed for the drop keys to not be mixed between meta panel and panel for "Contacts" group | |
714 base_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", lambda host, item: MicroblogPanel.onGroupDrop(host, None)) |