Allow registering header sections in the file lists

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2019-08-19 11:40:42 +02:00
parent 178ead4014
commit 975c1982a0
No known key found for this signature in database
GPG key ID: 4C614C6ED2CDE6DF
2 changed files with 62 additions and 0 deletions

View file

@ -58,6 +58,12 @@
*/ */
$fileList: null, $fileList: null,
$header: null,
headers: [],
$footer: null,
footers: [],
/** /**
* @type OCA.Files.BreadCrumb * @type OCA.Files.BreadCrumb
*/ */
@ -262,6 +268,8 @@
this.$container = options.scrollContainer || $(window); this.$container = options.scrollContainer || $(window);
this.$table = $el.find('table:first'); this.$table = $el.find('table:first');
this.$fileList = $el.find('#fileList'); this.$fileList = $el.find('#fileList');
this.$header = $el.find('#filelist-header');
this.$footer = $el.find('#filelist-footer');
if (!_.isUndefined(this._filesConfig)) { if (!_.isUndefined(this._filesConfig)) {
this._filesConfig.on('change:showhidden', function() { this._filesConfig.on('change:showhidden', function() {
@ -408,6 +416,46 @@
OC.Plugins.attach('OCA.Files.FileList', this); 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)
})
}, },
/** /**
@ -3642,6 +3690,18 @@
} }
return null; return null;
},
registerHeader: function(header) {
this.headers.push(
_.defaults(header, { order: 0 })
);
},
registerFooter: function(footer) {
this.footers.push(
_.defaults(footer, { order: 0 })
);
} }
}; };

View file

@ -19,6 +19,7 @@
<input type="hidden" class="max_human_file_size" <input type="hidden" class="max_human_file_size"
value="(max <?php isset($_['uploadMaxHumanFilesize']) ? p($_['uploadMaxHumanFilesize']) : ''; ?>)"> value="(max <?php isset($_['uploadMaxHumanFilesize']) ? p($_['uploadMaxHumanFilesize']) : ''; ?>)">
</div> </div>
<div id="filelist-header"></div>
<div id="emptycontent" class="hidden"> <div id="emptycontent" class="hidden">
<div class="icon-folder"></div> <div class="icon-folder"></div>
@ -68,6 +69,7 @@
<tfoot> <tfoot>
</tfoot> </tfoot>
</table> </table>
<div id="filelist-footer"></div>
<input type="hidden" name="dir" id="dir" value="" /> <input type="hidden" name="dir" id="dir" value="" />
<div class="hiddenuploadfield"> <div class="hiddenuploadfield">
<input type="file" id="file_upload_start" class="hiddenuploadfield" name="files[]" /> <input type="file" id="file_upload_start" class="hiddenuploadfield" name="files[]" />