11/**
22 * Properties for the ClassHelper component,
33 * made into a type for better readability.
4- * @typedef {Object } ClassHelperProps
4+ * @typedef {Object } HelpUrlProps
55 * The qualified domain name with protocol and port(if any)
66 * @property {string } origin
77 * The tracker name from the url
@@ -94,8 +94,8 @@ class ClassHelper extends HTMLElement {
9494 helpurl = null ;
9595 helpurlScript = null ;
9696
97- /** @type {ClassHelperProps } */
98- properties = null ;
97+ /** @type {HelpUrlProps } */
98+ helpurlProps = null ;
9999
100100 /** no-op function */
101101 preventDefault = e => e . preventDefault ( ) ;
@@ -106,9 +106,13 @@ class ClassHelper extends HTMLElement {
106106
107107 try {
108108 this . helpurl = this . findClassHelpLink ( ) ;
109+
110+ // Removing the helpurl click behavior
109111 this . helpurlScript = this . helpurl . getAttribute ( "onclick" ) ;
110112 this . helpurl . setAttribute ( "onclick" , "" ) ;
111113 this . helpurl . addEventListener ( "click" , this . preventDefault ) ;
114+
115+ this . helpurlProps = ClassHelper . parseHelpUrlData ( this . helpurl ) ;
112116 } catch ( err ) {
113117 console . warn ( "Classhelper not intercepting helpurl." ) ;
114118 if ( this . helpurl != null ) {
@@ -120,8 +124,8 @@ class ClassHelper extends HTMLElement {
120124 }
121125
122126 try {
123- this . properties = ClassHelper . parseHelpUrlData ( this . helpurl ) ;
124- apiURL = ClassHelper . getRestURL ( this . properties ) ;
127+ this . helpurlProps = ClassHelper . parseHelpUrlData ( this . helpurl ) ;
128+ apiURL = ClassHelper . getRestURL ( this . helpurlProps ) ;
125129 } catch ( e ) {
126130 // Failed parsing props -> reset, log and return.
127131 this . helpurl . removeEventListener ( "click" , this . preventDefault ) ;
@@ -137,7 +141,7 @@ class ClassHelper extends HTMLElement {
137141 console . error ( error . message ) ;
138142 } ) ;
139143
140- this . fetchDropdowns ( this . properties ) . catch ( error => {
144+ this . fetchDropdowns ( this . helpurlProps ) . catch ( error => {
141145 // Top level handling for dropdowns errors.
142146 console . error ( error . message ) ;
143147 } ) ;
@@ -149,22 +153,22 @@ class ClassHelper extends HTMLElement {
149153 }
150154
151155 const handleClickEvent = ( event ) => {
152- this . openPopUp ( apiURL , this . properties ) . catch ( error => {
156+ this . openPopUp ( apiURL , this . helpurlProps ) . catch ( error => {
153157 // Top level error handling for openPopUp method.
154158 cleanUpClosure ( ) ;
155159 } ) ;
156160 } ;
157161
158162 const handleNextPageEvent = ( event ) => {
159- this . pageChange ( event . detail . value , this . properties ) . catch ( error => {
163+ this . pageChange ( event . detail . value , this . helpurlProps ) . catch ( error => {
160164 // Top level error handling for nextPage method.
161165 this . removeEventListener ( "nextPage" , handleNextPageEvent ) ;
162166 cleanUpClosure ( ) ;
163167 } ) ;
164168 }
165169
166170 const handlePrevPageEvent = ( event ) => {
167- this . pageChange ( event . detail . value , this . properties ) . catch ( error => {
171+ this . pageChange ( event . detail . value , this . helpurlProps ) . catch ( error => {
168172 // Top level error handling for prevPage method.
169173 this . removeEventListener ( "prevPage" , handlePrevPageEvent ) ;
170174 cleanUpClosure ( ) ;
@@ -173,13 +177,13 @@ class ClassHelper extends HTMLElement {
173177
174178 const handleValueSelectedEvent = ( event ) => {
175179 // does not throw error
176- this . valueSelected ( this . properties , event . detail . value ) ;
180+ this . valueSelected ( this . helpurlProps , event . detail . value ) ;
177181 }
178182
179183 const handleSearchEvent = ( event ) => {
180- this . properties . pageIndex = 1 ;
181- const searchURL = ClassHelper . getSearchURL ( this . properties , event . detail . value ) ;
182- this . searchEvent ( searchURL , this . properties ) . catch ( error => {
184+ this . helpurlProps . pageIndex = 1 ;
185+ const searchURL = ClassHelper . getSearchURL ( this . helpurlProps , event . detail . value ) ;
186+ this . searchEvent ( searchURL , this . helpurlProps ) . catch ( error => {
183187 // Top level error handling for searchEvent method.
184188 this . removeEventListener ( "search" , handleSearchEvent ) ;
185189 cleanUpClosure ( ) ;
@@ -252,7 +256,7 @@ class ClassHelper extends HTMLElement {
252256 }
253257 }
254258
255- /** @param {ClassHelperProps } props */
259+ /** @param {HelpUrlProps } props */
256260 async fetchDropdowns ( props ) {
257261 // Singleton implementation
258262 if ( this . dropdowns != null ) {
@@ -336,7 +340,7 @@ class ClassHelper extends HTMLElement {
336340 /**
337341 * This method parses the helpurl link to get the necessary data for the classhelper.
338342 * @param {HTMLAnchorElement } link
339- * @returns {ClassHelperProps }
343+ * @returns {HelpUrlProps }
340344 */
341345 static parseHelpUrlData ( link ) {
342346 const width = parseInt ( link . dataset . width ) ;
@@ -352,7 +356,7 @@ class ClassHelper extends HTMLElement {
352356 const urlParts = link . dataset . helpurl . split ( "?" ) ;
353357
354358 if ( urlParts . length != 2 ) {
355- throw new Error ( "invalid helpurl from link" ) ;
359+ throw new Error ( "invalid helpurl from link, missing query params " ) ;
356360 }
357361
358362 const apiClassName = urlParts [ 0 ] ;
@@ -402,7 +406,7 @@ class ClassHelper extends HTMLElement {
402406 /**
403407 * from roundup docs rest api url - "{host}/{tracker}
404408 * we pass helpurl which is parsed from anchor tag and return a URL.
405- * @param {ClassHelperProps } props
409+ * @param {HelpUrlProps } props
406410 * @returns {URL }
407411 * @throws {Error }
408412 */
@@ -757,7 +761,7 @@ class ClassHelper extends HTMLElement {
757761 /**
758762 * main method called when classhelper is clicked
759763 * @param {URL | string } apiURL
760- * @param {ClassHelperProps } props
764+ * @param {HelpUrlProps } props
761765 * @throws {Error } when fetching or parsing data from roundup rest api fails
762766 */
763767 async openPopUp ( apiURL , props ) {
@@ -833,7 +837,7 @@ class ClassHelper extends HTMLElement {
833837
834838 /** method when next or previous button is clicked
835839 * @param {URL | string } apiURL
836- * @param {ClassHelperProps } props
840+ * @param {HelpUrlProps } props
837841 * @throws {Error } when fetching or parsing data from roundup rest api fails
838842 */
839843 async pageChange ( apiURL , props ) {
@@ -884,7 +888,7 @@ class ClassHelper extends HTMLElement {
884888 }
885889
886890 /** method when a value is selected in
887- * @param {ClassHelperProps } props
891+ * @param {HelpUrlProps } props
888892 * @param {string } value
889893 */
890894 valueSelected ( props , value ) {
@@ -895,7 +899,7 @@ class ClassHelper extends HTMLElement {
895899
896900 /** method when search is performed within classhelper, here we need to update the classhelper table with search results
897901 * @param {URL | string } apiURL
898- * @param {ClassHelperProps } props
902+ * @param {HelpUrlProps } props
899903 * @throws {Error } when fetching or parsing data from roundup rest api fails
900904 */
901905 async searchEvent ( apiURL , props ) {
0 commit comments