Kaynağa Gözat

Merge branch 'master' of github.com:webnotes/wnframework

version-14
Rushabh Mehta 12 yıl önce
ebeveyn
işleme
ab58822db0
2 değiştirilmiş dosya ile 38 ekleme ve 13 silme
  1. +7
    -0
      public/js/wn/ui/appframe.js
  2. +31
    -13
      public/js/wn/views/grid_report.js

+ 7
- 0
public/js/wn/ui/appframe.js Dosyayı Görüntüle

@@ -112,6 +112,13 @@ wn.ui.AppFrame = Class.extend({
changeYear: true,
}).val(dateutil.str_to_user(date) || "").appendTo(this.toolbar.parent());
},
add_check: function(label) {
this.add_toolbar();
return $("<label style='display: inline;'><input type='checkbox' \
style='margin-top: -2px;'/> " + label + "</label>")
.appendTo(this.toolbar.parent())
.find("input");
},
add_ripped_paper_effect: function(wrapper) {
if(!wrapper) var wrapper = wn.container.page;
var layout_main = $(wrapper).find('.layout-main');


+ 31
- 13
public/js/wn/views/grid_report.js Dosyayı Görüntüle

@@ -213,6 +213,8 @@ wn.views.GridReport = Class.extend({
input = me.appframe.add_label(v.label);
} else if(v.fieldtype=='Data') {
input = me.appframe.add_data(v.label);
} else if(v.fieldtype=='Check') {
input = me.appframe.add_check(v.label);
}

if(input) {
@@ -236,7 +238,9 @@ wn.views.GridReport = Class.extend({
var me = this;
$.each(this.filter_inputs, function(i, f) {
var opts = f.get(0).opts;
if(opts.fieldtype!='Button') {
if(opts.fieldtype=='Check') {
me[opts.fieldname] = f.attr('checked') == "checked" ? 1 : 0;
} else if(opts.fieldtype!='Button') {
me[opts.fieldname] = f.val();
if(opts.fieldtype=="Date") {
me[opts.fieldname] = dateutil.user_to_str(me[opts.fieldname]);
@@ -335,7 +339,17 @@ wn.views.GridReport = Class.extend({
$.each(hash.split('/').splice(1).join('/').split('&&'), function(i, f) {
var f = f.split("=");
if(me.filter_inputs[f[0]]) {
me.filter_inputs[f[0]].val(decodeURIComponent(f[1]));
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]);
}
@@ -349,8 +363,12 @@ wn.views.GridReport = Class.extend({
},
set_route: function() {
wn.set_route(wn.container.page.page_name, $.map(this.filter_inputs, function(v) {
var val = v.val();
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);
@@ -445,7 +463,7 @@ wn.views.GridReport = Class.extend({
currency_formatter: function(row, cell, value, columnDef, dataContext) {
return repl('<div style="text-align: right; %(_style)s">%(value)s</div>', {
_style: dataContext._style || "",
value: fmt_money(value)
value: dataContext._no_format ? value : fmt_money(value)
});
},
text_formatter: function(row, cell, value, columnDef, dataContext) {
@@ -455,7 +473,7 @@ wn.views.GridReport = Class.extend({
value: cstr(value)
});
},
check_formatter: function(row, cell, value, columnDef, dataContext) {
check_formatter: function(row, cell, value, columnDef, dataContext) {
return repl("<input type='checkbox' data-id='%(id)s' \
class='plot-check' %(checked)s>", {
"id": dataContext.id,
@@ -586,6 +604,14 @@ wn.views.GridReport = Class.extend({
: dateutil.str_to_user(me.to_date);
});
},
trigger_refresh_on_change: function(filters) {
var me = this;
$.each(filters, function(i, f) {
me.filter_inputs[f] && me.filter_inputs[f].change(function() {
me.filter_inputs.refresh.click()
});
});
}
});

wn.views.GridReportWithPlot = wn.views.GridReport.extend({
@@ -802,12 +828,4 @@ wn.views.TreeGridReport = wn.views.GridReportWithPlot.extend({
d.indent = indent;
});
},
trigger_refresh_on_change: function(filters) {
var me = this;
$.each(filters, function(i, f) {
me.filter_inputs[f] && me.filter_inputs[f].change(function() {
me.filter_inputs.refresh.click()
});
});
}
});

Yükleniyor…
İptal
Kaydet