allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [08/16] allura git commit: [#8230] Add interactive checkbox support for ForgeTracker
Date Mon, 15 Oct 2018 16:02:32 GMT
[#8230] Add interactive checkbox support for ForgeTracker


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/6c1a6ee6
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/6c1a6ee6
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/6c1a6ee6

Branch: refs/heads/master
Commit: 6c1a6ee62bea28f401fde8757611d2ac8150d933
Parents: 3689f90
Author: Shalitha Suranga <shalithasuranga@gmail.com>
Authored: Wed Oct 10 13:27:28 2018 +0530
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Oct 15 15:50:29 2018 +0000

----------------------------------------------------------------------
 .../forgetracker/templates/tracker/ticket.html  | 22 +++++++++++++++++-
 ForgeTracker/forgetracker/tracker_main.py       | 24 ++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/6c1a6ee6/ForgeTracker/forgetracker/templates/tracker/ticket.html
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/templates/tracker/ticket.html b/ForgeTracker/forgetracker/templates/tracker/ticket.html
index 2895829..b1cc974 100644
--- a/ForgeTracker/forgetracker/templates/tracker/ticket.html
+++ b/ForgeTracker/forgetracker/templates/tracker/ticket.html
@@ -149,7 +149,7 @@
   {{ c.vote_form.display(artifact=ticket) }}
 {% endif %}
 <div id="ticket_content">
-  {{g.markdown.cached_convert(ticket, 'description')|safe}}
+  <div class="active-md" data-markdownlink="">{{g.markdown.cached_convert(ticket, 'description')|safe}}</div>
   {% if ticket.attachments %}
     <strong class="grid-18">{{ticket.attachments|length}} Attachments</strong>
     <div class="clear">
@@ -252,6 +252,26 @@
         });
     </script>
   {% endif %}
+
+  {% if h.has_access(ticket, 'update') %}
+  <script>
+          new Checklists(".active-md", function(checkbox, callback) {
+          var uri = $(checkbox).closest('.active-md').data('markdownlink');
+          $.get(uri + 'get_markdown', callback);
+      }, function(markdown, checkbox, callback) {
+          var uri = $(checkbox).closest('.active-md').data('markdownlink');
+          $.ajax({
+              type: 'post',
+              url: uri + 'update_markdown',
+              data: {
+                  'text' : markdown,
+                  '_session_id' : $.cookie('_session_id')
+              },
+              success: callback
+          });
+      });
+  </script>
+  {% endif %}
 {% endblock %}
 
 {% block extra_css %}

http://git-wip-us.apache.org/repos/asf/allura/blob/6c1a6ee6/ForgeTracker/forgetracker/tracker_main.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 2ed6b2c..c065606 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1550,6 +1550,30 @@ class TicketController(BaseController, FeedController):
         c.app.globals.invalidate_bin_counts()
         redirect('.')
 
+    @without_trailing_slash
+    @expose('json:')
+    @require_post()
+    def update_markdown(self, text=None, **kw):  
+        if has_access(self.ticket, 'update'):
+            self.ticket.description = text
+            self.ticket.commit()
+            g.director.create_activity(c.user, 'modified', self.ticket,
+                            related_nodes=[c.project], tags=['ticket'])
+            g.spam_checker.check(text, artifact=self.ticket,
+                user=c.user, content_type='ticket')
+            return {
+                'status' : 'success'
+            }
+        else:
+            return {
+                'status' : 'no_permission'
+            }
+
+    @expose()
+    @without_trailing_slash
+    def get_markdown(self):
+        return self.ticket.description
+
     @expose('json:')
     @require_post()
     @validate(W.subscribe_form)


Mime
View raw message