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
Maintain pagination when an user role changes #3120
Maintain pagination when an user role changes #3120
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3120 +/- ##
==========================================
+ Coverage 91.89% 91.92% +0.03%
==========================================
Files 211 211
Lines 12921 12924 +3
==========================================
+ Hits 11874 11881 +7
+ Misses 1047 1043 -4
Continue to review full report at Codecov.
|
assets/javascripts/admin_user.js
Outdated
url: form.attr('action'), | ||
data: jQuery.param(data), | ||
error: function(err){ | ||
rollback(); |
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 work. The reason is likely that the rollback()
function uses this
but is not invoked with a this
parameter.
assets/javascripts/admin_user.js
Outdated
} | ||
}); | ||
} else | ||
rollback(); |
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.
Same as the previous comment regarding calling rollback()
. Besides, please use braces here for symmetry.
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.
Ahh a last change before commit, fixing this
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.
Sorry, yes, this is working, but I could rewrite in a better way
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 gave it a local test and it wasn't working (as well as the other rollback()
).
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.
Hope now works for you. Now this stores the form in a variable before to be used in the callbacks.
assets/javascripts/admin_user.js
Outdated
$(this).parent('form').submit(); | ||
} else { | ||
|
||
function rollback(){ |
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.
Please use a space like ) {
.
var form = $(this).parent('form'); | ||
var data = form.serializeArray(); | ||
|
||
$.ajax({ |
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.
Since the rollback()
function relies on the class being set to default
that class needs to be updated when this AJAX call succeeds.
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.
yes, right
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 is solved now. I am using removeClass and addClass from jquery, but if is necessary could be replaced by native javascript operations
659895f
to
b37ec17
Compare
Additionally I added a small piece of html to show an beautiful red alert if something happens on updating the role. |
Do you thing should be necessary expanse the test to include that the default class changes? |
@@ -9,6 +9,14 @@ | |||
<div class="col-sm-12"> | |||
<h2><%= title %></h2> | |||
|
|||
<div id="error" class="alert alert-danger" role="alert" style="display:none"> |
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.
The generic way this error is handled means that this is not necessarily an "Internal server error". Either distinguish the errors or keep it simple, e.g. "An error occurred when changing the user role.". I also wouldn't include the link to the bug tracker. After all the server might just be not reachable because the client's internet connection went off. And I would prefer to simply show a flash message using addFlash('danger', …);
instead of creating the elements manually.
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.
Good point. I didn't have notice of addFlash, very useful
Likely it isn't necessary to have automatic tests for every detail. |
b37ec17
to
66779a9
Compare
assets/javascripts/admin_user.js
Outdated
|
||
$.ajax({ | ||
type: 'POST', | ||
url: form.attr('action')+'sddsds', |
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.
+'sddsds'
?
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.
yes, sorry
66779a9
to
e940123
Compare
so one test failed "scheduler". That should be fixed meanwhile in master. We can retrigger the failing test which we did now or just rebase. I am not sure what changes @Martchus would still expect if any |
https://progress.opensuse.org/issues/47210 Problem: In the user administration page. When a role is changed the page is reloaded loosing the page in the paginator. Solution: Programmatically summit the form to prevent the page reload. This solves the problem.
e940123
to
42e1242
Compare
Re-based and pushed |
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.
Seems to work now.
https://progress.opensuse.org/issues/47210
Problem: In the user administration page. When a role is changed
the page is reloaded loosing the page in the paginator.
Solution: Programmatically summit the form to prevent the page
reload. This solves the problem