Skip to content

Commit

Permalink
v2-Beta14 release
Browse files Browse the repository at this point in the history
  • Loading branch information
kid1194 committed Mar 2, 2024
1 parent 9ce4445 commit b2afe54
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 6 deletions.
23 changes: 17 additions & 6 deletions frappe_better_attach_control/api/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
from .common import send_console_log


_FIELD_DOCTYPE_ = "DocField"


@frappe.whitelist(methods=["POST"], allow_guest=True)
def get_options(doctype, name):
if not doctype or not isinstance(doctype, str):
Expand All @@ -28,14 +25,28 @@ def get_options(doctype, name):
})
return ""

fieldtypes = ["in", ["Attach", "Attach Image"]]
options = frappe.db.get_value(
_FIELD_DOCTYPE_,
"DocField",
{
"fieldname": name,
"parent": doctype,
"parenttype": "DocType",
"parentfield": "fields",
"fieldtype": ["in", ["Attach", "Attach Image"]]
"fieldtype": fieldtypes
},
"options"
)

if options and isinstance(options, str):
return options

options = frappe.db.get_value(
"Custom Field",
{
"fieldname": name,
"dt": doctype,
"fieldtype": fieldtypes
},
"options"
)
Expand All @@ -50,7 +61,7 @@ def get_options(doctype, name):
"parent": doctype,
"parenttype": "Web Form",
"parentfield": "web_form_fields",
"fieldtype": ["in", ["Attach", "Attach Image"]]
"fieldtype": fieldtypes
},
"options"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1804,6 +1804,7 @@
opts.restrictions.allowed_file_types
));
var extra = [];
if (!opts.extra) opts.extra = {};
each(opts.extra.allowed_file_types, function(v) {
if (isRegExp(v) && is_ext_image("" + v.source) || isString(v) && is_ext_image(v))
extra.push(v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,7 @@
opts.restrictions.allowed_file_types
));
var extra2 = [];
if (!opts.extra) opts.extra = {};
each(opts.extra.allowed_file_types, function(v) {
if (isRegExp(v) && is_ext_image("" + v.source) || isString(v) && is_ext_image(v))
extra2.push(v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,7 @@
opts.restrictions.allowed_file_types
));
var extra = [];
if (!opts.extra) opts.extra = {};
each(opts.extra.allowed_file_types, function(v) {
if (isRegExp(v) && is_ext_image("" + v.source) || isString(v) && is_ext_image(v))
extra.push(v);
Expand Down
1 change: 1 addition & 0 deletions frappe_better_attach_control/public/js/controls/attach.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ frappe.ui.form.ControlAttach = class ControlAttach extends frappe.ui.form.Contro
opts.restrictions.allowed_file_types = to_images_list(toArray(
opts.restrictions.allowed_file_types
));
if (!opts.extra) opts.extra = {};
each(opts.extra.allowed_file_types, function(v) {
if (
(isRegExp(v) && is_ext_image('' + v.source))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ frappe.ui.form.ControlAttach = frappe.ui.form.ControlAttach.extend({
opts.restrictions.allowed_file_types
));
var extra = [];
if (!opts.extra) opts.extra = {};
each(opts.extra.allowed_file_types, function(v) {
if (
(isRegExp(v) && is_ext_image('' + v.source))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ frappe.ui.form.ControlAttach = frappe.ui.form.ControlAttach.extend({
opts.restrictions.allowed_file_types
));
var extra = [];
if (!opts.extra) opts.extra = {};
each(opts.extra.allowed_file_types, function(v) {
if (
(isRegExp(v) && is_ext_image('' + v.source))
Expand Down

0 comments on commit b2afe54

Please sign in to comment.