Skip to content
Snippets Groups Projects
Commit 10b62f9b authored by Moritz Strohm's avatar Moritz Strohm Committed by David Siegfried
Browse files

Show object count for folders, closes #1392

Closes #1392

Merge request studip/studip!887
parent 718e7331
No related branches found
No related tags found
No related merge requests found
<?php
class AddShowFolderSizeConfig extends Migration
{
public function description()
{
return 'Adds the configuration SHOW_FOLDER_SIZE.';
}
protected function up()
{
DBManager::get()->exec(
"INSERT IGNORE INTO `config`
(`field`, `value`, `type`, `range`,
`section`, `mkdate`, `chdate`,
`description`)
VALUES
('SHOW_FOLDER_SIZE', '1', 'boolean', 'global',
'files', UNIX_TIMESTAMP(), UNIX_TIMESTAMP(),
'SHOW_FOLDER_SIZE gibt an, ob die Anzahl der Objekte (Dateien und Unterordner) in einem Ordner angezeigt werden sollen.')"
);
}
protected function down()
{
DBManager::get()->exec(
"DELETE FROM `config_values` WHERE `field` = 'SHOW_FOLDER_SIZE'"
);
}
}
......@@ -133,6 +133,10 @@ class FilesystemVueDataManager
'name' => $folder->name,
'url' => URLHelper::getURL('dispatch.php/' . $controllerpath . '/' . $folder->getId()),
'user_id' => $folder->user_id,
'object_count' => (Config::get()->SHOW_FOLDER_SIZE
? count($folder->getFiles()) + count($folder->getSubfolders())
: 0
),
'author_name' => $folder->owner ? $folder->owner->getFullname('no_title_rev') : '',
'author_url' => $folder->owner && $folder->owner->id !== $GLOBALS['user']->id? URLHelper::getURL('dispatch.php/profile', ['username' => $folder->owner->username]) : '',
'chdate' => (int) $folder->chdate,
......
......@@ -7,6 +7,7 @@ import StudipAssetImg from './components/StudipAssetImg.vue';
import StudipDateTime from './components/StudipDateTime.vue';
import StudipDialog from './components/StudipDialog.vue';
import StudipFileSize from './components/StudipFileSize.vue';
import StudipFolderSize from './components/StudipFolderSize.vue';
import StudipIcon from './components/StudipIcon.vue';
import RangeInput from './components/RangeInput.vue';
import Datetimepicker from './components/Datetimepicker.vue';
......@@ -31,6 +32,7 @@ const BaseComponents = {
Datetimepicker,
StudipDialog,
StudipFileSize,
StudipFolderSize,
StudipIcon,
I18nTextarea,
// StudipLoadingIndicator,
......
......@@ -130,7 +130,10 @@
<span v-html="highlightString(folder.name)"></span>
</a>
</td>
<td class="responsive-hidden"></td>
<td class="responsive-hidden" :data-sort-value="folder.object_count">
<studip-folder-size v-if="folder.object_count"
:object_count="folder.object_count"></studip-folder-size>
</td>
<td v-if="showdownloads"
class="responsive-hidden">
</td>
......
<template>
<span>{{ folder_size }}</span>
</template>
<script>
export default {
name: 'studip-folder-size',
props: {
object_count: Number
},
computed: {
folder_size() {
if (this.object_count < 1) {
return '';
}
return this.$gettextInterpolate(
this.$ngettext('%{count} Objekt', '%{count} Objekte', this.object_count),
{count: this.object_count}
);
}
}
}
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment