Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow-up fixes for #1799 PR #1801

Merged
merged 3 commits into from
Dec 10, 2024
Merged

Follow-up fixes for #1799 PR #1801

merged 3 commits into from
Dec 10, 2024

Conversation

quimmrc
Copy link
Contributor

@quimmrc quimmrc commented Dec 4, 2024

Issue(s)
#1577

Description

  • Deletion of unnecessary parts of code
  • Handle of reloadOnSuccess dataset element: when binding; if undefined, it is set to false, otherwise it's parsed to later compare it using javascript logic
  • Brief new comments on the developers' instructions regarding the use of modals

@@ -9,10 +9,12 @@ const bwPageElement = document.getElementsByClassName('bw-page')[0];
const bindModalActivationElements = (querySelectorStr, handleModalFunction, container) => {
container.querySelectorAll(querySelectorStr).forEach(element => {
if (element.dataset.alreadyBinded !== undefined){ return; }
if (element.dataset.reloadOnSuccess === undefined){element.dataset.reloadOnSuccess=false}
else{element.dataset.reloadOnSuccess = JSON.parse(element.dataset.reloadOnSuccess)}
Copy link
Member

@ffont ffont Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Crec que aquí és millor no fer això, ja que aquesta funció no té perquè saber res de la lògica dels modals i el que necessiten saber de element. A part, aqui només "t'assegures" que reloadOnSuccess estigui definit a element i no és necessari encara, de moment n'hi ha prou passant element.

Més endavant faig un altre comentari que complementa aquest.

const handleDefaultModalWithForm = (modalUrl, modalActivationParam) => {
handleGenericModalWithForm(modalUrl, undefined, undefined, (req) => {showToast('Form submitted succesfully!')}, undefined, true, true, modalActivationParam, true);
const handleDefaultModalWithForm = (modalUrl, modalActivationParam, element) => {
handleGenericModalWithForm(modalUrl, undefined, undefined, (req) => {showToast(element.dataset.successMessage || 'Form submitted succesfully!')}, (req) => {showToast(element.dataset.errorMessage || "There were errors processing the form...")}, true, true, modalActivationParam, element.dataset.reloadOnSuccess);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aquí el que jo faria és que l'últim argumentario sigui element.dataset.reloadOnSuccess === "true" o element.dataset.reloadOnSuccess === "1" (o el valor que decidim que hauria de significar true). Així ja queda auto-explicat com funciona i no cal posar codi relacionat a altres llocs. Si que miraria si hi ha algun altre exemple en el codi on faci algo similar de passar una variable "bool" a traves d'un dataset, per veure quin valor faig servir (si "true", "on","1"...). D'entrada crec que "true" podria tenir sentit.

@@ -221,7 +223,8 @@ const handleGenericModalWithForm = (fetchContentUrl, onLoadedCallback, onClosedC
if (onFormSubmissionSucceeded !== undefined){
onFormSubmissionSucceeded(req);
}
if(dataReloadOnSuccess == true){
if(triggerPageReloadOnSuccess == "true"){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aquí com que el paràmetre ja serà de tipus bool, només cal fer if (triggerPageReloadOnSuccess) {.... Això seguint els canvis que et proposava més amunt.

@@ -221,7 +223,8 @@ const handleGenericModalWithForm = (fetchContentUrl, onLoadedCallback, onClosedC
if (onFormSubmissionSucceeded !== undefined){
onFormSubmissionSucceeded(req);
}
if(dataReloadOnSuccess == true){
if(triggerPageReloadOnSuccess == "true"){
console.log(triggerPageReloadOnSuccess)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elimina el console.log :)

Copy link
Member

@ffont ffont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gràcies!
T'he deixat petits comentaris per millorar, però ja gairebé ho tens!

@ffont ffont merged commit 30f43c5 into master Dec 10, 2024
1 check passed
@ffont ffont deleted the issue1577 branch December 10, 2024 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants