fix(webform): attachments and date
This commit is contained in:
parent
2bd8678357
commit
5863f5d4ec
5 changed files with 19 additions and 9 deletions
|
|
@ -125,7 +125,7 @@ frappe.ui.form.ControlDate = frappe.ui.form.ControlData.extend({
|
|||
let sysdefaults = frappe.sys_defaults;
|
||||
let date_format = sysdefaults && sysdefaults.date_format
|
||||
? sysdefaults.date_format : 'yyyy-mm-dd';
|
||||
frappe.msgprint(__("Date must be in format: {0}", [date_format]));
|
||||
frappe.msgprint(__("Date {0} must be in format: {1}", [value, date_format]));
|
||||
return '';
|
||||
}
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ $.extend(frappe.datetime, {
|
|||
},
|
||||
|
||||
_date: function(format, as_obj = false) {
|
||||
const { time_zone } = frappe.sys_defaults;
|
||||
const time_zone = frappe.sys_defaults && frappe.sys_defaults.time_zone;
|
||||
let date;
|
||||
if (time_zone) {
|
||||
date = moment.tz(time_zone);
|
||||
|
|
|
|||
|
|
@ -193,9 +193,13 @@ window.web_form_settings = {
|
|||
}
|
||||
frappe.boot = {
|
||||
sysdefaults: {
|
||||
float_precision: {{ frappe.get_system_settings('float_precision') }}
|
||||
float_precision: {{ frappe.get_system_settings('float_precision') }},
|
||||
date_format: "{{ frappe.get_system_settings('date_format') }}",
|
||||
}
|
||||
};
|
||||
|
||||
// for backward compatibility of some libs
|
||||
frappe.sys_defaults = frappe.boot.sysdefaults;
|
||||
{% if row_template %}web_form_settings.web_form_row_template = "{{ row_template }}";{% endif %}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -380,9 +380,10 @@ def accept(web_form, data, for_payment=False):
|
|||
if df and df.fieldtype=='Attach':
|
||||
if value and 'data:' and 'base64' in value:
|
||||
files.append((fieldname, value))
|
||||
doc.set(fieldname, '')
|
||||
continue
|
||||
|
||||
if not value and doc.get(fieldname):
|
||||
elif not value and doc.get(fieldname):
|
||||
files_to_delete.append(doc.get(fieldname))
|
||||
|
||||
doc.set(fieldname, value)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import DataTable from 'frappe-datatable';
|
||||
|
||||
export default function make_datatable(container, doctype) {
|
||||
let web_list_start = 0;
|
||||
const web_list_page_length = 20;
|
||||
|
|
@ -25,6 +23,14 @@ export default function make_datatable(container, doctype) {
|
|||
};
|
||||
|
||||
|
||||
let truncate = function(txt) {
|
||||
if (txt==null) txt = '';
|
||||
if (typeof txt==='string' && txt.length > 137) {
|
||||
return txt.substr(0, 137) + '...';
|
||||
}
|
||||
return txt;
|
||||
};
|
||||
|
||||
let append_rows = (data) => {
|
||||
let body = $(container + ' .results').find('tbody');
|
||||
for (let i=0; i<data.length; i++) {
|
||||
|
|
@ -36,12 +42,11 @@ export default function make_datatable(container, doctype) {
|
|||
});
|
||||
for (let fieldname of colnames) {
|
||||
let val = data[i][fieldname];
|
||||
if (val==null) val = '';
|
||||
$(`<td>${val}</td>`).appendTo(tablerow);
|
||||
$(`<td>${truncate(val)}</td>`).appendTo(tablerow);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
return new Promise(resolve => {
|
||||
frappe.call({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue