comparison src/browser/sat_browser/richtext.py @ 740:b6510fd9ae15

browser_side: implements tags UI
author souliane <souliane@mailoo.org>
date Thu, 19 Nov 2015 16:43:18 +0100
parents caad07bdb659
children c3cb68227cca
comparison
equal deleted inserted replaced
739:4545d48dee60 740:b6510fd9ae15
35 from constants import Const as C 35 from constants import Const as C
36 import dialog 36 import dialog
37 import base_panel 37 import base_panel
38 import editor_widget 38 import editor_widget
39 import html_tools 39 import html_tools
40 import list_manager
41
42 from sat_frontends.quick_frontend import quick_list_manager
40 43
41 44
42 class RichTextEditor(editor_widget.BaseTextEditor, FlexTable): 45 class RichTextEditor(editor_widget.BaseTextEditor, FlexTable):
43 """Panel for the rich text editor.""" 46 """Panel for the rich text editor."""
44 47
61 self.host = host 64 self.host = host
62 self.wysiwyg = False 65 self.wysiwyg = False
63 self.read_only = 'read_only' in options 66 self.read_only = 'read_only' in options
64 self.update_msg = 'update_msg' in options 67 self.update_msg = 'update_msg' in options
65 68
66 indices = (-1, -1, 0, -1) if self.read_only else (0, 1, 2, 3) 69 indices = (-1, -1, 0, -1, -1) if self.read_only else (0, 1, 2, 3, 4)
67 self.title_offset, self.toolbar_offset, self.content_offset, self.command_offset = indices 70 self.title_offset, self.toolbar_offset, self.content_offset, self.tags_offset, self.command_offset = indices
68 self.addStyleName(self.STYLE['main']) 71 self.addStyleName(self.STYLE['main'])
69 72
70 editor_widget.BaseTextEditor.__init__(self, content, None, modifiedCb, afterEditCb) 73 editor_widget.BaseTextEditor.__init__(self, content, None, modifiedCb, afterEditCb)
71 74
72 def addEditListener(self, listener): 75 def addEditListener(self, listener):
114 if not self.read_only and not hasattr(self, 'title_panel'): 117 if not self.read_only and not hasattr(self, 'title_panel'):
115 self.title_panel = base_panel.TitlePanel() 118 self.title_panel = base_panel.TitlePanel()
116 self.title_panel.addStyleName(self.STYLE['title']) 119 self.title_panel.addStyleName(self.STYLE['title'])
117 self.getFlexCellFormatter().setColSpan(self.title_offset, 0, 2) 120 self.getFlexCellFormatter().setColSpan(self.title_offset, 0, 2)
118 self.setWidget(self.title_offset, 0, self.title_panel) 121 self.setWidget(self.title_offset, 0, self.title_panel)
122
123 if not self.read_only and not hasattr(self, 'tags'):
124 suggested_tags = [] # TODO: feed this list with tags suggestion
125 tags = [] # TODO: feed this list with tags already assigned to this message
126 self.tags = list_manager.TagsPanel(suggested_tags, tags)
127 self.getFlexCellFormatter().setColSpan(self.tags_offset, 0, 2)
128 self.setWidget(self.tags_offset, 0, self.tags)
119 129
120 if not self.read_only and not hasattr(self, 'command'): 130 if not self.read_only and not hasattr(self, 'command'):
121 self.command = HorizontalPanel() 131 self.command = HorizontalPanel()
122 self.command.addStyleName("marginAuto") 132 self.command.addStyleName("marginAuto")
123 self.command.add(Button("Cancel", lambda: self.edit(True, True))) 133 self.command.add(Button("Cancel", lambda: self.edit(True, True)))