Skip to content
This repository was archived by the owner on May 30, 2019. It is now read-only.

Commit f617ee0

Browse files
wooldridgelaurelnaiad
authored andcommitted
browser (documentation): dialogs and states (ask, qnaDoc)
Added documentation for the allTags, contributor, and login dialogs. Also for the ask and qnaDoc states. NOTE: these changes are updates to JS comments only. (Adding comments to the HTML caused issues with the unit tests in a previous commit. Avoiding that here.)
1 parent 9c7deed commit f617ee0

File tree

12 files changed

+510
-154
lines changed

12 files changed

+510
-154
lines changed

appserver/java-spring/static/app/dialogs/allTags.js

Lines changed: 97 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -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',

appserver/java-spring/static/app/dialogs/contributor.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,22 @@ define(['app/module'], function (module) {
44
* @ngdoc controller
55
* @kind constructor
66
* @name contributorDialogCtlr
7+
* @description
8+
* Controller for the {@link contributorDialog}. The controller
9+
* is injected by the $modal service. Upon instantiation, the controller
10+
* looks up the specified contributor by ID on the server. See
11+
* <a href="http://angular-ui.github.io/bootstrap/"
12+
* target="_blank">ui.bootstrap.modal</a> for more information.
13+
*
714
* @param {angular.Scope} $scope (injected)
815
* @param {ui.bootstrap.modal.$modalInstance} $modalInstance (injected)
9-
* @param {object} ssContributor
10-
* @param {string} contributorId
11-
* @description Controller for the {@link contributorDialog}. The controller
12-
* is
13-
* injected by the $modal service.
16+
* @param {object} ssContributor respresents a Samplestack contributor with
17+
* properties for displayName, reputation, etc.
18+
* @param {string} contributorId The ID of the contributor whose information
19+
* is displayed
1420
*
15-
* Upon instantiation the `contributorDialogCtlr` looks up the specified
16-
* contributor by id on the server.
21+
* @property {ssContributor} $scope.contributor a Samplestack contributor
22+
* @property {boolean} $scope.notFound set to true if contributor not found
1723
*/
1824
module.controller('contributorDialogCtlr', [
1925
'$scope', '$modalInstance', 'ssContributor', 'contributorId',
@@ -31,7 +37,7 @@ define(['app/module'], function (module) {
3137
/**
3238
* @ngdoc method
3339
* @name contributorDialogCtlr#$scope.cancel
34-
* @description Dismisses the modal (without logging in).
40+
* @description Dismisses the dialog
3541
*/
3642
$scope.cancel = function () {
3743
$modalInstance.dismiss();
@@ -42,16 +48,16 @@ define(['app/module'], function (module) {
4248

4349
/**
4450
* @ngdoc dialog
45-
* @name contributorDialog
4651
* @kind function
47-
* @param {string} contributorId The id of the contributor whose information
48-
* should
49-
* be displayed
50-
* @description The
51-
* contributor dialog displays information about a contributor.
52+
* @name contributorDialog
53+
* @description A UI Bootstrap component that provides a modal dialog for
54+
* information about a Samplestack contributor. When called, this service
55+
* configures the dialog and the controller {@link contributorDialogCtlr},
56+
* and launches the dialog using the template. See
57+
* <a href="http://angular-ui.github.io/bootstrap/"
58+
* target="_blank">ui.bootstrap.modal</a> for more information.
5259
*
53-
* This is the service that configures the dialog and the
54-
* {@link contributorDialogCtlr}, and launches the dialog.
60+
* @param {string} contributorId The ID of the contributor
5561
*/
5662
module.factory('contributorDialog', [
5763
'$modal',

appserver/java-spring/static/app/dialogs/login.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@ define(['app/module'], function (module) {
44
* @ngdoc controller
55
* @kind constructor
66
* @name loginDialogCtlr
7+
* @description
8+
* Controller for {@link loginDialog}. The controller is injected by the
9+
* $modal service. Provides a user interface for authenticating a user.
10+
* Upon instantiation the `loginDialogCtlr` creates an empty instance of
11+
* {@link ssSession} for handling authentication. See
12+
* <a href="http://angular-ui.github.io/bootstrap/"
13+
* target="_blank">ui.bootstrap.modal</a> for more information.
14+
*
715
* @param {angular.Scope} $scope (injected)
816
* @param {ui.bootstrap.modal.$modalInstance} $modalInstance (injected)
917
* @param {object} ssSession Session object
1018
* @param {object} mlAuth Authentication object
11-
* @description
12-
* Controller for {@link loginDialog}. The controller is injected by the
13-
* $modal service.
14-
*
15-
* Used to provide a user interface through which to autenticate a user.
16-
*
17-
* Upon instantiation the `loginDialogCtlr` creates an empty instance of
18-
* {@link ssSession} for handling authentication.
1919
*
20-
* @property {string} $scope.error If present, indicates textually what
21-
* error occured while attempting to authenticate a user.
20+
* @property {string} $scope.error If present, indicates what error
21+
* occurred while attempting to authenticate a user.
22+
* @property {string} $scope.session.username The username input.
23+
* @property {string} $scope.session.password The password input.
2224
*/
2325
module.controller('loginDialogCtlr', [
2426

@@ -67,10 +69,23 @@ define(['app/module'], function (module) {
6769
);
6870
};
6971

72+
/**
73+
* @ngdoc method
74+
* @name loginDialogCtlr#$scope.onAuthSuccess
75+
* @description Called upon successful authentication and closes the
76+
* dialog.
77+
*/
7078
var onAuthSuccess = function (user) {
7179
$modalInstance.close(user);
7280
};
7381

82+
/**
83+
* @ngdoc method
84+
* @name loginDialogCtlr#$scope.onAuthFailure
85+
* @description Called upon failed authentication. Sets the error message
86+
* and attaches a ssSession object with username information only to
87+
* scope.
88+
*/
7489
var onAuthFailure = function (reason) {
7590
$scope.error = 'Login Failed: ' + reason;
7691
ssSession.create( { username: $scope.session.username })
@@ -80,7 +95,7 @@ define(['app/module'], function (module) {
8095
/**
8196
* @ngdoc method
8297
* @name loginDialogCtlr#$scope.cancel
83-
* @description Dismisses the dialog.
98+
* @description Dismisses the dialog (without logging in)
8499
*/
85100
$scope.cancel = function () {
86101
$modalInstance.dismiss();
@@ -107,11 +122,12 @@ define(['app/module'], function (module) {
107122
* @ngdoc dialog
108123
* @name loginDialog
109124
* @kind function
110-
*
111-
* @description User interface for logging into the Samplestack application.
112-
*
113-
* This is the service that cobfigures the dialog and
114-
* the {@link loginDialogCtlr}, and launches the dialog.
125+
* @description A UI Bootstrap component that provides a modal dialog for
126+
* logging into the Samplestack application. When called, this service
127+
* configures the dialog and the controller {@link loginDialogCtlr}, and
128+
* launches the dialog using the template. The size property controls the
129+
* size of the dialog. See <a href="http://angular-ui.github.io/bootstrap/"
130+
* target="_blank">ui.bootstrap.modal</a> for more information.
115131
*/
116132
module.factory('loginDialog', [
117133
'$modal',

appserver/java-spring/static/app/domain/ssContributor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ define(['app/module'], function (module) {
5757
id: { type: 'string', minLength: 36, maxLength: 36 },
5858
location: { type: [ 'string', 'null' ]},
5959
voteCount: { type: [ 'integer' ] }
60+
// displayName???
6061
}
6162
})
6263
};

0 commit comments

Comments
 (0)