Skip to content

Commit

Permalink
Update filtering to populate on load.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmeiklejohn committed Aug 16, 2012
1 parent 480c26b commit 8f0483a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
10 changes: 5 additions & 5 deletions priv/admin/js/gui.js
Expand Up @@ -43,11 +43,11 @@ $(document).ready(function() {
});
};

/* MAKE DROPDOWNS WORK */
$(document).on('change', '.gui-dropdown', function (e) {
var me = $(this), textSpot = me.prev().prev(), selected = me.find('option:selected').text();
textSpot.text(selected);
});
$.riakControl.updateDropdown = $.riakControl.updateDropdown || function updateDropdown (me, val) {
Ember.run.next(function() {
var textSpot = me.prev().prev(); textSpot.text(val);
});
};

/*
MAKE ON/OFF SWITCHES WORK
Expand Down
17 changes: 17 additions & 0 deletions priv/admin/js/ring.js
Expand Up @@ -34,6 +34,18 @@ minispade.register('ring', function() {
}
},

selectedPartitionFilter: function() {
var selectedPartitionFilterValue = this.get('selectedPartitionFilterValue');
var filters = this.get('filters');
var selectedPartitionFilter;

selectedPartitionFilter = filters.find(function(item) {
return item.get('value') === selectedPartitionFilterValue;
});

return selectedPartitionFilter;
}.property('filters', 'selectedPartitionFilterValue'),

filters: function() {
var content = this.get('content');

Expand Down Expand Up @@ -128,6 +140,11 @@ minispade.register('ring', function() {
});

RiakControl.PartitionFilterSelectView = Ember.Select.extend({
updateDisplay: function() {
var val = this.get('controller.selectedPartitionFilter.name');
$.riakControl.updateDropdown(this.$(), val);
}.observes('controller.selectedPartitionFilter'),

change: function(ev) {
var selection = this.get('selection');

Expand Down
4 changes: 2 additions & 2 deletions priv/admin/js/router.js
Expand Up @@ -111,12 +111,12 @@ minispade.register('router', function() {

connectOutlets: function(router, context) {
router.get('ringController').set('selectedPartitionFilter', context);
router.get('partitionFilterController').set('selectedPartitionFilter', context);
router.get('partitionFilterController').set('selectedPartitionFilterValue', context.value);
},

exit: function(router) {
router.get('ringController').set('selectedPartitionFilter', undefined);
router.get('partitionFilterController').set('selectedPartitionFilter', undefined);
router.get('partitionFilterController').set('selectedPartitionFilterValue', undefined);
},

index: Ember.Route.extend({
Expand Down
2 changes: 1 addition & 1 deletion priv/admin/js/templates/partition_filter.hbs
Expand Up @@ -3,6 +3,6 @@
<div class="gui-dropdown-wrapper">
<div class="gui-dropdown-bg gui-text smaller"></div>
<div class="gui-dropdown-cap left"></div>
{{view RiakControl.PartitionFilterSelectView id="filter" classNames="gui-dropdown" contentBinding="filters" optionLabelPath="content.name" optionValuePath="content.value" prompt="All" valueBinding="controller.selectedPartitionFilter.value"}}
{{view RiakControl.PartitionFilterSelectView id="filter" classNames="gui-dropdown" contentBinding="filters" optionLabelPath="content.name" optionValuePath="content.value" prompt="All" selectionBinding="controller.selectedPartitionFilter"}}
</div>
</div>

0 comments on commit 8f0483a

Please sign in to comment.