storage-file-list view

This commit is contained in:
antelle 2019-09-15 23:41:00 +02:00
parent f8f8a7c1d1
commit 2ce1d01535
2 changed files with 16 additions and 17 deletions

View File

@ -754,10 +754,8 @@ const OpenView = Backbone.View.extend({
});
}
const listView = new StorageFileListView({
model: {
files,
showHiddenFiles: config && config.showHiddenFiles
}
files,
showHiddenFiles: config && config.showHiddenFiles
});
listView.on('selected', file => {
if (file.dir) {

View File

@ -1,18 +1,20 @@
import Backbone from 'backbone';
import { View } from 'view-engine/view';
import { UrlFormat } from 'util/formatting/url-format';
import template from 'templates/storage-file-list.hbs';
const StorageFileListView = Backbone.View.extend({
template: require('templates/storage-file-list.hbs'),
class StorageFileListView extends View {
template = template;
events: {
events = {
'click .open-list__file': 'fileClick',
'click .open-list__check-wrap': 'showAllCheckClick'
},
};
initialize() {
constructor(model) {
super(model);
this.allStorageFiles = {};
this.showHiddenFiles = !!this.model.showHiddenFiles;
},
}
render() {
let files = this.model.files.map(file => {
@ -34,28 +36,27 @@ const StorageFileListView = Backbone.View.extend({
}
}
const density = files.length > 14 ? 3 : files.length > 7 ? 2 : 1;
this.renderTemplate({
super.render({
files,
density,
showHiddenFiles: this.showHiddenFiles,
canShowHiddenFiles
});
return this;
},
}
fileClick(e) {
const result = $(e.target)
.closest('.open-list__file')
.data('path');
const file = this.allStorageFiles[result];
this.trigger('selected', file);
},
this.emit('selected', file);
}
showAllCheckClick(e) {
e.stopPropagation();
this.showHiddenFiles = !this.showHiddenFiles;
this.render();
}
});
}
export { StorageFileListView };