-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn display set list of cards into table (#3125)
This PR turns the display set list of cards into a table and adds a seperate update view. New list view: ![image](https://github.com/comic/grand-challenge.org/assets/30069334/4089424b-3d4d-42bc-b6f4-8706b2473845) Update view: ![image](https://github.com/comic/grand-challenge.org/assets/30069334/a25e6f2a-ada6-4b2d-8901-b0aa8da9e191) Closes #3042
- Loading branch information
Showing
30 changed files
with
635 additions
and
901 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
45 changes: 45 additions & 0 deletions
45
app/grandchallenge/components/static/components/js/autocomplete_htmx.mjs
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 @@ | ||
function updateRequestConfig (event) { | ||
for (const [key, val] of Object.entries(event.detail.parameters)) { | ||
if (key.startsWith('interface')) { | ||
event.detail.parameters['interface'] = val | ||
delete event.detail.parameters[key] | ||
} | ||
} | ||
} | ||
|
||
function processSelectElements () { | ||
const selectElements = document.querySelectorAll('select[name^="interface"]') | ||
selectElements.forEach(elem => { | ||
const observer = new MutationObserver(function(mutationsList, observer) { | ||
for(let mutation of mutationsList) { | ||
if (mutation.target === elem) { | ||
elem.addEventListener('htmx:configRequest', updateRequestConfig); | ||
htmx.trigger(elem, 'interfaceSelected'); | ||
} | ||
} | ||
}); | ||
observer.observe(elem, {childList: true}); | ||
}); | ||
} | ||
|
||
htmx.onLoad((elem) => { | ||
processSelectElements(); | ||
const dalForwardConfScripts = document.querySelectorAll('.dal-forward-conf script'); | ||
dalForwardConfScripts.forEach(script => script.textContent = ''); | ||
let vals = []; | ||
const selectOptions = document.querySelectorAll('select:disabled[name^="interface"] option:checked'); | ||
selectOptions.forEach(option => { | ||
vals.push(option.value); | ||
}); | ||
|
||
if (vals.length) { | ||
vals = vals.map(val => `{"type": "const", "dst": "interface-${val}", "val": "${val}"}`); | ||
} | ||
|
||
const objectSlugVal = document.getElementById('objectSlug').dataset.slug; | ||
vals.push(`{"type": "const", "dst": "object", "val": "${objectSlugVal}"}`); | ||
|
||
dalForwardConfScripts.forEach(script => script.textContent = `[${vals.join(',')}]`); | ||
}); | ||
|
||
processSelectElements(); |
31 changes: 31 additions & 0 deletions
31
app/grandchallenge/components/static/components/js/create_extra_interfaces.mjs
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,31 @@ | ||
document.addEventListener('DOMContentLoaded', () => { | ||
|
||
htmx.onLoad( function() { | ||
const removeFormButtons = document.querySelectorAll('.remove-form'); | ||
for (const button of removeFormButtons) { | ||
button.addEventListener('click', (event) => { | ||
event.preventDefault(); | ||
const form = event.currentTarget.closest("form.extra-interface-form"); | ||
if (form) { | ||
form.remove(); | ||
} | ||
}); | ||
}; | ||
}); | ||
|
||
}); | ||
|
||
// force client side field validation for extra interface form fields | ||
// htmx post won't get sent otherwise | ||
document.getElementById('obj-form').addEventListener('submit', function(event) { | ||
var extraInterfaceForms = document.getElementsByClassName('extra-interface-form'); | ||
|
||
for (var i = 0; i < extraInterfaceForms.length; i++) { | ||
var form = extraInterfaceForms[i]; | ||
|
||
if (!form.checkValidity()) { | ||
form.reportValidity(); | ||
event.preventDefault(); | ||
} | ||
} | ||
}); |
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.