diff --git a/frappe/public/js/frappe/form/layout.js b/frappe/public/js/frappe/form/layout.js
index 8c6b813973..2f4f29b8f9 100644
--- a/frappe/public/js/frappe/form/layout.js
+++ b/frappe/public/js/frappe/form/layout.js
@@ -551,7 +551,7 @@ frappe.ui.form.Layout = Class.extend({
frappe.throw(__('Invalid "depends_on" expression'));
}
- } else if (expression.substr(0,3)=='fn:' && this.frm) {
+ } else if (expression.substr(0, 3)=='fn:' && this.frm) {
out = this.frm.script_manager.trigger(expression.substr(3), this.doctype, this.docname);
} else {
var value = doc[expression];
diff --git a/frappe/public/js/frappe/form/print_utils.js b/frappe/public/js/frappe/form/print_utils.js
index b9bde48216..5b04cd01a4 100644
--- a/frappe/public/js/frappe/form/print_utils.js
+++ b/frappe/public/js/frappe/form/print_utils.js
@@ -1,38 +1,50 @@
-frappe.ui.get_print_settings = function (pdf, callback, letter_head, pick_columns) {
+frappe.ui.get_print_settings = function(
+ pdf,
+ callback,
+ letter_head,
+ pick_columns
+) {
var print_settings = locals[":Print Settings"]["Print Settings"];
- var default_letter_head = locals[":Company"] && frappe.defaults.get_default('company')
- ? locals[":Company"][frappe.defaults.get_default('company')]["default_letter_head"]
- : '';
+ var default_letter_head =
+ locals[":Company"] && frappe.defaults.get_default("company")
+ ? locals[":Company"][frappe.defaults.get_default("company")][
+ "default_letter_head"
+ ]
+ : "";
- var columns = [{
- fieldtype: "Check",
- fieldname: "with_letter_head",
- label: __("With Letter head")
- }, {
- fieldtype: "Select",
- fieldname: "letter_head",
- label: __("Letter Head"),
- depends_on: "with_letter_head",
- options: frappe.boot.letter_heads,
- default: letter_head || default_letter_head
- }, {
- fieldtype: "Select",
- fieldname: "orientation",
- label: __("Orientation"),
- options: [
- { "value": "Landscape", "label": __("Landscape") },
- { "value": "Portrait", "label": __("Portrait") }
- ],
- default: "Landscape"
- }];
+ var columns = [
+ {
+ fieldtype: "Check",
+ fieldname: "with_letter_head",
+ label: __("With Letter head")
+ },
+ {
+ fieldtype: "Select",
+ fieldname: "letter_head",
+ label: __("Letter Head"),
+ depends_on: "with_letter_head",
+ options: frappe.boot.letter_heads,
+ default: letter_head || default_letter_head
+ },
+ {
+ fieldtype: "Select",
+ fieldname: "orientation",
+ label: __("Orientation"),
+ options: [
+ { value: "Landscape", label: __("Landscape") },
+ { value: "Portrait", label: __("Portrait") }
+ ],
+ default: "Landscape"
+ }
+ ];
if (pick_columns) {
columns.push(
{
label: __("Pick Columns"),
fieldtype: "Check",
- fieldname: "pick_columns",
+ fieldname: "pick_columns"
},
{
label: __("Select Columns"),
@@ -48,18 +60,22 @@ frappe.ui.get_print_settings = function (pdf, callback, letter_head, pick_column
);
}
- return frappe.prompt(columns, function (data) {
- var data = $.extend(print_settings, data);
- if (!data.with_letter_head) {
- data.letter_head = null;
- }
- if (data.letter_head) {
- data.letter_head = frappe.boot.letter_heads[print_settings.letter_head];
- }
- callback(data);
- }, __("Print Settings"));
-}
-
+ return frappe.prompt(
+ columns,
+ function(data) {
+ var data = $.extend(print_settings, data);
+ if (!data.with_letter_head) {
+ data.letter_head = null;
+ }
+ if (data.letter_head) {
+ data.letter_head =
+ frappe.boot.letter_heads[print_settings.letter_head];
+ }
+ callback(data);
+ },
+ __("Print Settings")
+ );
+};
// qz tray connection wrapper
// - allows active and inactive connections to resolve regardless
@@ -67,62 +83,87 @@ frappe.ui.get_print_settings = function (pdf, callback, letter_head, pick_column
// - if connection fails, catch the reject, fire the mimetype launcher
// - after mimetype launcher is fired, try to connect 3 more times
// - display success/fail message to user
-frappe.ui.form.qz_connect = function () {
- return new Promise(function (resolve, reject) {
+frappe.ui.form.qz_connect = function() {
+ return new Promise(function(resolve, reject) {
frappe.ui.form.qz_init().then(() => {
- if (qz.websocket.isActive()) { // if already active, resolve immediately
+ if (qz.websocket.isActive()) {
+ // if already active, resolve immediately
// frappe.show_alert({message: __('QZ Tray Connection Active!'), indicator: 'green'});
resolve();
} else {
// try to connect once before firing the mimetype launcher
frappe.show_alert({
- message: __('Attempting Connection to QZ Tray...'),
- indicator: 'blue'
+ message: __("Attempting Connection to QZ Tray..."),
+ indicator: "blue"
});
- qz.websocket.connect().then(() => {
- frappe.show_alert({
- message: __('Connected to QZ Tray!'),
- indicator: 'green'
- });
- resolve();
- }, function retry(err) {
- if (err.message === 'Unable to establish connection with QZ') {
- // if a connect was not successful, launch the mimetype, try 3 more times
+ qz.websocket.connect().then(
+ () => {
frappe.show_alert({
- message: __('Attempting to launch QZ Tray...'),
- indicator: 'blue'
- }, 14);
- window.location.assign("qz:launch");
- qz.websocket.connect({
- retries: 3,
- delay: 1
- }).then(() => {
- frappe.show_alert({
- message: __('Connected to QZ Tray!'),
- indicator: 'green'
- });
- resolve();
- },
- () => {
- frappe.throw(__('Error connecting to QZ Tray Application...
You need to have QZ Tray application installed and running, to use the Raw Print feature.
Click here to Download and install QZ Tray.
Click here to learn more about Raw Printing.'));
- reject();
+ message: __("Connected to QZ Tray!"),
+ indicator: "green"
});
- } else {
- frappe.show_alert({
- message: 'QZ Tray ' + err.toString(),
- indicator: 'red'
- }, 14);
- reject();
+ resolve();
+ },
+ function retry(err) {
+ if (
+ err.message ===
+ "Unable to establish connection with QZ"
+ ) {
+ // if a connect was not successful, launch the mimetype, try 3 more times
+ frappe.show_alert(
+ {
+ message: __(
+ "Attempting to launch QZ Tray..."
+ ),
+ indicator: "blue"
+ },
+ 14
+ );
+ window.location.assign("qz:launch");
+ qz.websocket
+ .connect({
+ retries: 3,
+ delay: 1
+ })
+ .then(
+ () => {
+ frappe.show_alert({
+ message: __(
+ "Connected to QZ Tray!"
+ ),
+ indicator: "green"
+ });
+ resolve();
+ },
+ () => {
+ frappe.throw(
+ __(
+ 'Error connecting to QZ Tray Application...
You need to have QZ Tray application installed and running, to use the Raw Print feature.
Click here to Download and install QZ Tray.
Click here to learn more about Raw Printing.'
+ )
+ );
+ reject();
+ }
+ );
+ } else {
+ frappe.show_alert(
+ {
+ message: "QZ Tray " + err.toString(),
+ indicator: "red"
+ },
+ 14
+ );
+ reject();
+ }
}
- });
+ );
}
});
});
-}
+};
-frappe.ui.form.qz_init = function () {
+frappe.ui.form.qz_init = function() {
// Initializing qz tray library
- return new Promise((resolve) => {
+ return new Promise(resolve => {
if (typeof qz === "object" && typeof qz.version === "string") {
// resolve immediately if already Initialized
resolve();
@@ -131,11 +172,11 @@ frappe.ui.form.qz_init = function () {
"/assets/frappe/node_modules/js-sha256/build/sha256.min.js",
"/assets/frappe/node_modules/qz-tray/qz-tray.js"
];
- frappe.require(qz_required_assets,() => {
+ frappe.require(qz_required_assets, () => {
qz.api.setPromiseType(function promise(resolver) {
return new Promise(resolver);
});
- qz.api.setSha256Type(function (data) {
+ qz.api.setSha256Type(function(data) {
// Codacy fix
/*global sha256*/
return sha256(data);
@@ -144,33 +185,39 @@ frappe.ui.form.qz_init = function () {
});
// note 'frappe.require' does not have callback on fail. Hence, any failure cannot be communicated to the user.
}
-
});
-}
+};
-frappe.ui.form.qz_get_printer_list = function () {
+frappe.ui.form.qz_get_printer_list = function() {
// returns the list of printers that are available to the QZ Tray
- return frappe.ui.form.qz_connect().then(function () {
- return qz.printers.find();
- }).then((data) => {
- return data;
- }).catch((err) => {
- frappe.ui.form.qz_fail(err);
- });
-}
+ return frappe.ui.form
+ .qz_connect()
+ .then(function() {
+ return qz.printers.find();
+ })
+ .then(data => {
+ return data;
+ })
+ .catch(err => {
+ frappe.ui.form.qz_fail(err);
+ });
+};
-frappe.ui.form.qz_success = function () {
+frappe.ui.form.qz_success = function() {
// notify qz successful print
frappe.show_alert({
- message: __('Print Sent to the printer!'),
- indicator: 'green'
+ message: __("Print Sent to the printer!"),
+ indicator: "green"
});
-}
+};
-frappe.ui.form.qz_fail = function (e) {
+frappe.ui.form.qz_fail = function(e) {
// notify qz errors
- frappe.show_alert({
- message: __("QZ Tray Failed: ") + e.toString(),
- indicator: 'red'
- }, 20);
-}
+ frappe.show_alert(
+ {
+ message: __("QZ Tray Failed: ") + e.toString(),
+ indicator: "red"
+ },
+ 20
+ );
+};
diff --git a/frappe/public/js/frappe/form/toolbar.js b/frappe/public/js/frappe/form/toolbar.js
index a8dd503f43..25b8d71f13 100644
--- a/frappe/public/js/frappe/form/toolbar.js
+++ b/frappe/public/js/frappe/form/toolbar.js
@@ -249,7 +249,7 @@ frappe.ui.form.Toolbar = class Toolbar {
}, true);
this.print_icon = this.page.add_action_icon("printer", function() {
me.frm.print_doc();
- },'', __("Print"));
+ }, '', __("Print"));
}
}
diff --git a/frappe/public/js/frappe/list/list_view_select.js b/frappe/public/js/frappe/list/list_view_select.js
index a059354ba8..646efcfbfe 100644
--- a/frappe/public/js/frappe/list/list_view_select.js
+++ b/frappe/public/js/frappe/list/list_view_select.js
@@ -1,4 +1,4 @@
-frappe.provide('frappe.views');
+frappe.provide("frappe.views");
frappe.views.ListViewSelect = class ListViewSelect {
constructor(opts) {
@@ -14,110 +14,112 @@ frappe.views.ListViewSelect = class ListViewSelect {
action,
true,
null,
- this.icon_map[view] || 'list'
+ this.icon_map[view] || "list"
);
- $el.parent().attr('data-view', view)
+ $el.parent().attr("data-view", view);
}
set_current_view() {
- this.current_view = 'List';
+ this.current_view = "List";
const route = frappe.get_route();
- const view_name = frappe.utils.to_title_case(route[2] || '');
+ const view_name = frappe.utils.to_title_case(route[2] || "");
if (route.length > 2 && frappe.views.view_modes.includes(view_name)) {
this.current_view = view_name;
- if (this.current_view === 'Kanban') {
+ if (this.current_view === "Kanban") {
this.kanban_board = route[3];
- } else if (this.current_view === 'Inbox') {
+ } else if (this.current_view === "Inbox") {
this.email_account = route[3];
}
}
}
set_route(view, calendar_name) {
- const route = [this.slug(), 'view', view];
+ const route = [this.slug(), "view", view];
if (calendar_name) route.push(calendar_name);
frappe.set_route(route);
}
setup_views() {
const views = {
- 'List': {
+ List: {
condition: true,
- action: () => this.set_route('list')
+ action: () => this.set_route("list")
},
- 'Report': {
+ Report: {
condition: true,
- action: () => this.set_route('report'),
+ action: () => this.set_route("report"),
current_view_handler: () => {
const reports = this.get_reports();
- this.setup_dropdown_in_sidebar(
- 'Report',
- reports,
- {
- label: __('Report Builder'),
- action: () => this.set_route('report')
- }
- );
- }
- },
- 'Dashboard': {
- condition: true,
- action: () => this.set_route('dashboard')
- },
- 'Calendar': {
- condition: frappe.views.calendar[this.doctype],
- action: () => this.set_route('calendar', 'default'),
- current_view_handler: () => {
- this.get_calendars().then(calendars => {
- this.setup_dropdown_in_sidebar(
- 'Calendar',
- calendars,
- );
+ this.setup_dropdown_in_sidebar("Report", reports, {
+ label: __("Report Builder"),
+ action: () => this.set_route("report")
});
}
},
- 'Gantt': {
- condition: frappe.views.calendar[this.doctype],
- action: () => this.set_route('gantt')
+ Dashboard: {
+ condition: true,
+ action: () => this.set_route("dashboard")
},
- 'Inbox': {
- condition: this.doctype === "Communication" && frappe.boot.email_accounts.length,
- action: () => this.set_route('inbox'),
+ Calendar: {
+ condition: frappe.views.calendar[this.doctype],
+ action: () => this.set_route("calendar", "default"),
+ current_view_handler: () => {
+ this.get_calendars().then(calendars => {
+ this.setup_dropdown_in_sidebar("Calendar", calendars);
+ });
+ }
+ },
+ Gantt: {
+ condition: frappe.views.calendar[this.doctype],
+ action: () => this.set_route("gantt")
+ },
+ Inbox: {
+ condition:
+ this.doctype === "Communication" &&
+ frappe.boot.email_accounts.length,
+ action: () => this.set_route("inbox"),
current_view_handler: () => {
const accounts = this.get_email_accounts();
let default_action;
- if (has_common(frappe.user_roles, ["System Manager", "Administrator"])) {
+ if (
+ has_common(frappe.user_roles, [
+ "System Manager",
+ "Administrator"
+ ])
+ ) {
default_action = {
- label: __('New Email Account'),
+ label: __("New Email Account"),
action: () => frappe.new_doc("Email Account")
- }
+ };
}
this.setup_dropdown_in_sidebar(
- 'Inbox',
+ "Inbox",
accounts,
- default_action,
+ default_action
);
}
},
- 'Image': {
+ Image: {
condition: this.list_view.meta.image_field,
- action: () => this.set_route('image')
+ action: () => this.set_route("image")
},
- 'Tree': {
- condition: frappe.treeview_settings[this.doctype] || frappe.get_meta(this.doctype).is_tree,
- action: () => this.set_route('tree')
+ Tree: {
+ condition:
+ frappe.treeview_settings[this.doctype] ||
+ frappe.get_meta(this.doctype).is_tree,
+ action: () => this.set_route("tree")
},
- 'Kanban': {
+ Kanban: {
condition: true,
action: () => this.setup_kanban_boards(),
current_view_handler: () => {
- frappe.views.KanbanView.get_kanbans(this.doctype).then((kanbans) =>
- this.setup_kanban_switcher(kanbans)
+ frappe.views.KanbanView.get_kanbans(this.doctype).then(
+ kanbans => this.setup_kanban_switcher(kanbans)
);
}
- },
- }
+ }
+ };
frappe.views.view_modes.forEach(view => {
if (this.current_view !== view && views[view].condition) {
@@ -125,71 +127,78 @@ frappe.views.ListViewSelect = class ListViewSelect {
}
if (this.current_view == view) {
- views[view].current_view_handler && views[view].current_view_handler();
+ views[view].current_view_handler &&
+ views[view].current_view_handler();
}
});
}
-
setup_dropdown_in_sidebar(view, items, default_action) {
if (!this.sidebar) return;
- const views_wrapper = this.sidebar.sidebar.find('.views-section');
- views_wrapper.find('.sidebar-label').html(`${__(view)}`);
- const $dropdown = views_wrapper.find('.views-dropdown');
+ const views_wrapper = this.sidebar.sidebar.find(".views-section");
+ views_wrapper.find(".sidebar-label").html(`${__(view)}`);
+ const $dropdown = views_wrapper.find(".views-dropdown");
let placeholder = `Select ${view}`;
let html = ``;
if (!items || !items.length) {
html = `