Merge branch 'responsive' of github.com:webnotes/wnframework into responsive
This commit is contained in:
commit
47faedd2b1
11 changed files with 178 additions and 101 deletions
|
|
@ -45,6 +45,41 @@ a {
|
|||
text-align: right;
|
||||
}
|
||||
|
||||
/* module */
|
||||
|
||||
.module-top .alert {
|
||||
padding-right: 15px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.module-top a, .module-top a:hover {
|
||||
color: black;
|
||||
font-size: 120%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.module-top .badge {
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.module-item-progress {
|
||||
margin-bottom: 10px;
|
||||
height: 17px;
|
||||
}
|
||||
|
||||
.module-item-progress-total {
|
||||
height: 7px;
|
||||
background-color: #999999;
|
||||
width: 0px;
|
||||
}
|
||||
|
||||
.module-item-progress-open {
|
||||
height: 7px;
|
||||
background-color: red;
|
||||
width: 0px;
|
||||
}
|
||||
|
||||
|
||||
/* fixed navbar in appframe */
|
||||
|
||||
.appframe .navbar {
|
||||
|
|
|
|||
|
|
@ -212,8 +212,8 @@ _f.Frm.prototype.setup_std_layout = function() {
|
|||
|
||||
_f.Frm.prototype.setup_print = function() {
|
||||
this.print_formats = wn.meta.get_print_formats(this.meta.name);
|
||||
this.print_sel = $a(null, 'select', '', {width:'160px'});
|
||||
add_sel_options(this.print_sel, this.print_formats);
|
||||
this.print_sel = $("<select>")
|
||||
.css({"width": "160px"}).add_options(this.print_formats).get(0);
|
||||
this.print_sel.value = this.print_formats[0];
|
||||
}
|
||||
|
||||
|
|
@ -413,7 +413,7 @@ _f.Frm.prototype.refresh = function(docname) {
|
|||
if (!this.opendocs[this.docname]) {
|
||||
this.check_doctype_conflict(this.docname);
|
||||
} else {
|
||||
if(this.doc && this.doc.__last_sync_on &&
|
||||
if(this.doc && (!this.doc.__unsaved) && this.doc.__last_sync_on &&
|
||||
(new Date() - this.doc.__last_sync_on) > (this.refresh_if_stale_for * 1000)) {
|
||||
this.reload_doc();
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -115,7 +115,9 @@ $.extend(_p, {
|
|||
c.removeChild(c.cur_sel);
|
||||
}
|
||||
c.appendChild(cur_frm.print_sel);
|
||||
c.cur_sel = cur_frm.print_sel;
|
||||
c.cur_sel = cur_frm.print_sel;
|
||||
if(cur_frm.$print_view_select && cur_frm.$print_view_select.val())
|
||||
c.cur_sel.value= cur_frm.$print_view_select.val();
|
||||
}
|
||||
|
||||
_p.dialog = d;
|
||||
|
|
|
|||
|
|
@ -18,11 +18,7 @@ wn.ui.form.ScriptManager = Class.extend({
|
|||
// js
|
||||
var cs = doctype.__js;
|
||||
if(cs) {
|
||||
try {
|
||||
var tmp = eval(cs);
|
||||
} catch(e) {
|
||||
this.log_error("eval", e);
|
||||
}
|
||||
var tmp = eval(cs);
|
||||
}
|
||||
|
||||
// css
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ wn.ui.form.Toolbar = Class.extend({
|
|||
var status_bar_parent = this.frm.appframe.$w.find(".status-bar").empty();
|
||||
if(this.frm.meta.is_submittable && !this.frm.doc.__islocal) {
|
||||
var status_bar = $("<h4>")
|
||||
.css({"margin": "0px"})
|
||||
.appendTo(status_bar_parent);
|
||||
|
||||
switch(this.frm.doc.docstatus) {
|
||||
|
|
|
|||
|
|
@ -290,6 +290,14 @@ $.extend(wn.model, {
|
|||
if(d) wn.model.clear_doc(d.doctype, d.name);
|
||||
});
|
||||
},
|
||||
|
||||
clear_table: function(doctype, parenttype, parent, parentfield) {
|
||||
$.each(locals[doctype] || {}, function(i, d) {
|
||||
if(d.parent===parent && d.parenttype===parenttype && d.parentfield===parentfield) {
|
||||
delete locals[doctype][d.name];
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
remove_from_locals: function(doctype, name) {
|
||||
this.clear_doclist(doctype, name);
|
||||
|
|
@ -297,7 +305,7 @@ $.extend(wn.model, {
|
|||
delete wn.views.formview[doctype].frm.opendocs[name];
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
clear_doc: function(doctype, name) {
|
||||
var doc = locals[doctype][name];
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ wn.views.FormFactory = wn.views.Factory.extend({
|
|||
}
|
||||
|
||||
wn.model.with_doc(dt, dn, function(dn, r) {
|
||||
|
||||
if(r && r['403']) return; // not permitted
|
||||
|
||||
if(!(locals[dt] && locals[dt][dn])) {
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ wn.views.GridReport = Class.extend({
|
|||
this.filter_inputs = {};
|
||||
this.preset_checks = [];
|
||||
this.tree_grid = {show: false};
|
||||
var me = this;
|
||||
$.extend(this, opts);
|
||||
|
||||
this.wrapper = $('<div>').appendTo(this.parent);
|
||||
|
|
@ -109,8 +110,10 @@ wn.views.GridReport = Class.extend({
|
|||
}
|
||||
this.make_waiting();
|
||||
|
||||
var me = this;
|
||||
this.get_data();
|
||||
this.get_data(function() {
|
||||
me.apply_filters_from_route();
|
||||
me.refresh();
|
||||
});
|
||||
},
|
||||
bind_show: function() {
|
||||
// bind show event to reset cur_report_grid
|
||||
|
|
@ -123,11 +126,14 @@ wn.views.GridReport = Class.extend({
|
|||
$(this.page).bind('show', function() {
|
||||
// reapply filters on show
|
||||
wn.cur_grid_report = me;
|
||||
me.get_data()
|
||||
me.get_data(function() {
|
||||
me.apply_filters_from_route();
|
||||
me.refresh();
|
||||
})
|
||||
});
|
||||
|
||||
},
|
||||
get_data: function() {
|
||||
get_data: function(callback) {
|
||||
var me = this;
|
||||
var progress_bar = null;
|
||||
if(!this.setup_filters_done)
|
||||
|
|
@ -138,8 +144,7 @@ wn.views.GridReport = Class.extend({
|
|||
me.setup_filters();
|
||||
me.setup_filters_done = true;
|
||||
}
|
||||
me.apply_filters_from_route();
|
||||
me.refresh();
|
||||
callback();
|
||||
}, progress_bar);
|
||||
},
|
||||
setup_filters: function() {
|
||||
|
|
@ -162,29 +167,42 @@ wn.views.GridReport = Class.extend({
|
|||
|
||||
// set route from filters
|
||||
// if route has changed, set route calls get data
|
||||
me.set_route();
|
||||
|
||||
// if route hasn't changed, call get data
|
||||
if(wn.get_route_str()===old_route) {
|
||||
me.get_data();
|
||||
}
|
||||
me.refresh();
|
||||
});
|
||||
|
||||
// reset filters
|
||||
this.filter_inputs.reset_filters && this.filter_inputs.reset_filters.click(function() {
|
||||
me.init_filter_values();
|
||||
me.set_route();
|
||||
me.refresh();
|
||||
});
|
||||
|
||||
// range
|
||||
this.filter_inputs.range && this.filter_inputs.range.change(function() {
|
||||
me.set_route();
|
||||
me.refresh();
|
||||
});
|
||||
|
||||
// plot check
|
||||
if(this.setup_plot_check)
|
||||
this.setup_plot_check();
|
||||
|
||||
},
|
||||
set_filter: function(key, value) {
|
||||
var filters = this.filter_inputs[key];
|
||||
if(filters) {
|
||||
var opts = filters.get(0).opts;
|
||||
if(opts.fieldtype === "Check") {
|
||||
if(cint(value)) {
|
||||
filters.attr("checked", "checked");
|
||||
} else {
|
||||
filters.removeAttr("checked");
|
||||
}
|
||||
} if(opts.fieldtype=="Date") {
|
||||
filters.val(wn.datetime.str_to_user(value));
|
||||
} else {
|
||||
filters.val(value);
|
||||
}
|
||||
} else {
|
||||
msgprint("Invalid Filter: " + key)
|
||||
}
|
||||
},
|
||||
set_autocomplete: function($filter, list) {
|
||||
var me = this;
|
||||
|
|
@ -192,7 +210,7 @@ wn.views.GridReport = Class.extend({
|
|||
source: list,
|
||||
select: function(event, ui) {
|
||||
$filter.val(ui.item.value);
|
||||
me.set_route();
|
||||
me.refresh();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
@ -261,7 +279,7 @@ wn.views.GridReport = Class.extend({
|
|||
}
|
||||
input.keypress(function(e) {
|
||||
if(e.which==13) {
|
||||
me.set_route();
|
||||
me.refresh();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -374,54 +392,22 @@ wn.views.GridReport = Class.extend({
|
|||
this.bind_show();
|
||||
|
||||
wn.cur_grid_report = this;
|
||||
this.apply_filters_from_route();
|
||||
$(this.wrapper).trigger('make');
|
||||
|
||||
},
|
||||
apply_filters_from_route: function() {
|
||||
var hash = decodeURIComponent(window.location.hash);
|
||||
var me = this;
|
||||
if(hash.indexOf('/') != -1) {
|
||||
$.each(hash.split('/').splice(1).join('/').split('&&'), function(i, f) {
|
||||
var f = f.split("=");
|
||||
if(me.filter_inputs[f[0]]) {
|
||||
var val = decodeURIComponent(f[1]);
|
||||
var opts = me.filter_inputs[f[0]].get(0).opts;
|
||||
if(opts.fieldtype === "Check") {
|
||||
if(cint(val)) {
|
||||
me.filter_inputs[f[0]].attr("checked", "checked");
|
||||
} else {
|
||||
me.filter_inputs[f[0]].removeAttr("checked");
|
||||
}
|
||||
} else {
|
||||
me.filter_inputs[f[0]].val(val);
|
||||
}
|
||||
} else {
|
||||
console.log("Invalid filter: " +f[0]);
|
||||
}
|
||||
if(wn.route_options) {
|
||||
$.each(wn.route_options, function(key, value) {
|
||||
me.set_filter(key, value);
|
||||
});
|
||||
wn.route_options = null;
|
||||
} else {
|
||||
this.init_filter_values();
|
||||
}
|
||||
this.set_default_values();
|
||||
|
||||
$(this.wrapper).trigger('apply_filters_from_route');
|
||||
},
|
||||
set_route: function() {
|
||||
var page_name = wn.container.page.page_name;
|
||||
var filters_route = $.map(this.filter_inputs, function(v) {
|
||||
var opts = v.get(0).opts;
|
||||
if(opts.fieldtype === "Check") {
|
||||
var val = v.attr("checked") ? 1 : 0;
|
||||
} else {
|
||||
var val = v.val();
|
||||
}
|
||||
if(val && val != opts.default_value)
|
||||
return encodeURIComponent(opts.fieldname)
|
||||
+ '=' + encodeURIComponent(val);
|
||||
}).join('&&');
|
||||
|
||||
wn.set_route(page_name, filters_route);
|
||||
$(this.wrapper).trigger('apply_filters_from_route');
|
||||
},
|
||||
options: {
|
||||
editable: false,
|
||||
|
|
@ -473,7 +459,9 @@ wn.views.GridReport = Class.extend({
|
|||
if(item._show) return true;
|
||||
|
||||
for (i in filters) {
|
||||
if(!this.apply_filter(item, i)) return false;
|
||||
if(!this.apply_filter(item, i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -559,9 +547,8 @@ wn.views.GridReport = Class.extend({
|
|||
var link_formatter = me.dataview_columns[cell].link_formatter;
|
||||
if (link_formatter.filter_input) {
|
||||
var html = repl('<a href="#" \
|
||||
onclick="wn.cur_grid_report.filter_inputs \
|
||||
.%(col_name)s.val(\'%(value)s\'); \
|
||||
wn.cur_grid_report.set_route(); return false;">\
|
||||
onclick="wn.cur_grid_report.set_filter(\'%(col_name)s\', \'%(value)s\'); \
|
||||
wn.cur_grid_report.refresh(); return false;">\
|
||||
%(value)s</a>', {
|
||||
value: value,
|
||||
col_name: link_formatter.filter_input,
|
||||
|
|
@ -665,7 +652,7 @@ wn.views.GridReport = Class.extend({
|
|||
var me = this;
|
||||
$.each(filters, function(i, f) {
|
||||
me.filter_inputs[f] && me.filter_inputs[f].change(function() {
|
||||
me.set_route();
|
||||
me.refresh();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ wn.views.show_open_count_list = function(element) {
|
|||
wn.views.moduleview.ModuleView = Class.extend({
|
||||
init: function(wrapper, module) {
|
||||
this.doctypes = [];
|
||||
this.top_item_total = {};
|
||||
this.top_item_open = {};
|
||||
$(wrapper).empty();
|
||||
wn.ui.make_app_page({
|
||||
parent: wrapper,
|
||||
|
|
@ -55,7 +57,8 @@ wn.views.moduleview.ModuleView = Class.extend({
|
|||
make_body: function() {
|
||||
var wrapper = this.wrapper;
|
||||
// make columns
|
||||
$(wrapper).find(".layout-main").html("<div class='row'>\
|
||||
$(wrapper).find(".layout-main").html("<div class='row module-top'></div>\
|
||||
<div class='row'>\
|
||||
<div class='col col-lg-6 main-section'></div>\
|
||||
<div class='col col-lg-6 side-section'></div>\
|
||||
</div>")
|
||||
|
|
@ -71,35 +74,83 @@ wn.views.moduleview.ModuleView = Class.extend({
|
|||
},
|
||||
add_section: function(section) {
|
||||
section._title = wn._(section.title);
|
||||
var list_group = $('<ul class="list-group">\
|
||||
<li class="list-group-item">\
|
||||
<h4 class="list-group-item-heading"><i class="'
|
||||
+ section.icon+'"></i> '
|
||||
+ wn._(section.title) +'</h4>\
|
||||
</li>\
|
||||
</ul>"').appendTo(section.right
|
||||
? $(this.wrapper).find(".side-section")
|
||||
: $(this.wrapper).find(".main-section"));
|
||||
if(section.top) {
|
||||
var list_group = $('<div>')
|
||||
.appendTo($(this.wrapper).find(".module-top"));
|
||||
} else {
|
||||
var list_group = $('<ul class="list-group">\
|
||||
<li class="list-group-item">\
|
||||
<h4 class="list-group-item-heading"><i class="'
|
||||
+ section.icon+'"></i> '
|
||||
+ wn._(section.title) +'</h4>\
|
||||
</li>\
|
||||
</ul>"').appendTo(section.right
|
||||
? $(this.wrapper).find(".side-section")
|
||||
: $(this.wrapper).find(".main-section"));
|
||||
}
|
||||
section.list_group = list_group;
|
||||
},
|
||||
add_item: function(item, section) {
|
||||
if(!item.description) item.description = "";
|
||||
if(item.count==null) item.count = "";
|
||||
if(section.top) {
|
||||
var $parent = $(repl('<div class="col col-lg-4">\
|
||||
<div class="alert"></div>\
|
||||
<div>\
|
||||
<div class="module-item-progress" data-doctype="%(doctype)s">\
|
||||
<div class="module-item-progress-total">\
|
||||
<div class="module-item-progress-open">\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div>', {doctype:item.doctype}))
|
||||
.appendTo(section.list_group)
|
||||
.find(".alert");
|
||||
this.top_item_total[item.doctype] = 0;
|
||||
} else {
|
||||
var $parent = $('<li class="list-group-item">').appendTo(section.list_group);
|
||||
}
|
||||
|
||||
$(repl('<li class="list-group-item">\
|
||||
<span' +
|
||||
$(repl('<span' +
|
||||
((item.doctype && item.description)
|
||||
? " data-doctype='"+item.doctype+"'"
|
||||
: "") + ">%(link)s</span>"
|
||||
+ (item.description
|
||||
+ ((item.description && !section.top)
|
||||
? " <span class='text-muted small'>%(description)s</span>"
|
||||
: "")
|
||||
+ ((section.right || !item.doctype)
|
||||
? ''
|
||||
: '<span data-doctype-count="%(doctype)s" style="margin-left: 2px;"></span>\
|
||||
<span class="clearfix"></span>')
|
||||
+ "</li>", item))
|
||||
.appendTo(section.list_group);
|
||||
: '<span data-doctype-count="%(doctype)s" style="margin-left: 2px;"></span>'), item))
|
||||
.appendTo($parent);
|
||||
|
||||
if(!section.top) {
|
||||
$('<span class="clearfix"></span>').appendTo($parent);
|
||||
}
|
||||
},
|
||||
set_top_item_count: function(doctype, count, open_count) {
|
||||
var me = this;
|
||||
if(this.top_item_total[doctype]!=null) {
|
||||
|
||||
if(count!=null)
|
||||
this.top_item_total[doctype] = count;
|
||||
if(open_count!=null)
|
||||
this.top_item_open[doctype] = open_count;
|
||||
|
||||
var maxtop = Math.max.apply(this, values(this.top_item_total));
|
||||
|
||||
$.each(this.top_item_total, function(doctype, item_count) {
|
||||
$(me.wrapper).find(".module-item-progress[data-doctype='"+ doctype +"']")
|
||||
.find(".module-item-progress-total")
|
||||
.css("width", cint(flt(item_count)/maxtop*100) + "%")
|
||||
})
|
||||
|
||||
$.each(this.top_item_open, function(doctype, item_count) {
|
||||
$(me.wrapper).find(".module-item-progress[data-doctype='"+ doctype +"']")
|
||||
.find(".module-item-progress-open")
|
||||
.css("width", cint(flt(item_count)/me.top_item_total[doctype]*100) + "%")
|
||||
})
|
||||
}
|
||||
},
|
||||
render_static: function() {
|
||||
// render sections
|
||||
|
|
@ -177,8 +228,9 @@ wn.views.moduleview.ModuleView = Class.extend({
|
|||
$.each(r.message.item_count, function(doctype, count) {
|
||||
$(me.wrapper).find("[data-doctype-count='"+doctype+"']")
|
||||
.html(count)
|
||||
.addClass("badge badge-count")
|
||||
.addClass("badge badge-count pull-right")
|
||||
.css({cursor:"pointer"});
|
||||
me.set_top_item_count(doctype, count)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -194,12 +246,13 @@ wn.views.moduleview.ModuleView = Class.extend({
|
|||
if(wn.boot.notification_info.open_count_doctype) {
|
||||
$.each(wn.boot.notification_info.open_count_doctype, function(doctype, count) {
|
||||
if(in_list(me.doctypes, doctype)) {
|
||||
me.set_top_item_count(doctype, null, count);
|
||||
$('<span>')
|
||||
.css({
|
||||
"cursor": "pointer",
|
||||
"margin-right": "0px"
|
||||
})
|
||||
.addClass("badge badge-important")
|
||||
.addClass("badge badge-important pull-right")
|
||||
.html(count)
|
||||
.attr("data-doctype", doctype)
|
||||
.insertAfter($(me.wrapper)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ wn.views.pageview = {
|
|||
if((locals.Page && locals.Page[name]) || name==window.page_name) {
|
||||
// already loaded
|
||||
callback();
|
||||
} if(localStorage["_page:" + name]) {
|
||||
} else if(localStorage["_page:" + name]) {
|
||||
// cached in local storage
|
||||
wn.model.sync(JSON.parse(localStorage["_page:" + name]));
|
||||
callback();
|
||||
|
|
@ -81,14 +81,10 @@ wn.views.Page = Class.extend({
|
|||
},
|
||||
trigger: function(eventname) {
|
||||
var me = this;
|
||||
try {
|
||||
if(pscript[eventname+'_'+this.name]) {
|
||||
pscript[eventname+'_'+this.name](me.wrapper);
|
||||
} else if(me.wrapper[eventname]) {
|
||||
me.wrapper[eventname](me.wrapper);
|
||||
}
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
if(pscript[eventname+'_'+this.name]) {
|
||||
pscript[eventname+'_'+this.name](me.wrapper);
|
||||
} else if(me.wrapper[eventname]) {
|
||||
me.wrapper[eventname](me.wrapper);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -329,10 +329,10 @@ class Database:
|
|||
try:
|
||||
return self.get_values_from_table(fields, filters, doctype, as_dict, debug)
|
||||
except Exception, e:
|
||||
if e.args[0]!=1146:
|
||||
if ignore and e.args[0] in (1146, 1054):
|
||||
return None
|
||||
else:
|
||||
raise e
|
||||
|
||||
# not a table, try in singles
|
||||
|
||||
return self.get_values_from_single(fields, filters, doctype, as_dict, debug)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue