Custom Buttons issue???? #340

Closed
opened 2018-09-13 06:46:11 +00:00 by Schrijvers123 · 4 comments
Schrijvers123 commented 2018-09-13 06:46:11 +00:00 (Migrated from github.com)

Steps to reproduce the issue

Build in the admin view a custom button with the following option:

Target Controller Method: addInvoice
Target: List
Type: Selection

Expected result

If I select no records in the list view it should give a popup that you need to select some records (just like Export Data)

Actual result

It's telling nothing. I can make an error message, but this means the the information is post, even there was no information

System information (as much as possible)

  • OS Name & Version: Windows 10
  • MySql Version: .5.5-10.1.35-MariaDB-1~xenial
  • Apache Version: 2.9.0
  • PHP Version: 7.1.21
  • Joomla Version: Joomla! 3.8.12 Stable [ Amani ] 28-August-2018 14:00 GMT
  • JCB Version:
  • Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0

Additional comments

If this is not a issue (bug) how to solve the problem so that the behaviour is the same as Export Data (the selecting part).

### Steps to reproduce the issue Build in the admin view a custom button with the following option: **Target Controller Method**: addInvoice **Target**: List **Type**: Selection ### Expected result If I select no records in the list view it should give a popup that you need to select some records (just like Export Data) ### Actual result It's telling nothing. I can make an error message, but this means the the information is post, even there was no information ### System information (as much as possible) - OS Name & Version: Windows 10 - MySql Version: .5.5-10.1.35-MariaDB-1~xenial - Apache Version: 2.9.0 - PHP Version: 7.1.21 - Joomla Version: Joomla! 3.8.12 Stable [ Amani ] 28-August-2018 14:00 GMT - JCB Version: - Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0 ### Additional comments If this is not a issue (bug) how to solve the problem so that the behaviour is the same as Export Data (the selecting part).

Due to the variation and crazy dynamic nature of that area, I have not added any javascript to the page to monitor the button on click, you can do that with some custom scripting, or in the controller check if there are values, and if not then simple return an error message like we do in the Joomla Components area in JCB when you click on Export JCB Packages This is the code in the controller:

if (!ComponentbuilderHelper::checkArray($pks))
{
	// Redirect to the list screen with error.
	$message = JText::_('COM_COMPONENTBUILDER_NO_COMPONENTS_WERE_SELECTED_PLEASE_MAKE_A_SELECTION_AND_TRY_AGAIN');
	$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error');
	return;
}

Adding these options manually allows for more options with the custom buttons.

Due to the variation and crazy dynamic nature of that area, I have not added any javascript to the page to monitor the button on click, you can do that with some custom scripting, or in the controller check if there are values, and if not then simple return an error message like we do in the Joomla Components area in JCB when you click on **Export JCB Packages** This is the code in the [controller](https://github.com/vdm-io/Joomla-Component-Builder/blob/staging/admin/controllers/joomla_components.php#L143): ``` if (!ComponentbuilderHelper::checkArray($pks)) { // Redirect to the list screen with error. $message = JText::_('COM_COMPONENTBUILDER_NO_COMPONENTS_WERE_SELECTED_PLEASE_MAKE_A_SELECTION_AND_TRY_AGAIN'); $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), $message, 'error'); return; } ``` Adding these options manually allows for more options with the custom buttons.
Schrijvers123 commented 2018-09-13 22:16:42 +00:00 (Migrated from github.com)

Thanks fro the explenation. The custome button type: selection, is only for the selected lines (records)? If so, that it would be nice to show a general message or do nothing. This looks to me the nature of the button.

Is type:select id different, please explain.

Thanks fro the explenation. The custome button type: selection, is only for the selected lines (records)? If so, that it would be nice to show a general message or do nothing. This looks to me the nature of the button. Is type:select id different, please explain.

Sure, you are right in that the wording selection in nature needs items selected 👍

That is not where the crazy dynamic nature is implied, but in the compiler.... look at the code here from line 3420 in the interpretation class of the compiler, you will see all custom buttons are build in this one method.

Custom buttons are used in both admin and site/custom admin views, so site and custom admin views, do not have items, but my have a list query that give the idea of a list to the compiler but in reality it is not a list and nothing is being selected.

I could push the boundary to try and catch the combination of adminview && selection and then simply add true as the fifth value in the JToolBarHelper::custom argument, which is what makes it validate that there is a selection made via JavaScript.

But this is a little heavy with all the polymorphic madness of the method. Let me see what I can do.. was hoping to get of easy with this request :)

But even if I do add this, never rely on browser side validation without server side validation.

Sure, you are right in that the wording selection in nature needs items selected :+1: That is not where the crazy dynamic nature is implied, but in the compiler.... look at the code here from [line 3420](https://github.com/vdm-io/Joomla-Component-Builder/blob/staging/admin/helpers/compiler/e_Interpretation.php#L3420) in the interpretation class of the compiler, you will see all custom buttons are build in this one method. Custom buttons are used in both admin and site/custom admin views, so site and custom admin views, do not have items, but my have a list query that give the idea of a list to the compiler but in reality it is not a list and nothing is being selected. I could push the boundary to try and catch the combination of `adminview && selection` and then simply add `true` as the fifth value in the `JToolBarHelper::custom` argument, which is what makes it validate that there is a selection made via JavaScript. But this is a little heavy with all the polymorphic madness of the method. Let me see what I can do.. was hoping to get of easy with this request :) But even if I do add this, never rely on browser side validation without server side validation.

Okay test the staging branch 👍

Okay test the staging branch :+1:
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#340
No description provided.