Mercurial > libervia-web
comparison browser_side/panels.py @ 362:019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 19 Feb 2014 16:38:13 +0100 |
parents | f4efffb9627c |
children | a74a2dfbe4f5 |
comparison
equal
deleted
inserted
replaced
361:f4efffb9627c | 362:019e1e706e74 |
---|---|
230 return (target_hook, _type, msg) | 230 return (target_hook, _type, msg) |
231 | 231 |
232 def onKeyPress(self, sender, keycode, modifiers): | 232 def onKeyPress(self, sender, keycode, modifiers): |
233 _txt = self.getText() | 233 _txt = self.getText() |
234 target_hook, type_, msg = self._getTarget(_txt) | 234 target_hook, type_, msg = self._getTarget(_txt) |
235 self.host.showWarning(type_, msg) | |
236 | 235 |
237 if keycode == KEY_ENTER: | 236 if keycode == KEY_ENTER: |
238 if _txt: | 237 if _txt: |
239 if target_hook: | 238 if target_hook: |
240 parsed_txt, data = target_hook | 239 parsed_txt, data = target_hook |
241 self.host.send([(type_, data)], parsed_txt) | 240 self.host.send([(type_, data)], parsed_txt) |
242 self.host._updateInputHistory(_txt) | 241 self.host._updateInputHistory(_txt) |
243 self.setText('') | 242 self.setText('') |
244 self.host.showWarning(None, None) | 243 self.host.showWarning(None, None) |
244 else: | |
245 self.host.showWarning(type_, msg) | |
245 MessageBox.onKeyPress(self, sender, keycode, modifiers) | 246 MessageBox.onKeyPress(self, sender, keycode, modifiers) |
246 | 247 |
247 def getTargetAndData(self): | 248 def getTargetAndData(self): |
248 """For external use, to get information about the (hypothetical) message | 249 """For external use, to get information about the (hypothetical) message |
249 that would be sent if we press Enter right now in the unibox. | 250 that would be sent if we press Enter right now in the unibox. |
527 else: # assume raw text message have no title | 528 else: # assume raw text message have no title |
528 self.bubble = LightTextEditor(content, self.__modifiedCb, self.__afterEditCb, True) | 529 self.bubble = LightTextEditor(content, self.__modifiedCb, self.__afterEditCb, True) |
529 self.bubble.setStyleName("bubble") | 530 self.bubble.setStyleName("bubble") |
530 self.entry_dialog.add(self.bubble) | 531 self.entry_dialog.add(self.bubble) |
531 self.bubble.edit(False) | 532 self.bubble.edit(False) |
533 self.bubble.addEditListener(self.__showWarning) | |
534 | |
535 def __showWarning(self, sender, keycode): | |
536 if keycode == KEY_ENTER: | |
537 self._blog_panel.host.showWarning(None, None) | |
538 else: | |
539 self._blog_panel.host.showWarning(*self._blog_panel.getWarningData(self.type == 'comment')) | |
532 | 540 |
533 def _delete(self, empty=False): | 541 def _delete(self, empty=False): |
534 """Ask confirmation for deletion. | 542 """Ask confirmation for deletion. |
535 @return: False if the deletion has been cancelled.""" | 543 @return: False if the deletion has been cancelled.""" |
536 def confirm_cb(answer): | 544 def confirm_cb(answer): |
645 """ | 653 """ |
646 entity = entity if isinstance(entity, list) else ([] if entity is None else [entity]) | 654 entity = entity if isinstance(entity, list) else ([] if entity is None else [entity]) |
647 entity.sort() # sort() do not return the sorted list: do it here, not on the "return" line | 655 entity.sort() # sort() do not return the sorted list: do it here, not on the "return" line |
648 return self.accepted_groups == entity | 656 return self.accepted_groups == entity |
649 | 657 |
650 def getWarningData(self): | 658 def getWarningData(self, comment=None): |
651 if self.selected_entry: | 659 """ |
652 if not self.selected_entry.comments: | 660 @param comment: True if the composed message is a comment. If None, consider we are |
661 composing from the unibox and guess the message type from self.selected_entry | |
662 @return: a couple (type, msg) for calling self.host.showWarning""" | |
663 if comment is None: # composing from the unibox | |
664 if self.selected_entry and not self.selected_entry.comments: | |
653 print ("ERROR: an item without comment is selected") | 665 print ("ERROR: an item without comment is selected") |
654 return ("NONE", None) | 666 return ("NONE", None) |
667 comment = self.selected_entry is not None | |
668 if comment: | |
655 return ("PUBLIC", "This is a <span class='warningTarget'>comment</span> and keep the initial post visibility, so it is potentialy public") | 669 return ("PUBLIC", "This is a <span class='warningTarget'>comment</span> and keep the initial post visibility, so it is potentialy public") |
656 | |
657 elif not self._accepted_groups: | 670 elif not self._accepted_groups: |
658 # we have a meta MicroblogPanel, we publish publicly | 671 # we have a meta MicroblogPanel, we publish publicly |
659 return ("PUBLIC", self.warning_msg_public) | 672 return ("PUBLIC", self.warning_msg_public) |
660 else: | 673 else: |
661 # we only accept one group at the moment | 674 # we only accept one group at the moment |