Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Add config option for hiding/filtering stats table
Browse files Browse the repository at this point in the history
Signed-off-by: Don Naegely <[email protected]>
  • Loading branch information
naegelyd committed Oct 21, 2014
1 parent 7ea9e26 commit 0b09abe
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 5 deletions.
22 changes: 22 additions & 0 deletions src/js/cilantro/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,28 @@ define([
*/
threshold: null,

/*
* A list of values used to determine which models are shown in the
* stats table on the Workspace page. When this value is null, there is
* no filtering done and all models will be listed in the table. When
* this value is the empty list([]), then the control itself will not
* be shown. Finally, when this list contains values, only the stat
* values with values in this list will be shown.
*
* NOTE: Values in this list must be of the format app_name.model_name,
* so, for example, if I wanted to include just a couple models I might
* set this list to:
*
* statsModelsList = [
* 'diagnoses.diagnosis',
* 'drugs.drug'
* ];
*
* And all models except Diagnosis from the diagnoses app and Drug from
* the drugs app will be ignored.
*/
statsModelsList: null,

/*
* Threshold for the max number of values that will be displayed in
* a filter on the context panel before they are hidden with ellipses.
Expand Down
31 changes: 28 additions & 3 deletions src/js/cilantro/models/stats.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,38 @@
/* global define */

define([
'./base'
], function(base) {
'./base',
'../core'
], function(base, c) {

var Count = base.Model.extend({});

var CountCollection = base.Collection.extend({
model: Count
model: Count,

parse: function(resp, options) {
base.Collection.prototype.parse.call(this, resp, options);

var statsConfig = c.config.get('statsModelsList'),
appModel = '',
validItems = [];

if (statsConfig === null) {
return resp;
}

if (statsConfig.length > 0) {
for (var i = 0; i < resp.length; i++) {
appModel = resp[i].app_name + '.' + resp[i].model_name;

if (statsConfig.indexOf(appModel) !== -1) {
validItems.push(resp[i]);
}
}
}

return validItems;
}
});

var Stats = base.Model.extend({
Expand Down
10 changes: 8 additions & 2 deletions src/js/cilantro/ui/workflows/workspace.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/* global define */

define([
'jquery',
'marionette',
'../core',
'../query',
'../stats'
], function(Marionette, c, query, stats) {
], function($, Marionette, c, query, stats) {

var WorkspaceWorkflow = Marionette.Layout.extend({
className: 'workspace-workflow',
Expand Down Expand Up @@ -118,13 +119,18 @@ define([
});
}

if (c.isSupported('2.3.6')) {
var showStats = c.config.get('statsModelsList') === null ||
c.config.get('statsModelsList').length > 0;
if (c.isSupported('2.3.6') && showStats) {
var dataSummaryView = new this.regionViews.dataSummary({
collection: this.data.stats.counts
});

this.dataSummary.show(dataSummaryView);
}
else {
$(this.dataSummary.el).remove()
}

this.listenTo(c.data.concepts, 'reset', function() {
this.queries.show(queryView);
Expand Down

0 comments on commit 0b09abe

Please sign in to comment.