diff 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
line wrap: on
line diff
--- a/libervia/pages/tickets/new/page_meta.py	Fri Jan 11 21:47:10 2019 +0100
+++ b/libervia/pages/tickets/new/page_meta.py	Sat Jan 19 11:42:37 2019 +0100
@@ -40,6 +40,14 @@
         xmlui_obj.widgets[u"labels"].type = u"string"
     except KeyError:
         pass
+
+    # same as for tickets_edit, we have to convert for now
+    wid = xmlui_obj.widgets[u'body']
+    if wid.type == u"xhtmlbox":
+        wid.type = u"textbox"
+        wid.value =  yield self.host.bridgeCall(
+            u"syntaxConvert", wid.value, C.SYNTAX_XHTML, u"markdown",
+            False, profile)
     template_data[u"new_ticket_xmlui"] = xmlui_obj
 
 
@@ -56,6 +64,15 @@
     except (KeyError, IndexError):
         pass
     profile = self.getProfile(request)
+
+    # we convert back body to XHTML
+    body = yield self.host.bridgeCall(
+        u"syntaxConvert", posted_data[u'body'][0], u"markdown", C.SYNTAX_XHTML,
+        False, profile)
+    posted_data[u'body'] = [u'<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML,
+                                                                     body=body)]
+
+
     yield self.host.bridgeCall(
         "ticketSet", service.full(), node, posted_data, u"", u"", {}, profile
     )