瀏覽代碼

fix: RTL for print views

version-14
Suraj Shetty 4 年之前
父節點
當前提交
6960a19208
共有 5 個檔案被更改,包括 11 行新增12 行删除
  1. +3
    -8
      frappe/printing/page/print/print.js
  2. +1
    -1
      frappe/public/html/print_template.html
  3. +3
    -1
      frappe/public/js/frappe/views/reports/query_report.js
  4. +1
    -1
      frappe/www/printview.html
  5. +3
    -1
      frappe/www/printview.py

+ 3
- 8
frappe/printing/page/print/print.js 查看文件

@@ -409,19 +409,14 @@ frappe.ui.form.PrintView = class {
setup_print_format_dom(out, $print_format) {
this.print_wrapper.find('.print-format-skeleton').remove();
let base_url = frappe.urllib.get_base_url();
let print_css = frappe.assets.bundled_asset('print.bundle.css');
let print_css = frappe.assets.bundled_asset('print.bundle.css', frappe.utils.is_rtl(this.lang_code));
this.$print_format_body.find('html').attr('dir', frappe.utils.is_rtl(this.lang_code) ? 'rtl': 'ltr');
this.$print_format_body.find('html').attr('lang', this.lang_code);
this.$print_format_body.find('head').html(
`<style type="text/css">${out.style}</style>
<link href="${base_url}${print_css}" rel="stylesheet">`
);

if (frappe.utils.is_rtl(this.lang_code)) {
let rtl_css = frappe.assets.bundled_asset('frappe-rtl.bundle.css');
this.$print_format_body.find('head').append(
`<link type="text/css" rel="stylesheet" href="${base_url}${rtl_css}"></link>`
);
}

this.$print_format_body.find('body').html(
`<div class="print-format print-format-preview">${out.html}</div>`
);


+ 1
- 1
frappe/public/html/print_template.html 查看文件

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" dir="{{ layout_direction }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">


+ 3
- 1
frappe/public/js/frappe/views/reports/query_report.js 查看文件

@@ -1264,7 +1264,9 @@ frappe.views.QueryReport = class QueryReport extends frappe.views.BaseList {
print_css: print_css,
print_settings: print_settings,
landscape: landscape,
columns: columns
columns: columns,
lang: frappe.boot.lang,
layout_direction: frappe.utils.is_rtl() ? "rtl" : "ltr"
});

frappe.render_pdf(html, print_settings);


+ 1
- 1
frappe/www/printview.html 查看文件

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="{{ lang }}" dir="{{ layout_direction }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">


+ 3
- 1
frappe/www/printview.py 查看文件

@@ -7,6 +7,7 @@ from frappe import _
from frappe.modules import get_doc_path
from frappe.core.doctype.access_log.access_log import make_access_log
from frappe.utils import cint, sanitize_html, strip_html
from frappe.utils.jinja_globals import is_rtl

no_cache = 1

@@ -44,7 +45,8 @@ def get_context(context):
"css": get_print_style(frappe.form_dict.style, print_format),
"comment": frappe.session.user,
"title": doc.get(meta.title_field) if meta.title_field else doc.name,
"has_rtl": True if frappe.local.lang in ["ar", "he", "fa", "ps"] else False
"lang": frappe.local.lang,
"layout_direction": "rtl" if is_rtl() else "ltr"
}

def get_print_format_doc(print_format_name, meta):


Loading…
取消
儲存