From c70a83c91d05ad0b4f72e7ee984723be0f2db53f Mon Sep 17 00:00:00 2001 From: prssanna Date: Wed, 9 Dec 2020 13:08:08 +0530 Subject: [PATCH 1/2] fix: don't separate files and folders --- .../public/js/frappe/views/file/file_view.js | 82 ++++++------------- 1 file changed, 27 insertions(+), 55 deletions(-) diff --git a/frappe/public/js/frappe/views/file/file_view.js b/frappe/public/js/frappe/views/file/file_view.js index 5c88d9a536..a19286c962 100644 --- a/frappe/public/js/frappe/views/file/file_view.js +++ b/frappe/public/js/frappe/views/file/file_view.js @@ -243,66 +243,38 @@ frappe.views.FileView = class FileView extends frappe.views.ListView { } } - get_item_html(d, draggable) { - const icon_class = d.icon_class + '-large'; - let file_body_html = - d._type == 'image' + render_grid_view() { + let html = this.data.map(d => { + const icon_class = d.icon_class + '-large'; + let file_body_html = d._type == 'image' ? `
${
 						d.file_name
-				  }
` + }">` : frappe.utils.icon(icon_class, { width: '40px', height: '45px' }); - const name = escape(d.name); - return ` -
-
- -
-
- ${file_body_html} -
- -
- `; - } - - render_grid_view() { - let folders_html = ''; - let files_html = ''; - - this.data.map((d) => { - d = this.prepare_datum(d); - if (d._type == 'folder') folders_html += this.get_item_html(d, false); - else files_html += this.get_item_html(d, true); - }); - - let get_html = (type, body_html) => { - if (body_html) { - const title = frappe.model.unscrub(type); - return `
- - ${__(title)} -
-
- ${body_html} -
`; - } - return ''; - }; - - let html = `
- ${get_html('folders', folders_html)} - ${get_html('files', files_html)} -
`; + const name = escape(d.name); + const draggable = d.type == 'Folder' ? false : true; + return ` + +
+ +
+
+ ${file_body_html} +
+ +
+ `; + }).join(''); this.$result.addClass('file-grid-view'); - this.$result.empty().html(html); + this.$result.empty().html( + `
+ ${html} +
` + ); } get_breadcrumbs_html() { From 00492a4e7541d0665b89f3575fc05ede10166c76 Mon Sep 17 00:00:00 2001 From: prssanna Date: Wed, 9 Dec 2020 13:08:56 +0530 Subject: [PATCH 2/2] fix: file checkbox click issue --- frappe/public/js/frappe/list/list_view.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frappe/public/js/frappe/list/list_view.js b/frappe/public/js/frappe/list/list_view.js index 76c0e82549..0c4322382d 100644 --- a/frappe/public/js/frappe/list/list_view.js +++ b/frappe/public/js/frappe/list/list_view.js @@ -1083,7 +1083,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { } setup_list_click() { - this.$result.on("click", ".list-row, .image-view-header", (e) => { + this.$result.on("click", ".list-row, .image-view-header, .file-header", (e) => { const $target = $(e.target); // tick checkbox if Ctrl/Meta key is pressed if (e.ctrlKey || (e.metaKey && !$target.is("a"))) { @@ -1101,6 +1101,7 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList { $target.is(":checkbox") || $target.is("a") ) { + e.stopPropagation(); return; } // open form