Mercurial > libervia-web
diff 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 |
line wrap: on
line diff
--- a/src/browser/sat_browser/blog.py Fri Feb 06 19:23:08 2015 +0100 +++ b/src/browser/sat_browser/blog.py Fri Feb 06 19:25:17 2015 +0100 @@ -414,14 +414,10 @@ assert(first.type == 'main_item') return first if first.empty else None - @classmethod - def registerClass(cls): - base_widget.LiberviaWidget.addDropKey("GROUP", cls.createPanel) - base_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", cls.createMetaPanel) + @staticmethod + def onGroupDrop(host, item): + """Generic panel creation for one, several or all groups (meta). - @classmethod - def createPanel(cls, host, item): - """Generic panel creation for one, several or all groups (meta). @parem host: the SatWebFrontend instance @param item: single group as a string, list of groups (as an array) or None (for the meta group = "all groups") @@ -430,17 +426,11 @@ items_ = tuple(item) if isinstance(item, list) else (() if item is None else (item,)) type_ = 'ALL' if items_ == () else 'GROUP' # XXX: pyjamas doesn't support use of cls directly - _new_panel = MicroblogPanel(host, _items) - host.FillMicroblogPanel(_new_panel) - host.bridge.call('getMassiveLastMblogs', _new_panel.massiveInsert, _type, _items, 10) - host.setSelected(_new_panel) - _new_panel.refresh() - return _new_panel - - @classmethod - def createMetaPanel(cls, host, item): - """Needed for the drop keys to not be mixed between meta panel and panel for "Contacts" group""" - return MicroblogPanel.createPanel(host, None) + widget = host.widgets.getOrCreateWidget(MicroblogPanel, items_, profile=C.PROF_KEY_NONE, on_new_widget=None, on_existing_widget=C.WIDGET_RECREATE) + host.FillMicroblogPanel(widget) + host.bridge.getMassiveLastMblogs(type_, items_, 10, profile=C.PROF_KEY_NONE, callback=widget.massiveInsert) + widget.refresh() # FIXME: needed ? + return widget @property def accepted_groups(self): @@ -716,3 +706,9 @@ if self.host.contact_lists[self.profile].isEntityInGroup(jid_, group): return True return False + + +base_widget.LiberviaWidget.addDropKey("GROUP", MicroblogPanel.onGroupDrop) + +# Needed for the drop keys to not be mixed between meta panel and panel for "Contacts" group +base_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", lambda host, item: MicroblogPanel.onGroupDrop(host, None))