Description
From a user interaction standpoint, it would be helpful to have the save icon blink whenever a user enters text into a comment form.
The save icon is the 馃捑 in the comment toolbar below:
See #9131, particularly this comment.
Currently the comment form saves every single time the input is changed. This isn't very useful to the user, so we'll also want to implement some kind of debouncing or setTimeout
delay.
Summary of Changes to Be Made
These changes can be done in separate PRs, and by different contributors. But they probably have to be done in sequence:
save
method in editor.js
, either wait 1000ms, or only run save
when user input has stopped for 500ms (you choose the time).save
method runs, so that user knows that it's running. Darken the icon background. Replace the 馃捑 with one of these FontAwesome spinner icons.Drag and drop to add an image or file, or choose one
with Saving...
to absolutely spell it out for the user.Useful Links & Images
What the end goal looks like:
These changes are going to be made in the comment/legacy editor, which lives at app/assets/javascripts/editor.js
:
https://github.com/publiclab/plots2/blob/62fdcd0dd54b47727a046a0129ba138710082f0b/app/assets/javascripts/editor.js#L116-L119
Leave a comment below if you want to claim this issue, and post here if you need any help getting oriented to the codebase! Good luck! 馃崁
Can I give it a shot! This one seems to implement some great functionality :D
@waridrox Definitely, go ahead!
I'm having a hard time thinking about how we can implement the spinner when the save function is being performed. That's because the whole toolbar is rendered as a partial initially so I'm not sure if we can render that specific save option differently than the rest of the toolbar icons.
I've managed to implement a debounce function in the save function though which may same some cpu resources.
@noi5e What are your views on this 馃 ?
@waridrox This is great work so far, and good questions!
I'm having a hard time thinking about how we can implement the spinner when the save function is being performed. That's because the whole toolbar is rendered as a partial initially so I'm not sure if we can render that specific save option differently than the rest of the toolbar icons.
The Editor
class has an attribute commentFormId
:
https://github.com/publiclab/plots2/blob/a44aff71c69671d2cb7142e1d93d45ff97114c06/app/assets/javascripts/editor.js#L10-L11
Which can be used to refer to the particular save button that needs to be updated:
https://github.com/publiclab/plots2/blob/a44aff71c69671d2cb7142e1d93d45ff97114c06/app/views/editor/_toolbar.html.erb#L81-L90
jQuery seems like the best tool to use in this situation. Perhaps the spinner icon can be a sibling of <i class="fa fa-save"></i>
set to display: none;
and jQuery will toggle()
visibility between one element and the other.
editorToolbar.js
does a similar thing with jQuery whenever images are uploaded to a comment form, and we need to toggle visibility of the image upload progress bars:
https://github.com/publiclab/plots2/blob/a44aff71c69671d2cb7142e1d93d45ff97114c06/app/assets/javascripts/editorToolbar.js#L26-L32
I've managed to implement a debounce function in the save function though which may same some cpu resources.
Nice! 馃檶
Another thing that we might do is to get away with the save icon completely and prompt the user somewhere that the posts get auto-saved so they don't need to worry about it. But that might not be a great idea from a perspective of user feedback.
Hmm... Personally I want users to be able to use a feature we already have, and for them to know about it in an intuitive way... I think this issue is the best way to do it that I can think of. But definitely open to hearing other ideas about how to do that!
Which can be used to refer to the particular save button that needs to be updated:
Thanks for the info! 馃槃
_Update_ - @noi5e, here are 3 versions of the implementations, though there is still a small problem to resolve 馃槄. But which one according to you best suits the need ?
_Save button with the spinner icon_
_Save button with no functionality_
_Everything working as expected except the dark spinner background_
As you might have noticed, in sample1 and sample2 there are conflicting CSS styles at the save button which I can't figure it out yet that turn the save icon 馃捑 to the white color of the background 馃槄 when the save button is clicked.
So I'm going forward with sample3 and adding the Saving...
text and see later if the CSS issue can be resolved...
Here's the final implementation @noi5e, I'm really not sure how to make the CSS styles work without affecting when the 馃捑 icon when it is clicked. Maybe someone else can try that 馃槄. Other than that I've implemented what was required.
Most helpful comment
@waridrox This is great work so far, and good questions!
The
Editor
class has an attributecommentFormId
:https://github.com/publiclab/plots2/blob/a44aff71c69671d2cb7142e1d93d45ff97114c06/app/assets/javascripts/editor.js#L10-L11
Which can be used to refer to the particular save button that needs to be updated:
https://github.com/publiclab/plots2/blob/a44aff71c69671d2cb7142e1d93d45ff97114c06/app/views/editor/_toolbar.html.erb#L81-L90
jQuery seems like the best tool to use in this situation. Perhaps the spinner icon can be a sibling of
<i class="fa fa-save"></i>
set todisplay: none;
and jQuery willtoggle()
visibility between one element and the other.editorToolbar.js
does a similar thing with jQuery whenever images are uploaded to a comment form, and we need to toggle visibility of the image upload progress bars:https://github.com/publiclab/plots2/blob/a44aff71c69671d2cb7142e1d93d45ff97114c06/app/assets/javascripts/editorToolbar.js#L26-L32
Nice! 馃檶
Hmm... Personally I want users to be able to use a feature we already have, and for them to know about it in an intuitive way... I think this issue is the best way to do it that I can think of. But definitely open to hearing other ideas about how to do that!