Commit 67c59014 authored by Robert Knight's avatar Robert Knight

Convert `<sort-dropdown>` to a component

parent 65c354de
...@@ -151,6 +151,7 @@ module.exports = angular.module('h', [ ...@@ -151,6 +151,7 @@ module.exports = angular.module('h', [
.component('selectionTabs', require('./directive/selection-tabs')) .component('selectionTabs', require('./directive/selection-tabs'))
.component('sidebarTutorial', require('./directive/sidebar-tutorial').component) .component('sidebarTutorial', require('./directive/sidebar-tutorial').component)
.component('shareDialog', require('./directive/share-dialog')) .component('shareDialog', require('./directive/share-dialog'))
.component('sortDropdown', require('./directive/sort-dropdown'))
.component('timestamp', require('./directive/timestamp')) .component('timestamp', require('./directive/timestamp'))
.directive('excerpt', require('./directive/excerpt').directive) .directive('excerpt', require('./directive/excerpt').directive)
...@@ -161,7 +162,6 @@ module.exports = angular.module('h', [ ...@@ -161,7 +162,6 @@ module.exports = angular.module('h', [
.directive('hOnTouch', require('./directive/h-on-touch')) .directive('hOnTouch', require('./directive/h-on-touch'))
.directive('hTooltip', require('./directive/h-tooltip')) .directive('hTooltip', require('./directive/h-tooltip'))
.directive('markdown', require('./directive/markdown')) .directive('markdown', require('./directive/markdown'))
.directive('sortDropdown', require('./directive/sort-dropdown'))
.directive('spinner', require('./directive/spinner')) .directive('spinner', require('./directive/spinner'))
.directive('statusButton', require('./directive/status-button')) .directive('statusButton', require('./directive/status-button'))
.directive('svgIcon', require('./directive/svg-icon')) .directive('svgIcon', require('./directive/svg-icon'))
......
'use strict'; 'use strict';
module.exports = function () { module.exports = {
return { controllerAs: 'vm',
controller: function () {}, controller: function () {},
restrict: 'E', bindings: {
scope: {
/** The name of the currently selected sort key. */ /** The name of the currently selected sort key. */
sortKey: '<', sortKey: '<',
/** A list of possible keys that the user can opt to sort by. */ /** A list of possible keys that the user can opt to sort by. */
...@@ -13,5 +12,4 @@ module.exports = function () { ...@@ -13,5 +12,4 @@ module.exports = function () {
onChangeSortKey: '&', onChangeSortKey: '&',
}, },
template: require('../templates/sort_dropdown.html'), template: require('../templates/sort_dropdown.html'),
};
}; };
...@@ -7,7 +7,7 @@ var util = require('./util'); ...@@ -7,7 +7,7 @@ var util = require('./util');
describe('sortDropdown', function () { describe('sortDropdown', function () {
before(function () { before(function () {
angular.module('app', []) angular.module('app', [])
.directive('sortDropdown', require('../sort-dropdown')); .component('sortDropdown', require('../sort-dropdown'));
}); });
beforeEach(function () { beforeEach(function () {
......
...@@ -3,16 +3,16 @@ ...@@ -3,16 +3,16 @@
type="button" type="button"
class="top-bar__btn" class="top-bar__btn"
dropdown-toggle dropdown-toggle
title="Sort by {{sortKey}}"> title="Sort by {{vm.sortKey}}">
<i class="h-icon-sort"></i> <i class="h-icon-sort"></i>
</button> </button>
<div class="dropdown-menu__top-arrow"></div> <div class="dropdown-menu__top-arrow"></div>
<ul class="dropdown-menu pull-right" role="menu"> <ul class="dropdown-menu pull-right" role="menu">
<li class="dropdown-menu__row" <li class="dropdown-menu__row"
ng-repeat="key in sortKeysAvailable" ng-repeat="key in vm.sortKeysAvailable"
ng-click="onChangeSortKey({sortKey: key})" ng-click="vm.onChangeSortKey({sortKey: key})"
><span class="dropdown-menu-radio" ><span class="dropdown-menu-radio"
ng-class="{'is-selected' : sortKey === key}" ng-class="{'is-selected' : vm.sortKey === key}"
></span><a class="dropdown-menu__link" href="">{{key}}</a></li> ></span><a class="dropdown-menu__link" href="">{{key}}</a></li>
</ul> </ul>
</span> </span>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment