[print-style] sync, fix tests and remove selection
This commit is contained in:
parent
595b4a88be
commit
7dedc69461
17 changed files with 647 additions and 638 deletions
|
|
@ -150,13 +150,13 @@ def handle_exception(e):
|
|||
elif http_status_code==403:
|
||||
frappe.respond_as_web_page(_("Not Permitted"),
|
||||
_("You do not have enough permissions to complete the action"),
|
||||
http_status_code=http_status_code, indicator_color='red', fullpage=True)
|
||||
http_status_code=http_status_code, indicator_color='red')
|
||||
return_as_message = True
|
||||
|
||||
elif http_status_code==404:
|
||||
frappe.respond_as_web_page(_("Not Found"),
|
||||
_("The resource you are looking for is not available"),
|
||||
http_status_code=http_status_code, indicator_color='red', fullpage=True)
|
||||
http_status_code=http_status_code, indicator_color='red')
|
||||
return_as_message = True
|
||||
|
||||
else:
|
||||
|
|
@ -166,7 +166,7 @@ def handle_exception(e):
|
|||
|
||||
frappe.respond_as_web_page("Server Error",
|
||||
traceback, http_status_code=http_status_code,
|
||||
indicator_color='red', fullpage=True)
|
||||
indicator_color='red')
|
||||
return_as_message = True
|
||||
|
||||
if e.__class__ == frappe.AuthenticationError:
|
||||
|
|
@ -179,7 +179,7 @@ def handle_exception(e):
|
|||
|
||||
if return_as_message:
|
||||
response = frappe.website.render.render("message",
|
||||
http_status_code=http_status_code, fullpage=True)
|
||||
http_status_code=http_status_code)
|
||||
|
||||
return response
|
||||
|
||||
|
|
|
|||
|
|
@ -236,8 +236,6 @@ def load_print(bootinfo, doclist):
|
|||
print_settings.doctype = ":Print Settings"
|
||||
doclist.append(print_settings)
|
||||
load_print_css(bootinfo, print_settings)
|
||||
doclist.extend(frappe.get_all('Print Style', 'name',
|
||||
dict(disabled=0), update=dict(doctype=':Print Style')))
|
||||
|
||||
def load_print_css(bootinfo, print_settings):
|
||||
import frappe.www.printview
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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('<img src="/assets/frappe/images/help/print-style-' +
|
||||
frm.doc.print_style.toLowerCase() + '.png" class="img-responsive">');
|
||||
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(
|
||||
`<img src="${r.message.preview}" class="img-responsive">`);
|
||||
} else {
|
||||
frm.get_field("print_style_preview").$wrapper.html(
|
||||
`<p style="margin: 60px 0px" class="text-center text-muted">${__("No Preview")}</p>`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
frappe.ui.form.on("Print Settings", "onload", function (frm) {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -3,6 +3,13 @@
|
|||
|
||||
frappe.ui.form.on('Print Style', {
|
||||
refresh: function(frm) {
|
||||
/* update in local */
|
||||
if (!frm.is_new() && !locals[':Print Style'][frm.doc.name]) {
|
||||
locals[':Print Style'][frm.doc.name] = frm.doc;
|
||||
}
|
||||
|
||||
frm.add_custom_button(__('Print Settings'), () => {
|
||||
frappe.set_route('Form', 'Print Settings');
|
||||
})
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -12,12 +12,9 @@ QUnit.test("test: Print Style", function (assert) {
|
|||
// insert a new Print Style
|
||||
() => frappe.tests.make('Print Style', [
|
||||
// values to be set
|
||||
{key: 'value'}
|
||||
{print_style_name: 'Test Print Style'},
|
||||
{css: '/* some css value */'}
|
||||
]),
|
||||
() => {
|
||||
assert.equal(cur_frm.doc.key, 'value');
|
||||
},
|
||||
() => done()
|
||||
]);
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,14 +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",
|
||||
"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-17 05:02:24.128436",
|
||||
"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
|
||||
}
|
||||
|
|
@ -1,14 +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: don't remove this line */",
|
||||
"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-17 05:02:05.043839",
|
||||
"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
|
||||
}
|
||||
|
|
@ -5,10 +5,11 @@
|
|||
"docstatus": 0,
|
||||
"doctype": "Print Style",
|
||||
"idx": 0,
|
||||
"modified": "2017-08-17 05:02:14.874082",
|
||||
"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
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -38,12 +38,6 @@ frappe.ui.form.PrintPreview = Class.extend({
|
|||
me.multilingual_preview();
|
||||
});
|
||||
|
||||
this.print_style_select = this.wrapper
|
||||
.find('.print-style-select')
|
||||
.on("change", function () {
|
||||
me.multilingual_preview();
|
||||
});
|
||||
|
||||
//On selection of language get code and pass it to preview method
|
||||
this.language_sel = this.wrapper
|
||||
.find(".languages")
|
||||
|
|
@ -70,13 +64,11 @@ frappe.ui.form.PrintPreview = Class.extend({
|
|||
|
||||
this.wrapper.find(".btn-download-pdf").click(function () {
|
||||
if (!me.is_old_style()) {
|
||||
let print_style = me.selected_style();
|
||||
var w = window.open(
|
||||
frappe.urllib.get_full_url("/api/method/frappe.utils.print_format.download_pdf?"
|
||||
+ "doctype=" + encodeURIComponent(me.frm.doc.doctype)
|
||||
+ "&name=" + encodeURIComponent(me.frm.doc.name)
|
||||
+ "&format=" + me.selected_format()
|
||||
+ (print_style ? '&style=' + print_style : '')
|
||||
+ "&no_letterhead=" + (me.with_letterhead() ? "0" : "1")
|
||||
+ (me.lang_code ? ("&_lang=" + me.lang_code) : ""))
|
||||
);
|
||||
|
|
@ -114,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();
|
||||
},
|
||||
|
|
@ -155,13 +148,11 @@ frappe.ui.form.PrintPreview = Class.extend({
|
|||
},
|
||||
new_page_preview: function (printit) {
|
||||
var me = this;
|
||||
let print_style = me.selected_style();
|
||||
var w = window.open(frappe.urllib.get_full_url("/printview?"
|
||||
+ "doctype=" + encodeURIComponent(me.frm.doc.doctype)
|
||||
+ "&name=" + encodeURIComponent(me.frm.doc.name)
|
||||
+ (printit ? "&trigger_print=1" : "")
|
||||
+ "&format=" + me.selected_format()
|
||||
+ (print_style ? '&style=' + print_style : '')
|
||||
+ "&no_letterhead=" + (me.with_letterhead() ? "0" : "1")
|
||||
+ (me.lang_code ? ("&_lang=" + me.lang_code) : "")));
|
||||
if (!w) {
|
||||
|
|
@ -174,7 +165,6 @@ frappe.ui.form.PrintPreview = Class.extend({
|
|||
args: {
|
||||
doc: this.frm.doc,
|
||||
print_format: this.selected_format(),
|
||||
style: this.selected_style(),
|
||||
no_letterhead: !this.with_letterhead() ? 1 : 0,
|
||||
_lang: this.lang_code
|
||||
},
|
||||
|
|
@ -202,8 +192,6 @@ frappe.ui.form.PrintPreview = Class.extend({
|
|||
},
|
||||
refresh_print_options: function () {
|
||||
this.print_formats = frappe.meta.get_print_formats(this.frm.doctype);
|
||||
this.print_style_select.empty()
|
||||
.add_options([''].concat(Object.keys(locals[':Print Style'] || {}).sort()));
|
||||
return this.print_sel
|
||||
.empty().add_options(this.print_formats);
|
||||
|
||||
|
|
@ -229,9 +217,6 @@ frappe.ui.form.PrintPreview = Class.extend({
|
|||
selected_format: function () {
|
||||
return this.print_sel.val() || this.frm.meta.default_print_format || "Standard";
|
||||
},
|
||||
selected_style: function () {
|
||||
return this.print_style_select.val() || '';
|
||||
},
|
||||
is_old_style: function (format) {
|
||||
return this.get_print_format(format).print_format_type === "Client";
|
||||
},
|
||||
|
|
@ -250,8 +235,6 @@ frappe.ui.form.PrintPreview = Class.extend({
|
|||
return this.print_letterhead.is(":checked") ? 1 : 0;
|
||||
},
|
||||
set_style: function (style) {
|
||||
$('#print-style').remove();
|
||||
console.log(style || frappe.boot.print_css);
|
||||
frappe.dom.set_style(style || frappe.boot.print_css, "print-style");
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -3,9 +3,8 @@
|
|||
<div class="col-xs-2">
|
||||
<select class="print-preview-select input-sm form-control"></select></div>
|
||||
<div class="col-xs-2">
|
||||
<select class="print-style-select input-sm form-control"></select></div>
|
||||
<div class="col-xs-2">
|
||||
<select class="languages input-sm form-control"></select></div>
|
||||
<select class="languages input-sm form-control"
|
||||
placeholder="{{ __("Language") }}"></select></div>
|
||||
<div class="col-xs-2">
|
||||
<div class="checkbox small" style="margin-top: 7px; margin-bottom: 0px;">
|
||||
<label>
|
||||
|
|
@ -13,13 +12,15 @@
|
|||
{%= __("Letter Head") %}</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-4 text-right">
|
||||
<div class="col-xs-6 text-right">
|
||||
<!-- <a class="close btn-print-close" style="margin-top: 2px; margin-left: 10px;">×</a> -->
|
||||
<div class="btn-group">
|
||||
<a class="btn-print-print btn-sm btn btn-default">
|
||||
<strong>{%= __("Print") %}</strong></a>
|
||||
<a class="btn-sm btn btn-default" href="#Form/Print Settings">
|
||||
{%= __("Settings...") %}</a>
|
||||
<a class="btn-print-edit btn-sm btn btn-default">
|
||||
{%= __("Customize") %}</a>
|
||||
{%= __("Customize...") %}</a>
|
||||
<a class="btn-print-preview btn-sm btn btn-default">
|
||||
{%= __("Full Page") %}</a>
|
||||
<a class="btn-download-pdf btn-sm btn btn-default">
|
||||
|
|
|
|||
|
|
@ -108,6 +108,10 @@ frappe.views.ListRenderer = Class.extend({
|
|||
add_field(this.meta.title_field);
|
||||
}
|
||||
|
||||
if (this.meta.image_field) {
|
||||
add_field(this.meta.image_field);
|
||||
}
|
||||
|
||||
// enabled / disabled
|
||||
if (frappe.meta.has_field(this.doctype, 'enabled')) { add_field('enabled'); }
|
||||
if (frappe.meta.has_field(this.doctype, 'disabled')) { add_field('disabled'); }
|
||||
|
|
|
|||
|
|
@ -61,8 +61,7 @@ data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}"
|
|||
|
||||
{%- macro render_field_with_label(df, doc) -%}
|
||||
<div class="row {% if df.bold %}important{% endif %} data-field" {{ fieldmeta(df) }}>
|
||||
<div class="col-xs-{{ "9" if df.fieldtype=="Check" else "5" }}
|
||||
{%- if not doc._align_labels_left %} text-right{%- endif -%}">
|
||||
<div class="col-xs-{{ "9" if df.fieldtype=="Check" else "5" }}">
|
||||
{% if df.fieldtype not in ("Image","HTML","Check") and
|
||||
doc.get(df.fieldname) != None %}
|
||||
<label>{{ _(df.label) }}</label>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue