Commits

Daniel Poelzleithner committed cc7650c

better title for draft/show

add source view mode into show draft fixes bug #298

  • Participants
  • Parent commits 5d797c6

Comments (0)

Files changed (4)

app/main/draft/_head.lua

+local draft = param.get("draft", "table")
+local initiative = draft.initiative
+local issue = initiative.issue
+
+slot.select("title", function()
+  ui.link{
+    content = issue.area.name,
+    module = "area",
+    view = "show",
+    id = issue.area.id
+  }
+  slot.put(" · ")
+  ui.link{
+    content = _("Issue ##{id}", { id = issue.id }),
+    module = "issue",
+    view = "show",
+    id = issue.id
+  }
+  slot.put(" · ")
+  ui.link{
+    content = _("Initiative: ")..initiative.name,
+    module = "initiative",
+    view = "show",
+    id = initiative.id
+  }
+end)

app/main/draft/_show.lua

 local draft = param.get("draft", "table")
+local source = param.get("source", atom.boolean)
 
 ui.form{
   attr = { class = "vertical" },
     ui.container{
       attr = { class = "draft_content wiki" },
       content = function()
-        slot.put(draft:get_content("html"))
+        if source then
+          ui.tag{
+            tag = "pre",
+            content = draft.content
+          }
+        else
+          slot.put(draft:get_content("html"))
+        end
       end
     }
   end

app/main/draft/diff.lua

 local old_draft = Draft:by_id(old_draft_id)
 local new_draft = Draft:by_id(new_draft_id)
 
-local initiative = new_draft.initiative
-local issue = initiative.issue
+execute.view{
+  module = "draft",
+  view = "_head",
+  params = { draft = new_draft}
+}
 
-slot.select("title", function()
-  ui.link{
-    content = issue.area.name,
-    module = "area",
-    view = "show",
-    id = issue.area.id
-  }
-  slot.put(" · ")
-  ui.link{
-    content = _("Issue ##{id}", { id = issue.id }),
-    module = "issue",
-    view = "show",
-    id = issue.id
-  }
-  slot.put(" · ")
-  ui.link{
-    content = _("Initiative: ")..initiative.name,
-    module = "initiative",
-    view = "show",
-    id = initiative.id
-  }
-  slot.put(" · ")
-  slot.put_into("title", _"Diff")
-
-end)
+slot.put_into("title", " · " .. _"Diff")
 
 if app.session.member_id and not new_draft.initiative.revoked then
   local supporter = Supporter:new_selector():add_where{"member_id = ?", app.session.member_id}:count()

app/main/draft/show.lua

 local draft = Draft:new_selector():add_where{ "id = ?", param.get_id() }:single_object_mode():exec()
+local source = param.get("source", atom.boolean)
+
+execute.view{
+  module = "draft",
+  view = "_head",
+  params = { draft = draft}
+}
+
+slot.put_into("title", " · " .. _"History")
+
+if source then
+  slot.select("actions", function()
+    ui.link{
+      content = _"Rendered",
+      module = "draft",
+      view = "show",
+      id = param.get_id(),
+      params = { source = false }
+    }
+    end
+  )
+else
+  slot.select("actions", function()
+    ui.link{
+      content = _"Source",
+      module = "draft",
+      view = "show",
+      id = param.get_id(),
+      params = { source = true }
+    }
+    end
+  )
+end
 
 execute.view{
   module = "draft",
   view = "_show",
-  params = { draft = draft }
+  params = { draft = draft, source = source }
 }