[cleanup] UI Fixes, minor

This commit is contained in:
Rushabh Mehta 2013-11-06 11:29:39 +05:30
parent debad715a7
commit 88b28ff7a1
8 changed files with 29 additions and 29 deletions

View file

@ -9,6 +9,10 @@ from webnotes.utils import cint, cstr
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def autoname(self):
self.set_fieldname()
self.doc.name = self.doc.dt + "-" + self.doc.fieldname
def set_fieldname(self):
if not self.doc.fieldname:
@ -104,7 +108,7 @@ def get_fields_label(dt=None, form=1):
field_list = [cstr(d.fieldname) for d in docfields]
return idx_label_list, field_list
def delete_and_create_custom_field_if_values_exist(doctype, df):
def create_custom_field_if_values_exist(doctype, df):
df = webnotes._dict(df)
if webnotes.conn.sql("""select count(*) from `tab{doctype}`
where ifnull({fieldname},'')!=''""".format(doctype=doctype, fieldname=df.fieldname))[0][0]:

View file

@ -2,12 +2,11 @@
{
"creation": "2013-01-10 16:34:01",
"docstatus": 0,
"modified": "2013-07-05 14:33:59",
"modified": "2013-11-05 20:07:27",
"modified_by": "Administrator",
"owner": "Administrator"
},
{
"autoname": "eval:doc.dt+\"-\"+doc.fieldname",
"description": "Adds a custom field to a DocType",
"doctype": "DocType",
"icon": "icon-glass",

View file

@ -2,7 +2,7 @@
{
"creation": "2013-02-18 13:36:19",
"docstatus": 0,
"modified": "2013-11-02 23:01:10",
"modified": "2013-11-05 20:09:08",
"modified_by": "Administrator",
"owner": "Administrator"
},
@ -155,7 +155,7 @@
"fieldtype": "Section Break"
},
{
"description": "<a onclick=\"msgprint('<ol>\\\n<li><b>field:[fieldname]</b> - By Field\\\n<li><b>naming_series:</b> - By Naming Series (field called naming_series must be present\\\n<li><b>eval:[expression]</b> - Evaluate an expression in python (self is doc)\\\n<li><b>Prompt</b> - Prompt user for a name\\\n<li><b>[series]</b> - Series by prefix (separated by a dot); for example PRE.#####\\\n</ol>')\">Naming Options</a>",
"description": "<a onclick=\"msgprint('<ol>\\\n<li><b>field:[fieldname]</b> - By Field\\\n<li><b>naming_series:</b> - By Naming Series (field called naming_series must be present\\\n<li><b>Prompt</b> - Prompt user for a name\\\n<li><b>[series]</b> - Series by prefix (separated by a dot); for example PRE.#####\\\n</ol>')\">Naming Options</a>",
"doctype": "DocField",
"fieldname": "autoname",
"fieldtype": "Data",

View file

@ -133,12 +133,12 @@ _f.Frm.prototype.field_map = function(fnames, fn) {
fnames = [fnames];
}
}
$.each(fnames, function(i,f) {
$.each(fnames, function(i,fieldname) {
//var field = cur_frm.fields_dict[f]; - much better design
var field = wn.meta.get_docfield(cur_frm.doctype, f, cur_frm.docname)
var field = wn.meta.get_docfield(cur_frm.doctype, fieldname, cur_frm.docname);
if(field) {
fn(field);
cur_frm.refresh_field(f);
cur_frm.refresh_field(fieldname);
};
})

View file

@ -147,8 +147,8 @@ wn.ui.form.ControlInput = wn.ui.form.Control.extend({
} else {
this.$wrapper = $('<div class="form-horizontal">\
<div class="form-group row" style="margin: 0px">\
<label class="control-label col-xs-'+(this.horizontal?"3":"12")+'" style="padding-right: 0px"></label>\
<div class="col-xs-'+(this.horizontal?"9":"12")+'">\
<label class="control-label small text-muted col-xs-'+(this.horizontal?"4":"12")+'" style="padding-right: 0px"></label>\
<div class="col-xs-'+(this.horizontal?"8":"12")+'">\
<div class="control-input"></div>\
<div class="control-value like-disabled-input" style="display: none;"></div>\
<p class="help-box small text-muted"></p>\
@ -450,13 +450,13 @@ wn.ui.form.ControlCheck = wn.ui.form.ControlData.extend({
input_type: "checkbox",
make_wrapper: function() {
this.$wrapper = $('<div class="form-group row">\
<div class="col-md-offset-3 col-md-9">\
<div class="checkbox">\
<div class="col-md-offset-4 col-md-8">\
<div class="checkbox" style="margin: 5px 0px">\
<label class="input-area">\
<span class="disp-area" style="display:none;"></span>\
<span class="label-area"></span>\
<span class="label-area small text-muted"></span>\
</label>\
<p class="help-box small text-muted">&nbsp;</p>\
<p class="help-box small text-muted"></p>\
</div>\
</div>\
</div>').appendTo(this.parent)
@ -697,9 +697,10 @@ wn.ui.form.ControlSelect = wn.ui.form.ControlData.extend({
wn.ui.form.ControlLink = wn.ui.form.ControlData.extend({
make_input: function() {
var me = this;
$('<div class="link-field">\
<input type="text" class="input-with-feedback form-control" style="width: 80%; display: inline-block">\
<span class="link-field-btn">\
$('<div class="link-field" style="display: table; width: 100%;">\
<input type="text" class="input-with-feedback form-control" \
style="display: table-cell">\
<span class="link-field-btn" style="display: table-cell">\
<a class="btn-search" title="Search Link">\
<i class="icon-search"></i>\
</a><a class="btn-open" title="Open Link">\

View file

@ -199,7 +199,7 @@ $.extend(wn.perm, {
}
if(explain) console.log("By Read Only:" + ret)
return ret;
}

View file

@ -36,8 +36,7 @@ bsEditor = Class.extend({
}).data("object", this);
this.bind_hotkeys();
this.init_file_drops();
this.init_file_drops();
},
set_editing: function() {
@ -56,7 +55,7 @@ bsEditor = Class.extend({
this.toolbar = window.bs_editor_toolbar;
},
setup_inline_toolbar: function() {
this.toolbar = new bsEditorToolbar(this.options, this.wrapper);
this.toolbar = new bsEditorToolbar(this.options, this.wrapper, this.editor);
},
onhide: function(action) {
this.editing = false;
@ -193,8 +192,9 @@ bsEditor = Class.extend({
})
bsEditorToolbar = Class.extend({
init: function(options, parent) {
init: function(options, parent, editor) {
this.options = options;
this.editor = editor;
this.inline = !!parent;
this.options.toolbar_style = $.extend((this.inline ? this.inline_style : this.fixed_style),
this.options.toolbar_style || {});
@ -330,7 +330,8 @@ bsEditorToolbar = Class.extend({
me.execCommand($(this).data(me.options.command_role));
me.save_selection();
// close dropdown
me.toolbar.find('[data-toggle="dropdown"]').dropdown("toggle");
if(me.toolbar.find("ul.dropdown-menu:visible").length)
me.toolbar.find('[data-toggle="dropdown"]').dropdown("toggle");
return false;
});
this.toolbar.find('[data-toggle=dropdown]').click(function() { me.restore_selection() });

View file

@ -272,12 +272,7 @@ class Document:
if not self.naming_series:
webnotes.msgprint(webnotes._("Naming Series mandatory"), raise_exception=True)
self.name = make_autoname(self.naming_series+'.#####')
# based on expression
elif autoname and autoname.startswith('eval:'):
doc = self # for setting
self.name = eval(autoname[5:])
# call the method!
elif autoname and autoname!='Prompt':
self.name = make_autoname(autoname, self.doctype)