-
Notifications
You must be signed in to change notification settings - Fork 88
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
Conversation
@@ -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)} |
There was a problem hiding this comment.
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); | ||
} |
There was a problem hiding this comment.
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"){ |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
elimina el console.log :)
There was a problem hiding this 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!
Issue(s)
#1577
Description