]> source.dussan.org Git - nextcloud-server.git/commitdiff
disable "deleted files" button if trash bin is empty
authorBjörn Schießle <schiessle@owncloud.com>
Fri, 26 Jul 2013 09:13:43 +0000 (11:13 +0200)
committerBjörn Schießle <schiessle@owncloud.com>
Fri, 26 Jul 2013 09:14:29 +0000 (11:14 +0200)
apps/files/css/files.css
apps/files/index.php
apps/files/js/filelist.js
apps/files/js/files.js
apps/files/templates/index.php
apps/files_trashbin/lib/trash.php

index f2ca1065ecad4fc977a0135dfefb0bf85fcfb699..117aac4c93e8ed977d42d467f085b0361ee67b2c 100644 (file)
@@ -24,7 +24,7 @@
 #new>ul>li>p { cursor:pointer; }
 #new>ul>li>form>input { padding:0.3em; margin:-0.3em; }
 
-#trash { height:17px; margin: 0 1em; z-index:1010; float: right; }
+#trash { margin: 0 1em; z-index:1010; float: right; }
 
 #upload {
        height:27px; padding:0; margin-left:0.2em; overflow:hidden;
index 2f0053915090d43146e4d49a7d739d36dd013c71..4f9e881eb2da08b0c567c8ae99e6139c6c8682a6 100644 (file)
@@ -126,6 +126,12 @@ if ($needUpgrade) {
                $publicUploadEnabled = 'no';
        }
 
+       $trashEnabled = \OCP\App::isEnabled('files_trashbin');
+       $trashEmpty = true;
+       if ($trashEnabled) {
+               $trashEmpty = \OCA\Files_Trashbin\Trashbin::isEmpty($user);
+       }
+       
        OCP\Util::addscript('files', 'fileactions');
        OCP\Util::addscript('files', 'files');
        OCP\Util::addscript('files', 'keyboardshortcuts');
@@ -136,7 +142,8 @@ if ($needUpgrade) {
        $tmpl->assign('isCreatable', \OC\Files\Filesystem::isCreatable($dir . '/'));
        $tmpl->assign('permissions', $permissions);
        $tmpl->assign('files', $files);
-       $tmpl->assign('trash', \OCP\App::isEnabled('files_trashbin'));
+       $tmpl->assign('trash', $trashEnabled);
+       $tmpl->assign('trashEmpty', $trashEmpty);
        $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
        $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
        $tmpl->assign('allowZipDownload', intval(OCP\Config::getSystemValue('allowZipDownload', true)));
index 04a9fb91649d7d34ef3c23f56b4354f4e1317b3c..b858e2580ee16b9e340f47abceda963ecec68477 100644 (file)
@@ -392,6 +392,7 @@ var FileList={
                                                        files.removeClass('selected');
                                                });
                                                procesSelection();
+                                               checkTrashStatus();
                                        } else {
                                                $.each(files,function(index,file) {
                                                        var deleteAction = $('tr').filterAttr('data-file',file).children("td.date").children(".move2trash");
index 98fc53b71a9d91d85726a6782d80f0085c5da5bc..55280edde4220029437a3e75b01216c70c2dd007 100644 (file)
@@ -121,10 +121,10 @@ $(document).ready(function() {
        });
 
        // Show trash bin
-       $('#trash a').live('click', function() {
+       $('#trash').on('click', function() {
                window.location=OC.filePath('files_trashbin', '', 'index.php');
        });
-
+       
        var lastChecked;
 
        // Sets the file link behaviour :
@@ -845,3 +845,11 @@ function getUniqueName(name){
        }
        return name;
 }
+
+function checkTrashStatus() {
+       $.post(OC.filePath('files_trashbin', 'ajax', 'isEmpty.php'), function(result){
+               if (result.data.isEmpty === false) {
+                       $("input[type=button][id=trash]").removeAttr("disabled");
+               }
+       });
+}
\ No newline at end of file
index e07316093685a379d3b092b584e4832860c9acc6..a70c0eaa117563f218b7bdb5162b4556365c37b6 100644 (file)
@@ -38,9 +38,7 @@
                                </form>
                        </div>
                        <?php if ($_['trash'] ): ?>
-                       <div id="trash" class="button">
-                               <a><?php p($l->t('Deleted files'));?></a>
-                       </div>
+                       <input id="trash" type="button" value="<?php p($l->t('Deleted Files'));?>" class="button" <?php $_['trashEmpty'] ? p('disabled') : '' ?>></input>
                        <?php endif; ?>
                        <div id="uploadprogresswrapper">
                                <div id="uploadprogressbar"></div>
index 50fdaccfb1efe0366a139b22dba50bb4c0c4bc0d..cff97418fe432a483c0060637742760de8b6a710 100644 (file)
@@ -868,5 +868,20 @@ class Trashbin {
                //Listen to delete user signal
                \OCP\Util::connectHook('OC_User', 'pre_deleteUser', "OCA\Files_Trashbin\Hooks", "deleteUser_hook");
        }
+       
+       /**
+        * @brief check if trash bin is empty for a given user
+        * @param string $user
+        */
+       public static function isEmpty($user) {
+
+               $trashSize = self::getTrashbinSize($user);
+
+               if ($trashSize !== false && $trashSize > 0) {
+                       return false;
+               }
+
+               return true;
+       }
 
 }