Skip to content

Fix command select using key OR value for selected #3052

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

Open
wants to merge 3 commits into
base: alpha
Choose a base branch
from

Conversation

Flobul
Copy link
Contributor

@Flobul Flobul commented Apr 20, 2025

Fix command select on widget using key AND value for selected value.
Give the choice to use key or value from #listValue#

Description

When #listValue# has same kind of value for key/value (i.e. 1|7;2|6;3|5;4|4;5|3;6|2;7|1), using the actuel condition broke the selected value.

Suggested changelog entry

Add option in command configuration to choose between key and value for the selected listValue

Related issues/external references

Fixes #
Fix bug introduced here #2675

Types of changes

  • Bug fix (non-breaking change which fixes)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

PR checklist

@@ -1671,7 +1671,8 @@ public function toHtml($_version = 'dashboard', $_options = '') {
$coupleArray = explode('|', $element);
$cmdValue = $this->getCmdValue();
if (is_object($cmdValue) && $cmdValue->getType() == 'info') {
if ($cmdValue->execCmd() == $coupleArray[0] || $cmdValue->execCmd() == $coupleArray[1]) {
$keySeclected = intval($this->getConfiguration('listValueSelected', 0));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$keySelected (instead of $keySeclected)

@@ -1671,7 +1671,8 @@ public function toHtml($_version = 'dashboard', $_options = '') {
$coupleArray = explode('|', $element);
$cmdValue = $this->getCmdValue();
if (is_object($cmdValue) && $cmdValue->getType() == 'info') {
if ($cmdValue->execCmd() == $coupleArray[0] || $cmdValue->execCmd() == $coupleArray[1]) {
$keySeclected = intval($this->getConfiguration('listValueSelected', 0));
if ($cmdValue->execCmd() == $coupleArray[$keySeclected]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$keySelected

<div class="form-group">
<label class="col-xs-4 control-label">{{Sélection par index de valeur}}</label>
<div class="col-xs-8">
<input type="checkbox" class="cmdAttr" data-l1key="configuration" data-l2key="listValueSelected" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a select input will be more appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.
Should be easier to understand, I think.

@kwizer15
Copy link
Contributor

On the other hand, it could potentially break the existing system. I think we should make sure that if this is not configured, we keep the old behavior.

@Flobul
Copy link
Contributor Author

Flobul commented Apr 20, 2025

For me, old system since this PR #2675 is buggy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants