diff --git a/frappe/app.py b/frappe/app.py
index 84df9e7a0b..6884aa26fa 100644
--- a/frappe/app.py
+++ b/frappe/app.py
@@ -178,7 +178,8 @@ def handle_exception(e):
make_error_snapshot(e)
if return_as_message:
- response = frappe.website.render.render("message", http_status_code=http_status_code)
+ response = frappe.website.render.render("message",
+ http_status_code=http_status_code)
return response
diff --git a/frappe/config/setup.py b/frappe/config/setup.py
index cd2f58fcc4..55ed2dbd9e 100644
--- a/frappe/config/setup.py
+++ b/frappe/config/setup.py
@@ -124,7 +124,7 @@ def get_data():
{
"type": "doctype",
"name": "Deleted Document",
- "label": _("Deleted Documents"),
+ "label": _("Deleted Documents"),
"description": _("Restore or permanently delete a document.")
},
]
@@ -180,6 +180,11 @@ def get_data():
"name": "Print Format",
"description": _("Customized HTML Templates for printing transactions.")
},
+ {
+ "type": "doctype",
+ "name": "Print Style",
+ "description": _("Stylesheets for Print Formats")
+ },
]
},
{
diff --git a/frappe/desk/page/setup_wizard/setup_wizard.css b/frappe/desk/page/setup_wizard/setup_wizard.css
index 5313a6b4bc..f61ea87863 100644
--- a/frappe/desk/page/setup_wizard/setup_wizard.css
+++ b/frappe/desk/page/setup_wizard/setup_wizard.css
@@ -8,13 +8,9 @@
}
@media (min-width: 768px) {
- .setup-wizard-slide.single-column {
+ .setup-wizard-slide {
max-width: 500px;
}
-
- .setup-wizard-slide.two-column {
- max-width: 768px;
- }
}
.setup-wizard-slide .lead {
@@ -45,7 +41,7 @@
}
.setup-wizard-slide.with-form {
- margin: 30px auto;
+ margin: 60px auto;
padding: 10px 50px;
border: 1px solid #d1d8dd;
box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.1);
@@ -145,7 +141,6 @@
cursor: pointer;
}
-
.setup-wizard-message-image {
margin: 15px auto;
}
diff --git a/frappe/model/sync.py b/frappe/model/sync.py
index 72e80a9ecc..9c80a946a1 100644
--- a/frappe/model/sync.py
+++ b/frappe/model/sync.py
@@ -56,8 +56,9 @@ def sync_for(app_name, force=0, sync_everything = False, verbose=False, reset_pe
def get_doc_files(files, start_path, force=0, sync_everything = False, verbose=False):
"""walk and sync all doctypes and pages"""
- document_type = ['doctype', 'page', 'report', 'print_format', 'website_theme', 'web_form', 'email_alert']
- for doctype in document_type:
+ document_types = ['doctype', 'page', 'report', 'print_format',
+ 'website_theme', 'web_form', 'email_alert', 'print_style']
+ for doctype in document_types:
doctype_path = os.path.join(start_path, doctype)
if os.path.exists(doctype_path):
diff --git a/frappe/modules/import_file.py b/frappe/modules/import_file.py
index 9a2c080d9b..ade3614c8e 100644
--- a/frappe/modules/import_file.py
+++ b/frappe/modules/import_file.py
@@ -87,7 +87,8 @@ def read_doc_from_file(path):
ignore_values = {
"Report": ["disabled"],
"Print Format": ["disabled"],
- "Email Alert": ["enabled"]
+ "Email Alert": ["enabled"],
+ "Print Style": ["disabled"]
}
ignore_doctypes = [""]
diff --git a/frappe/modules/utils.py b/frappe/modules/utils.py
index 79933a60a5..9e43a28c6f 100644
--- a/frappe/modules/utils.py
+++ b/frappe/modules/utils.py
@@ -10,8 +10,9 @@ import frappe.utils
from frappe import _
lower_case_files_for = ['DocType', 'Page', 'Report',
- "Workflow", 'Module Def', 'Desktop Item', 'Workflow State', 'Workflow Action', 'Print Format',
- "Website Theme", 'Web Form', 'Email Alert']
+ "Workflow", 'Module Def', 'Desktop Item', 'Workflow State',
+ 'Workflow Action', 'Print Format', "Website Theme", 'Web Form',
+ 'Email Alert', 'Print Style']
def export_module_json(doc, is_standard, module):
"""Make a folder for the given doc and add its json file (make it a standard
diff --git a/frappe/printing/doctype/print_format/test_print_format.py b/frappe/printing/doctype/print_format/test_print_format.py
index a32070e97b..e8375ae5e7 100644
--- a/frappe/printing/doctype/print_format/test_print_format.py
+++ b/frappe/printing/doctype/print_format/test_print_format.py
@@ -23,8 +23,8 @@ class TestPrintFormat(unittest.TestCase):
def test_print_user_modern(self):
print_html = self.test_print_user("Modern")
- self.assertTrue("/* modern format: don't remove this line */" in print_html)
+ self.assertTrue("/* modern format: for-test */" in print_html)
def test_print_user_classic(self):
print_html = self.test_print_user("Classic")
- self.assertTrue("font-family: serif;" in print_html)
+ self.assertTrue("/* classic format: for-test */" in print_html)
diff --git a/frappe/printing/doctype/print_settings/print_settings.js b/frappe/printing/doctype/print_settings/print_settings.js
index 5840c6930d..ef552e6d30 100644
--- a/frappe/printing/doctype/print_settings/print_settings.js
+++ b/frappe/printing/doctype/print_settings/print_settings.js
@@ -2,8 +2,15 @@
// For license information, please see license.txt
frappe.ui.form.on("Print Settings", "print_style", function (frm) {
- frm.get_field("print_style_preview").html('');
+ frappe.db.get_value('Print Style', frm.doc.print_style, 'preview').then((r) => {
+ if(r.message.preview) {
+ frm.get_field("print_style_preview").$wrapper.html(
+ `
`);
+ } else {
+ frm.get_field("print_style_preview").$wrapper.html(
+ `
${__("No Preview")}
`); + } + }); }); frappe.ui.form.on("Print Settings", "onload", function (frm) { diff --git a/frappe/printing/doctype/print_settings/print_settings.json b/frappe/printing/doctype/print_settings/print_settings.json index b191ac663a..7e1bfa6861 100644 --- a/frappe/printing/doctype/print_settings/print_settings.json +++ b/frappe/printing/doctype/print_settings/print_settings.json @@ -177,6 +177,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, + "label": "Page Settings", "length": 0, "no_copy": 0, "permlevel": 0, @@ -199,7 +200,7 @@ "columns": 0, "default": "1", "description": "", - "fieldname": "attach_view_link", + "fieldname": "with_letterhead", "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, @@ -208,11 +209,10 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Send document web view link in email", + "label": "Print with letterhead", "length": 0, "no_copy": 0, "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -229,8 +229,10 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "print_style_section", - "fieldtype": "Section Break", + "default": "1", + "description": "", + "fieldname": "allow_print_for_draft", + "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -238,10 +240,11 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Print Style", + "label": "Allow Print for Draft", "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -258,21 +261,22 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "Modern", - "fieldname": "print_style", - "fieldtype": "Select", + "default": "1", + "description": "", + "fieldname": "attach_view_link", + "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_global_search": 0, - "in_list_view": 1, + "in_list_view": 0, "in_standard_filter": 0, - "label": "Print Style", + "label": "Send document web view link in email", "length": 0, "no_copy": 0, - "options": "Modern\nClassic\nStandard\nMonochrome", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -289,9 +293,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "Default", - "fieldname": "font", - "fieldtype": "Select", + "fieldname": "column_break_10", + "fieldtype": "Column Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -299,10 +302,8 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Font", "length": 0, "no_copy": 0, - "options": "Default\nArial\nHelvetica\nVerdana\nMonospace", "permlevel": 0, "precision": "", "print_hide": 0, @@ -321,9 +322,9 @@ "bold": 0, "collapsible": 0, "columns": 0, - "description": "In points. Default is 9.", - "fieldname": "font_size", - "fieldtype": "Float", + "default": "1", + "fieldname": "add_draft_heading", + "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -331,10 +332,11 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Font Size", + "label": "Always add \"Draft\" Heading for printing draft documents", "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -351,8 +353,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "column_break_6", - "fieldtype": "Column Break", + "fieldname": "allow_page_break_inside_tables", + "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -360,9 +362,11 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, + "label": "Allow page break inside tables", "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -379,9 +383,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "1", "description": "", - "fieldname": "with_letterhead", + "fieldname": "allow_print_for_cancelled", "fieldtype": "Check", "hidden": 0, "ignore_user_permissions": 0, @@ -390,10 +393,11 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Print with letterhead", + "label": "Allow Print for Cancelled", "length": 0, "no_copy": 0, "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -410,10 +414,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "1", - "description": "", - "fieldname": "allow_print_for_draft", - "fieldtype": "Check", + "fieldname": "print_style_section", + "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -421,11 +423,10 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Allow Print for Draft", + "label": "Print Style", "length": 0, "no_copy": 0, "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -442,21 +443,21 @@ "bold": 0, "collapsible": 0, "columns": 0, - "default": "1", - "fieldname": "add_draft_heading", - "fieldtype": "Check", + "default": "Modern", + "fieldname": "print_style", + "fieldtype": "Link", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, "in_filter": 0, "in_global_search": 0, - "in_list_view": 0, + "in_list_view": 1, "in_standard_filter": 0, - "label": "Always add \"Draft\" Heading for printing draft documents", + "label": "Print Style", "length": 0, "no_copy": 0, + "options": "Print Style", "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -473,9 +474,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "description": "", - "fieldname": "allow_print_for_cancelled", - "fieldtype": "Check", + "fieldname": "print_style_preview", + "fieldtype": "HTML", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -483,11 +483,10 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Allow Print for Cancelled", + "label": "Print Style Preview", "length": 0, "no_copy": 0, "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -504,8 +503,8 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "allow_page_break_inside_tables", - "fieldtype": "Check", + "fieldname": "section_break_8", + "fieldtype": "Section Break", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -513,11 +512,10 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Allow page break inside tables", + "label": "Fonts", "length": 0, "no_copy": 0, "permlevel": 0, - "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -534,8 +532,9 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "section_break_8", - "fieldtype": "Section Break", + "default": "Default", + "fieldname": "font", + "fieldtype": "Select", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -543,9 +542,12 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, + "label": "Font", "length": 0, "no_copy": 0, + "options": "Default\nArial\nHelvetica\nVerdana\nMonospace", "permlevel": 0, + "precision": "", "print_hide": 0, "print_hide_if_no_value": 0, "read_only": 0, @@ -562,8 +564,9 @@ "bold": 0, "collapsible": 0, "columns": 0, - "fieldname": "print_style_preview", - "fieldtype": "HTML", + "description": "In points. Default is 9.", + "fieldname": "font_size", + "fieldtype": "Float", "hidden": 0, "ignore_user_permissions": 0, "ignore_xss_filter": 0, @@ -571,7 +574,7 @@ "in_global_search": 0, "in_list_view": 0, "in_standard_filter": 0, - "label": "Print Style Preview", + "label": "Font Size", "length": 0, "no_copy": 0, "permlevel": 0, @@ -597,7 +600,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2017-05-03 05:58:55.562540", + "modified": "2017-08-18 01:04:26.692081", "modified_by": "Administrator", "module": "Printing", "name": "Print Settings", diff --git a/frappe/printing/doctype/print_settings/test_print_settings.js b/frappe/printing/doctype/print_settings/test_print_settings.js new file mode 100644 index 0000000000..af61095e97 --- /dev/null +++ b/frappe/printing/doctype/print_settings/test_print_settings.js @@ -0,0 +1,23 @@ +/* eslint-disable */ +// rename this file from _test_[name] to test_[name] to activate +// and remove above this line + +QUnit.test("test: Print Settings", function (assert) { + let done = assert.async(); + + // number of asserts + assert.expect(1); + + frappe.run_serially([ + // insert a new Print Settings + () => frappe.tests.make('Print Settings', [ + // values to be set + {key: 'value'} + ]), + () => { + assert.equal(cur_frm.doc.key, 'value'); + }, + () => done() + ]); + +}); diff --git a/frappe/printing/doctype/print_style/__init__.py b/frappe/printing/doctype/print_style/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/printing/doctype/print_style/print_style.js b/frappe/printing/doctype/print_style/print_style.js new file mode 100644 index 0000000000..44c4a528f4 --- /dev/null +++ b/frappe/printing/doctype/print_style/print_style.js @@ -0,0 +1,10 @@ +// Copyright (c) 2017, Frappe Technologies and contributors +// For license information, please see license.txt + +frappe.ui.form.on('Print Style', { + refresh: function(frm) { + frm.add_custom_button(__('Print Settings'), () => { + frappe.set_route('Form', 'Print Settings'); + }) + } +}); diff --git a/frappe/printing/doctype/print_style/print_style.json b/frappe/printing/doctype/print_style/print_style.json new file mode 100644 index 0000000000..29e88a460a --- /dev/null +++ b/frappe/printing/doctype/print_style/print_style.json @@ -0,0 +1,214 @@ +{ + "allow_copy": 0, + "allow_guest_to_view": 0, + "allow_import": 0, + "allow_rename": 1, + "autoname": "field:print_style_name", + "beta": 0, + "creation": "2017-08-17 01:25:56.910716", + "custom": 0, + "docstatus": 0, + "doctype": "DocType", + "document_type": "", + "editable_grid": 1, + "engine": "InnoDB", + "fields": [ + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "print_style_name", + "fieldtype": "Data", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Print Style Name", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "disabled", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 1, + "in_standard_filter": 0, + "label": "Disabled", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "standard", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Standard", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "css", + "fieldtype": "Code", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "CSS", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 1, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_bulk_edit": 0, + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "columns": 0, + "fieldname": "preview", + "fieldtype": "Attach Image", + "hidden": 1, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_global_search": 0, + "in_list_view": 0, + "in_standard_filter": 0, + "label": "Preview", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "remember_last_selected_value": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + } + ], + "has_web_view": 0, + "hide_heading": 0, + "hide_toolbar": 0, + "idx": 0, + "image_field": "preview", + "image_view": 0, + "in_create": 0, + "is_submittable": 0, + "issingle": 0, + "istable": 0, + "max_attachments": 0, + "modified": "2017-08-17 02:18:08.132853", + "modified_by": "Administrator", + "module": "Printing", + "name": "Print Style", + "name_case": "", + "owner": "Administrator", + "permissions": [ + { + "amend": 0, + "apply_user_permissions": 0, + "cancel": 0, + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "if_owner": 0, + "import": 0, + "permlevel": 0, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "set_user_permissions": 0, + "share": 1, + "submit": 0, + "write": 1 + } + ], + "quick_entry": 0, + "read_only": 0, + "read_only_onload": 0, + "show_name_in_global_search": 0, + "sort_field": "modified", + "sort_order": "DESC", + "track_changes": 1, + "track_seen": 0 +} \ No newline at end of file diff --git a/frappe/printing/doctype/print_style/print_style.py b/frappe/printing/doctype/print_style/print_style.py new file mode 100644 index 0000000000..310babd5df --- /dev/null +++ b/frappe/printing/doctype/print_style/print_style.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2017, Frappe Technologies and contributors +# For license information, please see license.txt + +from __future__ import unicode_literals +import frappe +from frappe.model.document import Document + +class PrintStyle(Document): + def validate(self): + if (self.standard==1 + and not frappe.local.conf.get("developer_mode") + and not (frappe.flags.in_import or frappe.flags.in_test)): + + frappe.throw(frappe._("Standard Print Style cannot be changed. Please duplicate to edit.")) + + def on_update(self): + self.export_doc() + + def export_doc(self): + # export + from frappe.modules.utils import export_module_json + export_module_json(self, self.standard == 1, 'Printing') diff --git a/frappe/printing/doctype/print_style/test_print_style.js b/frappe/printing/doctype/print_style/test_print_style.js new file mode 100644 index 0000000000..d676a0c831 --- /dev/null +++ b/frappe/printing/doctype/print_style/test_print_style.js @@ -0,0 +1,20 @@ +/* eslint-disable */ +// rename this file from _test_[name] to test_[name] to activate +// and remove above this line + +QUnit.test("test: Print Style", function (assert) { + let done = assert.async(); + + // number of asserts + assert.expect(1); + + frappe.run_serially([ + // insert a new Print Style + () => frappe.tests.make('Print Style', [ + // values to be set + {print_style_name: 'Test Print Style'}, + {css: '/* some css value */'} + ]), + ]); + +}); diff --git a/frappe/printing/doctype/print_style/test_print_style.py b/frappe/printing/doctype/print_style/test_print_style.py new file mode 100644 index 0000000000..cee57f8826 --- /dev/null +++ b/frappe/printing/doctype/print_style/test_print_style.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +# Copyright (c) 2017, Frappe Technologies and Contributors +# See license.txt +from __future__ import unicode_literals + +import frappe +import unittest + +class TestPrintStyle(unittest.TestCase): + pass diff --git a/frappe/printing/print_style/__init__.py b/frappe/printing/print_style/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/printing/print_style/classic/__init__.py b/frappe/printing/print_style/classic/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/printing/print_style/classic/classic.json b/frappe/printing/print_style/classic/classic.json new file mode 100644 index 0000000000..1ad609a498 --- /dev/null +++ b/frappe/printing/print_style/classic/classic.json @@ -0,0 +1,15 @@ +{ + "creation": "2017-08-17 02:00:12.502887", + "css": "/*\n\tcommon style for whole page\n\tThis should include:\n\t+ page size related settings\n\t+ font family settings\n\t+ line spacing settings\n*/\n.print-format div,\n.print-format span,\n.print-format td,\n.print-format h1,\n.print-format h2,\n.print-format h3,\n.print-format h4 {\n\tfont-family: Georgia, serif;\n}\n\n/* classic format: for-test */", + "disabled": 0, + "docstatus": 0, + "doctype": "Print Style", + "idx": 1, + "modified": "2017-08-18 00:43:48.675833", + "modified_by": "Administrator", + "name": "Classic", + "owner": "Administrator", + "preview": "/assets/frappe/images/help/print-style-classic.png", + "print_style_name": "Classic", + "standard": 1 +} \ No newline at end of file diff --git a/frappe/printing/print_style/modern/__init__.py b/frappe/printing/print_style/modern/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/printing/print_style/modern/modern.json b/frappe/printing/print_style/modern/modern.json new file mode 100644 index 0000000000..2d79ab6e62 --- /dev/null +++ b/frappe/printing/print_style/modern/modern.json @@ -0,0 +1,15 @@ +{ + "creation": "2017-08-17 02:16:58.060374", + "css": ".print-heading {\n\ttext-align: right;\n\ttext-transform: uppercase;\n\tcolor: #666;\n\tpadding-bottom: 20px;\n\tmargin-bottom: 20px;\n\tborder-bottom: 1px solid #d1d8dd;\n}\n\n.print-heading h2 {\n\tfont-size: 24px;\n}\n\n.print-format th {\n\tbackground-color: #eee !important;\n\tborder-bottom: 0px !important;\n}\n\n/* modern format: for-test */", + "disabled": 0, + "docstatus": 0, + "doctype": "Print Style", + "idx": 0, + "modified": "2017-08-18 00:44:07.438147", + "modified_by": "Administrator", + "name": "Modern", + "owner": "Administrator", + "preview": "/assets/frappe/images/help/print-style-modern.png", + "print_style_name": "Modern", + "standard": 1 +} \ No newline at end of file diff --git a/frappe/printing/print_style/monochrome/__init__.py b/frappe/printing/print_style/monochrome/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/frappe/printing/print_style/monochrome/monochrome.json b/frappe/printing/print_style/monochrome/monochrome.json new file mode 100644 index 0000000000..eb75bc7211 --- /dev/null +++ b/frappe/printing/print_style/monochrome/monochrome.json @@ -0,0 +1,15 @@ +{ + "creation": "2017-08-17 02:16:20.992989", + "css": ".print-format * {\n\tcolor: #000 !important;\n}\n\n.print-format .alert {\n\tbackground-color: inherit;\n\tborder: 1px dashed #333;\n}\n\n.print-format .table-bordered,\n.print-format .table-bordered > thead > tr > th,\n.print-format .table-bordered > tbody > tr > th,\n.print-format .table-bordered > tfoot > tr > th,\n.print-format .table-bordered > thead > tr > td,\n.print-format .table-bordered > tbody > tr > td,\n.print-format .table-bordered > tfoot > tr > td {\n\tborder: 1px solid #333;\n}\n\n.print-format hr {\n\tborder-top: 1px solid #333;\n}\n\n.print-heading {\n\tborder-bottom: 2px solid #333;\n}\n", + "disabled": 0, + "docstatus": 0, + "doctype": "Print Style", + "idx": 0, + "modified": "2017-08-18 00:44:25.023898", + "modified_by": "Administrator", + "name": "Monochrome", + "owner": "Administrator", + "preview": "/assets/frappe/images/help/print-style-monochrome.png", + "print_style_name": "Monochrome", + "standard": 1 +} \ No newline at end of file diff --git a/frappe/public/css/form.css b/frappe/public/css/form.css index 00674934af..453266c2e0 100644 --- a/frappe/public/css/form.css +++ b/frappe/public/css/form.css @@ -11,6 +11,12 @@ padding: 10px 0px; border-bottom: 1px solid #d1d8dd; } +.print-toolbar > div { + padding-right: 0px; +} +.print-toolbar > div:last-child { + padding-right: 15px; +} .form-inner-toolbar { padding: 10px 15px 0px; background-color: #fafbfc; @@ -588,7 +594,8 @@ select.form-control { .password-strength-message { margin-top: -10px; } -.control-code { +.control-code, +.control-code.bold { height: 400px; font-family: Monaco, "Courier New", monospace; background-color: black; diff --git a/frappe/public/js/frappe/desk.js b/frappe/public/js/frappe/desk.js index 7c15d260bd..12aa52d39a 100644 --- a/frappe/public/js/frappe/desk.js +++ b/frappe/public/js/frappe/desk.js @@ -202,7 +202,7 @@ frappe.Application = Class.extend({ moment.tz.add(frappe.boot.timezone_info); } if(frappe.boot.print_css) { - frappe.dom.set_style(frappe.boot.print_css) + frappe.dom.set_style(frappe.boot.print_css, "print-style"); } frappe.user.name = frappe.boot.user.name; } else { diff --git a/frappe/public/js/frappe/dom.js b/frappe/public/js/frappe/dom.js index f3727ae16f..0a3890df29 100644 --- a/frappe/public/js/frappe/dom.js +++ b/frappe/public/js/frappe/dom.js @@ -93,6 +93,7 @@ frappe.dom = { se.appendChild(document.createTextNode(txt)); } document.getElementsByTagName('head')[0].appendChild(se); + return se; }, add: function(parent, newtag, className, cs, innerHTML, onclick) { if(parent && parent.substr)parent = frappe.dom.by_id(parent); diff --git a/frappe/public/js/frappe/form/print.js b/frappe/public/js/frappe/form/print.js index cc99eae370..da19c8bed8 100644 --- a/frappe/public/js/frappe/form/print.js +++ b/frappe/public/js/frappe/form/print.js @@ -35,7 +35,7 @@ frappe.ui.form.PrintPreview = Class.extend({ this.print_sel = this.wrapper .find(".print-preview-select") .on("change", function () { - me.multilingual_preview() + me.multilingual_preview(); }); //On selection of language get code and pass it to preview method @@ -79,7 +79,7 @@ frappe.ui.form.PrintPreview = Class.extend({ }); this.wrapper.find(".btn-print-edit").on("click", function () { - var print_format = me.get_print_format(); + let print_format = me.get_print_format(); if (print_format && print_format.name) { if (print_format.print_format_builder) { frappe.set_route("print-format-builder", print_format.name); @@ -106,7 +106,8 @@ frappe.ui.form.PrintPreview = Class.extend({ this.lang_code = this.frm.doc.language; // Load all languages in the field this.language_sel.empty() - .add_options(frappe.get_languages()) + .add_options([{value:'', label:__("Select Language...")}] + .concat(frappe.get_languages())) .val(this.lang_code); this.preview(); }, @@ -193,6 +194,7 @@ frappe.ui.form.PrintPreview = Class.extend({ this.print_formats = frappe.meta.get_print_formats(this.frm.doctype); return this.print_sel .empty().add_options(this.print_formats); + }, with_old_style: function (opts) { frappe.require("/assets/js/print_format_v3.min.js", function () { diff --git a/frappe/public/js/frappe/form/templates/print_layout.html b/frappe/public/js/frappe/form/templates/print_layout.html index eac092f390..bbdf415b17 100644 --- a/frappe/public/js/frappe/form/templates/print_layout.html +++ b/frappe/public/js/frappe/form/templates/print_layout.html @@ -3,7 +3,8 @@