forked from ontoportal/ontoportal_web_ui
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Harmonize API and UI urls in Search, Annotator and Recommender p…
…ages (#534) * create a stimulus controller to customize forms urls * harmonize search page api and ui urls * harmonize recommender api and ui urls * harmonize annotator api and ui urls * clean form url controller code
- Loading branch information
1 parent
a0716d3
commit fef53e3
Showing
8 changed files
with
50 additions
and
18 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,31 @@ | ||
import { Controller } from "@hotwired/stimulus" | ||
|
||
|
||
export default class extends Controller { | ||
|
||
submit(event){ | ||
event.preventDefault(); | ||
let selectedOptions, hiddenInput, optionString, selectElem | ||
let allSelects = this.element.querySelectorAll('select[name$="[]"]'); | ||
for (const select of allSelects) { | ||
const selectElem = select.name.substring(0, select.name.indexOf('[')); | ||
const selectedOptions = select.selectedOptions; | ||
if (selectedOptions.length > 0) { | ||
const optionString = Array.from(selectedOptions, option => option.value).join(","); | ||
const hiddenInput = this.#create_hidden_input_element(optionString, selectElem); | ||
event.currentTarget.appendChild(hiddenInput); | ||
select.remove(); | ||
} | ||
} | ||
|
||
event.currentTarget.submit(); | ||
} | ||
|
||
#create_hidden_input_element(optionString, name){ | ||
let hiddenInput = document.createElement('input'); | ||
hiddenInput.type = 'hidden'; | ||
hiddenInput.name = name; | ||
hiddenInput.value = optionString; | ||
return hiddenInput | ||
} | ||
} |
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