@@ -5,25 +5,42 @@ define(['app/module'], function (module) {
55 * @ngdoc controller
66 * @kind constructor
77 * @name allTagsDialogCtlr
8- * @usage the controller is injected by the $modal service
8+ * @description
9+ * Controller for {@link allTagsDialog}. The controller is injected by the
10+ * $modal service. It handles the display and search of tags in the dialog.
11+ * The user can page through the tags using a pagination component, sort
12+ * the tags by count or name, and filter the tags by typing a string. See
13+ * <a href="http://angular-ui.github.io/bootstrap/"
14+ * target="_blank">ui.bootstrap.modal</a> for more information.
15+ *
916 * @param {angular.Scope } $scope (injected)
1017 * @param {ui.bootstrap.modal.$modalInstance } $modalInstance (injected)
11- * @param {ui.bootstrap.$modalInstance } allTagsStartFromFilter Filter for
12- * columnar display of tags
13- * @param {Array.<object> } unselTags unselected tags
14- * @param {Array.<object> } selTags selected tags
15- * @property {Array.<string> } $scope.unselTags set of tags that are found
18+ * @param {object } ssTagsSearch Instantiated upon a search for
19+ * tags to populate the dialog. Represents the tag-specific search criteria.
20+ * @param {SsSearchObject } ssTagsSearch Represents the current search
21+ * criteria, facets, and results for the application.
22+ * @param {object } mlUtil An object with various utility methods.
23+ *
24+ * @property {Array.<string> } $scope.unselTags Set of tags that are found
1625 * in tags facet results but not presently selected as criteria.
17- * @property {Array.<string> } $scope.selTags set of tags that are found
26+ * @property {Array.<string> } $scope.selTags Set of tags that are found
1827 * in tags facet results are are presently selected as criteria.
19- * @property {Array.<string> } $scope.tags set of tags that are found
20- * in tags facet results. Since the list of tags is limited by configuration
21- * to 8, at most 8 tags will be in this array at any time.
22- *
23- *
24- * @description
25- * Controller for {@link allTagsDialog}. This dialog isn't fully implemented.
26- * More detail TBD.
28+ * @property {string } $scope.selected Text by which the tag set is
29+ * filtered.
30+ * @property {Array.<string> } $scope.arrTags Array whose length is equal to
31+ * the number of display columns.
32+ * @property {integer } $scope.tagsPerCol Number of tags to display in
33+ * each column.
34+ * @property {integer } $scope.maxSize Maximum number of page numbers
35+ * displayed in the pagination component.
36+ * @property {integer } $scope.pageSize Maximum number of tags to be
37+ * displayed on the page.
38+ * @property {Array.<object> } $scope.sorts Set of objects for controlling
39+ * the sort of the tags.
40+ * @property {Array.<string> } $scope.tags Set of tags that are found
41+ * in tags facet results. The total number is limited to a $scope.pageSize
42+ * maximum.
43+ * @property {object } $scope.selectedSort The currently selected sort.
2744 */
2845 module . controller ( 'allTagsDialogCtlr' , [
2946
@@ -41,10 +58,9 @@ define(['app/module'], function (module) {
4158 ) {
4259
4360 // Tag settings
44- /**
45- */
46- // get a fresh copy so we don't mess with main search while we're in
47- // the dialog
61+ //
62+ // get a copy of the search criteria, don't change the main search while
63+ // in the dialog
4864 var criteria = angular . copy ( searchObject . criteria ) ;
4965 criteria . constraints . tags . values = criteria . constraints . tags . values || [ ] ;
5066 $scope . selTags = criteria . constraints . tags . values ;
@@ -64,6 +80,14 @@ define(['app/module'], function (module) {
6480 $scope . currentPage = 1 ; // initial
6581 $scope . maxSize = 5 ;
6682 $scope . pageSize = numCols * $scope . tagsPerCol ;
83+
84+ /**
85+ * @ngdoc method
86+ * @name allTagsDialogCtlr#$scope.updatePage
87+ * @description
88+ * Handle pagination changes.
89+ * @param {string } currentPage the current page, initially set to 1.
90+ */
6791 $scope . updatePage = function ( currentPage ) {
6892 $scope . currentPage = currentPage ;
6993 search ( ) ;
@@ -109,20 +133,41 @@ define(['app/module'], function (module) {
109133 * Close the dialog via the $modalInstance. This resolves the promise
110134 * from the {@link allTagsDialog} service
111135 */
112-
113136 $scope . submit = function ( ) {
114137 $modalInstance . close ( $scope . selTags ) ;
115138 } ;
116139
140+ /**
141+ * @ngdoc method
142+ * @name allTagsDialogCtlr#$scope.cancel
143+ * @description
144+ * Cancel the dialog via the $modalInstance.
145+ */
117146 $scope . cancel = function ( ) {
118147 $modalInstance . dismiss ( ) ;
119148 } ;
120149
150+ /**
151+ * @ngdoc method
152+ * @name allTagsDialogCtlr#$scope.setSort
153+ * @description
154+ * Set the current sort for the tags.
155+ */
121156 $scope . setSort = function ( ) {
122157 $scope . selectedSort = this . sort ;
123158 search ( ) ;
124159 } ;
125160
161+ /**
162+ * @ngdoc method
163+ * @name allTagsDialogCtlr#$scope.selectTagTypeahead
164+ * @param {object } $item object with tag name and count properties
165+ * @param {integer } $model tag count (e.g, 123)
166+ * @param {string } $label selected item label (e.g., 'java (123)')
167+ * @description
168+ * Called upon tag selection in the typeahead menu. Adds tag name to
169+ * the $scope.selTags array and executes a search for tags.
170+ */
126171 $scope . selectTagTypeahead = function ( $item , $model , $label ) {
127172 $scope . selected = '' ; // Clear typeahead menu
128173 if ( $scope . selTags . indexOf ( $item . name ) === - 1 ) {
@@ -131,6 +176,14 @@ define(['app/module'], function (module) {
131176 }
132177 } ;
133178
179+ /**
180+ * @ngdoc method
181+ * @name allTagsDialogCtlr#$scope.typeaheadSearch
182+ * @param {string } searchForName input text
183+ * @description
184+ * Called upon entering text in the typeahead input. Returns a
185+ * promise which returns an array of menu item objects.
186+ */
134187 $scope . typeaheadSearch = function ( searchForName ) {
135188 var tagsSearch = ssTagsSearch . create ( {
136189 criteria : mlUtil . merge (
@@ -154,6 +207,15 @@ define(['app/module'], function (module) {
154207 } ) ;
155208 } ;
156209
210+ /**
211+ * @ngdoc method
212+ * @name allTagsDialogCtlr#$scope.search
213+ * @description
214+ * Performs a search for tags based on page and sort criteria.
215+ * Instantiates a ssTagsSearch object. Upon successful search, the
216+ * method populates a $scope.pagedTagsByColumn array of arrays which
217+ * organizes tags for display (an array of tags for each column).
218+ */
157219 var search = function ( ) {
158220 var tagsSearch = ssTagsSearch . create ( {
159221 criteria : mlUtil . merge (
@@ -173,22 +235,21 @@ define(['app/module'], function (module) {
173235 $scope . totalPages = Math . ceil (
174236 tagsSearch . results . count / $scope . pageSize
175237 ) ;
176- $scope . pagedTagsByColumn = [ ] ;
238+ $scope . pagedTagsByColumn = [ ] ; // array of arrays
177239 while (
178240 tagsSearch . results . items . length &&
179241 $scope . pagedTagsByColumn . length < numCols
180242 ) {
243+ // an array of tags in each column array
181244 $scope . pagedTagsByColumn . push (
182245 tagsSearch . results . items . splice ( 0 , $scope . tagsPerCol )
183246 ) ;
184247 }
185248 } ) ;
186249
187-
188250 } ;
189251
190-
191- // kick the search
252+ // perform the initial search
192253 search ( ) ;
193254
194255 }
@@ -199,21 +260,19 @@ define(['app/module'], function (module) {
199260 * @ngdoc dialog
200261 * @kind function
201262 * @name allTagsDialog
202- * @description
203- * Displays all tags in the database in a paged modal, and allows for
204- * searching and selecting the tags for inclusion as filters on a search.
205- * Uses <a href="http://angular-ui.github.io/bootstrap/"
206- * target="_blank">ui.bootstrap.modal</a>. Also see the
207- * {@link allTagsDialogCtlr}
208- * and the {@link allTagsStartFrom allTagsStartFrom filter}.
209- * @param {Array.<object> } unselTags unselected tags
210- * @param {Array.<object> } selTags selected tags
211- * @returns {angular.Promise } the promise will either be rejected
212- * or will resolve to an object the following properties that reflect the
213- * result of the user interaction has the dialog:
263+ * @description A UI Bootstrap component that provides a modal dialog for
264+ * displaying all tags available for a search. When called, this service
265+ * configures the dialog and the controller {@link allTagsDialogCtlr}, and
266+ * launches the dialog using the template. See
267+ * <a href="http://angular-ui.github.io/bootstrap/"
268+ * target="_blank">ui.bootstrap.modal</a> for more information.
269+ *
270+ * @param {SsSearchObject } searchObject An object representing the current
271+ * search criteria, facets, and results for the application.
214272 *
215- * * **unselTags** - `{Array.<object}` the unselected tags
216- * * **selTags** - `{Array.<object}` - the selected tags
273+ * @returns {angular.Promise } The promise will either be rejected
274+ * or will resolve to an object with an array of selected tags as its
275+ * property.
217276 */
218277 module . factory ( 'allTagsDialog' , [
219278 '$modal' ,
0 commit comments