Fixed tab spacing
This commit is contained in:
parent
d9f3b57bb8
commit
b99fd5a4d3
37 changed files with 506 additions and 512 deletions
|
|
@ -102,11 +102,10 @@ frappe.ui.form.on('User', {
|
||||||
|
|
||||||
if (frappe.route_flags.unsaved===1){
|
if (frappe.route_flags.unsaved===1){
|
||||||
delete frappe.route_flags.unsaved;
|
delete frappe.route_flags.unsaved;
|
||||||
for ( var i=0;i<frm.doc.user_emails.length;i++){
|
for ( var i=0;i<frm.doc.user_emails.length;i++) {
|
||||||
frm.doc.user_emails[i].idx=frm.doc.user_emails[i].idx+1;
|
frm.doc.user_emails[i].idx=frm.doc.user_emails[i].idx+1;
|
||||||
}
|
}
|
||||||
frm.doc.email_account
|
cur_frm.dirty();
|
||||||
cur_frm.dirty();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
validate: function(frm) {
|
validate: function(frm) {
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ frappe.customize_form.confirm = function(msg, frm) {
|
||||||
method: "reset_to_defaults",
|
method: "reset_to_defaults",
|
||||||
callback: function(r) {
|
callback: function(r) {
|
||||||
if(r.exc) {
|
if(r.exc) {
|
||||||
frappe.msgprintr.exc);
|
frappe.msgprint(r.exc);
|
||||||
} else {
|
} else {
|
||||||
d.hide();
|
d.hide();
|
||||||
frappe.customize_form.clear_locals_and_refresh(frm);
|
frappe.customize_form.clear_locals_and_refresh(frm);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ frappe.db = {
|
||||||
fieldname: fieldname,
|
fieldname: fieldname,
|
||||||
filters: filters
|
filters: filters
|
||||||
},
|
},
|
||||||
callback: function(r, rt) {
|
callback: function(r) {
|
||||||
callback && callback(r.message);
|
callback && callback(r.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -144,47 +144,47 @@ frappe.Application = Class.extend({
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
d.get_input("submit").on("click", function() {
|
d.get_input("submit").on("click", function() {
|
||||||
//setup spinner
|
//setup spinner
|
||||||
d.hide();
|
d.hide();
|
||||||
var s = new frappe.ui.Dialog({
|
var s = new frappe.ui.Dialog({
|
||||||
title: __("Checking one moment"),
|
title: __("Checking one moment"),
|
||||||
fields: [{
|
fields: [{
|
||||||
"fieldtype": "HTML",
|
"fieldtype": "HTML",
|
||||||
"fieldname": "checking"
|
"fieldname": "checking"
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
s.fields_dict.checking.$wrapper.html('<i class="fa fa-spinner fa-spin fa-4x"></i>')
|
s.fields_dict.checking.$wrapper.html('<i class="fa fa-spinner fa-spin fa-4x"></i>')
|
||||||
s.show();
|
s.show();
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: 'frappe.core.doctype.user.user.set_email_password',
|
method: 'frappe.core.doctype.user.user.set_email_password',
|
||||||
args: {
|
args: {
|
||||||
"email_account": email_account[i]["email_account"],
|
"email_account": email_account[i]["email_account"],
|
||||||
"user": user,
|
"user": user,
|
||||||
"password": d.get_value("password")
|
"password": d.get_value("password")
|
||||||
},
|
},
|
||||||
callback: function (passed)
|
callback: function (passed)
|
||||||
|
{
|
||||||
|
s.hide();
|
||||||
|
d.hide();//hide waiting indication
|
||||||
|
if (!passed["message"])
|
||||||
{
|
{
|
||||||
s.hide();
|
frappe.show_alert("Login Failed please try again", 5);
|
||||||
d.hide();//hide waiting indication
|
me.email_password_prompt(email_account, user, i)
|
||||||
if (!passed["message"])
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (i + 1 < email_account.length)
|
||||||
{
|
{
|
||||||
frappe.show_alert("Login Failed please try again", 5);
|
i = i + 1;
|
||||||
me.email_password_prompt(email_account, user, i)
|
me.email_password_prompt(email_account, user, i)
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (i + 1 < email_account.length)
|
|
||||||
{
|
|
||||||
i = i + 1;
|
|
||||||
me.email_password_prompt(email_account, user, i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
}
|
||||||
});
|
});
|
||||||
d.show();
|
});
|
||||||
|
d.show();
|
||||||
},
|
},
|
||||||
load_bootinfo: function() {
|
load_bootinfo: function() {
|
||||||
if(frappe.boot) {
|
if(frappe.boot) {
|
||||||
|
|
@ -555,20 +555,19 @@ frappe.get_desktop_icons = function(show_hidden, show_global) {
|
||||||
|
|
||||||
for (var i=0, l=frappe.boot.desktop_icons.length; i < l; i++) {
|
for (var i=0, l=frappe.boot.desktop_icons.length; i < l; i++) {
|
||||||
var m = frappe.boot.desktop_icons[i];
|
var m = frappe.boot.desktop_icons[i];
|
||||||
if ((['Setup', 'Core'].indexOf(m.module_name) === -1)
|
if ((['Setup', 'Core'].indexOf(m.module_name) === -1) && show_module(m)) {
|
||||||
&& show_module(m)) {
|
add_to_out(m);
|
||||||
add_to_out(m)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(frappe.user_roles.includes('System Manager')) {
|
if(frappe.user_roles.includes('System Manager')) {
|
||||||
var m = frappe.get_module('Setup');
|
var m = frappe.get_module('Setup');
|
||||||
if(show_module(m)) add_to_out(m)
|
if(show_module(m)) add_to_out(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(frappe.user_roles.includes('Administrator')) {
|
if(frappe.user_roles.includes('Administrator')) {
|
||||||
var m = frappe.get_module('Core');
|
var m = frappe.get_module('Core');
|
||||||
if(show_module(m)) add_to_out(m)
|
if(show_module(m)) add_to_out(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ frappe.ui.form.Control = Class.extend({
|
||||||
// if developer_mode=1, show fieldname as tooltip
|
// if developer_mode=1, show fieldname as tooltip
|
||||||
if(frappe.boot.user && frappe.boot.user.name==="Administrator" &&
|
if(frappe.boot.user && frappe.boot.user.name==="Administrator" &&
|
||||||
frappe.boot.developer_mode===1 && this.$wrapper) {
|
frappe.boot.developer_mode===1 && this.$wrapper) {
|
||||||
this.$wrapper.attr("title", __(this.df.fieldname));
|
this.$wrapper.attr("title", __(this.df.fieldname));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.render_input) {
|
if(this.render_input) {
|
||||||
|
|
@ -75,8 +75,9 @@ frappe.ui.form.Control = Class.extend({
|
||||||
if (this.doctype && status==="Read" && !this.only_input
|
if (this.doctype && status==="Read" && !this.only_input
|
||||||
&& is_null(frappe.model.get_value(this.doctype, this.docname, this.df.fieldname))
|
&& is_null(frappe.model.get_value(this.doctype, this.docname, this.df.fieldname))
|
||||||
&& !in_list(["HTML", "Image"], this.df.fieldtype)) {
|
&& !in_list(["HTML", "Image"], this.df.fieldtype)) {
|
||||||
if(explain) console.log("By Hide Read-only, null fields: None");
|
|
||||||
status = "None";
|
if(explain) console.log("By Hide Read-only, null fields: None");
|
||||||
|
status = "None";
|
||||||
}
|
}
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
|
|
@ -189,19 +190,19 @@ frappe.ui.form.ControlImage = frappe.ui.form.Control.extend({
|
||||||
this.$body = $("<div></div>").appendTo(this.$wrapper)
|
this.$body = $("<div></div>").appendTo(this.$wrapper)
|
||||||
.css({"margin-bottom": "10px"})
|
.css({"margin-bottom": "10px"})
|
||||||
this.$wrapper.on("refresh", function() {
|
this.$wrapper.on("refresh", function() {
|
||||||
var doc = null;
|
var doc = null;
|
||||||
me.$body.empty();
|
me.$body.empty();
|
||||||
|
|
||||||
var doc = me.get_doc();
|
var doc = me.get_doc();
|
||||||
if(doc && me.df.options && doc[me.df.options]) {
|
if(doc && me.df.options && doc[me.df.options]) {
|
||||||
me.$img = $("<img src='"+doc[me.df.options]+"' class='img-responsive'>")
|
me.$img = $("<img src='"+doc[me.df.options]+"' class='img-responsive'>")
|
||||||
.appendTo(me.$body);
|
.appendTo(me.$body);
|
||||||
} else {
|
} else {
|
||||||
me.$buffer = $("<div class='missing-image'><i class='octicon octicon-circle-slash'></i></div>")
|
me.$buffer = $("<div class='missing-image'><i class='octicon octicon-circle-slash'></i></div>")
|
||||||
.appendTo(me.$body)
|
.appendTo(me.$body)
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$('<div class="clearfix"></div>').appendTo(this.$wrapper);
|
$('<div class="clearfix"></div>').appendTo(this.$wrapper);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -430,7 +431,7 @@ frappe.ui.form.ControlData = frappe.ui.form.ControlInput.extend({
|
||||||
|
|
||||||
if (in_list(['Data', 'Link', 'Dynamic Link', 'Password', 'Select', 'Read Only', 'Attach', 'Attach Image'],
|
if (in_list(['Data', 'Link', 'Dynamic Link', 'Password', 'Select', 'Read Only', 'Attach', 'Attach Image'],
|
||||||
this.df.fieldtype)) {
|
this.df.fieldtype)) {
|
||||||
this.$input.attr("maxlength", this.df.length || 140);
|
this.$input.attr("maxlength", this.df.length || 140);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set_input_attributes();
|
this.set_input_attributes();
|
||||||
|
|
@ -1938,7 +1939,7 @@ frappe.ui.form.ControlSignature = frappe.ui.form.ControlData.extend({
|
||||||
this.set_editable(this.get_status()=="Write");
|
this.set_editable(this.get_status()=="Write");
|
||||||
this.load_pad();
|
this.load_pad();
|
||||||
if(this.get_status()=="Read") {
|
if(this.get_status()=="Read") {
|
||||||
$(this.disp_area).toggle(false);
|
$(this.disp_area).toggle(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
set_image: function(value) {
|
set_image: function(value) {
|
||||||
|
|
@ -1976,15 +1977,15 @@ frappe.ui.form.ControlSignature = frappe.ui.form.ControlData.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
set_editable: function(editable) {
|
set_editable: function(editable) {
|
||||||
this.$pad.toggle(editable);
|
this.$pad.toggle(editable);
|
||||||
this.img_wrapper.toggle(!editable);
|
this.img_wrapper.toggle(!editable);
|
||||||
this.$btnWrapper.toggle(editable);
|
this.$btnWrapper.toggle(editable);
|
||||||
if (editable) {
|
if (editable) {
|
||||||
this.$btnWrapper.addClass('editing');
|
this.$btnWrapper.addClass('editing');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.$btnWrapper.removeClass('editing');
|
this.$btnWrapper.removeClass('editing');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
set_my_value: function(value) {
|
set_my_value: function(value) {
|
||||||
if (this.saving || this.loading) return;
|
if (this.saving || this.loading) return;
|
||||||
|
|
|
||||||
|
|
@ -116,13 +116,13 @@ frappe.ui.form.Timeline = Class.extend({
|
||||||
|
|
||||||
var communications = this.get_communications(true);
|
var communications = this.get_communications(true);
|
||||||
|
|
||||||
$.each(communications.sort(function(a, b) { return a.creation > b.creation ? -1 : 1 }),
|
communications
|
||||||
function(i, c) {
|
.sort((a, b) => a.creation > b.creation ? -1 : 1)
|
||||||
if(c.content) {
|
.filter(c => c.content)
|
||||||
c.frm = me.frm;
|
.forEach(c => {
|
||||||
me.render_timeline_item(c);
|
c.frm = me.frm;
|
||||||
}
|
me.render_timeline_item(c);
|
||||||
});
|
});
|
||||||
|
|
||||||
// more btn
|
// more btn
|
||||||
if (this.more===undefined && communications.length===20) {
|
if (this.more===undefined && communications.length===20) {
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
</span>
|
</span>
|
||||||
<span class="text-muted" style="font-weight: normal;">
|
<span class="text-muted" style="font-weight: normal;">
|
||||||
– {%= data.comment_on %}</span>
|
– {%= data.comment_on %}</span>
|
||||||
{% if(inList(["Communication", "Feedback"], data.communication_type)) { %}
|
{% if(in_list(["Communication", "Feedback"], data.communication_type)) { %}
|
||||||
{% if (frappe.model.can_read(\'Communication\')) { %}
|
{% if (frappe.model.can_read(\'Communication\')) { %}
|
||||||
<a href="#Form/{%= data.doctype %}/{%= data.name %}"
|
<a href="#Form/{%= data.doctype %}/{%= data.name %}"
|
||||||
class="text-muted">
|
class="text-muted">
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ frappe.ui.form.Grid = Class.extend({
|
||||||
this.multiple_set = false;
|
this.multiple_set = false;
|
||||||
if(this.frm && this.frm.meta.__form_grid_templates
|
if(this.frm && this.frm.meta.__form_grid_templates
|
||||||
&& this.frm.meta.__form_grid_templates[this.df.fieldname]) {
|
&& this.frm.meta.__form_grid_templates[this.df.fieldname]) {
|
||||||
this.template = this.frm.meta.__form_grid_templates[this.df.fieldname];
|
this.template = this.frm.meta.__form_grid_templates[this.df.fieldname];
|
||||||
}
|
}
|
||||||
|
|
||||||
this.is_grid = true;
|
this.is_grid = true;
|
||||||
|
|
@ -428,27 +428,25 @@ frappe.ui.form.Grid = Class.extend({
|
||||||
&& (this.editable_fields || df.in_list_view)
|
&& (this.editable_fields || df.in_list_view)
|
||||||
&& (this.frm && this.frm.get_perm(df.permlevel, "read") || !this.frm)
|
&& (this.frm && this.frm.get_perm(df.permlevel, "read") || !this.frm)
|
||||||
&& !in_list(frappe.model.layout_fields, df.fieldtype)) {
|
&& !in_list(frappe.model.layout_fields, df.fieldtype)) {
|
||||||
if(df.columns) {
|
|
||||||
df.colsize=df.columns;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var colsize=2;
|
|
||||||
switch(df.fieldtype){
|
|
||||||
case"Text":
|
|
||||||
case"Small Text":
|
|
||||||
colsize=3;
|
|
||||||
break;
|
|
||||||
case"Check":
|
|
||||||
colsize=1
|
|
||||||
}
|
|
||||||
df.colsize=colsize
|
|
||||||
}
|
|
||||||
|
|
||||||
total_colsize += df.colsize
|
if(df.columns) {
|
||||||
if(total_colsize > 11)
|
df.colsize=df.columns;
|
||||||
return false;
|
|
||||||
this.visible_columns.push([df, df.colsize]);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
var colsize = 2;
|
||||||
|
switch(df.fieldtype) {
|
||||||
|
case "Text":
|
||||||
|
case "Small Text": colsize = 3; break;
|
||||||
|
case"Check": colsize = 1
|
||||||
|
}
|
||||||
|
df.colsize = colsize
|
||||||
|
}
|
||||||
|
|
||||||
|
total_colsize += df.colsize
|
||||||
|
if(total_colsize > 11)
|
||||||
|
return false;
|
||||||
|
this.visible_columns.push([df, df.colsize]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// redistribute if total-col size is less than 12
|
// redistribute if total-col size is less than 12
|
||||||
|
|
@ -943,15 +941,15 @@ frappe.ui.form.GridRow = Class.extend({
|
||||||
field.get_query = this.grid.get_field(df.fieldname).get_query;
|
field.get_query = this.grid.get_field(df.fieldname).get_query;
|
||||||
field.refresh();
|
field.refresh();
|
||||||
if(field.$input) {
|
if(field.$input) {
|
||||||
field.$input.addClass('input-sm');
|
|
||||||
field.$input
|
field.$input
|
||||||
|
.addClass('input-sm')
|
||||||
.attr('data-col-idx', column.column_index)
|
.attr('data-col-idx', column.column_index)
|
||||||
.attr('placeholder', __(df.label));
|
.attr('placeholder', __(df.label));
|
||||||
|
|
||||||
// flag list input
|
// flag list input
|
||||||
if (this.columns_list && this.columns_list.slice(-1)[0]===column) {
|
if (this.columns_list && this.columns_list.slice(-1)[0]===column) {
|
||||||
field.$input.attr('data-last-input', 1);
|
field.$input.attr('data-last-input', 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set_arrow_keys(field);
|
this.set_arrow_keys(field);
|
||||||
|
|
|
||||||
|
|
@ -54,18 +54,14 @@ frappe.ui.form.Layout = Class.extend({
|
||||||
this.make_section();
|
this.make_section();
|
||||||
}
|
}
|
||||||
$.each(this.fields, function(i, df) {
|
$.each(this.fields, function(i, df) {
|
||||||
switch(df.fieldtype) {
|
if(df.fieldtype === "Fold") {
|
||||||
case "Fold":
|
me.make_page(df);
|
||||||
me.make_page(df);
|
} else if (df.fieldtype === "Section Break") {
|
||||||
break;
|
me.make_section(df);
|
||||||
case "Section Break":
|
} else if (df.fieldtype === "Column Break") {
|
||||||
me.make_section(df);
|
me.make_column(df);
|
||||||
break;
|
} else {
|
||||||
case "Column Break":
|
me.make_field(df);
|
||||||
me.make_column(df);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
me.make_field(df);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,24 @@
|
||||||
// MIT License. See license.txt
|
// MIT License. See license.txt
|
||||||
|
|
||||||
frappe.ui.form.LinkSelector = Class.extend({
|
frappe.ui.form.LinkSelector = Class.extend({
|
||||||
init: function(opts) {
|
init: function (opts) {
|
||||||
/* help: Options: doctype, get_query, target */
|
/* help: Options: doctype, get_query, target */
|
||||||
$.extend(this, opts);
|
$.extend(this, opts);
|
||||||
|
|
||||||
var me = this;
|
var me = this;
|
||||||
if(this.doctype!="[Select]") {
|
if (this.doctype != "[Select]") {
|
||||||
frappe.model.with_doctype(this.doctype, function(r) {
|
frappe.model.with_doctype(this.doctype, function (r) {
|
||||||
me.make();
|
me.make();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.make();
|
this.make();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
make: function() {
|
make: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
this.dialog = new frappe.ui.Dialog({
|
this.dialog = new frappe.ui.Dialog({
|
||||||
title: __("Select {0}", [(this.doctype=='[Select]') ? __("value") : __(this.doctype)]),
|
title: __("Select {0}", [(this.doctype == '[Select]') ? __("value") : __(this.doctype)]),
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
fieldtype: "Data", fieldname: "txt", label: __("Beginning with"),
|
fieldtype: "Data", fieldname: "txt", label: __("Beginning with"),
|
||||||
|
|
@ -30,45 +30,45 @@ frappe.ui.form.LinkSelector = Class.extend({
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
primary_action_label: __("Search"),
|
primary_action_label: __("Search"),
|
||||||
primary_action: function() {
|
primary_action: function () {
|
||||||
me.search();
|
me.search();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(this.txt)
|
if (this.txt)
|
||||||
this.dialog.fields_dict.txt.set_input(this.txt);
|
this.dialog.fields_dict.txt.set_input(this.txt);
|
||||||
|
|
||||||
this.dialog.get_input("txt").on("keypress", function(e) {
|
this.dialog.get_input("txt").on("keypress", function (e) {
|
||||||
if(e.which===13) {
|
if (e.which === 13) {
|
||||||
me.search();
|
me.search();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.dialog.show();
|
this.dialog.show();
|
||||||
this.search();
|
this.search();
|
||||||
},
|
},
|
||||||
search: function() {
|
search: function () {
|
||||||
var args = {
|
var args = {
|
||||||
txt: this.dialog.fields_dict.txt.get_value(),
|
txt: this.dialog.fields_dict.txt.get_value(),
|
||||||
searchfield: "name"
|
searchfield: "name"
|
||||||
},
|
};
|
||||||
me = this;
|
var me = this;
|
||||||
|
|
||||||
if(this.target.set_custom_query) {
|
if (this.target.set_custom_query) {
|
||||||
this.target.set_custom_query(args);
|
this.target.set_custom_query(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// load custom query from grid
|
// load custom query from grid
|
||||||
if(this.target.is_grid && this.target.fieldinfo[this.fieldname]
|
if (this.target.is_grid && this.target.fieldinfo[this.fieldname]
|
||||||
&& this.target.fieldinfo[this.fieldname].get_query) {
|
&& this.target.fieldinfo[this.fieldname].get_query) {
|
||||||
$.extend(args,
|
$.extend(args,
|
||||||
this.target.fieldinfo[this.fieldname].get_query(cur_frm.doc));
|
this.target.fieldinfo[this.fieldname].get_query(cur_frm.doc));
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.link_search(this.doctype, args, function(r) {
|
frappe.link_search(this.doctype, args, function (r) {
|
||||||
var parent = me.dialog.fields_dict.results.$wrapper;
|
var parent = me.dialog.fields_dict.results.$wrapper;
|
||||||
parent.empty();
|
parent.empty();
|
||||||
if(r.values.length) {
|
if (r.values.length) {
|
||||||
$.each(r.values, function(i, v) {
|
$.each(r.values, function (i, v) {
|
||||||
var row = $(repl('<div class="row link-select-row">\
|
var row = $(repl('<div class="row link-select-row">\
|
||||||
<div class="col-xs-4">\
|
<div class="col-xs-4">\
|
||||||
<b><a href="#">%(name)s</a></b></div>\
|
<b><a href="#">%(name)s</a></b></div>\
|
||||||
|
|
@ -81,54 +81,56 @@ frappe.ui.form.LinkSelector = Class.extend({
|
||||||
|
|
||||||
row.find("a")
|
row.find("a")
|
||||||
.attr('data-value', v[0])
|
.attr('data-value', v[0])
|
||||||
.click(function() {
|
.click(function () {
|
||||||
var value = $(this).attr("data-value");
|
var value = $(this).attr("data-value");
|
||||||
var $link = this;
|
var $link = this;
|
||||||
if(me.target.is_grid) {
|
if (me.target.is_grid) {
|
||||||
// set in grid
|
// set in grid
|
||||||
me.set_in_grid(value);
|
me.set_in_grid(value);
|
||||||
} else {
|
} else {
|
||||||
if(me.target.doctype)
|
if (me.target.doctype)
|
||||||
me.target.parse_validate_and_set_in_model(value);
|
me.target.parse_validate_and_set_in_model(value);
|
||||||
else {
|
else {
|
||||||
me.target.set_input(value);
|
me.target.set_input(value);
|
||||||
me.target.$input.trigger("change");
|
me.target.$input.trigger("change");
|
||||||
|
}
|
||||||
|
me.dialog.hide();
|
||||||
}
|
}
|
||||||
me.dialog.hide();
|
return false;
|
||||||
}
|
})
|
||||||
return false;
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
$('<p><br><span class="text-muted">' + __("No Results") + '</span>'
|
$('<p><br><span class="text-muted">' + __("No Results") + '</span>'
|
||||||
+ (frappe.model.can_create(me.doctype) ?
|
+ (frappe.model.can_create(me.doctype) ?
|
||||||
('<br><br><a class="new-doc btn btn-default btn-sm">'
|
('<br><br><a class="new-doc btn btn-default btn-sm">'
|
||||||
+ __("Make a new {0}", [__(me.doctype)]) + "</a>") : '')
|
+ __("Make a new {0}", [__(me.doctype)]) + "</a>") : '')
|
||||||
+ '</p>').appendTo(parent).find(".new-doc").click(function() {
|
+ '</p>').appendTo(parent).find(".new-doc").click(function () {
|
||||||
me.target.new_doc();
|
me.target.new_doc();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, this.dialog.get_primary_btn());
|
}, this.dialog.get_primary_btn());
|
||||||
|
|
||||||
},
|
},
|
||||||
set_in_grid: function(value) {
|
set_in_grid: function (value) {
|
||||||
var me = this, updated = false;
|
var me = this, updated = false;
|
||||||
if(this.qty_fieldname) {
|
if (this.qty_fieldname) {
|
||||||
frappe.prompt({fieldname:"qty", fieldtype:"Float", label:"Qty",
|
frappe.prompt({
|
||||||
"default": 1, reqd: 1}, function(data) {
|
fieldname: "qty", fieldtype: "Float", label: "Qty",
|
||||||
$.each(me.target.frm.doc[me.target.df.fieldname] || [], function(i, d) {
|
"default": 1, reqd: 1
|
||||||
if(d[me.fieldname]===value) {
|
}, function (data) {
|
||||||
|
$.each(me.target.frm.doc[me.target.df.fieldname] || [], function (i, d) {
|
||||||
|
if (d[me.fieldname] === value) {
|
||||||
frappe.model.set_value(d.doctype, d.name, me.qty_fieldname, data.qty);
|
frappe.model.set_value(d.doctype, d.name, me.qty_fieldname, data.qty);
|
||||||
frappe.show_alert(__("Added {0} ({1})", [value, d[me.qty_fieldname]]));
|
frappe.show_alert(__("Added {0} ({1})", [value, d[me.qty_fieldname]]));
|
||||||
updated = true;
|
updated = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(!updated) {
|
if (!updated) {
|
||||||
var d = me.target.add_new_row();
|
var d = me.target.add_new_row();
|
||||||
frappe.model.set_value(d.doctype, d.name, me.fieldname, value);
|
frappe.model.set_value(d.doctype, d.name, me.fieldname, value);
|
||||||
frappe.after_ajax(function() {
|
frappe.after_ajax(function () {
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
frappe.model.set_value(d.doctype, d.name, me.qty_fieldname, data.qty);
|
frappe.model.set_value(d.doctype, d.name, me.qty_fieldname, data.qty);
|
||||||
frappe.show_alert(__("Added {0} ({1})", [value, data.qty]));
|
frappe.show_alert(__("Added {0} ({1})", [value, data.qty]));
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
@ -143,14 +145,14 @@ frappe.ui.form.LinkSelector = Class.extend({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.link_search = function(doctype, args, callback, btn) {
|
frappe.link_search = function (doctype, args, callback, btn) {
|
||||||
if(!args) {
|
if (!args) {
|
||||||
args = {
|
args = {
|
||||||
txt: ''
|
txt: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
args.doctype = doctype;
|
args.doctype = doctype;
|
||||||
if(!args.searchfield) {
|
if (!args.searchfield) {
|
||||||
args.searchfield = 'name';
|
args.searchfield = 'name';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,7 +160,7 @@ frappe.link_search = function(doctype, args, callback, btn) {
|
||||||
method: "frappe.desk.search.search_widget",
|
method: "frappe.desk.search.search_widget",
|
||||||
type: "GET",
|
type: "GET",
|
||||||
args: args,
|
args: args,
|
||||||
callback: function(r) {
|
callback: function (r) {
|
||||||
callback && callback(r);
|
callback && callback(r);
|
||||||
},
|
},
|
||||||
btn: btn
|
btn: btn
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
frappe.provide("frappe.ui.form");
|
frappe.provide("frappe.ui.form");
|
||||||
|
|
||||||
frappe.ui.form.PrintPreview = Class.extend({
|
frappe.ui.form.PrintPreview = Class.extend({
|
||||||
init: function(opts) {
|
init: function (opts) {
|
||||||
$.extend(this, opts);
|
$.extend(this, opts);
|
||||||
this.make();
|
this.make();
|
||||||
this.bind_events();
|
this.bind_events();
|
||||||
},
|
},
|
||||||
make: function() {
|
make: function () {
|
||||||
this.wrapper = this.frm.page.add_view("print", frappe.render_template("print_layout", {}));
|
this.wrapper = this.frm.page.add_view("print", frappe.render_template("print_layout", {}));
|
||||||
|
|
||||||
// only system manager can edit
|
// only system manager can edit
|
||||||
this.wrapper.find(".btn-print-edit").toggle(frappe.user.has_role("System Manager"));
|
this.wrapper.find(".btn-print-edit").toggle(frappe.user.has_role("System Manager"));
|
||||||
},
|
},
|
||||||
bind_events: function() {
|
bind_events: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.wrapper.find(".btn-print-close").click(function() {
|
this.wrapper.find(".btn-print-close").click(function () {
|
||||||
me.frm.hide_print();
|
me.frm.hide_print();
|
||||||
});
|
});
|
||||||
|
|
||||||
// hide print view on pressing escape, only if there is no focus on any input
|
// hide print view on pressing escape, only if there is no focus on any input
|
||||||
$(document).on("keydown", function(e) {
|
$(document).on("keydown", function (e) {
|
||||||
if (e.which===27 && me.frm && e.target===document.body) {
|
if (e.which === 27 && me.frm && e.target === document.body) {
|
||||||
me.frm.hide_print();
|
me.frm.hide_print();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -28,79 +28,81 @@ frappe.ui.form.PrintPreview = Class.extend({
|
||||||
this.print_formats = frappe.meta.get_print_formats(this.frm.meta.name);
|
this.print_formats = frappe.meta.get_print_formats(this.frm.meta.name);
|
||||||
this.print_letterhead = this.wrapper
|
this.print_letterhead = this.wrapper
|
||||||
.find(".print-letterhead")
|
.find(".print-letterhead")
|
||||||
.on("change", function() { me.print_sel.trigger("change"); })
|
.on("change", function () { me.print_sel.trigger("change"); })
|
||||||
.prop("checked", cint(
|
.prop("checked", cint(
|
||||||
(frappe.model.get_doc(":Print Settings", "Print Settings")
|
(frappe.model.get_doc(":Print Settings", "Print Settings")
|
||||||
|| {with_letterhead: 1}).with_letterhead) ? true : false);
|
|| { with_letterhead: 1 }).with_letterhead) ? true : false);
|
||||||
this.print_sel = this.wrapper
|
this.print_sel = this.wrapper
|
||||||
.find(".print-preview-select")
|
.find(".print-preview-select")
|
||||||
.on("change", function() {
|
.on("change", function () {
|
||||||
me.multilingual_preview()
|
me.multilingual_preview()
|
||||||
});
|
});
|
||||||
|
|
||||||
//On selection of language get code and pass it to preview method
|
//On selection of language get code and pass it to preview method
|
||||||
this.language_sel = this.wrapper
|
this.language_sel = this.wrapper
|
||||||
.find(".languages")
|
.find(".languages")
|
||||||
.on("change", function(){
|
.on("change", function () {
|
||||||
me.lang_code = me.language_sel.val()
|
me.lang_code = me.language_sel.val()
|
||||||
me.multilingual_preview()
|
me.multilingual_preview()
|
||||||
});
|
});
|
||||||
|
|
||||||
this.wrapper.find(".btn-print-print").click(function() {
|
this.wrapper.find(".btn-print-print").click(function () {
|
||||||
if(me.is_old_style()) {
|
if (me.is_old_style()) {
|
||||||
me.print_old_style();
|
me.print_old_style();
|
||||||
} else {
|
} else {
|
||||||
me.printit();
|
me.printit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.wrapper.find(".btn-print-preview").click(function() {
|
this.wrapper.find(".btn-print-preview").click(function () {
|
||||||
if(me.is_old_style()) {
|
if (me.is_old_style()) {
|
||||||
me.new_page_preview_old_style();
|
me.new_page_preview_old_style();
|
||||||
} else {
|
} else {
|
||||||
me.new_page_preview();
|
me.new_page_preview();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.wrapper.find(".btn-download-pdf").click(function() {
|
this.wrapper.find(".btn-download-pdf").click(function () {
|
||||||
if(!me.is_old_style()) {
|
if (!me.is_old_style()) {
|
||||||
var w = window.open(
|
var w = window.open(
|
||||||
frappe.urllib.get_full_url("/api/method/frappe.utils.print_format.download_pdf?"
|
frappe.urllib.get_full_url("/api/method/frappe.utils.print_format.download_pdf?"
|
||||||
+"doctype="+encodeURIComponent(me.frm.doc.doctype)
|
+ "doctype=" + encodeURIComponent(me.frm.doc.doctype)
|
||||||
+"&name="+encodeURIComponent(me.frm.doc.name)
|
+ "&name=" + encodeURIComponent(me.frm.doc.name)
|
||||||
+"&format="+me.selected_format()
|
+ "&format=" + me.selected_format()
|
||||||
+"&no_letterhead="+(me.with_letterhead() ? "0" : "1")
|
+ "&no_letterhead=" + (me.with_letterhead() ? "0" : "1")
|
||||||
+(me.lang_code ? ("&_lang="+me.lang_code) : ""))
|
+ (me.lang_code ? ("&_lang=" + me.lang_code) : ""))
|
||||||
);
|
);
|
||||||
if(!w) {
|
if (!w) {
|
||||||
frappe.msgprint(__("Please enable pop-ups")); return;
|
frappe.msgprint(__("Please enable pop-ups")); return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.wrapper.find(".btn-print-edit").on("click", function() {
|
this.wrapper.find(".btn-print-edit").on("click", function () {
|
||||||
var print_format = me.get_print_format();
|
var print_format = me.get_print_format();
|
||||||
if(print_format && print_format.name) {
|
if (print_format && print_format.name) {
|
||||||
if(print_format.print_format_builder) {
|
if (print_format.print_format_builder) {
|
||||||
frappe.set_route("print-format-builder", print_format.name);
|
frappe.set_route("print-format-builder", print_format.name);
|
||||||
} else {
|
} else {
|
||||||
frappe.set_route("Form", "Print Format", print_format.name);
|
frappe.set_route("Form", "Print Format", print_format.name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// start a new print format
|
// start a new print format
|
||||||
frappe.prompt({fieldname:"print_format_name", fieldtype:"Data", reqd: 1,
|
frappe.prompt({
|
||||||
label:"New Print Format Name"}, function(data) {
|
fieldname: "print_format_name", fieldtype: "Data", reqd: 1,
|
||||||
frappe.route_options = {
|
label: "New Print Format Name"
|
||||||
make_new: true,
|
}, function (data) {
|
||||||
doctype: me.frm.doctype,
|
frappe.route_options = {
|
||||||
name: data.print_format_name
|
make_new: true,
|
||||||
};
|
doctype: me.frm.doctype,
|
||||||
frappe.set_route("print-format-builder");
|
name: data.print_format_name
|
||||||
|
};
|
||||||
|
frappe.set_route("print-format-builder");
|
||||||
}, __("New Custom Print Format"), __("Start"));
|
}, __("New Custom Print Format"), __("Start"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
set_user_lang: function(){
|
set_user_lang: function () {
|
||||||
this.lang_code = this.frm.doc.language;
|
this.lang_code = this.frm.doc.language;
|
||||||
// Load all languages in the field
|
// Load all languages in the field
|
||||||
this.language_sel.empty()
|
this.language_sel.empty()
|
||||||
|
|
@ -108,9 +110,9 @@ frappe.ui.form.PrintPreview = Class.extend({
|
||||||
.val(this.lang_code);
|
.val(this.lang_code);
|
||||||
this.preview();
|
this.preview();
|
||||||
},
|
},
|
||||||
multilingual_preview: function(){
|
multilingual_preview: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
if(this.is_old_style()) {
|
if (this.is_old_style()) {
|
||||||
me.wrapper.find(".btn-download-pdf").toggle(false);
|
me.wrapper.find(".btn-download-pdf").toggle(false);
|
||||||
me.set_style();
|
me.set_style();
|
||||||
me.preview_old_style();
|
me.preview_old_style();
|
||||||
|
|
@ -119,30 +121,30 @@ frappe.ui.form.PrintPreview = Class.extend({
|
||||||
me.preview();
|
me.preview();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
preview: function() {
|
preview: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.get_print_html(function(out) {
|
this.get_print_html(function (out) {
|
||||||
me.wrapper.find(".print-format").html(out.html);
|
me.wrapper.find(".print-format").html(out.html);
|
||||||
me.set_style(out.style);
|
me.set_style(out.style);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
printit: function() {
|
printit: function () {
|
||||||
this.new_page_preview(true);
|
this.new_page_preview(true);
|
||||||
},
|
},
|
||||||
new_page_preview: function(printit) {
|
new_page_preview: function (printit) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var w = window.open(frappe.urllib.get_full_url("/printview?"
|
var w = window.open(frappe.urllib.get_full_url("/printview?"
|
||||||
+"doctype="+encodeURIComponent(me.frm.doc.doctype)
|
+ "doctype=" + encodeURIComponent(me.frm.doc.doctype)
|
||||||
+"&name="+encodeURIComponent(me.frm.doc.name)
|
+ "&name=" + encodeURIComponent(me.frm.doc.name)
|
||||||
+(printit ? "&trigger_print=1" : "")
|
+ (printit ? "&trigger_print=1" : "")
|
||||||
+"&format="+me.selected_format()
|
+ "&format=" + me.selected_format()
|
||||||
+"&no_letterhead="+(me.with_letterhead() ? "0" : "1")
|
+ "&no_letterhead=" + (me.with_letterhead() ? "0" : "1")
|
||||||
+(me.lang_code ? ("&_lang="+me.lang_code) : "")));
|
+ (me.lang_code ? ("&_lang=" + me.lang_code) : "")));
|
||||||
if(!w) {
|
if (!w) {
|
||||||
frappe.msgprint(__("Please enable pop-ups")); return;
|
frappe.msgprint(__("Please enable pop-ups")); return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
get_print_html: function(callback) {
|
get_print_html: function (callback) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "frappe.www.printview.get_html_and_style",
|
method: "frappe.www.printview.get_html_and_style",
|
||||||
args: {
|
args: {
|
||||||
|
|
@ -151,21 +153,21 @@ frappe.ui.form.PrintPreview = Class.extend({
|
||||||
no_letterhead: !this.with_letterhead() ? 1 : 0,
|
no_letterhead: !this.with_letterhead() ? 1 : 0,
|
||||||
_lang: this.lang_code
|
_lang: this.lang_code
|
||||||
},
|
},
|
||||||
callback: function(r) {
|
callback: function (r) {
|
||||||
if(!r.exc) {
|
if (!r.exc) {
|
||||||
callback(r.message);
|
callback(r.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
preview_old_style: function() {
|
preview_old_style: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
this.with_old_style({
|
this.with_old_style({
|
||||||
format: me.print_sel.val(),
|
format: me.print_sel.val(),
|
||||||
callback: function(html) {
|
callback: function (html) {
|
||||||
me.wrapper.find(".print-format").html('<div class="alert alert-warning">'
|
me.wrapper.find(".print-format").html('<div class="alert alert-warning">'
|
||||||
+__("Warning: This Print Format is in old style and cannot be generated via the API.")
|
+ __("Warning: This Print Format is in old style and cannot be generated via the API.")
|
||||||
+'</div>'
|
+ '</div>'
|
||||||
+ html);
|
+ html);
|
||||||
},
|
},
|
||||||
no_letterhead: !this.with_letterhead(),
|
no_letterhead: !this.with_letterhead(),
|
||||||
|
|
@ -173,55 +175,55 @@ frappe.ui.form.PrintPreview = Class.extend({
|
||||||
no_heading: true
|
no_heading: true
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
refresh_print_options: function() {
|
refresh_print_options: function () {
|
||||||
this.print_formats = frappe.meta.get_print_formats(this.frm.doctype);
|
this.print_formats = frappe.meta.get_print_formats(this.frm.doctype);
|
||||||
return this.print_sel
|
return this.print_sel
|
||||||
.empty().add_options(this.print_formats);
|
.empty().add_options(this.print_formats);
|
||||||
},
|
},
|
||||||
with_old_style: function(opts) {
|
with_old_style: function (opts) {
|
||||||
frappe.require("/assets/js/print_format_v3.min.js", function() {
|
frappe.require("/assets/js/print_format_v3.min.js", function () {
|
||||||
_p.build(opts.format, opts.callback, opts.no_letterhead, opts.only_body, opts.no_heading);
|
_p.build(opts.format, opts.callback, opts.no_letterhead, opts.only_body, opts.no_heading);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
print_old_style: function() {
|
print_old_style: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
frappe.require("/assets/js/print_format_v3.min.js", function() {
|
frappe.require("/assets/js/print_format_v3.min.js", function () {
|
||||||
_p.build(me.print_sel.val(), _p.go,
|
_p.build(me.print_sel.val(), _p.go,
|
||||||
!me.with_letterhead());
|
!me.with_letterhead());
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
new_page_preview_old_style: function() {
|
new_page_preview_old_style: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
frappe.require("/assets/js/print_format_v3.min.js", function() {
|
frappe.require("/assets/js/print_format_v3.min.js", function () {
|
||||||
_p.build(me.print_sel.val(), _p.preview, !me.with_letterhead());
|
_p.build(me.print_sel.val(), _p.preview, !me.with_letterhead());
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
selected_format: function() {
|
selected_format: function () {
|
||||||
return this.print_sel.val() || this.frm.meta.default_print_format || "Standard";
|
return this.print_sel.val() || this.frm.meta.default_print_format || "Standard";
|
||||||
},
|
},
|
||||||
is_old_style: function(format) {
|
is_old_style: function (format) {
|
||||||
return this.get_print_format(format).print_format_type==="Client";
|
return this.get_print_format(format).print_format_type === "Client";
|
||||||
},
|
},
|
||||||
get_print_format: function(format) {
|
get_print_format: function (format) {
|
||||||
if (!format) {
|
if (!format) {
|
||||||
format = this.selected_format();
|
format = this.selected_format();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(locals["Print Format"] && locals["Print Format"][format]) {
|
if (locals["Print Format"] && locals["Print Format"][format]) {
|
||||||
return locals["Print Format"][format]
|
return locals["Print Format"][format]
|
||||||
} else {
|
} else {
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
with_letterhead: function() {
|
with_letterhead: function () {
|
||||||
return this.print_letterhead.is(":checked") ? 1 : 0;
|
return this.print_letterhead.is(":checked") ? 1 : 0;
|
||||||
},
|
},
|
||||||
set_style: function(style) {
|
set_style: function (style) {
|
||||||
frappe.dom.set_style(style || frappe.boot.print_css, "print-style");
|
frappe.dom.set_style(style || frappe.boot.print_css, "print-style");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.ui.get_print_settings = function(pdf, callback, letter_head) {
|
frappe.ui.get_print_settings = function (pdf, callback, letter_head) {
|
||||||
var print_settings = locals[":Print Settings"]["Print Settings"];
|
var print_settings = locals[":Print Settings"]["Print Settings"];
|
||||||
|
|
||||||
var default_letter_head = locals[":Company"] && frappe.defaults.get_default('company')
|
var default_letter_head = locals[":Company"] && frappe.defaults.get_default('company')
|
||||||
|
|
@ -232,16 +234,16 @@ frappe.ui.get_print_settings = function(pdf, callback, letter_head) {
|
||||||
fieldtype: "Check",
|
fieldtype: "Check",
|
||||||
fieldname: "with_letter_head",
|
fieldname: "with_letter_head",
|
||||||
label: __("With Letter head")
|
label: __("With Letter head")
|
||||||
},{
|
}, {
|
||||||
fieldtype: "Select",
|
fieldtype: "Select",
|
||||||
fieldname: "letter_head",
|
fieldname: "letter_head",
|
||||||
label: __("Letter Head"),
|
label: __("Letter Head"),
|
||||||
depends_on: "with_letter_head",
|
depends_on: "with_letter_head",
|
||||||
options: $.map(frappe.boot.letter_heads, function(i,d){ return d }),
|
options: $.map(frappe.boot.letter_heads, function (i, d) { return d }),
|
||||||
default: letter_head || default_letter_head
|
default: letter_head || default_letter_head
|
||||||
}];
|
}];
|
||||||
|
|
||||||
if(pdf) {
|
if (pdf) {
|
||||||
columns.push({
|
columns.push({
|
||||||
fieldtype: "Select",
|
fieldtype: "Select",
|
||||||
fieldname: "orientation",
|
fieldname: "orientation",
|
||||||
|
|
@ -251,12 +253,12 @@ frappe.ui.get_print_settings = function(pdf, callback, letter_head) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.prompt(columns, function(data) {
|
frappe.prompt(columns, function (data) {
|
||||||
var data = $.extend(print_settings, data);
|
var data = $.extend(print_settings, data);
|
||||||
if(!data.with_letter_head) {
|
if (!data.with_letter_head) {
|
||||||
data.letter_head = null;
|
data.letter_head = null;
|
||||||
}
|
}
|
||||||
if(data.letter_head) {
|
if (data.letter_head) {
|
||||||
data.letter_head = frappe.boot.letter_heads[print_settings.letter_head];
|
data.letter_head = frappe.boot.letter_heads[print_settings.letter_head];
|
||||||
}
|
}
|
||||||
callback(data);
|
callback(data);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
frappe.provide("frappe.ui.form");
|
frappe.provide("frappe.ui.form");
|
||||||
|
|
||||||
frappe.ui.form.save = function(frm, action, callback, btn) {
|
frappe.ui.form.save = function (frm, action, callback, btn) {
|
||||||
$(btn).prop("disabled", true);
|
$(btn).prop("disabled", true);
|
||||||
|
|
||||||
// specified here because there are keyboard shortcuts to save
|
// specified here because there are keyboard shortcuts to save
|
||||||
|
|
@ -17,14 +17,14 @@ frappe.ui.form.save = function(frm, action, callback, btn) {
|
||||||
|
|
||||||
var freeze_message = working_label ? __(working_label) : "";
|
var freeze_message = working_label ? __(working_label) : "";
|
||||||
|
|
||||||
var save = function() {
|
var save = function () {
|
||||||
check_name(function() {
|
check_name(function () {
|
||||||
$(frm.wrapper).addClass('validated-form');
|
$(frm.wrapper).addClass('validated-form');
|
||||||
if(check_mandatory()) {
|
if (check_mandatory()) {
|
||||||
_call({
|
_call({
|
||||||
method: "frappe.desk.form.save.savedocs",
|
method: "frappe.desk.form.save.savedocs",
|
||||||
args: { doc: frm.doc, action:action},
|
args: { doc: frm.doc, action: action },
|
||||||
callback: function(r) {
|
callback: function (r) {
|
||||||
$(document).trigger("save", [frm.doc]);
|
$(document).trigger("save", [frm.doc]);
|
||||||
callback(r);
|
callback(r);
|
||||||
},
|
},
|
||||||
|
|
@ -38,7 +38,7 @@ frappe.ui.form.save = function(frm, action, callback, btn) {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var cancel = function() {
|
var cancel = function () {
|
||||||
var args = {
|
var args = {
|
||||||
doctype: frm.doc.doctype,
|
doctype: frm.doc.doctype,
|
||||||
name: frm.doc.name
|
name: frm.doc.name
|
||||||
|
|
@ -46,7 +46,7 @@ frappe.ui.form.save = function(frm, action, callback, btn) {
|
||||||
|
|
||||||
// update workflow state value if workflow exists
|
// update workflow state value if workflow exists
|
||||||
var workflow_state_fieldname = frappe.workflow.get_state_fieldname(frm.doctype);
|
var workflow_state_fieldname = frappe.workflow.get_state_fieldname(frm.doctype);
|
||||||
if(workflow_state_fieldname) {
|
if (workflow_state_fieldname) {
|
||||||
$.extend(args, {
|
$.extend(args, {
|
||||||
workflow_state_fieldname: workflow_state_fieldname,
|
workflow_state_fieldname: workflow_state_fieldname,
|
||||||
workflow_state: frm.doc[workflow_state_fieldname]
|
workflow_state: frm.doc[workflow_state_fieldname]
|
||||||
|
|
@ -57,7 +57,7 @@ frappe.ui.form.save = function(frm, action, callback, btn) {
|
||||||
_call({
|
_call({
|
||||||
method: "frappe.desk.form.save.cancel",
|
method: "frappe.desk.form.save.cancel",
|
||||||
args: args,
|
args: args,
|
||||||
callback: function(r) {
|
callback: function (r) {
|
||||||
$(document).trigger("save", [frm.doc]);
|
$(document).trigger("save", [frm.doc]);
|
||||||
callback(r);
|
callback(r);
|
||||||
},
|
},
|
||||||
|
|
@ -66,14 +66,14 @@ frappe.ui.form.save = function(frm, action, callback, btn) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var check_name = function(callback) {
|
var check_name = function (callback) {
|
||||||
var doc = frm.doc;
|
var doc = frm.doc;
|
||||||
var meta = locals.DocType[doc.doctype];
|
var meta = locals.DocType[doc.doctype];
|
||||||
if(doc.__islocal && (meta && meta.autoname
|
if (doc.__islocal && (meta && meta.autoname
|
||||||
&& meta.autoname.toLowerCase()=='prompt')) {
|
&& meta.autoname.toLowerCase() == 'prompt')) {
|
||||||
var d = frappe.prompt(__("Name"), function(values) {
|
var d = frappe.prompt(__("Name"), function (values) {
|
||||||
var newname = values.value;
|
var newname = values.value;
|
||||||
if(newname) {
|
if (newname) {
|
||||||
doc.__newname = strip(newname);
|
doc.__newname = strip(newname);
|
||||||
} else {
|
} else {
|
||||||
frappe.msgprint(__("Name is required"));
|
frappe.msgprint(__("Name is required"));
|
||||||
|
|
@ -84,11 +84,11 @@ frappe.ui.form.save = function(frm, action, callback, btn) {
|
||||||
|
|
||||||
}, __('Enter the name of the new {0}', [doc.doctype]), __("Create"));
|
}, __('Enter the name of the new {0}', [doc.doctype]), __("Create"));
|
||||||
|
|
||||||
if(doc.__newname) {
|
if (doc.__newname) {
|
||||||
d.set_value("value", doc.__newname);
|
d.set_value("value", doc.__newname);
|
||||||
}
|
}
|
||||||
|
|
||||||
d.onhide = function() {
|
d.onhide = function () {
|
||||||
$(btn).prop("disabled", false);
|
$(btn).prop("disabled", false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -96,36 +96,36 @@ frappe.ui.form.save = function(frm, action, callback, btn) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var check_mandatory = function() {
|
var check_mandatory = function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
var has_errors = false;
|
var has_errors = false;
|
||||||
frm.scroll_set = false;
|
frm.scroll_set = false;
|
||||||
|
|
||||||
if(frm.doc.docstatus==2) return true; // don't check for cancel
|
if (frm.doc.docstatus == 2) return true; // don't check for cancel
|
||||||
|
|
||||||
$.each(frappe.model.get_all_docs(frm.doc), function(i, doc) {
|
$.each(frappe.model.get_all_docs(frm.doc), function (i, doc) {
|
||||||
var error_fields = [];
|
var error_fields = [];
|
||||||
var folded = false;
|
var folded = false;
|
||||||
|
|
||||||
$.each(frappe.meta.docfield_list[doc.doctype] || [], function(i, docfield) {
|
$.each(frappe.meta.docfield_list[doc.doctype] || [], function (i, docfield) {
|
||||||
if(docfield.fieldname) {
|
if (docfield.fieldname) {
|
||||||
var df = frappe.meta.get_docfield(doc.doctype,
|
var df = frappe.meta.get_docfield(doc.doctype,
|
||||||
docfield.fieldname, frm.doc.name);
|
docfield.fieldname, frm.doc.name);
|
||||||
|
|
||||||
if(df.fieldtype==="Fold") {
|
if (df.fieldtype === "Fold") {
|
||||||
folded = frm.layout.folded;
|
folded = frm.layout.folded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(df.reqd && !frappe.model.has_value(doc.doctype, doc.name, df.fieldname)) {
|
if (df.reqd && !frappe.model.has_value(doc.doctype, doc.name, df.fieldname)) {
|
||||||
has_errors = true;
|
has_errors = true;
|
||||||
error_fields[error_fields.length] = __(df.label);
|
error_fields[error_fields.length] = __(df.label);
|
||||||
|
|
||||||
// scroll to field
|
// scroll to field
|
||||||
if(!me.scroll_set) {
|
if (!me.scroll_set) {
|
||||||
scroll_to(doc.parentfield || df.fieldname);
|
scroll_to(doc.parentfield || df.fieldname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(folded) {
|
if (folded) {
|
||||||
frm.layout.unfold();
|
frm.layout.unfold();
|
||||||
folded = false;
|
folded = false;
|
||||||
}
|
}
|
||||||
|
|
@ -133,8 +133,8 @@ frappe.ui.form.save = function(frm, action, callback, btn) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(error_fields.length) {
|
if (error_fields.length) {
|
||||||
if(doc.parenttype) {
|
if (doc.parenttype) {
|
||||||
var message = __('Mandatory fields required in table {0}, Row {1}',
|
var message = __('Mandatory fields required in table {0}, Row {1}',
|
||||||
[__(frappe.meta.docfield_map[doc.parenttype][doc.parentfield].label).bold(), doc.idx]);
|
[__(frappe.meta.docfield_map[doc.parenttype][doc.parentfield].label).bold(), doc.idx]);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -153,15 +153,15 @@ frappe.ui.form.save = function(frm, action, callback, btn) {
|
||||||
return !has_errors;
|
return !has_errors;
|
||||||
};
|
};
|
||||||
|
|
||||||
var scroll_to = function(fieldname) {
|
var scroll_to = function (fieldname) {
|
||||||
var f = cur_frm.fields_dict[fieldname];
|
var f = cur_frm.fields_dict[fieldname];
|
||||||
if(f) {
|
if (f) {
|
||||||
$(document).scrollTop($(f.wrapper).offset().top - 60);
|
$(document).scrollTop($(f.wrapper).offset().top - 60);
|
||||||
}
|
}
|
||||||
frm.scroll_set = true;
|
frm.scroll_set = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var _call = function(opts) {
|
var _call = function (opts) {
|
||||||
// opts = {
|
// opts = {
|
||||||
// method: "some server method",
|
// method: "some server method",
|
||||||
// args: {args to be passed},
|
// args: {args to be passed},
|
||||||
|
|
@ -170,7 +170,7 @@ frappe.ui.form.save = function(frm, action, callback, btn) {
|
||||||
// }
|
// }
|
||||||
$(opts.btn).prop("disabled", true);
|
$(opts.btn).prop("disabled", true);
|
||||||
|
|
||||||
if(frappe.ui.form.is_saving) {
|
if (frappe.ui.form.is_saving) {
|
||||||
// this is likely to happen if the user presses the shortcut cmd+s for a longer duration or uses double click
|
// this is likely to happen if the user presses the shortcut cmd+s for a longer duration or uses double click
|
||||||
// no need to show this to user, as they can see "Saving" in freeze message
|
// no need to show this to user, as they can see "Saving" in freeze message
|
||||||
console.log("Already saving. Please wait a few moments.")
|
console.log("Already saving. Please wait a few moments.")
|
||||||
|
|
@ -184,38 +184,39 @@ frappe.ui.form.save = function(frm, action, callback, btn) {
|
||||||
method: opts.method,
|
method: opts.method,
|
||||||
args: opts.args,
|
args: opts.args,
|
||||||
btn: opts.btn,
|
btn: opts.btn,
|
||||||
callback: function(r) {
|
callback: function (r) {
|
||||||
opts.callback && opts.callback(r);
|
opts.callback && opts.callback(r);
|
||||||
},
|
},
|
||||||
always: function(r) {
|
always: function (r) {
|
||||||
frappe.ui.form.is_saving = false;
|
frappe.ui.form.is_saving = false;
|
||||||
if(r) {
|
if (r) {
|
||||||
var doc = r.docs && r.docs[0];
|
var doc = r.docs && r.docs[0];
|
||||||
if(doc) {
|
if (doc) {
|
||||||
frappe.ui.form.update_calling_link(doc);
|
frappe.ui.form.update_calling_link(doc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
if(action==="cancel") {
|
if (action === "cancel") {
|
||||||
cancel();
|
cancel();
|
||||||
} else {
|
} else {
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe.ui.form.update_calling_link = function(newdoc) {
|
frappe.ui.form.update_calling_link = function (newdoc) {
|
||||||
if(frappe._from_link && newdoc.doctype===frappe._from_link.df.options) {
|
if (frappe._from_link && newdoc.doctype === frappe._from_link.df.options) {
|
||||||
var doc = frappe.get_doc(frappe._from_link.doctype, frappe._from_link.docname);
|
var doc = frappe.get_doc(frappe._from_link.doctype, frappe._from_link.docname);
|
||||||
// set value
|
// set value
|
||||||
if (doc && doc.parentfield){
|
if (doc && doc.parentfield) {
|
||||||
//update values for child table
|
//update values for child table
|
||||||
$.each(frappe._from_link.frm.fields_dict[doc.parentfield].grid.grid_rows, function(index, field) {
|
$.each(frappe._from_link.frm.fields_dict[doc.parentfield].grid.grid_rows, function (index, field) {
|
||||||
if(field.doc && field.doc.name===frappe._from_link.docname){
|
if (field.doc && field.doc.name === frappe._from_link.docname) {
|
||||||
frappe._from_link.set_value(newdoc.name);
|
frappe._from_link.set_value(newdoc.name);
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
frappe._from_link.set_value(newdoc.name);
|
frappe._from_link.set_value(newdoc.name);
|
||||||
}
|
}
|
||||||
|
|
@ -224,9 +225,9 @@ frappe.ui.form.update_calling_link = function(newdoc) {
|
||||||
frappe._from_link.refresh();
|
frappe._from_link.refresh();
|
||||||
|
|
||||||
// if from form, switch
|
// if from form, switch
|
||||||
if(frappe._from_link.frm) {
|
if (frappe._from_link.frm) {
|
||||||
frappe.set_route("Form", frappe._from_link.frm.doctype, frappe._from_link.frm.docname);
|
frappe.set_route("Form", frappe._from_link.frm.doctype, frappe._from_link.frm.docname);
|
||||||
setTimeout(function() { frappe.utils.scroll_to(frappe._from_link_scrollY); }, 100);
|
setTimeout(function () { frappe.utils.scroll_to(frappe._from_link_scrollY); }, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
frappe._from_link = null;
|
frappe._from_link = null;
|
||||||
|
|
|
||||||
|
|
@ -114,8 +114,8 @@ frappe.ui.form.ScriptManager = Class.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
function setup_add_fetch(df) {
|
function setup_add_fetch(df) {
|
||||||
if((in_list(['Data', 'Read Only', 'Text', 'Small Text',
|
if((['Data', 'Read Only', 'Text', 'Small Text',
|
||||||
'Text Editor', 'Code'], df.fieldtype) || df.read_only==1)
|
'Text Editor', 'Code'].includes(df.fieldtype) || df.read_only==1)
|
||||||
&& df.options && df.options.indexOf(".")!=-1) {
|
&& df.options && df.options.indexOf(".")!=-1) {
|
||||||
var parts = df.options.split(".");
|
var parts = df.options.split(".");
|
||||||
me.frm.add_fetch(parts[0], parts[1], df.fieldname);
|
me.frm.add_fetch(parts[0], parts[1], df.fieldname);
|
||||||
|
|
|
||||||
|
|
@ -163,8 +163,8 @@ frappe.ui.form.Share = Class.extend({
|
||||||
$(d.body).find(".edit-share").on("click", function() {
|
$(d.body).find(".edit-share").on("click", function() {
|
||||||
var user = $(this).parents(".shared-user:first").attr("data-user") || "",
|
var user = $(this).parents(".shared-user:first").attr("data-user") || "",
|
||||||
value = $(this).prop("checked") ? 1 : 0,
|
value = $(this).prop("checked") ? 1 : 0,
|
||||||
property = $(this).attr("name")
|
property = $(this).attr("name"),
|
||||||
var everyone = cint($(this).parents(".shared-user:first").attr("data-everyone"));
|
everyone = cint($(this).parents(".shared-user:first").attr("data-everyone"));
|
||||||
|
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: "frappe.share.set_permission",
|
method: "frappe.share.set_permission",
|
||||||
|
|
|
||||||
|
|
@ -58,10 +58,10 @@ frappe.ui.form.Sidebar = Class.extend({
|
||||||
this.frm.tags && this.frm.tags.refresh(this.frm.doc._user_tags);
|
this.frm.tags && this.frm.tags.refresh(this.frm.doc._user_tags);
|
||||||
this.sidebar.find(".modified-by").html(__("{0} edited this {1}",
|
this.sidebar.find(".modified-by").html(__("{0} edited this {1}",
|
||||||
["<strong>" + frappe.user.full_name(this.frm.doc.modified_by) + "</strong>",
|
["<strong>" + frappe.user.full_name(this.frm.doc.modified_by) + "</strong>",
|
||||||
"<br>" + comment_when(this.frm.doc.modified)]));
|
"<br>" + comment_when(this.frm.doc.modified)]));
|
||||||
this.sidebar.find(".created-by").html(__("{0} created this {1}",
|
this.sidebar.find(".created-by").html(__("{0} created this {1}",
|
||||||
["<strong>" + frappe.user.full_name(this.frm.doc.owner) + "</strong>",
|
["<strong>" + frappe.user.full_name(this.frm.doc.owner) + "</strong>",
|
||||||
"<br>" + comment_when(this.frm.doc.creation)]));
|
"<br>" + comment_when(this.frm.doc.creation)]));
|
||||||
|
|
||||||
this.refresh_like();
|
this.refresh_like();
|
||||||
this.setup_ratings();
|
this.setup_ratings();
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
// moment strings for translation
|
// moment strings for translation
|
||||||
|
|
||||||
function prettyDate(time, mini){
|
function prettyDate(time, mini) {
|
||||||
if(!time) {
|
if (!time) {
|
||||||
time = new Date();
|
time = new Date();
|
||||||
}
|
}
|
||||||
if(moment) {
|
if (moment) {
|
||||||
if(frappe.sys_defaults && frappe.sys_defaults.time_zone) {
|
if (frappe.sys_defaults && frappe.sys_defaults.time_zone) {
|
||||||
var ret = moment.tz(time, frappe.sys_defaults.time_zone).locale(frappe.boot.lang).fromNow(mini);
|
var ret = moment.tz(time, frappe.sys_defaults.time_zone).locale(frappe.boot.lang).fromNow(mini);
|
||||||
} else {
|
} else {
|
||||||
var ret = moment(time).locale(frappe.boot.lang).fromNow(mini);
|
var ret = moment(time).locale(frappe.boot.lang).fromNow(mini);
|
||||||
}
|
}
|
||||||
if(mini) {
|
if (mini) {
|
||||||
if(ret === moment().locale(frappe.boot.lang).fromNow(mini)) {
|
if (ret === moment().locale(frappe.boot.lang).fromNow(mini)) {
|
||||||
ret = __("now");
|
ret = __("now");
|
||||||
} else {
|
} else {
|
||||||
var parts = ret.split(" ");
|
var parts = ret.split(" ");
|
||||||
if(parts.length > 1) {
|
if (parts.length > 1) {
|
||||||
if(parts[0]==="a" || parts[0]==="an") {
|
if (parts[0] === "a" || parts[0] === "an") {
|
||||||
parts[0] = 1;
|
parts[0] = 1;
|
||||||
}
|
}
|
||||||
if(parts[1].substr(0, 2)==="mo"){
|
if (parts[1].substr(0, 2) === "mo") {
|
||||||
ret = parts[0] + " M";
|
ret = parts[0] + " M";
|
||||||
} else {
|
} else {
|
||||||
ret = parts[0] + " " + parts[1].substr(0, 1);
|
ret = parts[0] + " " + parts[1].substr(0, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -30,50 +30,50 @@ function prettyDate(time, mini){
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
if(!time) return ''
|
if (!time) return ''
|
||||||
var date = time;
|
var date = time;
|
||||||
if(typeof(time)=="string")
|
if (typeof (time) == "string")
|
||||||
date = new Date((time || "").replace(/-/g,"/").replace(/[TZ]/g," ").replace(/\.[0-9]*/, ""));
|
date = new Date((time || "").replace(/-/g, "/").replace(/[TZ]/g, " ").replace(/\.[0-9]*/, ""));
|
||||||
|
|
||||||
var diff = (((new Date()).getTime() - date.getTime()) / 1000),
|
var diff = (((new Date()).getTime() - date.getTime()) / 1000),
|
||||||
day_diff = Math.floor(diff / 86400);
|
day_diff = Math.floor(diff / 86400);
|
||||||
|
|
||||||
if ( isNaN(day_diff) || day_diff < 0 )
|
if (isNaN(day_diff) || day_diff < 0)
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
var when = day_diff == 0 && (
|
var when = day_diff == 0 && (
|
||||||
diff < 60 && __("just now") ||
|
diff < 60 && __("just now") ||
|
||||||
diff < 120 && __("1 minute ago") ||
|
diff < 120 && __("1 minute ago") ||
|
||||||
diff < 3600 && __("{0} minutes ago", [Math.floor( diff / 60 )]) ||
|
diff < 3600 && __("{0} minutes ago", [Math.floor(diff / 60)]) ||
|
||||||
diff < 7200 && __("1 hour ago") ||
|
diff < 7200 && __("1 hour ago") ||
|
||||||
diff < 86400 && ("{0} hours ago", [Math.floor( diff / 3600 )])) ||
|
diff < 86400 && ("{0} hours ago", [Math.floor(diff / 3600)])) ||
|
||||||
day_diff == 1 && __("Yesterday") ||
|
day_diff == 1 && __("Yesterday") ||
|
||||||
day_diff < 7 && __("{0} days ago", day_diff) ||
|
day_diff < 7 && __("{0} days ago", day_diff) ||
|
||||||
day_diff < 31 && __("{0} weeks ago", [Math.ceil( day_diff / 7 )]) ||
|
day_diff < 31 && __("{0} weeks ago", [Math.ceil(day_diff / 7)]) ||
|
||||||
day_diff < 365 && __("{0} months ago", [Math.ceil( day_diff / 30)]) ||
|
day_diff < 365 && __("{0} months ago", [Math.ceil(day_diff / 30)]) ||
|
||||||
__("> {0} year(s) ago", [Math.floor( day_diff / 365 )]);
|
__("> {0} year(s) ago", [Math.floor(day_diff / 365)]);
|
||||||
|
|
||||||
return when;
|
return when;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var comment_when = function(datetime, mini) {
|
var comment_when = function (datetime, mini) {
|
||||||
var timestamp = frappe.datetime.str_to_user ?
|
var timestamp = frappe.datetime.str_to_user ?
|
||||||
frappe.datetime.str_to_user(datetime) : datetime;
|
frappe.datetime.str_to_user(datetime) : datetime;
|
||||||
return '<span class="frappe-timestamp '
|
return '<span class="frappe-timestamp '
|
||||||
+(mini ? " mini" : "" ) + '" data-timestamp="'+datetime
|
+ (mini ? " mini" : "") + '" data-timestamp="' + datetime
|
||||||
+'" title="'+timestamp+'">'
|
+ '" title="' + timestamp + '">'
|
||||||
+ prettyDate(datetime, mini) + '</span>';
|
+ prettyDate(datetime, mini) + '</span>';
|
||||||
};
|
};
|
||||||
|
|
||||||
frappe.provide("frappe.datetime");
|
frappe.provide("frappe.datetime");
|
||||||
frappe.datetime.refresh_when = function() {
|
frappe.datetime.refresh_when = function () {
|
||||||
if(jQuery) {
|
if (jQuery) {
|
||||||
$(".frappe-timestamp").each(function() {
|
$(".frappe-timestamp").each(function () {
|
||||||
$(this).html(prettyDate($(this).attr("data-timestamp"), $(this).hasClass("mini")));
|
$(this).html(prettyDate($(this).attr("data-timestamp"), $(this).hasClass("mini")));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(function() { frappe.datetime.refresh_when() }, 60000); // refresh every minute
|
setInterval(function () { frappe.datetime.refresh_when() }, 60000); // refresh every minute
|
||||||
|
|
|
||||||
|
|
@ -84,28 +84,22 @@ $.extend(frappe.user, {
|
||||||
if(frappe.boot.user.allow_modules.indexOf(m) === -1) return null;
|
if(frappe.boot.user.allow_modules.indexOf(m) === -1) return null;
|
||||||
|
|
||||||
var ret = null;
|
var ret = null;
|
||||||
switch(type) {
|
if (type === "module") {
|
||||||
case "module":
|
if(frappe.boot.user.allow_modules.indexOf(m)!=-1 || frappe.modules[m].is_help)
|
||||||
if(frappe.boot.user.allow_modules.indexOf(m)!=-1 || frappe.modules[m].is_help)
|
|
||||||
ret = m;
|
|
||||||
break;
|
|
||||||
case "page":
|
|
||||||
if(frappe.boot.allowed_pages.indexOf(frappe.modules[m].link)!=-1)
|
|
||||||
ret = m;
|
|
||||||
break;
|
|
||||||
case "list":
|
|
||||||
if(frappe.model.can_read(frappe.modules[m]._doctype))
|
|
||||||
ret = m;
|
|
||||||
break;
|
|
||||||
case "view":
|
|
||||||
ret = m;
|
ret = m;
|
||||||
break;
|
} else if (type === "page") {
|
||||||
case "setup":
|
if(frappe.boot.allowed_pages.indexOf(frappe.modules[m].link)!=-1)
|
||||||
if(frappe.user.has_role("System Manager") || frappe.user.has_role("Administrator"))
|
|
||||||
ret = m;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = m;
|
ret = m;
|
||||||
|
} else if (type === "list") {
|
||||||
|
if(frappe.model.can_read(frappe.modules[m]._doctype))
|
||||||
|
ret = m;
|
||||||
|
} else if (type === "view") {
|
||||||
|
ret = m;
|
||||||
|
} else if (type === "setup") {
|
||||||
|
if(frappe.user.has_role("System Manager") || frappe.user.has_role("Administrator"))
|
||||||
|
ret = m;
|
||||||
|
} else {
|
||||||
|
ret = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -587,42 +587,42 @@ frappe.utils = {
|
||||||
// String.prototype.includes polyfill
|
// String.prototype.includes polyfill
|
||||||
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/includes
|
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/includes
|
||||||
if (!String.prototype.includes) {
|
if (!String.prototype.includes) {
|
||||||
String.prototype.includes = function(search, start) {
|
String.prototype.includes = function (search, start) {
|
||||||
'use strict';
|
'use strict';
|
||||||
if (typeof start !== 'number') {
|
if (typeof start !== 'number') {
|
||||||
start = 0;
|
start = 0;
|
||||||
}
|
}
|
||||||
if (start + search.length > this.length) {
|
if (start + search.length > this.length) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return this.indexOf(search, start) !== -1;
|
return this.indexOf(search, start) !== -1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Array.prototype.includes polyfill
|
// Array.prototype.includes polyfill
|
||||||
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
|
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
|
||||||
if (!Array.prototype.includes) {
|
if (!Array.prototype.includes) {
|
||||||
Object.defineProperty(Array.prototype, 'includes', {
|
Object.defineProperty(Array.prototype, 'includes', {
|
||||||
value: function(searchElement, fromIndex) {
|
value: function(searchElement, fromIndex) {
|
||||||
if (this == null) {
|
if (this == null) {
|
||||||
throw new TypeError('"this" is null or not defined');
|
throw new TypeError('"this" is null or not defined');
|
||||||
}
|
}
|
||||||
var o = Object(this);
|
var o = Object(this);
|
||||||
var len = o.length >>> 0;
|
var len = o.length >>> 0;
|
||||||
if (len === 0) {
|
if (len === 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var n = fromIndex | 0;
|
||||||
|
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
|
||||||
|
while (k < len) {
|
||||||
|
if (o[k] === searchElement) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
k++;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var n = fromIndex | 0;
|
});
|
||||||
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
|
|
||||||
while (k < len) {
|
|
||||||
if (o[k] === searchElement) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
k++;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// Array de duplicate
|
// Array de duplicate
|
||||||
if (!Array.prototype.uniqBy) {
|
if (!Array.prototype.uniqBy) {
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,8 @@ $.extend(frappe.model, {
|
||||||
updated.push(f.fieldname);
|
updated.push(f.fieldname);
|
||||||
} else if(f.fieldtype == "Select" && f.options && typeof f.options === 'string'
|
} else if(f.fieldtype == "Select" && f.options && typeof f.options === 'string'
|
||||||
&& !in_list(["[Select]", "Loading..."], f.options)) {
|
&& !in_list(["[Select]", "Loading..."], f.options)) {
|
||||||
doc[f.fieldname] = f.options.split("\n")[0];
|
|
||||||
|
doc[f.fieldname] = f.options.split("\n")[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -252,18 +253,19 @@ $.extend(frappe.model, {
|
||||||
// dont copy name and blank fields
|
// dont copy name and blank fields
|
||||||
var df = frappe.meta.get_docfield(doc.doctype, key);
|
var df = frappe.meta.get_docfield(doc.doctype, key);
|
||||||
|
|
||||||
if(df && key.substr(0,2)!='__'
|
if (df && key.substr(0, 2) != '__'
|
||||||
&& !in_list(no_copy_list, key)
|
&& !in_list(no_copy_list, key)
|
||||||
&& !(df && (!from_amend && cint(df.no_copy)==1))) {
|
&& !(df && (!from_amend && cint(df.no_copy) == 1))) {
|
||||||
var value = doc[key] || [];
|
|
||||||
if(df.fieldtype==="Table") {
|
var value = doc[key] || [];
|
||||||
for(var i=0, j=value.length; i<j; i++) {
|
if (df.fieldtype === "Table") {
|
||||||
var d = value[i];
|
for (var i = 0, j = value.length; i < j; i++) {
|
||||||
frappe.model.copy_doc(d, from_amend, newdoc, df.fieldname);
|
var d = value[i];
|
||||||
}
|
frappe.model.copy_doc(d, from_amend, newdoc, df.fieldname);
|
||||||
} else {
|
|
||||||
newdoc[key] = doc[key];
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
newdoc[key] = doc[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ frappe.provide('frappe.model');
|
||||||
|
|
||||||
$.extend(frappe.model, {
|
$.extend(frappe.model, {
|
||||||
no_value_type: ['Section Break', 'Column Break', 'HTML', 'Table',
|
no_value_type: ['Section Break', 'Column Break', 'HTML', 'Table',
|
||||||
'Button', 'Image', 'Fold', 'Heading'],
|
'Button', 'Image', 'Fold', 'Heading'],
|
||||||
|
|
||||||
layout_fields: ['Section Break', 'Column Break', 'Fold'],
|
layout_fields: ['Section Break', 'Column Break', 'Fold'],
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,23 +26,23 @@ frappe.RoleEditor = Class.extend({
|
||||||
|
|
||||||
role_toolbar.find(".btn-add")
|
role_toolbar.find(".btn-add")
|
||||||
.html(__('Add all roles'))
|
.html(__('Add all roles'))
|
||||||
.on("click", function() {
|
.on("click", function () {
|
||||||
$(me.wrapper).find('input[type="checkbox"]').each(function(i, check) {
|
$(me.wrapper).find('input[type="checkbox"]').each(function (i, check) {
|
||||||
if(!$(check).is(":checked")) {
|
if (!$(check).is(":checked")) {
|
||||||
check.checked = true;
|
check.checked = true;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
role_toolbar.find(".btn-remove")
|
role_toolbar.find(".btn-remove")
|
||||||
.html(__('Clear all roles'))
|
.html(__('Clear all roles'))
|
||||||
.on("click", function() {
|
.on("click", function() {
|
||||||
$(me.wrapper).find('input[type="checkbox"]').each(function(i, check) {
|
$(me.wrapper).find('input[type="checkbox"]').each(function(i, check) {
|
||||||
if($(check).is(":checked")) {
|
if($(check).is(":checked")) {
|
||||||
check.checked = false;
|
check.checked = false;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$.each(this.roles, function(i, role) {
|
$.each(this.roles, function(i, role) {
|
||||||
$(me.wrapper).append(repl('<div class="user-role" \
|
$(me.wrapper).append(repl('<div class="user-role" \
|
||||||
|
|
@ -70,10 +70,10 @@ frappe.RoleEditor = Class.extend({
|
||||||
|
|
||||||
// set user roles as checked
|
// set user roles as checked
|
||||||
$.each((me.frm.doc.roles || []), function(i, user_role) {
|
$.each((me.frm.doc.roles || []), function(i, user_role) {
|
||||||
var checkbox = $(me.wrapper)
|
var checkbox = $(me.wrapper)
|
||||||
.find('[data-user-role="'+user_role.role+'"] input[type="checkbox"]').get(0);
|
.find('[data-user-role="'+user_role.role+'"] input[type="checkbox"]').get(0);
|
||||||
if(checkbox) checkbox.checked = true;
|
if(checkbox) checkbox.checked = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
set_roles_in_table: function() {
|
set_roles_in_table: function() {
|
||||||
var opts = this.get_roles();
|
var opts = this.get_roles();
|
||||||
|
|
@ -82,9 +82,9 @@ frappe.RoleEditor = Class.extend({
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
$.each((me.frm.doc.roles || []), function(i, user_role) {
|
$.each((me.frm.doc.roles || []), function(i, user_role) {
|
||||||
existing_roles_map[user_role.role] = user_role.name;
|
existing_roles_map[user_role.role] = user_role.name;
|
||||||
existing_roles_list.push(user_role.role);
|
existing_roles_list.push(user_role.role);
|
||||||
});
|
});
|
||||||
|
|
||||||
// remove unchecked roles
|
// remove unchecked roles
|
||||||
$.each(opts.unchecked_roles, function(i, role) {
|
$.each(opts.unchecked_roles, function(i, role) {
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ frappe.ui.Chart = Class.extend({
|
||||||
|
|
||||||
if(this.opts.data && ((this.opts.data.columns && this.opts.data.columns.length >= 1)
|
if(this.opts.data && ((this.opts.data.columns && this.opts.data.columns.length >= 1)
|
||||||
|| (this.opts.data.rows && this.opts.data.rows.length >= 1))) {
|
|| (this.opts.data.rows && this.opts.data.rows.length >= 1))) {
|
||||||
this.chart = this.render_chart();
|
this.chart = this.render_chart();
|
||||||
this.show_chart(true);
|
this.show_chart(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.chart;
|
return this.chart;
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ frappe.ui.FilterList = Class.extend({
|
||||||
// This gives a predictable stats order
|
// This gives a predictable stats order
|
||||||
me.wrapper.find(".filter-stat").empty();
|
me.wrapper.find(".filter-stat").empty();
|
||||||
$.each(me.stats, function (i, v) {
|
$.each(me.stats, function (i, v) {
|
||||||
me.render_filters(v, (r.message|| {})[v.name]);
|
me.render_filters(v, (r.message|| {})[v.name]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -353,7 +353,7 @@ frappe.ui.FilterList = Class.extend({
|
||||||
fieldname: fieldname,
|
fieldname: fieldname,
|
||||||
condition: condition,
|
condition: condition,
|
||||||
value: value
|
value: value
|
||||||
});
|
});
|
||||||
|
|
||||||
this.filters.push(filter);
|
this.filters.push(filter);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -233,8 +233,8 @@ frappe.show_progress = function(title, count, total) {
|
||||||
});
|
});
|
||||||
dialog.progress = $('<div class="progress"><div class="progress-bar"></div></div>')
|
dialog.progress = $('<div class="progress"><div class="progress-bar"></div></div>')
|
||||||
.appendTo(dialog.body);
|
.appendTo(dialog.body);
|
||||||
dialog.progress_bar = dialog.progress.css({"margin-top": "10px"})
|
dialog.progress_bar = dialog.progress.css({"margin-top": "10px"})
|
||||||
.find(".progress-bar");
|
.find(".progress-bar");
|
||||||
dialog.$wrapper.removeClass("fade");
|
dialog.$wrapper.removeClass("fade");
|
||||||
dialog.show();
|
dialog.show();
|
||||||
frappe.cur_progress = dialog;
|
frappe.cur_progress = dialog;
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,7 @@ frappe.ui.Page = Class.extend({
|
||||||
return this.$title_area.find(".title-icon")
|
return this.$title_area.find(".title-icon")
|
||||||
.html('<i class="'+icon+' fa-fw"></i> ')
|
.html('<i class="'+icon+' fa-fw"></i> ')
|
||||||
.toggle(true);
|
.toggle(true);
|
||||||
},
|
},
|
||||||
|
|
||||||
add_help_button: function(txt) {
|
add_help_button: function(txt) {
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -136,41 +136,41 @@ frappe.search.utils = {
|
||||||
route: route,
|
route: route,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
frappe.boot.user.can_read.forEach(function(item) {
|
frappe.boot.user.can_read.forEach(function (item) {
|
||||||
level = me.fuzzy_search(keywords, item);
|
level = me.fuzzy_search(keywords, item);
|
||||||
if(level) {
|
if (level) {
|
||||||
target = item;
|
target = item;
|
||||||
if(in_list(frappe.boot.single_types, item)) {
|
if (in_list(frappe.boot.single_types, item)) {
|
||||||
out.push(option("", ["Form", item, item], 0.05));
|
out.push(option("", ["Form", item, item], 0.05));
|
||||||
|
|
||||||
} else if(frappe.boot.user.can_search.includes(item)) {
|
} else if (frappe.boot.user.can_search.includes(item)) {
|
||||||
// include 'making new' option
|
// include 'making new' option
|
||||||
if(in_list(frappe.boot.user.can_create, item)) {
|
if (in_list(frappe.boot.user.can_create, item)) {
|
||||||
var match = item;
|
var match = item;
|
||||||
out.push({
|
out.push({
|
||||||
type: "New",
|
type: "New",
|
||||||
label: __("New {0}", [me.bolden_match_part(__(item), keywords)]),
|
label: __("New {0}", [me.bolden_match_part(__(item), keywords)]),
|
||||||
value: __("New {0}", [__(item)]),
|
value: __("New {0}", [__(item)]),
|
||||||
index: level + 0.01,
|
index: level + 0.01,
|
||||||
match: item,
|
match: item,
|
||||||
onclick: function() { frappe.new_doc(match, true); }
|
onclick: function () { frappe.new_doc(match, true); }
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
if (in_list(frappe.boot.treeviews, item)) {
|
||||||
|
out.push(option("Tree", ["Tree", item], 0.05));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
out.push(option("List", ["List", item], 0.05));
|
||||||
|
if (frappe.model.can_get_report(item)) {
|
||||||
|
out.push(option("Report", ["Report", item], 0.04));
|
||||||
}
|
}
|
||||||
if(in_list(frappe.boot.treeviews, item)) {
|
if (frappe.boot.calendars.indexOf(item) !== -1) {
|
||||||
out.push(option("Tree", ["Tree", item], 0.05));
|
out.push(option("Calendar", ["List", item, "Calendar"], 0.03));
|
||||||
|
out.push(option("Gantt", ["List", item, "Gantt"], 0.02));
|
||||||
} else {
|
|
||||||
out.push(option("List", ["List", item], 0.05));
|
|
||||||
if(frappe.model.can_get_report(item)) {
|
|
||||||
out.push(option("Report", ["Report", item], 0.04));
|
|
||||||
}
|
|
||||||
if(frappe.boot.calendars.indexOf(item) !== -1) {
|
|
||||||
out.push(option("Calendar", ["List", item, "Calendar"], 0.03));
|
|
||||||
out.push(option("Gantt", ["List", item, "Gantt"], 0.02));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return out;
|
return out;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -357,26 +357,26 @@ frappe.upload = {
|
||||||
var filename = fileobjs[i].name;
|
var filename = fileobjs[i].name;
|
||||||
fields.push({'fieldname': 'label1', 'fieldtype': 'Heading', 'label': filename});
|
fields.push({'fieldname': 'label1', 'fieldtype': 'Heading', 'label': filename});
|
||||||
fields.push({'fieldname': filename+'_is_private', 'fieldtype': 'Check', 'label': 'Private', 'default': 1});
|
fields.push({'fieldname': filename+'_is_private', 'fieldtype': 'Check', 'label': 'Private', 'default': 1});
|
||||||
}
|
}
|
||||||
|
|
||||||
var d = new frappe.ui.Dialog({
|
var d = new frappe.ui.Dialog({
|
||||||
'title': __('Make file(s) private or public?'),
|
'title': __('Make file(s) private or public?'),
|
||||||
'fields': fields,
|
'fields': fields,
|
||||||
primary_action: function(){
|
primary_action: function(){
|
||||||
var i =0,j = fileobjs.length;
|
var i =0,j = fileobjs.length;
|
||||||
d.hide();
|
d.hide();
|
||||||
opts.loopcallback = function (){
|
opts.loopcallback = function (){
|
||||||
if (i < j) {
|
if (i < j) {
|
||||||
args.is_private = d.fields_dict[fileobjs[i].name + "_is_private"].get_value()
|
args.is_private = d.fields_dict[fileobjs[i].name + "_is_private"].get_value()
|
||||||
frappe.upload.upload_file(fileobjs[i], args, opts);
|
frappe.upload.upload_file(fileobjs[i], args, opts);
|
||||||
i++;
|
i++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
opts.loopcallback();
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
d.show();
|
opts.loopcallback();
|
||||||
opts.confirm_is_private = 0;
|
}
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
|
opts.confirm_is_private = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -325,7 +325,7 @@ frappe.views.Calendar = Class.extend({
|
||||||
$.each(this.filters, function(i, df) {
|
$.each(this.filters, function(i, df) {
|
||||||
if(df.options===value)
|
if(df.options===value)
|
||||||
me.page.fields_dict[df.fieldname].set_input(value);
|
me.page.fields_dict[df.fieldname].set_input(value);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -334,7 +334,7 @@ frappe.views.CommunicationComposer = Class.extend({
|
||||||
<p class='add-more-attachments'>\
|
<p class='add-more-attachments'>\
|
||||||
<a class='text-muted small'><i class='octicon octicon-plus' style='font-size: 12px'></i> "
|
<a class='text-muted small'><i class='octicon octicon-plus' style='font-size: 12px'></i> "
|
||||||
+__("Add Attachment")+"</a></p>").appendTo(attach.empty())
|
+__("Add Attachment")+"</a></p>").appendTo(attach.empty())
|
||||||
attach.find(".add-more-attachments a").on('click',this,function() {
|
attach.find(".add-more-attachments a").on('click',this,function() {
|
||||||
me.upload = frappe.ui.get_upload_dialog(args);
|
me.upload = frappe.ui.get_upload_dialog(args);
|
||||||
})
|
})
|
||||||
me.render_attach()
|
me.render_attach()
|
||||||
|
|
@ -397,10 +397,12 @@ frappe.views.CommunicationComposer = Class.extend({
|
||||||
var form_values = this.get_values();
|
var form_values = this.get_values();
|
||||||
if(!form_values) return;
|
if(!form_values) return;
|
||||||
|
|
||||||
var selected_attachments = $.map($(me.dialog.wrapper)
|
var selected_attachments =
|
||||||
.find("[data-file-name]:checked"), function(element) {
|
$.map($(me.dialog.wrapper)
|
||||||
|
.find("[data-file-name]:checked"), function (element) {
|
||||||
return $(element).attr("data-file-name");
|
return $(element).attr("data-file-name");
|
||||||
})
|
});
|
||||||
|
|
||||||
|
|
||||||
if(form_values.attach_document_print) {
|
if(form_values.attach_document_print) {
|
||||||
if (cur_frm.print_preview.is_old_style(form_values.select_print_format || "")) {
|
if (cur_frm.print_preview.is_old_style(form_values.select_print_format || "")) {
|
||||||
|
|
@ -496,7 +498,7 @@ frappe.views.CommunicationComposer = Class.extend({
|
||||||
me.dialog.hide();
|
me.dialog.hide();
|
||||||
|
|
||||||
if ((frappe.last_edited_communication[me.doc] || {})[me.key]) {
|
if ((frappe.last_edited_communication[me.doc] || {})[me.key]) {
|
||||||
delete frappe.last_edited_communication[me.doc][me.key];
|
delete frappe.last_edited_communication[me.doc][me.key];
|
||||||
}
|
}
|
||||||
if (cur_frm) {
|
if (cur_frm) {
|
||||||
// clear input
|
// clear input
|
||||||
|
|
@ -553,11 +555,12 @@ frappe.views.CommunicationComposer = Class.extend({
|
||||||
},
|
},
|
||||||
setup_awesomplete: function() {
|
setup_awesomplete: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
[this.dialog.fields_dict.recipients.input,
|
[
|
||||||
this.dialog.fields_dict.cc.input]
|
this.dialog.fields_dict.recipients.input,
|
||||||
.map(function(input) {
|
this.dialog.fields_dict.cc.input
|
||||||
me.setup_awesomplete_for_input(input);
|
].map(function(input) {
|
||||||
});
|
me.setup_awesomplete_for_input(input);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
setup_awesomplete_for_input: function(input) {
|
setup_awesomplete_for_input: function(input) {
|
||||||
function split(val) {
|
function split(val) {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
* frappe.views.EmailInboxView
|
* frappe.views.EmailInboxView
|
||||||
*/
|
*/
|
||||||
|
|
||||||
frappe.provide("frappe.views");
|
frappe.provide("frappe.views");
|
||||||
|
|
||||||
frappe.views.InboxView = frappe.views.ListRenderer.extend({
|
frappe.views.InboxView = frappe.views.ListRenderer.extend({
|
||||||
name: 'Inbox',
|
name: 'Inbox',
|
||||||
|
|
|
||||||
|
|
@ -577,9 +577,9 @@ frappe.views.GridReport = Class.extend({
|
||||||
get_link_open_icon: function(doctype, name) {
|
get_link_open_icon: function(doctype, name) {
|
||||||
return repl(' <a href="#Form/%(doctype)s/%(name)s">\
|
return repl(' <a href="#Form/%(doctype)s/%(name)s">\
|
||||||
<i class="fa fa-share" style="cursor: pointer;"></i></a>', {
|
<i class="fa fa-share" style="cursor: pointer;"></i></a>', {
|
||||||
doctype: doctype,
|
doctype: doctype,
|
||||||
name: encodeURIComponent(name)
|
name: encodeURIComponent(name)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
make_date_range_columns: function() {
|
make_date_range_columns: function() {
|
||||||
this.columns = [];
|
this.columns = [];
|
||||||
|
|
@ -640,8 +640,8 @@ frappe.views.GridReport = Class.extend({
|
||||||
build_columns(function(date) {
|
build_columns(function(date) {
|
||||||
if(!me.last_date) return true;
|
if(!me.last_date) return true;
|
||||||
return $.map(frappe.report_dump.data['Fiscal Year'], function(v) {
|
return $.map(frappe.report_dump.data['Fiscal Year'], function(v) {
|
||||||
return date==v.year_start_date ? true : null;
|
return date==v.year_start_date ? true : null;
|
||||||
}).length;
|
}).length;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -874,7 +874,7 @@ frappe.views.TreeGridReport = frappe.views.GridReportWithPlot.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
frappe.tools.downloadify(data, ["Report Manager", "System Manager"], me.title);
|
frappe.tools.downloadify(data, ["Report Manager", "System Manager"], me.title);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -222,14 +222,14 @@ frappe.views.QueryReport = Class.extend({
|
||||||
{data: frappe.slickgrid_tools.get_filtered_items(this.dataView), filters:this.get_values(), report:this});
|
{data: frappe.slickgrid_tools.get_filtered_items(this.dataView), filters:this.get_values(), report:this});
|
||||||
|
|
||||||
//Render Report in HTML
|
//Render Report in HTML
|
||||||
var html = frappe.render_template("print_template", {
|
var html = frappe.render_template("print_template", {
|
||||||
content:content,
|
content:content,
|
||||||
title:__(this.report_name),
|
title:__(this.report_name),
|
||||||
base_url: base_url,
|
base_url: base_url,
|
||||||
print_css: print_css,
|
print_css: print_css,
|
||||||
print_settings: this.print_settings,
|
print_settings: this.print_settings,
|
||||||
landscape: landscape
|
landscape: landscape
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// rows filtered by inline_filter of slickgrid
|
// rows filtered by inline_filter of slickgrid
|
||||||
var visible_idx = frappe.slickgrid_tools
|
var visible_idx = frappe.slickgrid_tools
|
||||||
|
|
@ -519,7 +519,7 @@ frappe.views.QueryReport = Class.extend({
|
||||||
col.name = col.id = col.label = df.label;
|
col.name = col.id = col.label = df.label;
|
||||||
|
|
||||||
return col
|
return col
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
filter_hidden_columns: function() {
|
filter_hidden_columns: function() {
|
||||||
this.columns = $.map(this.columns, function(c, i) {
|
this.columns = $.map(this.columns, function(c, i) {
|
||||||
|
|
|
||||||
|
|
@ -500,9 +500,9 @@ frappe.views.ReportView = frappe.ui.BaseList.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
edit_cell: function(row, docfield) {
|
edit_cell: function(row, docfield) {
|
||||||
if(!docfield || docfield.fieldname !== "idx" &&
|
if(!docfield || docfield.fieldname !== "idx"
|
||||||
frappe.model.std_fields_list.indexOf(docfield.fieldname)!==-1) {
|
&& frappe.model.std_fields_list.indexOf(docfield.fieldname)!==-1) {
|
||||||
return;
|
return;
|
||||||
} else if(frappe.boot.user.can_write.indexOf(this.doctype)===-1) {
|
} else if(frappe.boot.user.can_write.indexOf(this.doctype)===-1) {
|
||||||
frappe.throw({message:__("No permission to edit"), title:__('Not Permitted')});
|
frappe.throw({message:__("No permission to edit"), title:__('Not Permitted')});
|
||||||
}
|
}
|
||||||
|
|
@ -581,13 +581,13 @@ frappe.views.ReportView = frappe.ui.BaseList.extend({
|
||||||
if(this.can_delete) {
|
if(this.can_delete) {
|
||||||
std_columns = std_columns.concat([{
|
std_columns = std_columns.concat([{
|
||||||
id:'_check', field:'_check', name: "", width: 30, maxWidth: 30,
|
id:'_check', field:'_check', name: "", width: 30, maxWidth: 30,
|
||||||
formatter: function(row, cell, value, columnDef, dataContext) {
|
formatter: function(row, cell, value, columnDef, dataContext) {
|
||||||
return repl("<input type='checkbox' \
|
return repl("<input type='checkbox' \
|
||||||
data-row='%(row)s' %(checked)s>", {
|
data-row='%(row)s' %(checked)s>", {
|
||||||
row: row,
|
row: row,
|
||||||
checked: (dataContext.selected ? "checked=\"checked\"" : "")
|
checked: (dataContext.selected ? "checked=\"checked\"" : "")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
return std_columns.concat(this.build_columns());
|
return std_columns.concat(this.build_columns());
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
|
||||||
// MIT License. See license.txt
|
// MIT License. See license.txt
|
||||||
|
|
||||||
get_server_fields = function(method, arg, table_field, doc, dt, dn, allow_edit, call_back) {
|
window.get_server_fields = function(method, arg, table_field, doc, dt, dn, allow_edit, call_back) {
|
||||||
console.warn("This function 'get_server_fields' has been deprecated and will be removed soon.");
|
console.warn("This function 'get_server_fields' has been deprecated and will be removed soon.");
|
||||||
frappe.dom.freeze();
|
frappe.dom.freeze();
|
||||||
if($.isPlainObject(arg)) arg = JSON.stringify(arg);
|
if($.isPlainObject(arg)) arg = JSON.stringify(arg);
|
||||||
return $c('runserverobj',
|
return $c('runserverobj', {'method': method, 'docs': JSON.stringify(doc), 'arg': arg },
|
||||||
args={'method': method, 'docs': JSON.stringify(doc), 'arg': arg },
|
|
||||||
function(r, rt) {
|
function(r, rt) {
|
||||||
frappe.dom.unfreeze();
|
frappe.dom.unfreeze();
|
||||||
if (r.message) {
|
if (r.message) {
|
||||||
|
|
@ -24,12 +23,11 @@ get_server_fields = function(method, arg, table_field, doc, dt, dn, allow_edit,
|
||||||
doc = locals[doc.doctype][doc.name];
|
doc = locals[doc.doctype][doc.name];
|
||||||
call_back(doc, dt, dn);
|
call_back(doc, dt, dn);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
set_multiple = function (dt, dn, dict, table_field) {
|
window.set_multiple = function (dt, dn, dict, table_field) {
|
||||||
var d = locals[dt][dn];
|
var d = locals[dt][dn];
|
||||||
for(var key in dict) {
|
for(var key in dict) {
|
||||||
d[key] = dict[key];
|
d[key] = dict[key];
|
||||||
|
|
@ -40,7 +38,7 @@ set_multiple = function (dt, dn, dict, table_field) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh_many = function (flist, dn, table_field) {
|
window.refresh_many = function (flist, dn, table_field) {
|
||||||
for(var i in flist) {
|
for(var i in flist) {
|
||||||
if (table_field)
|
if (table_field)
|
||||||
refresh_field(flist[i], dn, table_field);
|
refresh_field(flist[i], dn, table_field);
|
||||||
|
|
@ -49,7 +47,7 @@ refresh_many = function (flist, dn, table_field) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_field_tip = function(n,txt) {
|
window.set_field_tip = function(n,txt) {
|
||||||
var df = frappe.meta.get_docfield(cur_frm.doctype, n, cur_frm.docname);
|
var df = frappe.meta.get_docfield(cur_frm.doctype, n, cur_frm.docname);
|
||||||
if(df)df.description = txt;
|
if(df)df.description = txt;
|
||||||
|
|
||||||
|
|
@ -84,11 +82,11 @@ refresh_field = function(n, docname, table_field) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_field_options = function(n, txt) {
|
window.set_field_options = function(n, txt) {
|
||||||
cur_frm.set_df_property(n, 'options', txt)
|
cur_frm.set_df_property(n, 'options', txt)
|
||||||
}
|
}
|
||||||
|
|
||||||
set_field_permlevel = function(n, level) {
|
window.set_field_permlevel = function(n, level) {
|
||||||
cur_frm.set_df_property(n, 'permlevel', level)
|
cur_frm.set_df_property(n, 'permlevel', level)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,7 +190,7 @@ _f.Frm.prototype.set_df_property = function(fieldname, property, value, docname,
|
||||||
var df = this.get_docfield(fieldname);
|
var df = this.get_docfield(fieldname);
|
||||||
} else {
|
} else {
|
||||||
var grid = cur_frm.fields_dict[table_field].grid,
|
var grid = cur_frm.fields_dict[table_field].grid,
|
||||||
fname = frappe.utils.filter_dict(grid.docfields, {'fieldname': fieldname});
|
fname = frappe.utils.filter_dict(grid.docfields, {'fieldname': fieldname});
|
||||||
if (fname && fname.length)
|
if (fname && fname.length)
|
||||||
var df = frappe.meta.get_docfield(fname[0].parent, fieldname, docname);
|
var df = frappe.meta.get_docfield(fname[0].parent, fieldname, docname);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -164,5 +164,5 @@ frappe.urllib = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get_url_arg = frappe.urllib.get_arg;
|
window.get_url_arg = frappe.urllib.get_arg;
|
||||||
get_url_dict = frappe.urllib.get_dict;
|
window.get_url_dict = frappe.urllib.get_dict;
|
||||||
|
|
|
||||||
|
|
@ -393,12 +393,11 @@ _f.Frm.prototype.refresh = function(docname) {
|
||||||
|
|
||||||
if(docname) {
|
if(docname) {
|
||||||
// record switch
|
// record switch
|
||||||
if(this.docname != docname && (!this.meta.in_dialog || this.in_form) &&
|
if(this.docname != docname && (!this.meta.in_dialog || this.in_form) && !this.meta.istable) {
|
||||||
!this.meta.istable) {
|
frappe.utils.scroll_to(0);
|
||||||
frappe.utils.scroll_to(0);
|
this.hide_print();
|
||||||
this.hide_print();
|
}
|
||||||
}
|
frappe.ui.form.close_grid_form();
|
||||||
frappe.ui.form.close_grid_form();
|
|
||||||
this.docname = docname;
|
this.docname = docname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -609,7 +609,7 @@ $.extend(_p, {
|
||||||
return html;
|
return html;
|
||||||
},
|
},
|
||||||
|
|
||||||
add_layout: function(doctype) {v
|
add_layout: function(doctype) {
|
||||||
var layout = new Layout();
|
var layout = new Layout();
|
||||||
layout.addrow();
|
layout.addrow();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue