Skip to content
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

Merged
merged 4 commits into from Oct 9, 2019
Merged

Don't allow update 0 plugin #14811

merged 4 commits into from Oct 9, 2019

Conversation

MrYamous
Copy link
Contributor

Fix for issue #14785

Button for updating plugins is now disabled by default, enabled if at least one plugin is selected

Copy link
Member

@diosmosis diosmosis left a 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');
}
}
Copy link
Member

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);

Copy link
Contributor Author

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(){
Copy link
Member

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 %} />
Copy link
Member

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.

Copy link
Contributor Author

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 ?

Copy link
Member

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?

Copy link
Contributor Author

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);
Copy link
Member

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.

Copy link
Contributor Author

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.

@tsteur
Copy link
Member

tsteur commented Oct 9, 2019

Thanks @MrYamous It works 👍 very appreciated

@tsteur tsteur merged commit e5b034d into matomo-org:3.x-dev Oct 9, 2019
@tsteur tsteur added the Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. label Oct 9, 2019
@tsteur tsteur added this to the 3.12.0 milestone Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants