]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow registering header sections in the file lists 17482/head
authorJulius Härtl <jus@bitgrid.net>
Mon, 19 Aug 2019 09:40:42 +0000 (11:40 +0200)
committerJulius Härtl <jus@bitgrid.net>
Wed, 23 Oct 2019 06:48:15 +0000 (08:48 +0200)
Signed-off-by: Julius Härtl <jus@bitgrid.net>
apps/files/js/filelist.js
apps/files/templates/list.php

index 0e24c09ec07262229a0d51cabb7b81ee7be5aeab..58e2bfae7ff047d44f38861d49fc487f1cd45c90 100644 (file)
                 */
                $fileList: null,
 
+               $header: null,
+               headers: [],
+
+               $footer: null,
+               footers: [],
+
                /**
                 * @type OCA.Files.BreadCrumb
                 */
                        this.$container = options.scrollContainer || $(window);
                        this.$table = $el.find('table:first');
                        this.$fileList = $el.find('#fileList');
+                       this.$header = $el.find('#filelist-header');
+                       this.$footer = $el.find('#filelist-footer');
 
                        if (!_.isUndefined(this._filesConfig)) {
                                this._filesConfig.on('change:showhidden', function() {
 
 
                        OC.Plugins.attach('OCA.Files.FileList', this);
+
+                       this.initHeadersAndFooters()
+               },
+
+               initHeadersAndFooters: function() {
+                       this.headers.sort(function(a, b) {
+                               return a.order - b.order;
+                       })
+                       this.footers.sort(function(a, b) {
+                               return a.order - b.order;
+                       })
+                       var uniqueIds = [];
+                       var self = this;
+                       this.headers.forEach(function(header) {
+                               if (header.id) {
+                                       if (uniqueIds.indexOf(header.id) !== -1) {
+                                               return
+                                       }
+                                       uniqueIds.push(header.id)
+                               }
+                               self.$header.append(header.el)
+
+                               setTimeout(function() {
+                                       header.render(self)
+                               }, 0)
+                       })
+
+                       uniqueIds = [];
+                       this.footers.forEach(function(footer) {
+                               if (footer.id) {
+                                       if (uniqueIds.indexOf(footer.id) !== -1) {
+                                               return
+                                       }
+                                       uniqueIds.push(footer.id)
+                               }
+                               self.$footer.append(footer.el)
+                               setTimeout(function() {
+                                       footer.render(self)
+                               }, 0)
+                       })
                },
 
                /**
                        }
 
                        return null;
+               },
+
+               registerHeader: function(header) {
+                       this.headers.push(
+                               _.defaults(header, { order: 0 })
+                       );
+               },
+
+               registerFooter: function(footer) {
+                       this.footers.push(
+                               _.defaults(footer, { order: 0 })
+                       );
                }
        };
 
index 8b20c84e0087708f32bb48a1d3df62a4d2966b0c..697a0a9cf445b8c65e7049acf5ddd53af3ad33dd 100644 (file)
@@ -19,6 +19,7 @@
        <input type="hidden" class="max_human_file_size"
                   value="(max <?php isset($_['uploadMaxHumanFilesize']) ? p($_['uploadMaxHumanFilesize']) : ''; ?>)">
 </div>
+<div id="filelist-header"></div>
 
 <div id="emptycontent" class="hidden">
        <div class="icon-folder"></div>
@@ -68,6 +69,7 @@
        <tfoot>
        </tfoot>
 </table>
+<div id="filelist-footer"></div>
 <input type="hidden" name="dir" id="dir" value="" />
 <div class="hiddenuploadfield">
        <input type="file" id="file_upload_start" class="hiddenuploadfield" name="files[]" />