@@ -1324,9 +1324,11 @@ try {
13241324 var selectedSegment = segments . find ( segment => String ( segment . id ) === document . getElementById ( "filter-segment-input" ) . value ) ;
13251325 if ( selectedSegment ) filteredQuestions = filteredQuestions . filter ( q => JSON . parse ( selectedSegment . question_ids ) . find ( qId => String ( qId . id ) === String ( q . id ) ) ) ;
13261326 }
1327+ if ( this && ( this . id === 'filter-segment-input' ) ) pagination . questions . page = 0 ;
13271328 pagination . questions . total = filteredQuestions . length ;
13281329 if ( document . querySelector ( '.questions #current-page' ) ) document . querySelector ( '.questions #current-page' ) . innerText = `Page ${ pagination . questions . page + 1 } of ${ Math . ceil ( pagination . questions . total / pagination . questions . perPage ) } ` ;
13291330 var currentPageQuestions = filteredQuestions . slice ( pagination . questions . page * pagination . questions . perPage , ( pagination . questions . page + 1 ) * pagination . questions . perPage ) ;
1331+ syncPagination ( ) ;
13301332 renderedEditors = { } ;
13311333 if ( active ) {
13321334 Array . from ( document . querySelector ( '.questions .section' ) . children ) . forEach ( rq => {
@@ -1915,10 +1917,15 @@ try {
19151917 if ( ! a . flagged && b . flagged ) return 1 ;
19161918 return b . id - a . id ;
19171919 } ) ;
1920+ if ( this && ( ( this . id === 'course-period-input' ) || ( this . id === 'filter-segment-input' ) || ( this . id === 'sort-question-input' ) || ( this . id === 'sort-seat-input' ) ) ) {
1921+ pagination . awaitingResponses . page = 0 ;
1922+ pagination . responses . page = 0 ;
1923+ }
19181924 pagination . awaitingResponses . total = responses1 . filter ( r => ( ( r . status === 'Invalid Format' ) || ( r . status === 'Unknown, Recorded' ) ) && document . querySelector ( '.awaitingResponses .section' ) ) . length ;
19191925 pagination . responses . total = responses1 . filter ( r => ! ( ( r . status === 'Invalid Format' ) || ( r . status === 'Unknown, Recorded' ) ) && document . querySelector ( '.responses .section' ) ) . length ;
19201926 if ( document . querySelector ( '.awaitingResponses #current-page' ) ) document . querySelector ( '.awaitingResponses #current-page' ) . innerText = `Page ${ pagination . awaitingResponses . page + 1 } of ${ Math . ceil ( pagination . awaitingResponses . total / pagination . awaitingResponses . perPage ) } ` ;
19211927 if ( document . querySelector ( '.responses #current-page' ) ) document . querySelector ( '.responses #current-page' ) . innerText = `Page ${ pagination . responses . page + 1 } of ${ Math . ceil ( pagination . responses . total / pagination . responses . perPage ) } ` ;
1928+ syncPagination ( ) ;
19221929 const awaitingSection = document . querySelector ( '.awaitingResponses .section' ) ;
19231930 const responsesSection = document . querySelector ( '.responses .section' ) ;
19241931 const awaitingResponses = responses1 . filter ( r => ( r . status === 'Invalid Format' || r . status === 'Unknown, Recorded' ) ) ;
@@ -5450,7 +5457,6 @@ try {
54505457 }
54515458
54525459 function viewRoster ( ) {
5453- console . log ( rosters )
54545460 if ( ! this || ! this . parentElement || ! this . parentElement . querySelector ( 'input' ) . id ) return ;
54555461 const roster = rosters . find ( roster => String ( roster . period ) === this . parentElement . querySelector ( 'input' ) . id . split ( 'period-' ) [ 1 ] ) ;
54565462 var rosterDataString = '' ;
@@ -5815,7 +5821,7 @@ try {
58155821 const questionTitle = this . parentElement . parentElement . querySelector ( '#question-text-input' ) ?. value ;
58165822 const questionDescription = renderedEditors [ Number ( questionId ) ] . getText ( ) . replaceAll ( '\\n' , ' ' ) . replaceAll ( ' ' , ' ' ) . trim ( ) || null ;
58175823 const questionImages = [ ...new Set ( JSON . parse ( questions . find ( q => String ( q . id ) === questionId ) . images ) ) ] ;
5818- console . log ( questionTitle , questionDescription , questionImages ) ;
5824+ // console.log(questionTitle, questionDescription, questionImages);
58195825 ui . setUnsavedChanges ( true ) ;
58205826 if ( questionImages . length || questionDescription ) {
58215827 ui . startLoader ( ) ;
@@ -5975,6 +5981,18 @@ try {
59755981 paginationSection . parentElement . querySelector ( '#next-page-button' ) . disabled = ( pagination [ group ] . page + 1 >= Math . ceil ( pagination [ group ] . total / pagination [ group ] . perPage ) ) ? true : false ;
59765982 paginationSection . parentElement . querySelector ( '#previous-page-button' ) . disabled = false ;
59775983 }
5984+
5985+ function syncPagination ( ) {
5986+ Object . keys ( pagination ) . forEach ( group => {
5987+ if ( document . querySelector ( `.${ group } .pagination` ) ) {
5988+ document . querySelectorAll ( `.${ group } .pagination` ) . forEach ( paginationSection => {
5989+ paginationSection . parentElement . querySelector ( '#current-page' ) . innerText = `Page ${ pagination [ group ] . page + 1 } of ${ Math . ceil ( pagination [ group ] . total / pagination [ group ] . perPage ) } ` ;
5990+ paginationSection . parentElement . querySelector ( '#next-page-button' ) . disabled = ( pagination [ group ] . page + 1 >= Math . ceil ( pagination [ group ] . total / pagination [ group ] . perPage ) ) ? true : false ;
5991+ paginationSection . parentElement . querySelector ( '#previous-page-button' ) . disabled = ( pagination [ group ] . page - 1 < 0 ) ? true : false ;
5992+ } ) ;
5993+ }
5994+ } ) ;
5995+ }
59785996} catch ( error ) {
59795997 if ( storage . get ( "developer" ) ) {
59805998 alert ( `Error @ admin.js: ${ error . message } ` ) ;
0 commit comments