77 * @property {number } width // width of the popup window
88 * @property {number } height // height of the popup window
99 * The form on which the classhelper is being used
10- * @property {string } formName
10+ * @property {string | null } formName
1111 * The form property on which the classhelper is being used
12- * @property {string } formProperty
13- * @property {string } tableSelectionType // it has to be "checkbox" or "radio"(if any)
12+ * @property {string | null } formProperty
13+ * @property {string | null } tableSelectionType // it has to be "checkbox" or "radio"(if any)
1414 * The fields on which the table is sorted
15- * @property {string[] } sort
15+ * @property {string[] | undefined } sort
1616 * The actual fields to be displayed in the table
17- * @property {string[] } fields
17+ * @property {string[] | undefined } fields
1818 * @property {number } pageIndex
1919 * @property {number } pageSize
2020 */
@@ -82,7 +82,7 @@ class ClassHelper extends HTMLElement {
8282 * Stores the result from api calls made to rest api,
8383 * for the parameters in searchWith attribute of this web component
8484 * where a parameter is defined as a dropdown in
85- * @type {Object.<string, Object .<string, string>> } */
85+ * @type {Object.<string, Map .<string, string>> } */
8686 dropdowns = null ;
8787
8888 /** @type {HTMLAnchorElement } */
@@ -128,15 +128,13 @@ class ClassHelper extends HTMLElement {
128128 const initialRequestURL = ClassHelper . getRestURL ( this . trackerBaseURL , this . helpurlProps ) ;
129129
130130 ClassHelper . fetchTranslations ( ) . catch ( error => {
131- // Top level handling for translation errors.
132- // Fallbacks to use english keywords.
133- /** @todo think about the showing it to user */
134- console . error ( error . message ) ;
131+ console . warn ( "Classhelper failed in translating." )
132+ console . error ( error ) ;
135133 } ) ;
136134
137- this . fetchDropdowns ( this . helpurlProps ) . catch ( error => {
135+ this . fetchDropdowns ( ) . catch ( error => {
138136 // Top level handling for dropdowns errors.
139- console . error ( error . message ) ;
137+ console . error ( error ) ;
140138 } ) ;
141139
142140 const cleanUpClosure = ( ) => {
@@ -236,21 +234,19 @@ class ClassHelper extends HTMLElement {
236234 let resp ;
237235 try {
238236 resp = await fetch ( url ) ;
239- if ( ! resp . ok ) throw new Error ( ) ;
237+ if ( ! resp . ok ) throw new Error ( "Not 2xx status code." , { cause : resp } ) ;
240238 } catch ( error ) {
241- console . error ( error ) ;
242- throw new Error ( "error fetching translations from roundup rest api" ) ;
239+ throw new Error ( "error fetching translations from roundup rest api" , { cause : error } ) ;
243240 }
244241
245242 try {
246243 ClassHelper . translations = await resp . json ( ) ;
247244 } catch ( error ) {
248- throw new Error ( "error parsing translation json from roundup rest api" ) ;
245+ throw new Error ( "error parsing translation json from roundup rest api" , { cause : error } ) ;
249246 }
250247 }
251248
252- /** @param {HelpUrlProps } props */
253- async fetchDropdowns ( props ) {
249+ async fetchDropdowns ( ) {
254250 // Singleton implementation
255251 if ( this . dropdowns != null ) {
256252 return ;
@@ -265,9 +261,9 @@ class ClassHelper extends HTMLElement {
265261
266262 for ( let param of params ) {
267263 if ( param . includes ( "[]" ) ) {
268- const splitResult = param . split ( "[]" ) ;
269- param = splitResult [ 0 ] ;
270- const sortOrder = splitResult [ 1 ] ;
264+ const segments = param . split ( "[]" ) ;
265+ param = segments [ 0 ] ;
266+ const sortOrder = segments [ 1 ] ;
271267 let url = `${ this . trackerBaseURL } /rest/data/${ param } ?@fields=id,name` ;
272268 if ( sortOrder ) {
273269 url += `&@sort=${ sortOrder } ` ;
@@ -276,10 +272,9 @@ class ClassHelper extends HTMLElement {
276272 let resp ;
277273 try {
278274 resp = await fetch ( url ) ;
279- if ( ! resp . ok ) throw new Error ( ) ;
275+ if ( ! resp . ok ) throw new Error ( "Not 2xx status code." , { cause : resp } ) ;
280276 } catch ( error ) {
281- console . error ( error ) ;
282- throw new Error ( "error fetching dropdowns from roundup rest api" ) ;
277+ throw new Error ( "error fetching dropdowns from roundup rest api" , { cause : error } ) ;
283278 }
284279
285280 let json ;
@@ -302,7 +297,7 @@ class ClassHelper extends HTMLElement {
302297 /**
303298 * Find the anchor tag that provides the classhelp link.
304299 * @returns {HTMLAnchorElement }
305- * @throws {Error } when there are no links or more than one link
300+ * @throws {Error } when the anchor tag is not classhelp link
306301 */
307302 findClassHelpLink ( ) {
308303 const links = this . querySelectorAll ( "a" ) ;
@@ -334,6 +329,7 @@ class ClassHelper extends HTMLElement {
334329 * This method parses the helpurl link to get the necessary data for the classhelper.
335330 * @param {HTMLAnchorElement } link
336331 * @returns {HelpUrlProps }
332+ * @throws {Error } when the helpurl link is not proper
337333 */
338334 static parseHelpUrlProps ( link ) {
339335 const width = parseInt ( link . dataset . width ) ;
0 commit comments