diff libervia/pages/merge-requests/edit/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/merge-requests/edit/page_meta.py	Fri Jan 11 21:47:10 2019 +0100
+++ b/libervia/pages/merge-requests/edit/page_meta.py	Sat Jan 19 11:42:37 2019 +0100
@@ -68,6 +68,15 @@
         )
     except KeyError:
         pass
+
+    # same as tickets_edit
+    wid = ticket.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"] = ticket
 
 
@@ -85,6 +94,14 @@
     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(
         "mergeRequestSet",
         service.full(),