Skip to content

Commit b2afe54

Browse files
committed
v2-Beta14 release
1 parent 9ce4445 commit b2afe54

File tree

7 files changed

+23
-6
lines changed

7 files changed

+23
-6
lines changed

frappe_better_attach_control/api/field.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
from .common import send_console_log
1010

1111

12-
_FIELD_DOCTYPE_ = "DocField"
13-
14-
1512
@frappe.whitelist(methods=["POST"], allow_guest=True)
1613
def get_options(doctype, name):
1714
if not doctype or not isinstance(doctype, str):
@@ -28,14 +25,28 @@ def get_options(doctype, name):
2825
})
2926
return ""
3027

28+
fieldtypes = ["in", ["Attach", "Attach Image"]]
3129
options = frappe.db.get_value(
32-
_FIELD_DOCTYPE_,
30+
"DocField",
3331
{
3432
"fieldname": name,
3533
"parent": doctype,
3634
"parenttype": "DocType",
3735
"parentfield": "fields",
38-
"fieldtype": ["in", ["Attach", "Attach Image"]]
36+
"fieldtype": fieldtypes
37+
},
38+
"options"
39+
)
40+
41+
if options and isinstance(options, str):
42+
return options
43+
44+
options = frappe.db.get_value(
45+
"Custom Field",
46+
{
47+
"fieldname": name,
48+
"dt": doctype,
49+
"fieldtype": fieldtypes
3950
},
4051
"options"
4152
)
@@ -50,7 +61,7 @@ def get_options(doctype, name):
5061
"parent": doctype,
5162
"parenttype": "Web Form",
5263
"parentfield": "web_form_fields",
53-
"fieldtype": ["in", ["Attach", "Attach Image"]]
64+
"fieldtype": fieldtypes
5465
},
5566
"options"
5667
)

frappe_better_attach_control/public/js/better_attach_webform.js

+1
Original file line numberDiff line numberDiff line change
@@ -1804,6 +1804,7 @@
18041804
opts.restrictions.allowed_file_types
18051805
));
18061806
var extra = [];
1807+
if (!opts.extra) opts.extra = {};
18071808
each(opts.extra.allowed_file_types, function(v) {
18081809
if (isRegExp(v) && is_ext_image("" + v.source) || isString(v) && is_ext_image(v))
18091810
extra.push(v);

frappe_better_attach_control/public/js/better_attach_webform_v12.js

+1
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,7 @@
17631763
opts.restrictions.allowed_file_types
17641764
));
17651765
var extra2 = [];
1766+
if (!opts.extra) opts.extra = {};
17661767
each(opts.extra.allowed_file_types, function(v) {
17671768
if (isRegExp(v) && is_ext_image("" + v.source) || isString(v) && is_ext_image(v))
17681769
extra2.push(v);

frappe_better_attach_control/public/js/better_attach_webform_v13.js

+1
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,7 @@
17991799
opts.restrictions.allowed_file_types
18001800
));
18011801
var extra = [];
1802+
if (!opts.extra) opts.extra = {};
18021803
each(opts.extra.allowed_file_types, function(v) {
18031804
if (isRegExp(v) && is_ext_image("" + v.source) || isString(v) && is_ext_image(v))
18041805
extra.push(v);

frappe_better_attach_control/public/js/controls/attach.js

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ frappe.ui.form.ControlAttach = class ControlAttach extends frappe.ui.form.Contro
122122
opts.restrictions.allowed_file_types = to_images_list(toArray(
123123
opts.restrictions.allowed_file_types
124124
));
125+
if (!opts.extra) opts.extra = {};
125126
each(opts.extra.allowed_file_types, function(v) {
126127
if (
127128
(isRegExp(v) && is_ext_image('' + v.source))

frappe_better_attach_control/public/js/controls/v12/attach.js

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ frappe.ui.form.ControlAttach = frappe.ui.form.ControlAttach.extend({
113113
opts.restrictions.allowed_file_types
114114
));
115115
var extra = [];
116+
if (!opts.extra) opts.extra = {};
116117
each(opts.extra.allowed_file_types, function(v) {
117118
if (
118119
(isRegExp(v) && is_ext_image('' + v.source))

frappe_better_attach_control/public/js/controls/v13/attach.js

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ frappe.ui.form.ControlAttach = frappe.ui.form.ControlAttach.extend({
118118
opts.restrictions.allowed_file_types
119119
));
120120
var extra = [];
121+
if (!opts.extra) opts.extra = {};
121122
each(opts.extra.allowed_file_types, function(v) {
122123
if (
123124
(isRegExp(v) && is_ext_image('' + v.source))

0 commit comments

Comments
 (0)