From c22ae21ae4af2f48a52249da0206b299ef3ef485 Mon Sep 17 00:00:00 2001 From: Thomas Rueckstiess Date: Tue, 7 Jul 2015 13:11:29 +0200 Subject: [PATCH 1/3] load documents on 'open' click. --- scout-ui/src/home/collection.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/scout-ui/src/home/collection.js b/scout-ui/src/home/collection.js index 76cc1353b4d..0f09445d17d 100644 --- a/scout-ui/src/home/collection.js +++ b/scout-ui/src/home/collection.js @@ -62,10 +62,10 @@ module.exports = AmpersandView.extend({ hook: 'stats-subview', prepareView: function(el) { return new CollectionStatsView({ - el: el, - parent: this, - model: this.model - }); + el: el, + parent: this, + model: this.model + }); } }, fields: { @@ -84,21 +84,21 @@ module.exports = AmpersandView.extend({ hook: 'refine-bar', prepareView: function(el) { return new RefineBarView({ - el: el, - parent: this, - model: app.queryOptions - }); + el: el, + parent: this, + model: app.queryOptions + }); } }, documents: { - waitFor: 'model.documents', + waitFor: 'open', hook: 'documents-subview', prepareView: function(el) { return new DocumentListView({ - el: el, - parent: this, - collection: this.model.documents - }); + el: el, + parent: this, + collection: this.model.documents + }); } } } From 3482cd49a03cb4d72515e8e2126f78817d507eed Mon Sep 17 00:00:00 2001 From: Thomas Rueckstiess Date: Tue, 7 Jul 2015 18:39:52 +0200 Subject: [PATCH 2/3] (bug) removed handler that calls redraw on model change. --- scout-ui/src/minicharts/viz.js | 35 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/scout-ui/src/minicharts/viz.js b/scout-ui/src/minicharts/viz.js index 67aa6046e29..16b80d833f3 100644 --- a/scout-ui/src/minicharts/viz.js +++ b/scout-ui/src/minicharts/viz.js @@ -51,9 +51,6 @@ module.exports = AmpersandView.extend({ }, initialize: function(opts) { - if (this.model !== undefined) { - this.listenTo(this.model, 'change', this.redraw); - } if (this.width === 'auto' || this.width === undefined) { this._autoWidth = true; @@ -134,23 +131,23 @@ module.exports = AmpersandView.extend({ }); } return this; - }, - - redraw: function() { - this._chooseDataSource(); - this.data = this.transform(this.data); - - this._measure(); - - if (this.vizFn) { - this.vizFn({ - width: this.width, - height: this.height, - data: this.data, - el: this.el, - }); - } } + // redraw: function() { + // debug('redraw', this.cid); + // this._chooseDataSource(); + // this.data = this.transform(this.data); + // + // this._measure(); + // + // if (this.vizFn) { + // this.vizFn({ + // width: this.width, + // height: this.height, + // data: this.data, + // el: this.el, + // }); + // } + // } }); /** From 61755b7673e20c8b3da828c6c70f7abea22cc175 Mon Sep 17 00:00:00 2001 From: Thomas Rueckstiess Date: Tue, 7 Jul 2015 19:09:17 +0200 Subject: [PATCH 3/3] debounced function that triggered type bar width changes for each document. --- scout-ui/src/field-list/type-list-item.js | 19 ++++++++----------- scout-ui/src/minicharts/viz.js | 1 - 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/scout-ui/src/field-list/type-list-item.js b/scout-ui/src/field-list/type-list-item.js index 67ed92fe500..b8ddbd0f26d 100644 --- a/scout-ui/src/field-list/type-list-item.js +++ b/scout-ui/src/field-list/type-list-item.js @@ -3,6 +3,7 @@ var $ = require('jquery'); var format = require('util').format; var _ = require('underscore'); var numeral = require('numeral'); +var debug = require('debug')('scout-ui:field-list:type-list-item'); require('bootstrap/js/tooltip'); @@ -19,16 +20,6 @@ module.exports = AmpersandView.extend({ } } ], - 'model.probability': [ - { - hook: 'bar', - type: function(el) { - $(el).css({ - width: Math.floor(this.model.probability * 100) + '%' - }); - } - } - ] }, events: { 'click .schema-field-wrapper': 'typeClicked' @@ -46,6 +37,9 @@ module.exports = AmpersandView.extend({ $(this.el).tooltip({ title: format('%s (%s)', this.model.getId(), numeral(this.model.probability).format('%')) }); + $(this.queryByHook('bar')).css({ + width: Math.floor(this.model.probability * 100) + '%' + }); }.bind(this), 300)); }, template: require('./type-list-item.jade'), @@ -54,6 +48,9 @@ module.exports = AmpersandView.extend({ if (!fieldList.minichartModel || (fieldList.minichartModel.modelType !== this.model.modelType)) { fieldList.switchView(this.model); } + }, + render: function() { + this.renderWithTemplate(this); + return this; } - }); diff --git a/scout-ui/src/minicharts/viz.js b/scout-ui/src/minicharts/viz.js index 16b80d833f3..5caf267b76b 100644 --- a/scout-ui/src/minicharts/viz.js +++ b/scout-ui/src/minicharts/viz.js @@ -133,7 +133,6 @@ module.exports = AmpersandView.extend({ return this; } // redraw: function() { - // debug('redraw', this.cid); // this._chooseDataSource(); // this.data = this.transform(this.data); //