Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Merge develop to main #237

Merged
merged 16 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"attached_to_doctype": "Print Format",
"attached_to_field": "print_designer_preview_img",
"attached_to_name": "Sales Invoice PD Format v2",
"content_hash": "360404e78fedf97c58269738b5e58b64",
"creation": "2024-04-16 19:22:32.564571",
"docstatus": 0,
"doctype": "File",
"file_name": "print_designer-sales_invoice_pd_format_v2-preview.jpg",
"file_size": 148126,
"file_type": "JPG",
"file_url": "/private/files/print_designer-sales_invoice_pd_format_v2-preview.jpg",
"folder": "Home",
"idx": 0,
"is_attachments_folder": 0,
"is_folder": 0,
"is_home_folder": 0,
"is_private": 1,
"modified": "2024-04-16 19:22:32.564571",
"modified_by": "Administrator",
"name": "040d5e33f6",
"owner": "Administrator",
"uploaded_to_dropbox": 0,
"uploaded_to_google_drive": 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"attached_to_doctype": "Print Format",
"attached_to_field": "print_designer_preview_img",
"attached_to_name": "Sales Order PD v2",
"content_hash": "37ff9dd2c9e9a1de2aa350a2336a56eb",
"creation": "2024-04-16 19:07:23.829817",
"docstatus": 0,
"doctype": "File",
"file_name": "print_designer-sales_order_pd_v2-preview6a56eb.jpg",
"file_size": 154063,
"file_type": "JPG",
"file_url": "/private/files/print_designer-sales_order_pd_v2-preview6a56eb.jpg",
"folder": "Home",
"idx": 0,
"is_attachments_folder": 0,
"is_folder": 0,
"is_home_folder": 0,
"is_private": 1,
"modified": "2024-04-16 19:07:23.829817",
"modified_by": "Administrator",
"name": "9ec0db389d",
"owner": "Administrator",
"uploaded_to_dropbox": 0,
"uploaded_to_google_drive": 0
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions print_designer/default_templates/erpnext/sales_order_pd_v2.json

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions print_designer/print_designer/client_scripts/print.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// TODO: revisit and properly implement this client script
frappe.pages["print"].on_page_load = function (wrapper) {
frappe.require(["pdfjs.bundle.css", "print_designer.bundle.css"]);
frappe.ui.make_app_page({
Expand Down Expand Up @@ -398,10 +399,22 @@ frappe.ui.form.PrintView = class PrintView extends frappe.ui.form.PrintView {
if (
frappe.meta
.get_print_formats(this.frm.doctype)
.includes(this.toolbar_print_format_selector.$input.val()) ||
!this.frm.meta.default_print_format
.includes(this.toolbar_print_format_selector.$input.val())
)
return;
if (!this.frm.meta.default_print_format) {
let pd_print_format = "";
if (this.frm.doctype == "Sales Invoice") {
pd_print_format = "Sales Invoice PD Format v2";
} else if (this.frm.doctype == "Sales Order") {
pd_print_format = "Sales Order PD v2";
}
if (pd_print_format) {
this.print_format_selector.val(pd_print_format);
this.toolbar_print_format_selector.$input.val(pd_print_format);
}
return;
}
this.toolbar_print_format_selector.$input.empty();
this.toolbar_print_format_selector.$input.val(this.frm.meta.default_print_format);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% macro getFontStyles(fonts) -%}{%for key, value in fonts.items()%}{{key ~ ':ital,wght@'}}{%for index, size in enumerate(value.weight)%}{%if index > 0%};{%endif%}0,{{size}}{%endfor%}{%for index, size in enumerate(value.italic)%}{%if index > 0%};{%endif%}1,{{size}}{%endfor%}{% if not loop.last %}{{'&display=swap&family='}}{%endif%}{%endfor%}{%- endmacro %}
{% macro getFontStyles(fonts) -%}{%for key, value in fonts.items()%}{{key ~ ':ital,wght@'}}{%for index, size in enumerate(value.weight)%}{%if index > 0%};{%endif%}0,{{size}}{%endfor%}{%for index, size in enumerate(value.italic)%}{%if index > 0 or value.weight|length != 0 %};{%endif%}1,{{size}}{%endfor%}{% if not loop.last %}{{'&display=swap&family='}}{%endif%}{%endfor%}{%- endmacro %}

{% macro render_google_fonts(settings) %}
<link rel="preconnect" href="https://fonts.gstatic.com" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<!-- third Arg is row which is not sent outside table -->
{% macro span_tag(field, element, row = {}, send_to_jinja = {}) -%}
{% set span_value = spanvalue(field, element, row, send_to_jinja) %}
{%- if span_value -%}
{%- if span_value or field.fieldname in ['page', 'topage', 'time', 'date'] -%}
<span class="{% if not field.is_static and field.is_labelled %}baseSpanTag{% endif %}">
{% if not field.is_static and field.is_labelled%}
<span class="{% if row %}printTable{% else %}dynamicText{% endif %} label-text labelSpanTag" style="user-select:auto; {%if element.labelStyle %}{{convert_css(element.labelStyle)}}{%endif%}{%if field.labelStyle %}{{convert_css(field.labelStyle)}}{%endif%} white-space:nowrap; ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
<!-- third Arg is row which is not sent outside table -->
{% macro render_spantag(field, element, row = {}, send_to_jinja = {}) -%}
{% set span_value = render_spanvalue(field, element, row, send_to_jinja) %}
{%- if span_value -%}
{%- if span_value or field.fieldname in ['page', 'topage', 'time', 'date'] -%}
<span class="{% if not field.is_static and field.is_labelled %}baseSpanTag{% endif %}">
{% if not field.is_static and field.is_labelled %}
<span class="{% if row %}printTable{% else %}dynamicText{% endif %} label-text labelSpanTag" style="user-select:auto; {%if element.labelStyle %}{{convert_css(element.labelStyle)}}{%endif%}{%if field.labelStyle %}{{convert_css(field.labelStyle)}}{%endif%} white-space:nowrap; ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const handleBlur = (e) => {
width.value = targetRect.width + 2;
height.value = targetRect.height + 2;
}
content.value = DOMRef.value.firstElementChild.innerHTML;
content.value = DOMRef.value.firstElementChild.innerText; // This will break styled texts :(
MainStore.getCurrentElementsId.includes(id.value) &&
DOMRef.value.classList.add("active-elements");
contenteditable.value = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,20 @@ const handleDblClick = (table, column) => {
const handleMenuClick = (index, action) => {
switch (action) {
case "before":
columns.value.splice(index, 0, { id: index, label: "" });
columns.value.splice(index, 0, {
id: index,
label: "",
style: {},
applyStyleToHeader: false,
});
break;
case "after":
columns.value.splice(index + 1, 0, { id: index + 1, label: "" });
columns.value.splice(index + 1, 0, {
id: index + 1,
label: "",
style: {},
applyStyleToHeader: false,
});
break;
case "delete":
columns.value.splice(index, 1)[0].dynamicContent?.forEach((el) => {
Expand Down
23 changes: 7 additions & 16 deletions print_designer/public/js/print_designer/store/ElementStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,12 @@ export const useElementStore = defineStore("ElementStore", {
r = JSON.parse(xhr.responseText);
if (r.message.doctype === "File") {
file_url = r.message.file_url;
// if format is not saved then update the preview image value with it
if (MainStore.isFormatSaving) {
MainStore.print_designer_preview_img = file_url;
} else {
// if format is already saved then update the print_designer_preview_img field
frappe.db.set_value(
"Print Format",
MainStore.printDesignName,
"print_designer_preview_img",
file_url
);
}
frappe.db.set_value(
"Print Format",
MainStore.printDesignName,
"print_designer_preview_img",
file_url
);
}
} catch (e) {
r = xhr.responseText;
Expand Down Expand Up @@ -254,23 +248,20 @@ export const useElementStore = defineStore("ElementStore", {
css: css,
};
const PrintFormatData = this.getPrintFormatData({ header, body, footer });
MainStore.isFormatSaving = true;
await this.generatePreview();

objectToSave.print_designer_print_format = PrintFormatData;
objectToSave.print_designer_preview_img = MainStore.print_designer_preview_img;
if (MainStore.isOlderSchema("1.1.0")) {
await this.printFormatCopyOnOlderSchema(objectToSave);
} else {
await frappe.db.set_value("Print Format", MainStore.printDesignName, objectToSave);
MainStore.isFormatSaving = false;
frappe.show_alert(
{
message: `Print Format Saved Successfully`,
indicator: "green",
},
5
);
await this.generatePreview();
}
},
checkIfAnyTableIsEmpty() {
Expand Down
Loading