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

18.0 fix select type on ticket list #32120

Closed

Conversation

thomas-Ngr
Copy link
Contributor

@thomas-Ngr thomas-Ngr commented Nov 27, 2024

FIX Select type in ticket list

see issue #31619 (issue mentions 20.0 ; I confirm on 18.0 and develop)

We have a problem on ticket type selection :

  • on creation form, default value should be set and empty value should be forbidden.
  • on ticket list search field, default value should not be set and empty value should be allowed.

The function selectTypesTickets deals with many cases when $selected is empty :

  • the field can be empty, and we don't want to select the default value (this is the case in ticket list search field, which is a multiselect)
  • the field can be empty, and we want to select the default value (theoritical case, I will not deal with it)
  • the field should not be empty, and we want to select the default value (this is the case in ticket creation card)
  • the field should not be empty, and there is no default value (this may be the case in ticket creation card) -> this means the select will be selected on the first entry. The function should display an entry that is obviously wrong, like 'Please select type.'

To illustrate the problem on ticket list search field, when I load ticket/list.php (or do a search without setting the field for ticket type), the search field for type is set to default by DLB :

image

This means that I have to remove this field each time I do a new search.

This PR :

  • modifies selectTypesTickets to match these requirements
  • changes the call to selectTypesTickets in creation form to forbid empty value.

As a consequence :

  • on ticket list, the search field for type remains empty
  • on creation card, the default value is selected
  • on creation card, if there is no default value, the value '-- Select type --' is the first of the list and is used.
    image

@rycks
Copy link
Contributor

rycks commented Nov 28, 2024

i will try your fix on my dolibarr :)

Copy link
Contributor

@rycks rycks left a comment

Choose a reason for hiding this comment

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

ok for me

@lvessiller-opendsi
Copy link
Contributor

lvessiller-opendsi commented Nov 28, 2024

Sorry but I have changed my point of view and I revert my review.
There still exist a problem when you edit the type field, you can reset the value if you select "-- Select type --" value.
However this field must be mandatory.

@@ -753,7 +755,7 @@ public function selectTypesTickets($selected = '', $htmlname = 'tickettype', $fi
print ' selected="selected"';
} elseif (in_array($id, $selected)) {
print ' selected="selected"';
} elseif ($arraytypes['use_default'] == "1" && empty($selected)) {
} elseif ($arraytypes['use_default'] == "1" && empty($selected) && !$empty) {
print ' selected="selected"';
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the test !$empty should be replace with a specific list mode using multiselect

$object->type_code = GETPOST('update_value_type', 'aZ09');
$object->severity_code = GETPOST('update_value_severity', 'aZ09');
$object->category_code = GETPOST('update_value_category', 'aZ09');
if (!GETPOST("update_value_type", 'alpha')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry but I have changed my point of view and I revert my review. There still exist a problem when you edit the type field, you can reset the value if you select "-- Select type --" value. However this field must be mandatory.

This is due to the fact that these fields are not checked before updating.

The right way to fix this would be to use a function Ticket::validate() in create() and update(). But this function does not exist in DLB18 (I did not look after).

So I implemented a control in line with the code for ticket creation.

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.

3 participants