Mercurial > libervia-web
comparison libervia/pages/tickets/new/page_meta.py @ 1143:7bd47d32da87
pages (tickets, merge-requests): convert body from/to markdown while editing/creating new ticket:
there is currently no way to edit XHTML directly inside the browser with Libervia pages, this patch works around this by doing a conversion to/from markdown.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 19 Jan 2019 11:42:37 +0100 |
parents | 28e3eb3bb217 |
children | 29eb15062416 |
comparison
equal
deleted
inserted
replaced
1142:003597f895a0 | 1143:7bd47d32da87 |
---|---|
38 try: | 38 try: |
39 # small trick to get a one line text input instead of the big textarea | 39 # small trick to get a one line text input instead of the big textarea |
40 xmlui_obj.widgets[u"labels"].type = u"string" | 40 xmlui_obj.widgets[u"labels"].type = u"string" |
41 except KeyError: | 41 except KeyError: |
42 pass | 42 pass |
43 | |
44 # same as for tickets_edit, we have to convert for now | |
45 wid = xmlui_obj.widgets[u'body'] | |
46 if wid.type == u"xhtmlbox": | |
47 wid.type = u"textbox" | |
48 wid.value = yield self.host.bridgeCall( | |
49 u"syntaxConvert", wid.value, C.SYNTAX_XHTML, u"markdown", | |
50 False, profile) | |
43 template_data[u"new_ticket_xmlui"] = xmlui_obj | 51 template_data[u"new_ticket_xmlui"] = xmlui_obj |
44 | 52 |
45 | 53 |
46 @defer.inlineCallbacks | 54 @defer.inlineCallbacks |
47 def on_data_post(self, request): | 55 def on_data_post(self, request): |
54 try: | 62 try: |
55 posted_data["labels"] = [l.strip() for l in posted_data["labels"][0].split(",")] | 63 posted_data["labels"] = [l.strip() for l in posted_data["labels"][0].split(",")] |
56 except (KeyError, IndexError): | 64 except (KeyError, IndexError): |
57 pass | 65 pass |
58 profile = self.getProfile(request) | 66 profile = self.getProfile(request) |
67 | |
68 # we convert back body to XHTML | |
69 body = yield self.host.bridgeCall( | |
70 u"syntaxConvert", posted_data[u'body'][0], u"markdown", C.SYNTAX_XHTML, | |
71 False, profile) | |
72 posted_data[u'body'] = [u'<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML, | |
73 body=body)] | |
74 | |
75 | |
59 yield self.host.bridgeCall( | 76 yield self.host.bridgeCall( |
60 "ticketSet", service.full(), node, posted_data, u"", u"", {}, profile | 77 "ticketSet", service.full(), node, posted_data, u"", u"", {}, profile |
61 ) | 78 ) |
62 # we don't want to redirect to creation page on success, but to tickets list | 79 # we don't want to redirect to creation page on success, but to tickets list |
63 data["post_redirect_page"] = ( | 80 data["post_redirect_page"] = ( |