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