-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Disable cover upload submit
button while uploading
#8754
Disable cover upload submit
button while uploading
#8754
Conversation
Alas it seems I ran into some problems with the linter because I called my new function above the Any advice re: the best way to resolve this would be wonderful! Note: it seems to be the
Preventing this error from happening (i.e. by ensuring the |
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.
Nice! This looks great! One change -- should also fix the linting issue.
const btn = $('#imageUpload'); | ||
btn.prop('disabled', true).html(btn.data('loading-text')); |
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.
This doesn't need to be in a function; you can move these lines down to just after 83. That will also let the validation checks pass first before disabling the button.
We want those error checks to run first; because if it returns it won't actually upload the image, so we don't want to show the loading text.
So I think you will have to fix the val
bug!
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.
Sounds good to me! I'll go ahead and make the changes here, then have a look at the val
issue tomorrow.
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.
Moved everything and it all seems to be working great; just wanted to double check whether the val
fix should be done here as well or as a separate issue/PR. Thanks so much!
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.
Oh here is good! Should be a quick fix :) Note you'll have to do a rebase ontop of the lastest master since the other covers PR touches similar code 👍
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.
Great! Will finish everything up in the morning!
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.
Done! And fixing the val
bug made it clear that the checks to return an error if no file/url/id had been submitted - if (file === '' && url == '' && coverid == '')
- had been failing the whole time because the coverid val defaults to undefined
and not ''
. So I threw in a quick fix for that as well by switching to if (!file && !url && !coverid)
, so now it looks a bit cleaner and the correct error message shows if nothing is entered.
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.
Nice! Much cleaner 🥳
23440c1
to
8ea5a81
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #8754 +/- ##
==========================================
- Coverage 16.62% 16.61% -0.01%
==========================================
Files 88 88
Lines 4698 4700 +2
Branches 837 837
==========================================
Hits 781 781
- Misses 3399 3401 +2
Partials 518 518 ☔ View full report in Codecov by Sentry. |
5caec20
to
3e9e522
Compare
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.
Lgtm! Thanks @rebecca-shoptaw ! Tested uploading, upload causing an error, upload via upload vs via url.
@@ -68,7 +68,9 @@ | |||
</div> | |||
|
|||
<div class="formElement" style="margin: $('15px 0px 0px 15px;' if doc.type.key == '/type/work' else '0px;')"> | |||
<button type="submit" name="upload" id="imageUpload" value="$_('Submit')" class="largest">$_("Submit")</button> | |||
<button type="submit" name="upload" id="imageUpload" value="$_('Submit')" class="largest" data-loading-text='$_("Uploading...")'> |
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.
Let's stick to using data-i18n
for localized strings.
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.
Let's chat about it during our ABC call! We use a few different patterns in the code, +1 it would be good to standardize on one.
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.
How do I find the other patterns?
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.
I think I've seen 3 patterns?
- data-i18n
- one-offs (like here)
- IIRC some parts of the codebase have like i18n in a separate <script> tag? I can't recall
It's a touch hard to search for! I think data-i18n is a reasonable standard should we choose to adopt it :)
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.
Here are some examples I found of 2/3
2:
<a href="javascript:;" data-confirm-text="$:_('Yes, I\'m sure')" data-cancel-text="$_('No, cancel')"><span></span>$_('Remove this item?')</a> |
3:
<input type="hidden" name="list-i18n-strings" value="$json_encode(show_list_i18n_strings)"> |
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.
oof... if I ever find the guy that implemented #3
...
Converting these to use data-i18n
could be a good first issue (or issues).
Closes #8749
Feature. Adds a js function to disable
Submit
button and replace text withUploading...
when form is submitted.Technical
The
addLoadingStyling
function is currently defined locally within the on submit function for#addcover-form
. Could be moved into theinitCoversAddManage
function or elsewhere in the case of re-use (i.e. for theSave
button in the manage cover window).Another note: there is no function to clear the styling because the template is re-rendered when the function returns; if re-used elsewhere, a simple cleanup function may be necessary.
With @cdrini's help, I settled on the
data-loading-text
attribute to store the "Uploading..." message for translation purposes. Any other implementation of the function would require the same attribute in the corresponding HTML.Testing
Manage Covers
Submit
button in theAdd
tabScreenshot
Stakeholders
@cdrini