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
Don't allow update 0 plugin #14811
Don't allow update 0 plugin #14811
Conversation
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.
Hi @MrYamous thanks for your first contribution, we appreciate your time and effort! I left a couple comments after reviewing the code, once the changes are made we can merge the pull request.
} else if (checked_boxes === 0) { | ||
document.getElementById('update-selected-plugins').classList.add('disabled'); | ||
} | ||
} |
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 function should not be added to the global scope and should not be referenced via onclick=
. Instead, jQuery should be used to bind an anonymous function to the event (as is done above). Can you make this change?
Also, this code can be simplified to just check if at least one input is checked, eg:
var isAtLeastOneChecked = $('span.checkbox-container > input[checked]').length >= 1;
$('#update-selected-plugins').prop('disabled', !isAtLeastOneChecked);
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.
Hi @diosmosis thanks for your review and your advice
I made a new commit considering your tip :)
@@ -101,6 +101,21 @@ | |||
}); | |||
}); | |||
}); | |||
|
|||
function boxes_selected(){ |
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.
In general we don't use snake case in matomo, we use camel case (so this function name would be boxesSelected
).
@@ -26,7 +26,7 @@ | |||
<tr {% if plugin.isActivated|default(false) %}class="active-plugin"{% else %}class="inactive-plugin"{% endif %}> | |||
<td class="select-cell"> | |||
<span class="checkbox-container"> | |||
<input type="checkbox" id="select-plugin-{{ plugin.name|e('html_attr') }}" {% if plugin.isDownloadable is defined and not plugin.isDownloadable %}disabled="disabled"{% endif %} /> | |||
<input type="checkbox" id="select-plugin-{{ plugin.name|e('html_attr') }}" onclick="boxes_selected()" {% if plugin.isDownloadable is defined and not plugin.isDownloadable %}disabled="disabled"{% endif %} /> |
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.
@MrYamous it doesn't work for me because of an error when I click on it that this method is not defined... but even when removing this onclick it still seems to not activate the "update selected" button.
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.
@tsteur According to diosmosis's feedback, i removed this onclick and boxes_selectes(). Did you test the last commit ?
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.
There is still onclick="boxes_selected()"
though but no such method. Maybe you forgot to commit something?
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.
Exact, i missed one onclick, fixed in a new commit
@@ -74,6 +74,11 @@ | |||
|
|||
<script> | |||
$(function () { | |||
$('span.checkbox-container').on('click', function() { | |||
var isAtLeastOneChecked = $('span.checkbox-container > input[checked]').length >= 1; | |||
$('#update-selected-plugins').prop('disabled', !isAtLeastOneChecked); |
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 reckon you might also need to remove the CSS class disabled
? It's still not working for me here.
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.
Hello, sorry i did some mistakes with selector.
Thanks @MrYamous It works 👍 very appreciated |
Fix for issue #14785
Button for updating plugins is now disabled by default, enabled if at least one plugin is selected