瀏覽代碼

Merge branch 'hotfix'

version-14
Nabin Hait 8 年之前
父節點
當前提交
d3cfd0bbb4
共有 4 個檔案被更改,包括 33 行新增15 行删除
  1. +1
    -1
      frappe/__init__.py
  2. +21
    -8
      frappe/print/page/print_format_builder/print_format_builder.js
  3. +3
    -1
      frappe/print/page/print_format_builder/print_format_builder_field.html
  4. +8
    -5
      frappe/www/print.py

+ 1
- 1
frappe/__init__.py 查看文件

@@ -13,7 +13,7 @@ import os, sys, importlib, inspect, json
from .exceptions import *
from .utils.jinja import get_jenv, get_template, render_template

__version__ = '7.1.17'
__version__ = '7.1.18'
__title__ = "Frappe Framework"

local = Local()


+ 21
- 8
frappe/print/page/print_format_builder/print_format_builder.js 查看文件

@@ -31,6 +31,7 @@ frappe.PrintFormatBuilder = Class.extend({
this.refresh();
},
refresh: function() {
this.custom_html_count = 0;
if(!this.print_format) {
this.show_start();
} else {
@@ -203,7 +204,6 @@ frappe.PrintFormatBuilder = Class.extend({
prepare_data: function() {
this.print_heading_template = null;
this.data = JSON.parse(this.print_format.format_data || "[]");
this.fields_dict = {};
if(!this.data.length) {
// new layout
this.data = this.meta.fields;
@@ -224,7 +224,9 @@ frappe.PrintFormatBuilder = Class.extend({
}

this.layout_data = [];
var section = null, column = null, me = this;
this.fields_dict = {};
this.custom_html_dict = {};
var section = null, column = null, me = this, custom_html_count = 0;

// create a new placeholder for column and set
// it as "column"
@@ -251,7 +253,12 @@ frappe.PrintFormatBuilder = Class.extend({
// print_hide should always be false
if(f.fieldname==="_custom_html") {
f.label = "Custom HTML";
f.fieldtype = "Custom HTML"
f.fieldtype = "Custom HTML";

// set custom html id to map data properties later
custom_html_count++;
f.custom_html_id = custom_html_count;
me.custom_html_dict[f.custom_html_id] = f
} else {
f = $.extend(frappe.meta.get_docfield(me.print_format.doc_type,
f.fieldname) || {}, f);
@@ -480,11 +487,17 @@ frappe.PrintFormatBuilder = Class.extend({
});
},
setup_html_data: function() {
// set `data` for Custom HTML fields
// set JQuery `data` for Custom HTML fields, since editing the HTML
// directly causes problem becuase of HTML reformatting
//
// this is based on a dummy attribute custom_html_id, since all custom html
// fields have the same fieldname `_custom_html`
var me = this;
this.page.main.find('[data-fieldtype="Custom HTML"]').each(function() {
$(this).find('.html-content')
.data('content', me.fields_dict[$(this).attr('data-fieldname')].options);
var fieldname = $(this).attr('data-fieldname');
var content = $($(this).find('.html-content')[0]);
var html = me.custom_html_dict[parseInt(content.attr('data-custom-html-id'))].options;
content.data('content', html);
})
},
update_columns_in_section: function(section, no_of_columns, new_no_of_columns) {
@@ -682,7 +695,7 @@ frappe.PrintFormatBuilder = Class.extend({
d.set_input("content", content);

d.set_primary_action(__("Update"), function() {
$content.data('content', d.get_value("content"));
$($content[0]).data('content', d.get_value("content"));
$content.html(d.get_value("content"));
d.hide();
});
@@ -744,7 +757,7 @@ frappe.PrintFormatBuilder = Class.extend({
if(fieldtype==="Custom HTML") {
// custom html as HTML field
df.fieldtype = "HTML";
df.options = $this.find(".html-content").data('content');
df.options = $($this.find(".html-content")[0]).data('content');
}
data.push(df);
});


+ 3
- 1
frappe/print/page/print_format_builder/print_format_builder_field.html 查看文件

@@ -20,7 +20,9 @@
<a class="edit-html btn btn-default btn-xs">
{%= __("Edit HTML") %}</a>
</div>
<div class="html-content">
<div class="html-content"
{% if field.custom_html_id!==undefined %}
data-custom-html-id={{ field.custom_html_id }}{% endif %}>
{{ field.options || me.get_no_content() }}</div>
{% } else { %}
<span class="field-label">{{ field.label }}</span>


+ 8
- 5
frappe/www/print.py 查看文件

@@ -232,6 +232,11 @@ def make_layout(doc, meta, format_data=None):

def get_new_section(): return {'columns': [], 'has_data': False}

def append_empty_field_dict_to_page_column(page):
""" append empty columns dict to page layout """
if not page[-1]['columns']:
page[-1]['columns'].append({'fields': []})

for df in format_data or meta.fields:
if format_data:
# embellish df with original properties
@@ -263,16 +268,13 @@ def make_layout(doc, meta, format_data=None):

else:
# add a column if not yet added
if not page[-1]['columns']:
page[-1]['columns'].append({'fields': []})
append_empty_field_dict_to_page_column(page)

if df.fieldtype=="HTML" and df.options:
doc.set(df.fieldname, True) # show this field

if is_visible(df, doc) and has_value(df, doc):
if page[-1]['columns'] == []:
# if no column, add one
page[-1]['columns'].append({'fields': []})
append_empty_field_dict_to_page_column(page)

page[-1]['columns'][-1]['fields'].append(df)

@@ -293,6 +295,7 @@ def make_layout(doc, meta, format_data=None):
# new page, with empty section and column
page = [get_new_section()]
layout.append(page)
append_empty_field_dict_to_page_column(page)

# continue the table in a new page
df = copy.copy(df)


Loading…
取消
儲存