Commits

Olemis Lang committed 1107144

BH Theme #146 : Discard inline modifications

  • Participants
  • Parent commits d77abf4
  • Branches t146_inline_edit

Comments (0)

Files changed (1)

File t146/t146_r1420132_inplace_ticket_form.diff

 
 diff -r da551ebf15e9 bhtheme/htdocs/bloodhound.css
 --- a/bhtheme/htdocs/bloodhound.css	Fri Dec 14 04:41:19 2012 -0500
-+++ b/bhtheme/htdocs/bloodhound.css	Fri Dec 14 12:51:28 2012 -0500
++++ b/bhtheme/htdocs/bloodhound.css	Fri Dec 14 13:11:33 2012 -0500
 @@ -202,10 +202,6 @@
    width: 505px;
  }
  h6 {
 diff -r da551ebf15e9 bhtheme/templates/bh_ticket.html
 --- a/bhtheme/templates/bh_ticket.html	Fri Dec 14 04:41:19 2012 -0500
-+++ b/bhtheme/templates/bh_ticket.html	Fri Dec 14 12:51:28 2012 -0500
-@@ -48,8 +48,11 @@
++++ b/bhtheme/templates/bh_ticket.html	Fri Dec 14 13:11:33 2012 -0500
+@@ -48,20 +48,70 @@
          modify_elem.parent().hide();
    
          function modify_ticket() {
 +            return;
            $('[data-edit="inplace"]').each(function() {
 -              var fc = $(this);
+-              var fieldurl = fc.find('a').attr('href');
 +              var fc = $(this).addClass('edit-active');
-               var fieldurl = fc.find('a').attr('href');
                var fieldnm = fc.attr('id').substr(3);
-               fc.empty();
-@@ -58,10 +61,50 @@
+-              fc.empty();
++              fc.attr('data-edit-orig', fc.html()).empty();
+               var editor = $('#properties #field-' + fieldnm);
+               if (editor.length == 0)
                  editor = $('#editor-' + fieldnm);
                var fieldval = editor.val();
                editor = editor.clone(false).appendTo(fc).val(fieldval);
 +                var submit_ticket = $('#tmpl-inplace-submit').html();
 +                submit_ticket = $(submit_ticket).prepend(editor)
 +                    .appendTo(fc);
++                submit_ticket.find('#edit-cancel').click(revert_ticket);
 +                editor.wrap('<div class="btn-group"></div>')
 +
 +                // Workflow actions
 +                            .attr('title', action_help);
 +                  })
 +              }
++            });
++        }
++
++        function revert_ticket() {
++          $('[data-edit="inplace"]').each(function() {
++              var fc = $(this).removeClass('edit-active');
++              fc.html(fc.attr('data-edit-orig'));
              });
          }
    
-@@ -397,7 +440,8 @@
+@@ -397,7 +447,8 @@
                          <th><label for="field-summary">Summary:</label></th>
                          <td class="fullrow" colspan="3">
                            <input type="text" id="field-summary" name="field_summary"
                          </td>
                        </tr>
                        <py:if test="only_for_admin">
-@@ -593,5 +637,24 @@
+@@ -593,5 +644,27 @@
          </bh:widget>
        </div>
      </div>
 +        </ul>
 +      </div>
 +      <div class="btn-group">
-+      <button class="btn-link" title="Discard changes">Cancel</button></div>
++        <button id="edit-cancel" class="btn-link" title="Discard changes">
++          Cancel
++        </button>
++      </div>
 +      </div>
 +    </script>
    </body>