[fix] control.js

This commit is contained in:
Rushabh Mehta 2016-01-15 16:55:35 +05:30
parent 276c444edc
commit 39e75cb0c1
3 changed files with 19 additions and 14 deletions

View file

@ -51,11 +51,11 @@ frappe.ui.form.Control = Class.extend({
if (cint(this.df.hidden)) {
if(explain) console.log("By Hidden: None");
return "None";
} else if (cint(this.df.read_only)) {
if(explain) console.log("By Read Only: Read");
return "Read";
}
return "Write";
@ -923,11 +923,14 @@ frappe.ui.form.ControlSelect = frappe.ui.form.ControlData.extend({
this._super();
this.set_options();
},
set_input: function(value) {
set_input: function(value) {
// refresh options first - (new ones??)
this.set_options(value || "");
var input_value = this.$input.val();
var input_value = null;
if(this.$input) {
var input_value = this.$input.val();
}
// not a possible option, repair
if(this.doctype && this.docname) {
@ -944,7 +947,7 @@ frappe.ui.form.ControlSelect = frappe.ui.form.ControlData.extend({
this.set_value(input_value);
}
}
this._super(value);
},
@ -963,11 +966,13 @@ frappe.ui.form.ControlSelect = frappe.ui.form.ControlData.extend({
}
this.last_options = options.toString();
var selected = this.$input.find(":selected").val();
this.$input.empty().add_options(options || []);
if(value===undefined && selected) {
this.$input.val(selected);
if(this.$input) {
var selected = this.$input.find(":selected").val();
this.$input.empty().add_options(options || []);
if(value===undefined && selected) {
this.$input.val(selected);
}
}
},
get_file_attachment_list: function() {

View file

@ -230,14 +230,14 @@ frappe.ui.Page = Class.extend({
get_inner_group_button: function(label) {
var $group = this.inner_toolbar.find('.btn-group[data-label="'+label+'"]');
if(!$group.length) {
$group = $('<div class="btn-group" data-label='+label+' style="margin-left: 10px;">\
$group = $('<div class="btn-group" data-label="'+label+'" style="margin-left: 10px;">\
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\
'+label+' <span class="caret"></span></button>\
<ul class="dropdown-menu" style="margin-top: -8px;"></ul></div>').appendTo(this.inner_toolbar.removeClass("hide"));
}
return $group;
},
set_inner_btn_group_as_primary: function(label) {
this.get_inner_group_button(label).find("button").removeClass("btn-default").addClass("btn-primary");
},

View file

@ -8,7 +8,7 @@ frappe.template.compile = function(str, name) {
if(!frappe.template.compiled[key]) {
if(str.indexOf("'")!==-1) {
str.replace(/'/g, "\\'");
console.warn("Warning: Single quotes (') may not work in templates");
//console.warn("Warning: Single quotes (') may not work in templates");
}
// repace jinja style tags