You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2014/07/07 21:34:23 UTC

git commit: [#7353] added confirmation dialogs for wiki page deletion & restoration.

Repository: allura
Updated Branches:
  refs/heads/master 18cff87f4 -> 4b24c095a


[#7353] added confirmation dialogs for wiki page deletion & restoration.


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

Branch: refs/heads/master
Commit: 4b24c095afc48caeef584e9119622f1afc1531d4
Parents: 18cff87
Author: Alexander Luberg <al...@slashdotmedia.com>
Authored: Tue Jun 24 14:53:55 2014 -0700
Committer: Dave Brondsema <db...@slashdotmedia.com>
Committed: Mon Jul 7 19:30:24 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/widgets/form_fields.py        |  5 +--
 ForgeWiki/forgewiki/templates/wiki/master.html  | 36 ++++++++++++--------
 .../forgewiki/templates/wiki/page_edit.html     | 16 ++++++++-
 .../forgewiki/templates/wiki/page_history.html  | 11 +++---
 .../forgewiki/templates/wiki/page_view.html     | 17 ++++++++-
 .../forgewiki/tests/functional/test_root.py     |  8 ++---
 ForgeWiki/forgewiki/wiki_main.py                |  8 +++--
 7 files changed, 71 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/4b24c095/Allura/allura/lib/widgets/form_fields.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/form_fields.py b/Allura/allura/lib/widgets/form_fields.py
index e3060dc..a43014a 100644
--- a/Allura/allura/lib/widgets/form_fields.py
+++ b/Allura/allura/lib/widgets/form_fields.py
@@ -508,6 +508,7 @@ class Lightbox(ew_core.Widget):
     defaults = dict(
         name=None,
         trigger=None,
+        options='',
         content='',
         content_template=None)
 
@@ -517,14 +518,14 @@ class Lightbox(ew_core.Widget):
             var $lightbox = $('#lightbox_%s');
             var $trigger = $('%s');
             $trigger.bind('click', function(e) {
-                $lightbox.lightbox_me();
+                $lightbox.lightbox_me(%s);
                 return false;
             });
             $($lightbox).delegate('.close', 'click', function(e) {
                 $lightbox.trigger('close');
                 return false;
             });
-        ''' % (self.name, self.trigger))
+        ''' % (self.name, self.trigger, self.options))
 
 
 class DisplayOnlyField(ew.HiddenField):

http://git-wip-us.apache.org/repos/asf/allura/blob/4b24c095/ForgeWiki/forgewiki/templates/wiki/master.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/master.html b/ForgeWiki/forgewiki/templates/wiki/master.html
index c237ab7..529c483 100644
--- a/ForgeWiki/forgewiki/templates/wiki/master.html
+++ b/ForgeWiki/forgewiki/templates/wiki/master.html
@@ -43,20 +43,26 @@
         <div class="grid-7"><input type="submit" value="Create page"></div>
     </form>
   ''')}}
-<script type="text/javascript">
-  $('.post-link')
-    .click(function() {
-        var dialog_text = $(".confirm_revert_"+$(this).data("version"));
-        var modal = $('#lightbox_revert');
-        modal.html(dialog_text.html());
-        modal.find('.continue_revert').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>
+    <script type="text/javascript">
+        $('.post-link').click(function () {
+            var version = $(this).data("dialog-id");
+            if (version) {
+                var dialog_text = $(".confirmation_dialog_" + version);
+            } else {
+                var 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>
   {% block wiki_extra_js %}{% endblock %}
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/4b24c095/ForgeWiki/forgewiki/templates/wiki/page_edit.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_edit.html b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
index 534527e..bdd35c6 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_edit.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_edit.html
@@ -34,7 +34,20 @@
 {% block actions %}
   <a href="." title="View Page"><b data-icon="{{g.icons['search'].char}}" class="ico {{g.icons['search'].css}}" title="View Page"></b></a>
   {% if page_exists and h.has_access(page, 'delete')() %}
-    <a class="post-link" href="./delete" title="Delete"><b data-icon="{{g.icons['delete'].char}}" class="ico {{g.icons['delete'].css}}" title="Delete"></b></a>
+    <a class="post-link" href="#" title="Delete"><b data-icon="{{g.icons['delete'].char}}" class="ico {{g.icons['delete'].css}}" title="Delete"></b></a>
+    <div class="confirmation_dialog" style="display:none">
+        <b class="ico ico-close close" data-icon="D"></b>
+
+        <h1>Confirm page deletion</h1>
+        <p>
+            Do you really want to delete the page?
+            You can undo it later.
+        </p>
+        <p>
+            <button class="continue_confirm" href="./delete">Yes</button>
+            <input type="button" value="Cancel" class="cancel_confirmation close">
+        </p>
+    </div>
   {% endif %}
 {% endblock %}
 
@@ -66,6 +79,7 @@
     {{c.attachment_add.display(action=page.url() + 'attach', name='file_info')}}
   {% endif %}
 </div>
+{{c.confirmation.display(content='')}}
 {% endblock %}
 
 {% block wiki_extra_js %}

http://git-wip-us.apache.org/repos/asf/allura/blob/4b24c095/ForgeWiki/forgewiki/templates/wiki/page_history.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_history.html b/ForgeWiki/forgewiki/templates/wiki/page_history.html
index 53fd54a..41ff4ba 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_history.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_history.html
@@ -52,8 +52,9 @@
           <td><input name="v2" type="radio" value="{{p.version}}"/></td>
           <td class="tright">
             {% if i != 0 and h.has_access(p, 'edit')() %}
-              <a class="post-link" data-version="{{p.version}}" href="#"><b data-icon="{{g.icons['fork'].char}}" class="ico {{g.icons['fork'].css}}" title="Revert to version {{p.version}}"></b></a>
-              <div class="confirm_revert_{{p.version}}" style="display:none">
+              <a class="post-link" data-dialog-id="{{p.version}}" href="#"><b data-icon="{{g.icons['fork'].char}}" class="ico {{g.icons['fork'].css}}" title="Revert to version {{p.version}}"></b></a>
+
+              <div class="confirmation_dialog_{{p.version}}" style="display:none">
                 <b class="ico ico-close close" data-icon="D"></b>
                 <h1>Confirm revert to version {{p.version}}</h1>
                 <p>
@@ -61,8 +62,8 @@
                   You can undo it later by reverting changes made by this revert.
                 </p>
                 <p>
-                  <button class="continue_revert" href="./revert?version={{p.version}}">Yes</button>
-                  <input type="button" value="Cancel" class="cancel_revert close">
+                  <button class="continue_confirm" href="./revert?version={{p.version}}">Yes</button>
+                  <input type="button" value="Cancel" class="cancel_confirmation close">
                 </p>
               </div>
             {% endif %}
@@ -75,5 +76,5 @@
   </table>
 </form>
 {{c.page_list.display(limit=limit, page=page, count=count)}}
-{{c.revert.display(content='')}}
+{{c.confirmation.display(content='')}}
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/4b24c095/ForgeWiki/forgewiki/templates/wiki/page_view.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_view.html b/ForgeWiki/forgewiki/templates/wiki/page_view.html
index 2000b11..c076f57 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_view.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_view.html
@@ -46,7 +46,20 @@
     {% endif %}
     <a href="history" title="History"><b data-icon="{{g.icons['history'].char}}" class="ico {{g.icons['history'].css}}" title="History"></b></a>
   {% elif h.has_access(page, 'delete')() %}
-    <a class="post-link" href="undelete" title="Undelete"><b data-icon="{{g.icons['undelete'].char}}" class="ico {{g.icons['undelete'].css}}" title="Undelete"></b></a>
+    <a class="post-link" href="#" title="Undelete"><b data-icon="{{g.icons['undelete'].char}}" class="ico {{g.icons['undelete'].css}}" title="Undelete"></b></a>
+    <div class="confirmation_dialog" style="display:none">
+        <b class="ico ico-close close" data-icon="D"></b>
+        <h1>Confirm page restoration</h1>
+        <p>
+            Do you really want to restore the page?
+            You can undo it later.
+        </p>
+        <p>
+            <button class="continue_confirm" href="./undelete">Yes</button>
+            <input type="button" value="Cancel" class="cancel_confirmation close">
+        </p>
+    </div>
+
   {% endif %}
   {% if c.user and c.user != c.user.anonymous() %}
     {{c.subscribe_form.display(value=subscribed, action='subscribe', style='icon')}}
@@ -98,4 +111,6 @@
     {% set thread = page.discussion_thread %}
     <div>{{c.thread.display(value=thread,page=pagenum,limit=limit,count=count)}}</div>
   {% endif %}
+  {{c.confirmation.display(content='')}}
+
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/4b24c095/ForgeWiki/forgewiki/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 3ac9737..072be6a 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -235,16 +235,16 @@ class TestRootController(TestController):
         assert '2 by Test Admin' in response
         assert '1 by Test Admin' in response
         # you can revert to an old revison, but not the current one
-        assert response.html.find('a', {'data-version': '1'})
-        assert not response.html.find('a', {'data-version': '2'})
+        assert response.html.find('a', {'data-dialog-id': '1'})
+        assert not response.html.find('a', {'data-dialog-id': '2'})
         response = self.app.get('/wiki/tést/history',
                                 extra_environ=dict(username='*anonymous'))
         # two revisions are shown
         assert '2 by Test Admin' in response
         assert '1 by Test Admin' in response
         # you cannot revert to any revision
-        assert not response.html.find('a', {'data-version': '1'})
-        assert not response.html.find('a', {'data-version': '2'})
+        assert not response.html.find('a', {'data-dialog-id': '1'})
+        assert not response.html.find('a', {'data-dialog-id': '2'})
 
     def test_page_diff(self):
         self.app.post(

http://git-wip-us.apache.org/repos/asf/allura/blob/4b24c095/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index d1e02c2..8c46f00 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -61,7 +61,9 @@ class W:
     create_page_lightbox = CreatePageWidget(
         name='create_wiki_page', trigger='#sidebar a.add_wiki_page')
     markdown_editor = ffw.MarkdownEdit()
-    revert = ffw.Lightbox(name='revert', trigger='a.post-link')
+    confirmation = ffw.Lightbox(name='confirm',
+                                trigger='a.post-link',
+                                options="{ modalCSS: { minHeight: 0, width: 'inherit', top: '150px'}}")
     label_edit = ffw.LabelEdit()
     attachment_add = ffw.AttachmentAdd()
     attachment_list = ffw.AttachmentList()
@@ -488,6 +490,7 @@ class PageController(BaseController, FeedController):
     def index(self, version=None, page=0, limit=25, **kw):
         if not self.page:
             redirect(c.app.url + h.urlquote(self.title) + '/edit')
+        c.confirmation = W.confirmation
         c.thread = W.thread
         c.attachment_list = W.attachment_list
         c.subscribe_form = W.page_subscribe_form
@@ -524,6 +527,7 @@ class PageController(BaseController, FeedController):
             page = self.page
         else:
             page = self.fake_page()
+        c.confirmation = W.confirmation
         c.markdown_editor = W.markdown_editor
         c.attachment_add = W.attachment_add
         c.attachment_list = W.attachment_list
@@ -558,7 +562,7 @@ class PageController(BaseController, FeedController):
             raise exc.HTTPNotFound
         c.page_list = W.page_list
         c.page_size = W.page_size
-        c.revert = W.revert
+        c.confirmation = W.confirmation
         limit, pagenum, start = g.handle_paging(limit, page, default=25)
         count = 0
         pages = self.page.history()