Skip to content

Commit

Permalink
v2-Beta4 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kid1194 committed Dec 13, 2022
1 parent 2bceb06 commit 19db9c6
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
3 changes: 0 additions & 3 deletions frappe_better_attach_control/api/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


import os
import mimetypes

import frappe
from frappe import _
Expand Down Expand Up @@ -88,10 +87,8 @@ def _get_files_by_search_text(text):
def _prepare_files(files):
for i in range(len(files)):
file = files[i]
file["type"] = ""
file["size"] = 0
if not cint(file["is_folder"]):
file["type"] = mimetypes.guess_type(f.file_url)[0] or ""
file["size"] = flt(file["file_size"])
if not file["size"]:
try:
Expand Down
12 changes: 12 additions & 0 deletions frappe_better_attach_control/public/js/uploader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ frappe.ui.FileUploader = class FileUploader extends frappe.ui.FileUploader {
).then(fn(function(r) {
let { files = [], has_more = false } = r.message || {};
if (!isEmpty(files)) {
files = files.map(function(f) {
if (f.name == null) f.name = f.file_name || get_filename(f.file_url);
if (f.type == null) f.type = get_file_type(get_file_ext(f.file_url)) || '';
if (f.size == null) f.size = 0;
return f;
});
files = files.filter(this.check_restrictions);
files.sort(function(a, b) {
if (a.is_folder && b.is_folder) {
Expand Down Expand Up @@ -189,6 +195,12 @@ frappe.ui.FileUploader = class FileUploader extends frappe.ui.FileUploader {
).then(fn(function(r) {
let files = r.message || [];
if (!isEmpty(files)) {
files = files.map(function(f) {
if (f.name == null) f.name = f.file_name || get_filename(f.file_url);
if (f.type == null) f.type = get_file_type(get_file_ext(f.file_url)) || '';
if (f.size == null) f.size = 0;
return f;
});
files = files.filter(this.check_restrictions);
if (!isEmpty(files)) {
files = files.map(fn(function(file) {
Expand Down
6 changes: 6 additions & 0 deletions frappe_better_attach_control/public/js/uploader/v12/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ frappe.ui.FileUploader = class FileUploader extends frappe.ui.FileUploader {
).then(fn(function(r) {
let files = r.message || [];
if (!isEmpty(files)) {
files = files.map(function(f) {
if (f.name == null) f.name = f.file_name || get_filename(f.file_url);
if (f.type == null) f.type = get_file_type(get_file_ext(f.file_url)) || '';
if (f.size == null) f.size = 0;
return f;
});
files = files.filter(this.check_restrictions);
files.sort(function(a, b) {
if (a.is_folder && b.is_folder) {
Expand Down
12 changes: 12 additions & 0 deletions frappe_better_attach_control/public/js/uploader/v13/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ frappe.ui.FileUploader = class FileUploader extends frappe.ui.FileUploader {
).then(fn(function(r) {
let { files = [], has_more = false } = r.message || {};
if (!isEmpty(files)) {
files = files.map(function(f) {
if (f.name == null) f.name = f.file_name || get_filename(f.file_url);
if (f.type == null) f.type = get_file_type(get_file_ext(f.file_url)) || '';
if (f.size == null) f.size = 0;
return f;
});
files = files.filter(this.check_restrictions);
files.sort(function(a, b) {
if (a.is_folder && b.is_folder) {
Expand Down Expand Up @@ -178,6 +184,12 @@ frappe.ui.FileUploader = class FileUploader extends frappe.ui.FileUploader {
).then(fn(function(r) {
let files = r.message || [];
if (!isEmpty(files)) {
files = files.map(function(f) {
if (f.name == null) f.name = f.file_name || get_filename(f.file_url);
if (f.type == null) f.type = get_file_type(get_file_ext(f.file_url)) || '';
if (f.size == null) f.size = 0;
return f;
});
files = files.filter(this.check_restrictions)
.map(fn(function(file) {
return this.make_file_node(file);
Expand Down

0 comments on commit 19db9c6

Please sign in to comment.