-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select - Updates select mechanism, table styling, and adds tests. #15
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict'; | ||
|
||
/** | ||
* @ngdoc directive | ||
* @name alchemy.directive:alchSelected | ||
* @restrict A | ||
* | ||
* @scope | ||
* | ||
* @element ANY | ||
* | ||
* @description | ||
* Provides a count of selected items and an action to de-select those items. | ||
* | ||
* @param {object} alchSelected object that selected functionality is attached to | ||
* | ||
* @example | ||
<example> | ||
<file name="index.html"> | ||
<div ng-controller="SearchController"> | ||
<div alch-selected="testModel"></div> | ||
</div> | ||
</file> | ||
<file name="script.js"> | ||
function SearchController($scope) { | ||
$scope.testModel = {}; | ||
|
||
$scope.testModel.numSelected = 5; | ||
} | ||
</file> | ||
</example> | ||
* | ||
*/ | ||
angular.module('alchemy').directive('alchSelected', function(){ | ||
return { | ||
restrict: 'A', | ||
transclude: true, | ||
replace: true, | ||
scope: { | ||
'selected' : '=alchSelected' | ||
}, | ||
templateUrl: 'component/templates/selected.html', | ||
|
||
controller: ['$scope', function($scope) { | ||
$scope.deselectAll = function(){ | ||
$scope.selected.selectAll(false); | ||
}; | ||
}] | ||
}; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div> | ||
<div class="deselect-action-container"> | ||
<span ng-model="selected.numSelected">{{ selected.numSelected }} Selected</span> | ||
<a class="deselect-action" | ||
ng-class="{ 'disabled-link' : selected.numSelected == 0 }" | ||
ng-click="deselectAll()"> | ||
Deselect All | ||
</a> | ||
</div> | ||
<div class="select-all-action-container" | ||
ng-show="selected.moreResults()"> | ||
All {{ table.offset }} results shown are currently selected. | ||
<a class="table-select-all-action">Select all {{ table.total }} results.</a> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wondering, if it makes sense to say user that he has selected all options and give him option to "select all". And if I deselect one row, this options disappears. It looks that it needs to be vice-versa - when I don't have selected all, I have option to actually select all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happens when I check all (from the left top) - the message says: "All results shown are currently selected. Select all results." There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This action was intended from this scenario
This link appears and gives them that option. It's similar to how gmail handles when you select all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, this makes sense. Actually the sentence "Select all 100 results" as is done in the code would help, however it seems that total number is not working in the example. |
||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use strict'; | ||
|
||
describe('Directive: Search', function () { | ||
var element, | ||
scope, | ||
testModel; | ||
|
||
beforeEach(module('alchemy', 'alch-templates')); | ||
|
||
beforeEach(function(){ | ||
testModel = { | ||
selectAll: function(selected) { | ||
if (!selected) { | ||
testModel.numSelected = 0; | ||
} | ||
}, | ||
numSelected: 0, | ||
offset: 10, | ||
total: 20 | ||
}; | ||
}); | ||
|
||
describe('', function(){ | ||
|
||
beforeEach(inject(function($rootScope, $compile){ | ||
element = angular.element('<div alch-selected="model"></div>'); | ||
|
||
scope = $rootScope; | ||
scope.model = testModel; | ||
|
||
$compile(element)(scope); | ||
scope.$digest(); | ||
})); | ||
|
||
it('should update the numSelected', inject(function ($rootScope, $compile) { | ||
testModel.numSelected = 5; | ||
|
||
expect(scope.model.numSelected).toBe(5); | ||
})); | ||
|
||
it('should reset the selected count to zero when deselect is clicked', inject(function ($rootScope, $compile) { | ||
var deselect = element.find('.deselect-action'); | ||
|
||
scope.model.numSelected = 5; | ||
$(deselect).click(); | ||
|
||
expect(testModel.numSelected).toBe(0); | ||
expect($(deselect).hasClass('disabled-link')).toBeTruthy(); | ||
})); | ||
}); | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just small matter of styling - there needs to be pointer cursor and some visual change if this item on hover (e.g. underline). ... applies also for "select all results"