* [fixes] print format cleanup, options for alignment and print from web form * [print-format] select module for exportversion-14
@@ -15,6 +15,14 @@ frappe.ui.form.on("Print Format", "refresh", function(frm) { | |||||
} | } | ||||
if(!frm.is_new()) { | if(!frm.is_new()) { | ||||
frm.add_custom_button(__("Edit Format"), function() { | |||||
if(!frm.doc.doc_type) { | |||||
msgprint(__("Please select DocType first")); | |||||
return; | |||||
} | |||||
frappe.set_route("print-format-builder", frm.doc.name); | |||||
}); | |||||
frm.add_custom_button(__("Make Default"), function() { | frm.add_custom_button(__("Make Default"), function() { | ||||
frappe.call({ | frappe.call({ | ||||
method: "frappe.print.doctype.print_format.print_format.make_default", | method: "frappe.print.doctype.print_format.print_format.make_default", | ||||
@@ -22,17 +30,6 @@ frappe.ui.form.on("Print Format", "refresh", function(frm) { | |||||
name: frm.doc.name | name: frm.doc.name | ||||
} | } | ||||
}) | }) | ||||
}) | |||||
} | |||||
}); | |||||
frappe.ui.form.on("Print Format", "edit_format", function(frm) { | |||||
if(!frm.doc.doc_type) { | |||||
msgprint(__("Please select DocType first")); | |||||
return; | |||||
}); | |||||
} | } | ||||
frappe.route_options = { | |||||
print_format: frm | |||||
}; | |||||
frappe.set_route("print-format-builder"); | |||||
}); | }); |
@@ -8,11 +8,14 @@ | |||||
"custom": 0, | "custom": 0, | ||||
"docstatus": 0, | "docstatus": 0, | ||||
"doctype": "DocType", | "doctype": "DocType", | ||||
"editable_grid": 0, | |||||
"engine": "InnoDB", | |||||
"fields": [ | "fields": [ | ||||
{ | { | ||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"description": "", | "description": "", | ||||
"fieldname": "doc_type", | "fieldname": "doc_type", | ||||
"fieldtype": "Link", | "fieldtype": "Link", | ||||
@@ -39,6 +42,34 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"fieldname": "module", | |||||
"fieldtype": "Link", | |||||
"hidden": 0, | |||||
"ignore_user_permissions": 0, | |||||
"ignore_xss_filter": 0, | |||||
"in_filter": 0, | |||||
"in_list_view": 0, | |||||
"label": "Module", | |||||
"length": 0, | |||||
"no_copy": 0, | |||||
"options": "Module Def", | |||||
"permlevel": 0, | |||||
"precision": "", | |||||
"print_hide": 0, | |||||
"print_hide_if_no_value": 0, | |||||
"read_only": 0, | |||||
"report_hide": 0, | |||||
"reqd": 0, | |||||
"search_index": 0, | |||||
"set_only_once": 0, | |||||
"unique": 0 | |||||
}, | |||||
{ | |||||
"allow_on_submit": 0, | |||||
"bold": 0, | |||||
"collapsible": 0, | |||||
"columns": 0, | |||||
"fieldname": "disabled", | "fieldname": "disabled", | ||||
"fieldtype": "Check", | "fieldtype": "Check", | ||||
"hidden": 0, | "hidden": 0, | ||||
@@ -63,6 +94,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"fieldname": "column_break_3", | "fieldname": "column_break_3", | ||||
"fieldtype": "Column Break", | "fieldtype": "Column Break", | ||||
"hidden": 0, | "hidden": 0, | ||||
@@ -86,6 +118,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"default": "No", | "default": "No", | ||||
"fieldname": "standard", | "fieldname": "standard", | ||||
"fieldtype": "Select", | "fieldtype": "Select", | ||||
@@ -114,6 +147,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"fieldname": "custom_format", | "fieldname": "custom_format", | ||||
"fieldtype": "Check", | "fieldtype": "Check", | ||||
"hidden": 0, | "hidden": 0, | ||||
@@ -139,6 +173,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"depends_on": "custom_format", | "depends_on": "custom_format", | ||||
"fieldname": "section_break_6", | "fieldname": "section_break_6", | ||||
"fieldtype": "Section Break", | "fieldtype": "Section Break", | ||||
@@ -163,6 +198,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"default": "Server", | "default": "Server", | ||||
"depends_on": "custom_format", | "depends_on": "custom_format", | ||||
"description": "", | "description": "", | ||||
@@ -191,6 +227,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"depends_on": "custom_format", | "depends_on": "custom_format", | ||||
"fieldname": "html", | "fieldname": "html", | ||||
"fieldtype": "Code", | "fieldtype": "Code", | ||||
@@ -219,6 +256,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"depends_on": "eval:!doc.custom_format", | "depends_on": "eval:!doc.custom_format", | ||||
"fieldname": "section_break_9", | "fieldname": "section_break_9", | ||||
"fieldtype": "Section Break", | "fieldtype": "Section Break", | ||||
@@ -227,6 +265,7 @@ | |||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"label": "Style Settings", | |||||
"length": 0, | "length": 0, | ||||
"no_copy": 0, | "no_copy": 0, | ||||
"permlevel": 0, | "permlevel": 0, | ||||
@@ -244,15 +283,70 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"depends_on": "eval:!doc.custom_format", | |||||
"fieldname": "edit_format", | |||||
"fieldtype": "Button", | |||||
"columns": 0, | |||||
"default": "1", | |||||
"fieldname": "align_labels_left", | |||||
"fieldtype": "Check", | |||||
"hidden": 0, | |||||
"ignore_user_permissions": 0, | |||||
"ignore_xss_filter": 0, | |||||
"in_filter": 0, | |||||
"in_list_view": 0, | |||||
"label": "Align Labels to the Left", | |||||
"length": 0, | |||||
"no_copy": 0, | |||||
"permlevel": 0, | |||||
"precision": "", | |||||
"print_hide": 0, | |||||
"print_hide_if_no_value": 0, | |||||
"read_only": 0, | |||||
"report_hide": 0, | |||||
"reqd": 0, | |||||
"search_index": 0, | |||||
"set_only_once": 0, | |||||
"unique": 0 | |||||
}, | |||||
{ | |||||
"allow_on_submit": 0, | |||||
"bold": 0, | |||||
"collapsible": 0, | |||||
"columns": 0, | |||||
"default": "1", | |||||
"fieldname": "show_section_headings", | |||||
"fieldtype": "Check", | |||||
"hidden": 0, | |||||
"ignore_user_permissions": 0, | |||||
"ignore_xss_filter": 0, | |||||
"in_filter": 0, | |||||
"in_list_view": 0, | |||||
"label": "Show Section Headings", | |||||
"length": 0, | |||||
"no_copy": 0, | |||||
"permlevel": 0, | |||||
"precision": "", | |||||
"print_hide": 0, | |||||
"print_hide_if_no_value": 0, | |||||
"read_only": 0, | |||||
"report_hide": 0, | |||||
"reqd": 0, | |||||
"search_index": 0, | |||||
"set_only_once": 0, | |||||
"unique": 0 | |||||
}, | |||||
{ | |||||
"allow_on_submit": 0, | |||||
"bold": 0, | |||||
"collapsible": 0, | |||||
"columns": 0, | |||||
"default": "1", | |||||
"fieldname": "line_breaks", | |||||
"fieldtype": "Check", | |||||
"hidden": 0, | "hidden": 0, | ||||
"ignore_user_permissions": 0, | "ignore_user_permissions": 0, | ||||
"ignore_xss_filter": 0, | "ignore_xss_filter": 0, | ||||
"in_filter": 0, | "in_filter": 0, | ||||
"in_list_view": 0, | "in_list_view": 0, | ||||
"label": "Edit Format", | |||||
"label": "Show Line Breaks after Sections", | |||||
"length": 0, | "length": 0, | ||||
"no_copy": 0, | "no_copy": 0, | ||||
"permlevel": 0, | "permlevel": 0, | ||||
@@ -270,6 +364,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"fieldname": "column_break_11", | "fieldname": "column_break_11", | ||||
"fieldtype": "Column Break", | "fieldtype": "Column Break", | ||||
"hidden": 0, | "hidden": 0, | ||||
@@ -294,6 +389,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"default": "Default", | "default": "Default", | ||||
"depends_on": "eval:!doc.custom_format", | "depends_on": "eval:!doc.custom_format", | ||||
"fieldname": "font", | "fieldname": "font", | ||||
@@ -322,6 +418,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"fieldname": "css_section", | "fieldname": "css_section", | ||||
"fieldtype": "Section Break", | "fieldtype": "Section Break", | ||||
"hidden": 0, | "hidden": 0, | ||||
@@ -346,6 +443,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"fieldname": "css", | "fieldname": "css", | ||||
"fieldtype": "Code", | "fieldtype": "Code", | ||||
"hidden": 0, | "hidden": 0, | ||||
@@ -371,6 +469,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"fieldname": "custom_html_help", | "fieldname": "custom_html_help", | ||||
"fieldtype": "HTML", | "fieldtype": "HTML", | ||||
"hidden": 0, | "hidden": 0, | ||||
@@ -397,6 +496,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"depends_on": "custom_format", | "depends_on": "custom_format", | ||||
"fieldname": "section_break_13", | "fieldname": "section_break_13", | ||||
"fieldtype": "Section Break", | "fieldtype": "Section Break", | ||||
@@ -422,6 +522,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"depends_on": "custom_format", | "depends_on": "custom_format", | ||||
"fieldname": "print_format_help", | "fieldname": "print_format_help", | ||||
"fieldtype": "HTML", | "fieldtype": "HTML", | ||||
@@ -448,6 +549,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"fieldname": "format_data", | "fieldname": "format_data", | ||||
"fieldtype": "Code", | "fieldtype": "Code", | ||||
"hidden": 1, | "hidden": 1, | ||||
@@ -473,6 +575,7 @@ | |||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
"collapsible": 0, | "collapsible": 0, | ||||
"columns": 0, | |||||
"fieldname": "print_format_builder", | "fieldname": "print_format_builder", | ||||
"fieldtype": "Check", | "fieldtype": "Check", | ||||
"hidden": 1, | "hidden": 1, | ||||
@@ -499,13 +602,14 @@ | |||||
"hide_toolbar": 0, | "hide_toolbar": 0, | ||||
"icon": "icon-print", | "icon": "icon-print", | ||||
"idx": 1, | "idx": 1, | ||||
"image_view": 0, | |||||
"in_create": 0, | "in_create": 0, | ||||
"in_dialog": 0, | "in_dialog": 0, | ||||
"is_submittable": 0, | "is_submittable": 0, | ||||
"issingle": 0, | "issingle": 0, | ||||
"istable": 0, | "istable": 0, | ||||
"max_attachments": 0, | "max_attachments": 0, | ||||
"modified": "2016-05-05 17:15:45.522931", | |||||
"modified": "2016-10-10 06:06:34.530193", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"module": "Print", | "module": "Print", | ||||
"name": "Print Format", | "name": "Print Format", | ||||
@@ -521,6 +625,7 @@ | |||||
"export": 0, | "export": 0, | ||||
"if_owner": 0, | "if_owner": 0, | ||||
"import": 0, | "import": 0, | ||||
"is_custom": 0, | |||||
"permlevel": 0, | "permlevel": 0, | ||||
"print": 1, | "print": 1, | ||||
"read": 1, | "read": 1, | ||||
@@ -23,6 +23,9 @@ class PrintFormat(Document): | |||||
self.extract_images() | self.extract_images() | ||||
if not self.module: | |||||
self.module = frappe.db.get_value('DocType', self.doc_type, 'module') | |||||
if self.html: | if self.html: | ||||
validate_template(self.html) | validate_template(self.html) | ||||
@@ -46,8 +49,7 @@ class PrintFormat(Document): | |||||
def export_doc(self): | def export_doc(self): | ||||
# export | # export | ||||
from frappe.modules.utils import export_module_json | from frappe.modules.utils import export_module_json | ||||
export_module_json(self, self.standard == 'Yes', | |||||
frappe.db.get_value("DocType", self.doc_type, "module")) | |||||
export_module_json(self, self.standard == 'Yes', self.module) | |||||
def on_trash(self): | def on_trash(self): | ||||
if self.doc_type: | if self.doc_type: | ||||
@@ -4,7 +4,13 @@ frappe.pages['print-format-builder'].on_page_load = function(wrapper) { | |||||
} | } | ||||
frappe.pages['print-format-builder'].on_page_show = function(wrapper) { | frappe.pages['print-format-builder'].on_page_show = function(wrapper) { | ||||
if(frappe.route_options) { | |||||
var route = frappe.get_route(); | |||||
if(route.length>1) { | |||||
frappe.model.with_doc('Print Format', route[1], function() { | |||||
frappe.print_format_builder.print_format = frappe.get_doc('Print Format', route[1]); | |||||
frappe.print_format_builder.refresh(); | |||||
}); | |||||
} else if(frappe.route_options) { | |||||
if(frappe.route_options.make_new) { | if(frappe.route_options.make_new) { | ||||
var doctype = frappe.route_options.doctype; | var doctype = frappe.route_options.doctype; | ||||
var name = frappe.route_options.name; | var name = frappe.route_options.name; | ||||
@@ -157,9 +163,10 @@ frappe.PrintFormatBuilder = Class.extend({ | |||||
me.print_format = null; | me.print_format = null; | ||||
me.refresh(); | me.refresh(); | ||||
}, true); | }, true); | ||||
me.page.add_menu_item(__("Edit Properties"), function() { | |||||
me.page.clear_inner_toolbar(); | |||||
me.page.add_inner_button(__("Edit Properties"), function() { | |||||
frappe.set_route("Form", "Print Format", me.print_format.name); | frappe.set_route("Form", "Print Format", me.print_format.name); | ||||
}, true); | |||||
}); | |||||
}); | }); | ||||
}, | }, | ||||
setup_sidebar: function() { | setup_sidebar: function() { | ||||
@@ -217,8 +224,9 @@ frappe.PrintFormatBuilder = Class.extend({ | |||||
section.no_of_columns += 1; | section.no_of_columns += 1; | ||||
} | } | ||||
var set_section = function() { | |||||
var set_section = function(label) { | |||||
section = me.get_new_section(); | section = me.get_new_section(); | ||||
if(label) section.label = label; | |||||
column = null; | column = null; | ||||
me.layout_data.push(section); | me.layout_data.push(section); | ||||
} | } | ||||
@@ -239,7 +247,7 @@ frappe.PrintFormatBuilder = Class.extend({ | |||||
} | } | ||||
if(f.fieldtype==="Section Break") { | if(f.fieldtype==="Section Break") { | ||||
set_section(); | |||||
set_section(f.label); | |||||
} else if(f.fieldtype==="Column Break") { | } else if(f.fieldtype==="Column Break") { | ||||
set_column(); | set_column(); | ||||
@@ -265,7 +273,7 @@ frappe.PrintFormatBuilder = Class.extend({ | |||||
}); | }); | ||||
}, | }, | ||||
get_new_section: function() { | get_new_section: function() { | ||||
return {columns: [], no_of_columns: 0}; | |||||
return {columns: [], no_of_columns: 0, label:''}; | |||||
}, | }, | ||||
get_new_column: function() { | get_new_column: function() { | ||||
return {fields: []} | return {fields: []} | ||||
@@ -330,7 +338,8 @@ frappe.PrintFormatBuilder = Class.extend({ | |||||
if(fieldname==="_custom_html") { | if(fieldname==="_custom_html") { | ||||
var field = me.get_custom_html_field(); | var field = me.get_custom_html_field(); | ||||
} else { | } else { | ||||
var field = frappe.meta.get_docfield(me.print_format.doc_type, fieldname); | |||||
var field = frappe.meta.get_docfield(me.print_format.doc_type, | |||||
fieldname); | |||||
} | } | ||||
$item.replaceWith(frappe.render_template("print_format_builder_field", | $item.replaceWith(frappe.render_template("print_format_builder_field", | ||||
@@ -355,6 +364,7 @@ frappe.PrintFormatBuilder = Class.extend({ | |||||
this.page.main.on("click", ".section-settings", function() { | this.page.main.on("click", ".section-settings", function() { | ||||
var section = $(this).parent().parent(); | var section = $(this).parent().parent(); | ||||
var no_of_columns = section.find(".section-column").length; | var no_of_columns = section.find(".section-column").length; | ||||
var label = section.attr('data-label'); | |||||
// new dialog | // new dialog | ||||
var d = new frappe.ui.Dialog({ | var d = new frappe.ui.Dialog({ | ||||
@@ -364,7 +374,13 @@ frappe.PrintFormatBuilder = Class.extend({ | |||||
label:__("No of Columns"), | label:__("No of Columns"), | ||||
fieldname:"no_of_columns", | fieldname:"no_of_columns", | ||||
fieldtype:"Select", | fieldtype:"Select", | ||||
options: ["1", "2", "3"], | |||||
options: ["1", "2", "3", "4"], | |||||
}, | |||||
{ | |||||
label:__("Section Heading"), | |||||
fieldname:"label", | |||||
fieldtype:"Data", | |||||
description: __('Will only be shown if section headings are enabled') | |||||
}, | }, | ||||
{ | { | ||||
label: __("Remove Section"), | label: __("Remove Section"), | ||||
@@ -383,12 +399,16 @@ frappe.PrintFormatBuilder = Class.extend({ | |||||
}); | }); | ||||
d.set_input("no_of_columns", no_of_columns + ""); | d.set_input("no_of_columns", no_of_columns + ""); | ||||
d.set_input("label", label || ""); | |||||
d.set_primary_action(__("Update"), function() { | d.set_primary_action(__("Update"), function() { | ||||
// resize number of columns | // resize number of columns | ||||
me.update_columns_in_section(section, no_of_columns, | me.update_columns_in_section(section, no_of_columns, | ||||
cint(d.get_value("no_of_columns"))); | cint(d.get_value("no_of_columns"))); | ||||
section.attr('data-label', d.get_value('label') || ''); | |||||
section.find('.section-label').html(d.get_value('label') || ''); | |||||
d.hide(); | d.hide(); | ||||
}); | }); | ||||
@@ -486,16 +506,16 @@ frappe.PrintFormatBuilder = Class.extend({ | |||||
}); | }); | ||||
var $body = $(d.body); | var $body = $(d.body); | ||||
var doc_fields = frappe.get_meta(doctype).fields; | var doc_fields = frappe.get_meta(doctype).fields; | ||||
var docfields_by_name = {}; | var docfields_by_name = {}; | ||||
// docfields by fieldname | // docfields by fieldname | ||||
$.each(doc_fields, function(j, f) { | $.each(doc_fields, function(j, f) { | ||||
if(f) docfields_by_name[f.fieldname] = f; | if(f) docfields_by_name[f.fieldname] = f; | ||||
}) | }) | ||||
// add field which are in column_names first to preserve order | // add field which are in column_names first to preserve order | ||||
var fields = []; | var fields = []; | ||||
$.each(column_names, function(i, v) { | $.each(column_names, function(i, v) { | ||||
@@ -505,7 +525,7 @@ frappe.PrintFormatBuilder = Class.extend({ | |||||
}) | }) | ||||
// add remaining fields | // add remaining fields | ||||
$.each(doc_fields, function(j, f) { | $.each(doc_fields, function(j, f) { | ||||
if (f && !in_list(column_names, f.fieldname) | |||||
if (f && !in_list(column_names, f.fieldname) | |||||
&& !in_list(["Section Break", "Column Break"], f.fieldtype) && f.label) { | && !in_list(["Section Break", "Column Break"], f.fieldtype) && f.label) { | ||||
fields.push(f); | fields.push(f); | ||||
} | } | ||||
@@ -612,7 +632,8 @@ frappe.PrintFormatBuilder = Class.extend({ | |||||
// add pages | // add pages | ||||
this.page.main.find(".print-format-builder-section").each(function() { | this.page.main.find(".print-format-builder-section").each(function() { | ||||
data.push({"fieldtype": "Section Break"}); | |||||
var section = {"fieldtype": "Section Break", 'label': $(this).attr('data-label') || '' }; | |||||
data.push(section); | |||||
$(this).find(".print-format-builder-column").each(function() { | $(this).find(".print-format-builder-column").each(function() { | ||||
data.push({"fieldtype": "Column Break"}); | data.push({"fieldtype": "Column Break"}); | ||||
$(this).find(".print-format-builder-field").each(function() { | $(this).find(".print-format-builder-field").each(function() { | ||||
@@ -656,7 +677,7 @@ frappe.PrintFormatBuilder = Class.extend({ | |||||
}, | }, | ||||
callback: function(r) { | callback: function(r) { | ||||
me.print_format = r.message; | me.print_format = r.message; | ||||
msgprint(__("Saved")); | |||||
frappe.show_alert({message: __("Saved"), indicator: 'green'}); | |||||
} | } | ||||
}); | }); | ||||
} | } | ||||
@@ -1,9 +1,10 @@ | |||||
<div class="print-format-builder-section row light-bg"> | |||||
<div class="print-format-builder-section row light-bg" data-label={{ section.label || "" }}> | |||||
<div class="print-format-builder-section-head"> | <div class="print-format-builder-section-head"> | ||||
<a class="section-settings pull-right | <a class="section-settings pull-right | ||||
btn-default btn-xs"> | btn-default btn-xs"> | ||||
<span class="octicon octicon-gear text-muted"></span></a> | <span class="octicon octicon-gear text-muted"></span></a> | ||||
<span class="octicon octicon-three-bars drag-handle"></span> | <span class="octicon octicon-three-bars drag-handle"></span> | ||||
<span class="section-label">{{ section.label || "" }}</span> | |||||
</div> | </div> | ||||
{% for(var j=0; j < section.columns.length; j++) { | {% for(var j=0; j < section.columns.length; j++) { | ||||
var column = section.columns[j]; %} | var column = section.columns[j]; %} | ||||
@@ -67,6 +67,9 @@ a.text-muted, | |||||
a.text-extra-muted { | a.text-extra-muted { | ||||
text-decoration: none; | text-decoration: none; | ||||
} | } | ||||
.underline { | |||||
text-decoration: underline; | |||||
} | |||||
/* the element that this class is applied to, should have a max width for this to work*/ | /* the element that this class is applied to, should have a max width for this to work*/ | ||||
.text-ellipsis, | .text-ellipsis, | ||||
.ellipsis { | .ellipsis { | ||||
@@ -81,8 +81,7 @@ frappe.ui.form.PrintPreview = Class.extend({ | |||||
var print_format = me.get_print_format(); | var print_format = me.get_print_format(); | ||||
if(print_format && print_format.name) { | if(print_format && print_format.name) { | ||||
if(print_format.print_format_builder) { | if(print_format.print_format_builder) { | ||||
frappe.route_options = {"doc": print_format, "make_new": false}; | |||||
frappe.set_route("print-format-builder"); | |||||
frappe.set_route("print-format-builder", print_format.name); | |||||
} else { | } else { | ||||
frappe.set_route("Form", "Print Format", print_format.name); | frappe.set_route("Form", "Print Format", print_format.name); | ||||
} | } | ||||
@@ -242,14 +242,25 @@ frappe.hide_progress = function() { | |||||
} | } | ||||
// Floating Message | // Floating Message | ||||
frappe.show_alert = function(txt, seconds) { | |||||
frappe.show_alert = function(message, seconds) { | |||||
if(typeof message==='string') { | |||||
message = { | |||||
message: message | |||||
} | |||||
} | |||||
if(!$('#dialog-container').length) { | if(!$('#dialog-container').length) { | ||||
$('<div id="dialog-container"><div id="alert-container"></div></div>').appendTo('body'); | $('<div id="dialog-container"><div id="alert-container"></div></div>').appendTo('body'); | ||||
} | } | ||||
if(message.indicator) { | |||||
message_html = '<span class="indicator ' + message.indicator + '">' + message.message + '</span>'; | |||||
} else { | |||||
message_html = message.message; | |||||
} | |||||
var div = $(repl('<div class="alert desk-alert" style="display: none;">' | var div = $(repl('<div class="alert desk-alert" style="display: none;">' | ||||
+ '<a class="close">×</a><span class="alert-message">%(txt)s</span>' | |||||
+ '</div>', {txt: txt})) | |||||
+ '<span class="alert-message">%(txt)s</span><a class="close">×</a>' | |||||
+ '</div>', {txt: message_html})) | |||||
.appendTo("#alert-container") | .appendTo("#alert-container") | ||||
.fadeIn(300); | .fadeIn(300); | ||||
@@ -77,6 +77,10 @@ a.text-muted, a.text-extra-muted { | |||||
text-decoration: none; | text-decoration: none; | ||||
} | } | ||||
.underline { | |||||
text-decoration: underline; | |||||
} | |||||
/* the element that this class is applied to, should have a max width for this to work*/ | /* the element that this class is applied to, should have a max width for this to work*/ | ||||
.text-ellipsis, | .text-ellipsis, | ||||
.ellipsis { | .ellipsis { | ||||
@@ -19,6 +19,13 @@ | |||||
{{ _("Cancel") }}</a> | {{ _("Cancel") }}</a> | ||||
<button type="submit" class="btn btn-primary btn-sm btn-form-submit"> | <button type="submit" class="btn btn-primary btn-sm btn-form-submit"> | ||||
{{ _("Save") }}</button> | {{ _("Save") }}</button> | ||||
{%- if allow_print %} | |||||
<div class='text-right' style='margin-top: 15px;'> | |||||
<a class='text-muted small' href='/print?doctype={{ doc.doctype}}&name={{ doc.name }}' target="_blank"> | |||||
<i class='icon icon-print'></i> {{ _("Print") }}</a> | |||||
</div> | |||||
{% endif -%} | |||||
{% elif is_list %} | {% elif is_list %} | ||||
<div style="padding-bottom: 15px;"> | <div style="padding-bottom: 15px;"> | ||||
<a href="/{{ pathname }}{{ delimeter }}new=1" class="btn btn-primary btn-new btn-sm"> | <a href="/{{ pathname }}{{ delimeter }}new=1" class="btn btn-primary btn-new btn-sm"> | ||||
@@ -22,12 +22,16 @@ | |||||
{% for section in page %} | {% for section in page %} | ||||
<div class="row section-break"> | <div class="row section-break"> | ||||
{% for column in section %} | |||||
<div class="col-xs-{{ (12 / section|len)|int }} column-break"> | |||||
{% for df in column %} | |||||
{%- if doc._line_breaks and loop.index != 1 -%}<hr>{%- endif -%} | |||||
{%- if doc._show_section_headings and section.label -%} | |||||
<h4 class='col-sm-12'>{{ section.label }}</h4> | |||||
{%- endif -%} | |||||
{% for column in section.columns %} | |||||
<div class="col-xs-{{ (12 / section.columns|len)|int }} column-break"> | |||||
{% for df in column.fields %} | |||||
{{ render_field(df, doc) }} | {{ render_field(df, doc) }} | ||||
{% endfor %} | {% endfor %} | ||||
</div> | |||||
</div> | |||||
{% endfor %} | {% endfor %} | ||||
</div> | </div> | ||||
{% endfor %} | {% endfor %} | ||||
@@ -54,13 +54,15 @@ data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}" | |||||
{%- macro render_field_with_label(df, doc) -%} | {%- macro render_field_with_label(df, doc) -%} | ||||
<div class="row {% if df.bold %}important{% endif %} data-field" {{ fieldmeta(df) }}> | <div class="row {% if df.bold %}important{% endif %} data-field" {{ fieldmeta(df) }}> | ||||
<div class="col-xs-5 text-right"> | |||||
<div class="col-xs-{{ "9" if df.fieldtype=="Check" else "5" }} | |||||
{%- if not doc._align_labels_left %} text-right{%- endif -%}"> | |||||
{% if df.fieldtype not in ("Image","HTML") and | {% if df.fieldtype not in ("Image","HTML") and | ||||
doc.get(df.fieldname) != None %} | doc.get(df.fieldname) != None %} | ||||
<label>{{ _(df.label) }}</label> | <label>{{ _(df.label) }}</label> | ||||
{% endif %} | {% endif %} | ||||
</div> | </div> | ||||
<div class="col-xs-7 {{ get_align_class(df.fieldtype) }} value"> | |||||
<div class="col-xs-{{ "3" if df.fieldtype=="Check" else "7" }} | |||||
{{ get_align_class(df.fieldtype) }} value"> | |||||
{% if doc.get(df.fieldname) != None -%} | {% if doc.get(df.fieldname) != None -%} | ||||
{{ print_value(df, doc) }}{% endif %} | {{ print_value(df, doc) }}{% endif %} | ||||
</div> | </div> | ||||
@@ -105,7 +107,7 @@ data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}" | |||||
{%- endmacro %} | {%- endmacro %} | ||||
{% macro get_align_class(fieldtype) %} | {% macro get_align_class(fieldtype) %} | ||||
{%- if fieldtype in ("Int", "Float", "Currency") -%}{{ "text-right" }} | |||||
{%- if fieldtype in ("Int", "Float", "Currency", "Check") -%}{{ "text-right" }} | |||||
{%- else -%}{{ "" }} | {%- else -%}{{ "" }} | ||||
{%- endif -%} | {%- endif -%} | ||||
{% endmacro %} | {% endmacro %} | ||||
@@ -10,6 +10,7 @@ | |||||
"doctype": "DocType", | "doctype": "DocType", | ||||
"document_type": "Document", | "document_type": "Document", | ||||
"editable_grid": 0, | "editable_grid": 0, | ||||
"engine": "InnoDB", | |||||
"fields": [ | "fields": [ | ||||
{ | { | ||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
@@ -294,6 +295,32 @@ | |||||
"set_only_once": 0, | "set_only_once": 0, | ||||
"unique": 0 | "unique": 0 | ||||
}, | }, | ||||
{ | |||||
"allow_on_submit": 0, | |||||
"bold": 0, | |||||
"collapsible": 0, | |||||
"columns": 0, | |||||
"fieldname": "allow_print", | |||||
"fieldtype": "Check", | |||||
"hidden": 0, | |||||
"ignore_user_permissions": 0, | |||||
"ignore_xss_filter": 0, | |||||
"in_filter": 0, | |||||
"in_list_view": 0, | |||||
"label": "Allow Print", | |||||
"length": 0, | |||||
"no_copy": 0, | |||||
"permlevel": 0, | |||||
"precision": "", | |||||
"print_hide": 0, | |||||
"print_hide_if_no_value": 0, | |||||
"read_only": 0, | |||||
"report_hide": 0, | |||||
"reqd": 0, | |||||
"search_index": 0, | |||||
"set_only_once": 0, | |||||
"unique": 0 | |||||
}, | |||||
{ | { | ||||
"allow_on_submit": 0, | "allow_on_submit": 0, | ||||
"bold": 0, | "bold": 0, | ||||
@@ -914,7 +941,7 @@ | |||||
"issingle": 0, | "issingle": 0, | ||||
"istable": 0, | "istable": 0, | ||||
"max_attachments": 0, | "max_attachments": 0, | ||||
"modified": "2016-09-30 07:55:47.895642", | |||||
"modified": "2016-10-10 05:03:19.428894", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"module": "Website", | "module": "Website", | ||||
"name": "Web Form", | "name": "Web Form", | ||||
@@ -931,6 +958,7 @@ | |||||
"export": 0, | "export": 0, | ||||
"if_owner": 0, | "if_owner": 0, | ||||
"import": 0, | "import": 0, | ||||
"is_custom": 0, | |||||
"permlevel": 0, | "permlevel": 0, | ||||
"print": 0, | "print": 0, | ||||
"read": 1, | "read": 1, | ||||
@@ -96,6 +96,10 @@ def get_html(doc, name=None, print_format=None, meta=None, | |||||
# determine template | # determine template | ||||
if print_format: | if print_format: | ||||
doc._show_section_headings = print_format.show_section_headings | |||||
doc._line_breaks = print_format.line_breaks | |||||
doc._align_labels_left = print_format.align_labels_left | |||||
if print_format.format_data: | if print_format.format_data: | ||||
# set format data | # set format data | ||||
format_data = json.loads(print_format.format_data) | format_data = json.loads(print_format.format_data) | ||||
@@ -226,6 +230,8 @@ def make_layout(doc, meta, format_data=None): | |||||
doc.print_heading_template = format_data[0].get("options") | doc.print_heading_template = format_data[0].get("options") | ||||
format_data = format_data[1:] | format_data = format_data[1:] | ||||
def get_new_section(): return {'columns': [{'fields': []}], 'has_data': False} | |||||
for df in format_data or meta.fields: | for df in format_data or meta.fields: | ||||
if format_data: | if format_data: | ||||
# embellish df with original properties | # embellish df with original properties | ||||
@@ -240,20 +246,32 @@ def make_layout(doc, meta, format_data=None): | |||||
df.print_hide = 0 | df.print_hide = 0 | ||||
if df.fieldtype=="Section Break" or page==[]: | if df.fieldtype=="Section Break" or page==[]: | ||||
if len(page) > 1 and not any(page[-1]): | |||||
# truncate prev section if empty | |||||
del page[-1] | |||||
if len(page) > 1: | |||||
if page[-1]['has_data']==False: | |||||
# truncate last section if empty | |||||
del page[-1] | |||||
elif page[-1]['columns'][-1]['fields']==[]: | |||||
# truncate last column in empty | |||||
del page[-1]['columns'][-1] | |||||
page.append([]) | |||||
section = get_new_section() | |||||
if df.fieldtype=='Section Break' and df.label: | |||||
section['label'] = df.label | |||||
if df.fieldtype=="Column Break" or (page[-1]==[] and df.fieldtype!="Section Break"): | |||||
page[-1].append([]) | |||||
page.append(section) | |||||
if df.fieldtype=="Column Break" and page[-1]['columns'][-1]['fields'] != []: | |||||
# if last column break and last column is not empty | |||||
page[-1]['columns'].append({'fields': []}) | |||||
if df.fieldtype=="HTML" and df.options: | if df.fieldtype=="HTML" and df.options: | ||||
doc.set(df.fieldname, True) # show this field | doc.set(df.fieldname, True) # show this field | ||||
if is_visible(df, doc) and has_value(df, doc): | if is_visible(df, doc) and has_value(df, doc): | ||||
page[-1][-1].append(df) | |||||
page[-1]['columns'][-1]['fields'].append(df) | |||||
# section has fields | |||||
page[-1]['has_data'] = True | |||||
# if table, add the row info in the field | # if table, add the row info in the field | ||||
# if a page break is found, create a new docfield | # if a page break is found, create a new docfield | ||||
@@ -267,7 +285,7 @@ def make_layout(doc, meta, format_data=None): | |||||
df.end = i | df.end = i | ||||
# new page, with empty section and column | # new page, with empty section and column | ||||
page = [[[]]] | |||||
page = [get_new_section()] | |||||
layout.append(page) | layout.append(page) | ||||
# continue the table in a new page | # continue the table in a new page | ||||