PR-5.2-dev Pending

User tests: Successful: Unsuccessful:

avatar sinahaghparast
sinahaghparast
8 Apr 2024

Pull Request for Issue # .

Summary of Changes

This class is responsible for displaying presentation data in list format.
This class is a typical example of a Model-View-Controller (MVC) pattern in Joomla, where ListView handles the presentation logic for list-type views. It's designed to be flexible and customizable through configuration options and subclassing. The use of properties like $items and $pagination suggests that this class is used to render lists of data, such as articles or products, with support for features like filtering, sorting, and pagination. The canDo property is likely used to determine user permissions for various actions within the list, ensuring that users can only perform actions they're authorized to do.

  • addToolbar(): This method adds the page title and toolbar to the view. It calls another method to initialize the toolbar and adds preferences and help buttons if the user has the appropriate permissions.

  • appendMoreButton(): This method is a placeholder for appending additional buttons to the toolbar. It provides an example of how to add an edit button based on user permissions.
    The class uses Joomla's MVC pattern and provides a structured way to handle list views with support for pagination, filtering, and toolbars. The use of comments and PHPDoc blocks helps to understand the purpose and functionality of each method. The class is designed to be extensible, allowing developers to customize the view by overriding these methods in subclasses.

  • Variables Initialization:

    • $viewName: Stores the name of the current view.
    • $singularViewName: Stores the singular form of the view name, which is useful for singular actions like 'add new item'.
    • $componentName: Extracts the component name from the class property option.
    • $extensionClass: Constructs the class name of the component.
    • $developer: Extracts the developer's name from the namespace.
    • $trashCondition: Determines the state value for trashed items.
  • Toolbar Configuration:

    • Sets the title of the toolbar using the toolbarTitle and toolbarIcon properties.
    • Adds a 'New' button if the user has the 'create' permission.
    • Configures a dropdown button for changing the status of items if the user has the 'edit state' permission or there are transitions available.
    • Adds buttons for publishing, unpublishing, featuring, archiving, checking in, and trashing items based on user permissions and the current state of the items.
    • Adds a batch processing button if batch operations are supported and the user has the necessary permissions.
  • Transitions Handling:

    • If transitions are available and the user can execute them, the method adds a section in the dropdown for running transitions.
    • Each transition is represented by a button that, when clicked, sets the transition ID and submits the form to execute the transition.
      This method is a good example of how Joomla! provides a structured approach to managing toolbars in MVC components, allowing for a clean separation of concerns and making it easy to customize toolbar actions based on user permissions and component state.

It has already been discussed here
#43070

Testing Instructions

class HtmlView extends ListView
{
public function __construct($config = [])
{
$config['toolbar_title'] = Text::_('COM_XYZ');
$config['option'] = ApplicationHelper::getComponentName();
$config['toolbar_icon'] = 'signup';
$config['help_link'] = '#';
parent::__construct($config);
}
}

Actual result BEFORE applying this Pull Request

Toolbar show buttons side by side

Expected result AFTER applying this Pull Request

Toolbar show dropdown button

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

avatar sinahaghparast sinahaghparast - open - 8 Apr 2024
avatar sinahaghparast sinahaghparast - change - 8 Apr 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 8 Apr 2024
Category Libraries
avatar sinahaghparast sinahaghparast - change - 8 Apr 2024
Title
5.2 list view
5.2 Update ListView.php - Review addToolbar function
avatar sinahaghparast sinahaghparast - edited - 8 Apr 2024
avatar richard67
richard67 - comment - 8 Apr 2024

My above change suggestions are only a few of the many violated code style rules. We use PSR-12 rules.

avatar brianteeman
brianteeman - comment - 8 Apr 2024

Please explain what these changes add to Joomla and how this is different than the current behaviour. Please use your own words and not chatgpt to describe these changes and not just provide a documentation of the code.

avatar sinahaghparast sinahaghparast - change - 8 Apr 2024
Labels Added: PR-5.2-dev
avatar sinahaghparast
sinahaghparast - comment - 8 Apr 2024

Hello,
New figure of List view after changes commit.

Screenshot 2024-04-08 at 23-17-28 COM_MRJOOMLACART COM_MRJOOMLACART_STATUS - Joomla! 5 - Administration

Screenshot 2024-04-08 at 23-16-26 COM_MRJOOMLACART COM_MRJOOMLACART_STATUS - Joomla! 5 - Administration

Developers can create HtmlView class extends \Joomla\MVC\View\ListView class, this class is suiet for any pages that show items (records of database). Toolbar is similar to com_content and other core component...

As far as I was familiar with the structure of Joomla, I observed the cases. Again, if I have forgotten something, please let me know.

avatar brianteeman
brianteeman - comment - 9 Apr 2024

When you add new code to Joomla that requires a new docblock we do not put a value for @since as the code may not be merged in that version. Instead we require you to use @since __DEPLOY_VERSION__. When it is merged and a new Joomla release is made then we have internal build scripts that will create the correct value.

avatar sinahaghparast
sinahaghparast - comment - 9 Apr 2024

I done it...

avatar Hackwar Hackwar - change - 10 Apr 2024
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2024-04-10 20:25:59
Closed_By Hackwar
avatar Hackwar
Hackwar - comment - 10 Apr 2024

Hello @sinahaghparast thank you for your contribution. We discussed this today in the maintainer meeting and unfortunately we see a few problems with this. We understand what you are trying to do, but we don't think that your approach is really that universal as you want it to be.

More importantly however we think such a solution would need a greater plan and concept. If you want to introduce rapid development code (similar to FoF, which we had in the past, or Koowa) this should be based on an overarching plan which covers basically all parts of a component or, even better, all extension types. It would be highly problematic to have a new concept like this one and then it is ONLY applied to this one class. And then a few months later someone else comes along and creates something similar to the toolbar in the edit view and uses a different concept than yours. That would mean quite a mess. That is why we think without a greater plan we can't even start working into that direction.

It would be good if you could join an initiative on Mattermost to create such a greater plan. Until then I unfortunately have to close this PR.

avatar Hackwar Hackwar - close - 10 Apr 2024

Add a Comment

Login with GitHub to post a comment