Mercurial > libervia-web
changeset 737:398b54bd97f0
browser_side: remove RichMessageEditor and RecipientManager which are not used since the removal of the unibox
author | souliane <souliane@mailoo.org> |
---|---|
date | Thu, 19 Nov 2015 12:08:58 +0100 |
parents | fe3c2357a8c9 |
children | caad07bdb659 |
files | src/browser/public/libervia.css src/browser/sat_browser/richtext.py |
diffstat | 2 files changed, 0 insertions(+), 201 deletions(-) [+] |
line wrap: on
line diff
--- a/src/browser/public/libervia.css Thu Nov 19 11:41:03 2015 +0100 +++ b/src/browser/public/libervia.css Thu Nov 19 12:08:58 2015 +0100 @@ -1273,11 +1273,6 @@ display: table; } -.richMessageEditor { - width: 100%; - margin: 9px 18px; -} - .richTextTitle { margin-bottom: 5px; } @@ -1301,11 +1296,6 @@ height: 250px; } -.richMessageArea { - width: 100%; - height: 250px; -} - .richTextWysiwyg { min-height: 50px; background-color: white; @@ -1380,10 +1370,6 @@ color: red; } -.recipientSpacer { - height: 15px; -} - /* Popup (context) menu */ .popupMenuItem {
--- a/src/browser/sat_browser/richtext.py Thu Nov 19 11:41:03 2015 +0100 +++ b/src/browser/sat_browser/richtext.py Thu Nov 19 12:08:58 2015 +0100 @@ -342,193 +342,6 @@ _dialog.show() -class RichMessageEditor(RichTextEditor): - """Use the rich text editor for sending messages with extended addressing. - Recipient panels are on top and data may be synchronized from/to the unibox.""" - - @classmethod - def getOrCreate(cls, host, parent=None, callback=None): - """Get or create the message editor associated to that host. - Add it to parent if parent is not None, otherwise display it - in a popup dialog. - @param host: the host - @param parent: parent panel (or None to display in a popup). - @return: the RichTextEditor instance if parent is not None, - otherwise a popup DialogBox containing the RichTextEditor. - """ - if not hasattr(host, 'richtext'): - modifiedCb = lambda content: True - - def afterEditCb(content): - if hasattr(host.richtext, 'popup'): - host.richtext.popup.hide() - else: - host.richtext.setVisible(False) - callback() - options = ['no_title'] - style = {'main': 'richMessageEditor', 'textarea': 'richMessageArea'} - host.richtext = RichMessageEditor(host, None, modifiedCb, afterEditCb, options, style) - - def add(widget, parent): - if widget.getParent() is not None: - if widget.getParent() != parent: - widget.removeFromParent() - parent.add(widget) - else: - parent.add(widget) - widget.setVisible(True) - widget.initialized = False # fake a new creation - widget.edit(True) - - if parent is None: - if not hasattr(host.richtext, 'popup'): - host.richtext.popup = DialogBox(autoHide=False, centered=True) - host.richtext.popup.setHTML("Compose your message") - host.richtext.popup.add(host.richtext) - add(host.richtext, host.richtext.popup) - host.richtext.popup.center() - else: - add(host.richtext, parent) - return host.richtext.popup if parent is None else host.richtext - - def _prepareUI(self, y_offset=0): - """Prepare the UI to host recipients panel, toolbar, text area... - @param y_offset: Y offset to start from (extra rows on top)""" - self.recipient_offset = y_offset - self.recipient_spacer_offset = self.recipient_offset + len(composition.RECIPIENT_TYPES) - RichTextEditor._prepareUI(self, self.recipient_spacer_offset + 1) - - def refresh(self, edit=None): - """Refresh the UI between edition/display mode - @param edit: set to True to display the edition mode""" - if edit is None: - edit = hasattr(self, 'textarea') and self.textarea.getVisible() - RichTextEditor.refresh(self, edit) - - for widget in ['recipient', 'recipient_spacer']: - if hasattr(self, widget): - getattr(self, widget).setVisible(edit) - - if not edit: - return - - if not hasattr(self, 'recipient'): - # recipient types sub-panels are automatically added by the manager - self.recipient = RecipientManager(self, self.recipient_offset) - self.recipient_spacer = HTML('') - self.recipient_spacer.setStyleName('recipientSpacer') - self.getFlexCellFormatter().setColSpan(self.recipient_spacer_offset, 0, 2) - self.setWidget(self.recipient_spacer_offset, 0, self.recipient_spacer) - - if not hasattr(self, 'sync_button'): - self.sync_button = Button("Back to quick box", lambda: self.edit(True, sync=True)) - self.command.insert(self.sync_button, 1) - - def syncToEditor(self): - """Synchronize from unibox.""" - def setContent(target, data): - if hasattr(self, 'recipient'): - self.recipient.setContacts({"To": [target]} if target else {}) - self.setContent({'text': data if data else '', 'syntax': ''}) - self.textarea.setText(data if data else '') - data, target = self.host.uni_box.getTargetAndData() if self.host.uni_box else (None, None) - setContent(target, data) - - def __syncToUniBox(self, recipients=None, emptyText=False): - """Synchronize to unibox if a maximum of one recipient is set. - @return True if the sync could be done, False otherwise""" - # FIXME: To be removed (unibox doesn't exist anymore) - if not self.host.uni_box: - return - setText = lambda: self.host.uni_box.setText("" if emptyText else self.getContent()['text']) - if not hasattr(self, 'recipient'): - setText() - return True - if recipients is None: - recipients = self.recipient.getItemsByKey() - target = "" - # we could eventually allow more in the future - allowed = 1 - for key in recipients: - count = len(recipients[key]) - if count == 0: - continue - allowed -= count - if allowed < 0: - return False - # TODO: change this if later more then one recipients are allowed - target = recipients[key][0] - setText() - if target == "": - return True - if target.startswith("@"): - _class = blog.MicroblogPanel - target = None if target == "@@" else target[1:] - else: - _class = chat.Chat - self.host.displayWidget(_class, target) - return True - - def syncFromEditor(self, content): - """Synchronize to unibox and close the dialog afterward. Display - a message and leave the dialog open if the sync was not possible.""" - if self.__syncToUniBox(): - self._afterEditCb(content) - return - dialog.InfoDialog("Too many recipients", - "A message with more than one direct recipient (To)," + - " or with any special recipient (Cc or Bcc), could not be" + - " stored in the quick box.\n\nPlease finish your composing" + - " in the rich text editor, and send your message directly" + - " from here.", Width="400px").center() - - def edit(self, edit=True, abort=False, sync=False): - if not edit and not abort and not sync: # force sending message even when the text has not been modified - if not self.__sendMessage(): # message has not been sent (missing information), do nothing - return - RichTextEditor.edit(self, edit, abort, sync) - - def __sendMessage(self): - """Send the message.""" - recipients = self.recipient.getItemsByKey() - targets = [] - for addr in recipients: - for recipient in recipients[addr]: - if recipient.startswith("@"): - targets.append(("PUBLIC", None, addr) if recipient == "@@" else ("GROUP", recipient[1:], addr)) - else: - targets.append(("chat", recipient, addr)) - # check that we actually have a message target and data - content = self.getContent() - if content['text'] == "" or len(targets) == 0: - dialog.InfoDialog("Missing information", - "Some information are missing and the message hasn't been sent.", Width="400px").center() - return None - self.__syncToUniBox(recipients, emptyText=True) - extra = {'content_rich': content['text']} - if hasattr(self, 'title_panel'): - extra.update({'title': content['title']}) - self.host.send(targets, content['text'], extra=extra) - return True - - -class RecipientManager(list_manager.ListManager): - """A manager for sub-panels to set the recipients for each recipient type.""" - - def __init__(self, parent, y_offset=0): - # TODO: be sure we also display empty groups and disconnected contacts + their groups - # store the full list of potential recipients (groups and contacts) - list_ = [] - list_.append("@@") - list_.extend("@%s" % group for group in parent.host.contact_panel.getGroups()) - list_.extend(contact for contact in parent.host.contact_list.roster_entities) - list_manager.ListManager.__init__(self, parent, composition.RECIPIENT_TYPES, list_, {'y': y_offset}) - - self.registerPopupMenuPanel(entries=composition.RECIPIENT_TYPES, - hide=lambda sender, key: self.__children[key]["panel"].isVisible(), - callback=self.setContactPanelVisible) - - class EditTextArea(TextArea, KeyboardHandler): def __init__(self, _parent): TextArea.__init__(self)