-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into 74_enter_evaluators_a11y_fix
- Loading branch information
Showing
13 changed files
with
635 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
export default class extends Controller { | ||
static targets = ["container", "loadMoreButton"] | ||
static values = { | ||
page: Number, | ||
totalCount: Number | ||
} | ||
|
||
connect() { | ||
this.pageValue = 1 | ||
this.checkHasMoreSubmissions() | ||
} | ||
|
||
async loadMore() { | ||
this.pageValue++ | ||
|
||
try { | ||
const url = new URL(window.location.href) | ||
url.searchParams.set('page', this.pageValue) | ||
url.searchParams.set('partial', 'true') | ||
|
||
const response = await fetch(url, { | ||
headers: { | ||
'Accept': 'text/html', | ||
'X-Requested-With': 'XMLHttpRequest' | ||
} | ||
}) | ||
if (!response.ok) throw new Error('Network response was not ok') | ||
|
||
const html = await response.text() | ||
this.containerTarget.insertAdjacentHTML('beforeend', html) | ||
this.checkHasMoreSubmissions() | ||
} catch (error) { | ||
console.error("Error loading more submissions:", error) | ||
} | ||
} | ||
|
||
checkHasMoreSubmissions() { | ||
const rows = this.containerTarget.querySelectorAll('tr') | ||
if (rows.length >= this.totalCountValue) { | ||
this.loadMoreButtonTarget.classList.add('display-none') | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// app/javascript/controllers/sort_filter_menu_controller.js | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
export default class extends Controller { | ||
static targets = ["menuItem"] | ||
|
||
connect() { | ||
this.updateCheckmarks() | ||
} | ||
|
||
toggle(event) { | ||
event.preventDefault() | ||
const clickedItem = event.currentTarget | ||
const filterValue = clickedItem.dataset.filterValue | ||
|
||
const currentUrl = new URL(window.location.href) | ||
const [param, value] = filterValue.split('=') | ||
|
||
if (currentUrl.searchParams.get(param) === value) { | ||
this.clearAllFilters() | ||
} else { | ||
this.applyFilter(filterValue) | ||
} | ||
} | ||
|
||
applyFilter(filterValue) { | ||
const currentUrl = new URL(window.location.href) | ||
const [param, value] = filterValue.split('=') | ||
|
||
this.removeExistingParams(currentUrl) | ||
currentUrl.searchParams.set(param, value) | ||
window.location.href = currentUrl.toString() | ||
} | ||
|
||
clearAllFilters() { | ||
const currentUrl = new URL(window.location.href) | ||
this.removeExistingParams(currentUrl) | ||
window.location.href = currentUrl.toString() | ||
} | ||
|
||
removeExistingParams(url) { | ||
const paramsToRemove = ['status', 'eligible_for_evaluation', 'selected_to_advance', 'sort'] | ||
paramsToRemove.forEach(key => { | ||
url.searchParams.delete(key) | ||
}) | ||
} | ||
|
||
updateCheckmarks() { | ||
const currentUrl = new URL(window.location.href) | ||
this.menuItemTargets.forEach(item => { | ||
const checkmark = item.querySelector('.checkmark') | ||
const [param, value] = item.dataset.filterValue.split('=') | ||
if (currentUrl.searchParams.get(param) === value) { | ||
checkmark.style.display = 'inline' | ||
} else { | ||
checkmark.style.display = 'none' | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.