Browse Source

[minor] more options for frappe.set_query and set_indicator in dashboard

version-14
Rushabh Mehta 8 years ago
parent
commit
72ed223d41
5 changed files with 37 additions and 9 deletions
  1. +0
    -1
      frappe/public/css/form.css
  2. +21
    -5
      frappe/public/js/frappe/form/control.js
  3. +15
    -1
      frappe/public/js/frappe/form/dashboard.js
  4. +1
    -1
      frappe/public/js/legacy/form.js
  5. +0
    -1
      frappe/public/less/form.less

+ 0
- 1
frappe/public/css/form.css View File

@@ -80,7 +80,6 @@
}
.form-dashboard-section {
padding: 15px 30px;
margin: 0px;
border-bottom: 1px solid #EBEFF2;
}
.form-dashboard-section:last-child {


+ 21
- 5
frappe/public/js/frappe/form/control.js View File

@@ -1361,13 +1361,29 @@ frappe.ui.form.ControlLink = frappe.ui.form.ControlData.extend({
if(this.get_query || this.df.get_query) {
var get_query = this.get_query || this.df.get_query;
if($.isPlainObject(get_query)) {
var filters = set_nulls(get_query);
var filters = null;
if(get_query.filters) {
// passed as {'filters': {'key':'value'}}
filters = get_query.filters;
} else if(get_query.query) {

// passed as {'query': 'path.to.method'}
args.query = get_query;
} else {

// dict is filters
filters = get_query;
}

// extend args for custom functions
$.extend(args, filters);
if (filters) {
var filters = set_nulls(filters);

// add "filters" for standard query (search.py)
args.filters = filters;
// extend args for custom functions
$.extend(args, filters);

// add "filters" for standard query (search.py)
args.filters = filters;
}
} else if(typeof(get_query)==="string") {
args.query = get_query;
} else {


+ 15
- 1
frappe/public/js/frappe/form/dashboard.js View File

@@ -344,8 +344,22 @@ frappe.ui.form.Dashboard = Class.extend({
add_indicator: function(label, color) {
this.show();
this.stats_area.removeClass('hidden');
return $('<div class="col-sm-3"><span class="indicator '+color+'">'

// set colspan
var indicators = this.stats_area.find('.indicator-column');
var n_indicators = indicators.length + 1;
if(n_indicators > 4) { colspan = 3 }
else { colspan = 12 / n_indicators; }

// reset classes in existing indicators
if(indicators.length) {
indicators.removeClass().addClass('col-sm-'+colspan).addClass('indicator-column');
}

var indicator = $('<div class="col-sm-'+colspan+' indicator-column"><span class="indicator '+color+'">'
+label+'</span></div>').appendTo(this.stats_area);

return indicator;
},

//graphs


+ 1
- 1
frappe/public/js/legacy/form.js View File

@@ -114,7 +114,7 @@ _f.Frm.prototype.setup = function() {
frm: this,
parent: $('<div>').appendTo(this.page.main.parent())
})
$("body").attr("data-sidebar", 1);
$("body").attr("data-sidebar", 1);
}
this.setup_drag_drop();



+ 0
- 1
frappe/public/less/form.less View File

@@ -111,7 +111,6 @@

.form-dashboard-section {
padding: 15px 30px;
margin: 0px;
border-bottom: 1px solid @light-border-color;
}



Loading…
Cancel
Save