Merge branch 'responsive' of github.com:webnotes/wnframework into responsive
This commit is contained in:
commit
aa9a7bdeef
8 changed files with 83 additions and 24 deletions
|
|
@ -430,6 +430,10 @@ textarea[data-fieldtype="Small Text"] {
|
|||
}
|
||||
}
|
||||
|
||||
.modal-backdrop {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* buttons */
|
||||
.btn-default {
|
||||
color: #ffffff;
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ wn.ui.form.ControlInt = wn.ui.form.ControlData.extend({
|
|||
this.$input
|
||||
.css({"text-align": "right"})
|
||||
.on("focus", function() {
|
||||
this.select();
|
||||
setTimeout(function() { document.activeElement.select() }, 100);
|
||||
return false;
|
||||
})
|
||||
},
|
||||
|
|
@ -371,7 +371,7 @@ wn.ui.form.ControlDate = wn.ui.form.ControlData.extend({
|
|||
return value ? dateutil.user_to_str(value) : value;
|
||||
},
|
||||
format_for_input: function(value) {
|
||||
return dateutil.str_to_user(value);
|
||||
return value ? dateutil.str_to_user(value) : "";
|
||||
},
|
||||
validate: function(value, callback) {
|
||||
var value = wn.datetime.validate(value);
|
||||
|
|
@ -461,13 +461,16 @@ wn.ui.form.ControlButton = wn.ui.form.ControlData.extend({
|
|||
.prependTo(me.input_area)
|
||||
.css({"margin-bottom": "7px"})
|
||||
.on("click", function() {
|
||||
if(me.frm && me.frm.cscript) {
|
||||
if(me.frm && me.frm.doc && me.frm.cscript) {
|
||||
if(me.frm.cscript[me.df.fieldname]) {
|
||||
me.frm.script_manager.trigger(me.df.fieldname, me.doctype, me.docname);
|
||||
} else {
|
||||
me.frm.runscript(me.df.options, me);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(me.df.click) {
|
||||
me.df.click();
|
||||
}
|
||||
});
|
||||
this.input = this.$input.get(0);
|
||||
this.has_input = true;
|
||||
|
|
@ -670,7 +673,8 @@ wn.ui.form.ControlLink = wn.ui.form.ControlData.extend({
|
|||
me.autocomplete_open = false;
|
||||
},
|
||||
select: function(event, ui) {
|
||||
me.parse_validate_and_set_in_model(ui.item.value);
|
||||
if(me.frm && me.frm.doc)
|
||||
me.parse_validate_and_set_in_model(ui.item.value);
|
||||
}
|
||||
}).data('uiAutocomplete')._renderItem = function(ul, item) {
|
||||
return $('<li></li>')
|
||||
|
|
@ -684,15 +688,17 @@ wn.ui.form.ControlLink = wn.ui.form.ControlData.extend({
|
|||
this.$wrapper.find(".ui-helper-hidden-accessible").remove();
|
||||
},
|
||||
set_custom_query: function(args) {
|
||||
if(this.get_query) {
|
||||
var q = this.get_query(this.frm && this.frm.doc, this.doctype, this.docname);
|
||||
if(this.get_query || this.df.get_query) {
|
||||
var q = (this.get_query || this.df.get_query)(this.frm && this.frm.doc, this.doctype, this.docname);
|
||||
|
||||
if (typeof(q)==="string") {
|
||||
args.query = q;
|
||||
} else if($.isPlainObject(q)) {
|
||||
if(q.filters) {
|
||||
$.each(q.filters, function(key, value) {
|
||||
q.filters[key] = value===undefined ? null : value;
|
||||
if(value!==undefined) {
|
||||
q.filters[key] = value || null;
|
||||
}
|
||||
});
|
||||
}
|
||||
$.extend(args, q);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ wn.form.formatters = {
|
|||
}
|
||||
},
|
||||
Date: function(value) {
|
||||
return dateutil.str_to_user(value);
|
||||
return value ? dateutil.str_to_user(value) : "";
|
||||
},
|
||||
Text: function(value) {
|
||||
if(value) {
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ wn.ui.form.GridRow = Class.extend({
|
|||
this.wrapper.find(".data-row, .panel-heading")
|
||||
.click(function() {
|
||||
me.toggle_view();
|
||||
return false;
|
||||
});
|
||||
this.set_button_events();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,19 +145,55 @@ $.extend(wn.model, {
|
|||
},
|
||||
|
||||
map_current_doc: function(opts) {
|
||||
wn.call({
|
||||
type: "GET",
|
||||
method: opts.method,
|
||||
args: {
|
||||
"source_name": opts.source_name,
|
||||
"target_doclist": wn.model.get_doclist(cur_frm.doc.doctype, cur_frm.doc.name)
|
||||
},
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
var doclist = wn.model.sync(r.message);
|
||||
cur_frm.refresh();
|
||||
}
|
||||
if(opts.get_query_filters) {
|
||||
opts.get_query = function() {
|
||||
return {filters: opts.get_query_filters};
|
||||
}
|
||||
});
|
||||
}
|
||||
var _map = function() {
|
||||
wn.call({
|
||||
type: "GET",
|
||||
method: opts.method,
|
||||
args: {
|
||||
"source_name": opts.source_name,
|
||||
"target_doclist": wn.model.get_doclist(cur_frm.doc.doctype, cur_frm.doc.name)
|
||||
},
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
var doclist = wn.model.sync(r.message);
|
||||
cur_frm.refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if(opts.source_doctype) {
|
||||
var d = new wn.ui.Dialog({
|
||||
title: wn._("Get From ") + wn._(opts.source_doctype),
|
||||
fields: [
|
||||
{
|
||||
"fieldtype": "Link",
|
||||
"label": wn._(opts.source_doctype),
|
||||
"fieldname": opts.source_doctype,
|
||||
"options": opts.source_doctype,
|
||||
"get_query": opts.get_query,
|
||||
reqd:1},
|
||||
{
|
||||
"fieldtype": "Button",
|
||||
"label": wn._("Get"),
|
||||
click: function() {
|
||||
var values = d.get_values();
|
||||
if(!values)
|
||||
return;
|
||||
opts.source_name = values[opts.source_doctype];
|
||||
d.hide();
|
||||
_map();
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
d.show();
|
||||
} else if(opts.source_name) {
|
||||
_map();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
@ -34,7 +34,7 @@ wn.ui.Dialog = wn.ui.FieldGroup.extend({
|
|||
this.make();
|
||||
},
|
||||
make: function() {
|
||||
this.$wrapper = $('<div class="modal fade" style="overflow: auto;">\
|
||||
this.$wrapper = $('<div class="modal" style="overflow: auto;">\
|
||||
<div class="modal-dialog">\
|
||||
<div class="modal-content">\
|
||||
<div class="modal-header">\
|
||||
|
|
|
|||
|
|
@ -47,6 +47,11 @@ wn.views.Container = Class.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
// hide dialog
|
||||
if(cur_dialog && cur_dialog.display) {
|
||||
cur_dialog.hide();
|
||||
}
|
||||
|
||||
// hide current
|
||||
if(this.page && this.page != page) {
|
||||
$(this.page).toggle(false);
|
||||
|
|
|
|||
|
|
@ -59,7 +59,14 @@ def search_widget(doctype, txt, query=None, searchfield="name", start=0,
|
|||
searchfield, txt))
|
||||
else:
|
||||
if isinstance(filters, dict):
|
||||
filters = map(lambda f: [doctype, f[0], "=", f[1]], filters.items())
|
||||
filters_items = filters.items()
|
||||
filters = []
|
||||
for f in filters_items:
|
||||
if isinstance(f[1], (list, tuple)):
|
||||
filters.append([doctype, f[0], f[1][0], f[1][1]])
|
||||
else:
|
||||
filters.append([doctype, f[0], "=", f[1]])
|
||||
|
||||
if filters==None:
|
||||
filters = []
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue