Add form for edit history entry comparing
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 2 Jul 2014 13:05:53 +0000 (15:05 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 9 Jul 2014 19:58:56 +0000 (21:58 +0200)
com.woltlab.wcf/templates/editHistory.tpl
wcfsetup/install/files/lib/page/EditHistoryPage.class.php

index 70e5f4902055866c8d05b4203cb9ee8f4e88374b..1c5fc9689b72808f9b9ad5611a348ca30a0debf0 100644 (file)
 {include file='userNotice'}
 
 <pre>{$diff}</pre>
-<div class="tabularBox tabularBoxTitle marginTop">
-       <header>
-               <h2>{lang}wcf.edit.versions{/lang} <span class="badge badgeInverse">{#$objects|count}</span></h2>
-       </header>
-       
-       <table class="table">
-               <thead>
-                       <tr>
-                               <th class="columnID columnEditID" colspan="2">{lang}wcf.global.objectID{/lang}</th>
-                               <th class="columnText columnUser">{lang}wcf.user.username{/lang}</th>
-                               <th class="columnText columnTime">{lang}wcf.edit.time{/lang}</th>
-                               <th class="columnText columnEditReason">{lang}wcf.edit.reason{/lang}</th>
-                               
-                               {event name='columnHeads'}
-                       </tr>
-               </thead>
+
+<form action="{link controller='EditHistory'}{/link}" method="get">
+       <div class="tabularBox tabularBoxTitle marginTop">
+               <header>
+                       <h2>{lang}wcf.edit.versions{/lang} <span class="badge badgeInverse">{#$objects|count}</span></h2>
+               </header>
                
-               <tbody>
-                       <tr>
-                               <td class="columnIcon">
-                                       <span class="icon icon16 icon-undo disabled"></span>
-                                       {event name='rowButtons'}
-                               </td>
-                               <td class="columnID"><strong>{lang}wcf.edit.currentVersion{/lang}</strong></td>
-                               <td class="columnText columnUser"><a href="{link controller='User' id=$object->getUserID() title=$object->getUsername()}{/link}">{$object->getUsername()}</a></td>
-                               <td class="columnText columnTime">{@$object->getTime()|time}</td>
-                               <td class="columnText columnEditReason">{$object->getEditReason()}</td>
-                               
-                               {event name='columns'}
-                       </tr>
-                       {foreach from=$objects item=edit}
-                               <tr class="jsEditRow">
+               <table class="table">
+                       <thead>
+                               <tr>
+                                       <th class="columnID columnEditID" colspan="2">{lang}wcf.global.objectID{/lang}</th>
+                                       <th class="columnText columnUser">{lang}wcf.user.username{/lang}</th>
+                                       <th class="columnText columnTime">{lang}wcf.edit.time{/lang}</th>
+                                       <th class="columnText columnEditReason">{lang}wcf.edit.reason{/lang}</th>
+                                       
+                                       {event name='columnHeads'}
+                               </tr>
+                       </thead>
+                       
+                       <tbody>
+                               <tr>
                                        <td class="columnIcon">
-                                               <span class="icon icon16 icon-undo"></span>
+                                               <span class="icon icon16 icon-undo disabled"></span>
+                                               <input type="radio" name="oldID" value="current"{if $oldID == 'current'} checked="checked"{/if} /> <input type="radio" name="newID" value="current"{if $newID == 'current'} checked="checked"{/if} />
                                                {event name='rowButtons'}
                                        </td>
-                                       <td class="columnID">{@$edit->entryID}</td>
-                                       <td class="columnText columnUser"><a href="{link controller='User' id=$edit->userID title=$edit->username}{/link}">{$edit->username}</a></td>
-                                       <td class="columnText columnTime">{@$edit->time|time}</td>
-                                       <td class="columnText columnEditReason">{$edit->editReason}</td>
+                                       <td class="columnID"><strong>{lang}wcf.edit.currentVersion{/lang}</strong></td>
+                                       <td class="columnText columnUser"><a href="{link controller='User' id=$object->getUserID() title=$object->getUsername()}{/link}">{$object->getUsername()}</a></td>
+                                       <td class="columnText columnTime">{@$object->getTime()|time}</td>
+                                       <td class="columnText columnEditReason">{$object->getEditReason()}</td>
                                        
                                        {event name='columns'}
                                </tr>
-                       {/foreach}
-               </tbody>
-       </table>
+                               {foreach from=$objects item=edit}
+                                       <tr class="jsEditRow">
+                                               <td class="columnIcon">
+                                                       <span class="icon icon16 icon-undo"></span>
+                                                       <input type="radio" name="oldID" value="{@$edit->entryID}"{if $oldID == $edit->entryID} checked="checked"{/if} /> <input type="radio" name="newID" value="{@$edit->entryID}"{if $newID == $edit->entryID} checked="checked"{/if} />
+                                                       {event name='rowButtons'}
+                                               </td>
+                                               <td class="columnID">{@$edit->entryID}</td>
+                                               <td class="columnText columnUser"><a href="{link controller='User' id=$edit->userID title=$edit->username}{/link}">{$edit->username}</a></td>
+                                               <td class="columnText columnTime">{@$edit->time|time}</td>
+                                               <td class="columnText columnEditReason">{$edit->editReason}</td>
+                                               
+                                               {event name='columns'}
+                                       </tr>
+                               {/foreach}
+                       </tbody>
+                       <script data-relocate="true">
+                               //<![CDATA[
+                               $(function () {
+                                       $('input[name=newID]').on('change', function (event) {
+                                               var newID = $(this).val();
+                                               
+                                               $('input[name=oldID]').each(function (event) {
+                                                       if ($(this).val() >= newID) $(this).disable();
+                                                       else $(this).enable();
+                                               });
+                                       });
+                                       
+                                       $('input[name=oldID]').on('change', function (event) {
+                                               var oldID = $(this).val();
+                                               
+                                               $('input[name=newID]').each(function (event) {
+                                                       if ($(this).val() <= oldID) $(this).disable();
+                                                       else $(this).enable();
+                                               });
+                                       });
+                                       $('input:checked').trigger('change');
+                               });
+                               //]]>
+                       </script>
+               </table>
+       </div>
        
-</div>
+       <div class="formSubmit">
+               {@SID_INPUT_TAG}
+               <button class="button" data-type="submit">{lang}wcf.edit.button.compare{/lang}</button>
+       </div>
+</form>
 
 {include file='footer'}
 
index ae2e5f904353e044d3f893762ffd91d014154461..c692cbb2684b50b639264fd1c30e85f9b5ef8fac 100644 (file)
@@ -124,6 +124,7 @@ class EditHistoryPage extends AbstractPage {
                
                if (!$this->new) {
                        $this->new = $this->object;
+                       $this->newID = 'current';
                }
        }