allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject [1/3] allura git commit: [#8249] Fix ForgeBlog revert issue and add confirmation dialog
Date Fri, 26 Oct 2018 20:39:54 GMT
Repository: allura
Updated Branches:
  refs/heads/master ab13d4799 -> 889363784


[#8249] Fix ForgeBlog revert issue and add confirmation dialog


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

Branch: refs/heads/master
Commit: f554fa53beedb078e46d3cdaf07279085daef053
Parents: ab13d47
Author: Shalitha <shalithasuranga@gmail.com>
Authored: Sun Oct 21 13:31:45 2018 +0530
Committer: Kenton Taylor <ktaylor@slashdotmedia.com>
Committed: Fri Oct 26 20:31:22 2018 +0000

----------------------------------------------------------------------
 ForgeBlog/forgeblog/main.py                     |  8 +++-
 .../forgeblog/templates/blog/post_history.html  | 40 +++++++++++++++++++-
 2 files changed, 45 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/f554fa53/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index db79cd3..066c238 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -70,6 +70,9 @@ class W:
     edit_post_form = widgets.EditPostForm()
     view_post_form = widgets.ViewPostForm()
     attachment_list = ffw.AttachmentList()
+    confirmation = ffw.Lightbox(name='confirm',
+                            trigger='a.post-link',
+                            options="{ modalCSS: { minHeight: 0, width: 'inherit', top: '150px'}}")
     preview_post_form = widgets.PreviewPostForm()
     subscribe_form = SubscribeForm(thing='post')
     search_results = SearchResults()
@@ -391,6 +394,7 @@ class PostController(BaseController, FeedController):
     @without_trailing_slash
     @expose('jinja:forgeblog:templates/blog/post_history.html')
     def history(self, **kw):
+        c.confirmation = W.confirmation
         posts = self.post.history()
         return dict(title=self.post.title, posts=posts)
 
@@ -449,14 +453,14 @@ class PostController(BaseController, FeedController):
 
     @without_trailing_slash
     @require_post()
-    @expose()
+    @expose('json:')
     def revert(self, version, **kw):
         require_access(self.post, 'write')
         orig = self._get_version(version)
         if orig:
             self.post.text = orig.text
         self.post.commit()
-        redirect('.')
+        return dict(location='.')
 
     @expose('json:')
     @require_post()

http://git-wip-us.apache.org/repos/asf/allura/blob/f554fa53/ForgeBlog/forgeblog/templates/blog/post_history.html
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/templates/blog/post_history.html b/ForgeBlog/forgeblog/templates/blog/post_history.html
index fd1efbf..136d52e 100644
--- a/ForgeBlog/forgeblog/templates/blog/post_history.html
+++ b/ForgeBlog/forgeblog/templates/blog/post_history.html
@@ -44,7 +44,19 @@
                   <td>
                     <a href="./?version={{p.version}}" class="btn">View Revision</a>
                     {% if loop.index0 != 0 and h.has_access(p, 'edit')() %}
-                    <a href="./revert?version={{p.version}}" class="btn">Revert to
version {{p.version}}</a>
+                    <a href="#" class="btn post-link" data-dialog-id="{{p.version}}">Revert
to version {{p.version}}</a>
+                    <div class="confirmation_dialog_{{p.version}}" style="display:none">
+                      {{ g.icons['close'].render(tag='b', extra_css='close') }}
+                      <h1>Confirm revert to version {{p.version}}</h1>
+                      <p>
+                        Do you really want to revert page to version {{p.version}}?
+                        You can undo it later by reverting changes made by this revert.
+                      </p>
+                      <p>
+                        <button class="continue_confirm" href="./revert?version={{p.version}}">Yes</button>
+                        <input type="button" value="Cancel" class="cancel_confirmation
close">
+                      </p>
+                    </div>
                     {% endif %}
                   </td>
                 </tr>
@@ -52,4 +64,30 @@
               </tbody>
             </table>
           </form>
+{{c.confirmation.display(content='')}}
+{% block extra_js %}
+    <script type="text/javascript">
+        $('.post-link').click(function () {
+            var dialog_text;
+            var version = $(this).data("dialog-id");
+            if (version) {
+                dialog_text = $(".confirmation_dialog_" + version);
+            } else {
+                dialog_text = $(".confirmation_dialog");
+            }
+
+            var modal = $('#lightbox_confirm');
+            modal.html(dialog_text.html());
+
+            modal.find('.continue_confirm').click(function (evt) {
+                var cval = $.cookie('_session_id');
+                evt.preventDefault();
+                $.post($(this).attr('href'), {_session_id: cval}, function (val) {
+                    window.location = val.location;
+                }, 'json');
+            });
+        });
+    </script>
+{% endblock %}
+
 {% endblock %}


Mime
View raw message