Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"dependencies": {
"ampersand-app": "^1.0.4",
"ampersand-collection": "^1.4.5",
"ampersand-collection-filterable": "^0.2.1",
"ampersand-collection-lodash-mixin": "^2.0.1",
"ampersand-collection-rest-mixin": "^4.2.0",
"ampersand-model": "^5.0.3",
Expand Down
20 changes: 11 additions & 9 deletions src/field-list/type-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var tooltipMixin = require('../tooltip-mixin');
var $ = require('jquery');

module.exports = View.extend(tooltipMixin, {
template: require('./type-list-item.jade'),
namespace: 'TypeListItem',
bindings: {
'model.name': [
Expand All @@ -24,16 +25,16 @@ module.exports = View.extend(tooltipMixin, {
'click .schema-field-wrapper': 'typeClicked'
},
initialize: function() {
this.listenTo(this.model, 'change:count', _.debounce(function() {
this.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));
this.listenTo(this.model, 'change:probability', _.debounce(this.update.bind(this), 300));
},
update: function() {
$(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) + '%'
});
},
template: require('./type-list-item.jade'),
typeClicked: function() {
var fieldList = this.parent.parent;
if (!fieldList.minichartModel || fieldList.minichartModel.modelType !== this.model.modelType) {
Expand All @@ -42,6 +43,7 @@ module.exports = View.extend(tooltipMixin, {
},
render: function() {
this.renderWithTemplate(this);
this.update();
return this;
}
});
15 changes: 15 additions & 0 deletions src/models/sampled-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,24 @@ var _ = require('lodash');
var Schema = require('mongodb-schema').Schema;
var wrapError = require('./wrap-error');
var app = require('ampersand-app');
var FieldCollection = require('mongodb-schema').FieldCollection;
var filterableMixin = require('ampersand-collection-filterable');

/**
* wrapping mongodb-schema's FieldCollection with a filterable mixin
*/
var FilterableFieldCollection = FieldCollection.extend(filterableMixin, {
modelType: 'FilterableFieldCollection'
});

module.exports = Schema.extend({
namespace: 'SampledSchema',
/**
* Our fields need to be filterable, adding a mixin
*/
collections: {
fields: FilterableFieldCollection
},
/**
* Clear any data accumulated from sampling.
*/
Expand Down