Skip to content

Commit

Permalink
Latest misc fixes (joomla#25)
Browse files Browse the repository at this point in the history
* Fixed title 'bleeding' over popup
Fixed popup arrows too close from target

* Cleanup, key order and new keys

* Guided Tours plural

* Unused files

* Empty state for steps view when no step has ever been created for a tour

* Removed title and description sorts, incompatible with the way content is stored in the database (language keys)

* Removed title and description sorts, incompatible with the way content is stored in the database (language keys)

* Added empty state
Fixed tour_id filter
Fixed page title not translated

* Fixed page title translation and icon

* Added getEmptyStateQuery to return steps of a tour
Fixed tour_id filter
Removed useless comments

* Empty spaces errors

* Empty spaces errors
  • Loading branch information
obuisard authored Feb 3, 2023
1 parent daf1025 commit dcccbe9
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 496 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@
<option value="">JGLOBAL_SORT_BY</option>
<option value="a.id ASC">JGRID_HEADING_ID_ASC</option>
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.description ASC">JDESCRIPTION_ASC</option>
<option value="a.description DESC">JDESCRIPTION_DESC</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.type ASC">JTYPE_ASC</option>
<option value="a.type DESC">JTYPE_DESC</option>
<option value="a.type ASC">COM_GUIDEDTOURS_ORDER_TYPE_ASC</option>
<option value="a.type DESC">COM_GUIDEDTOURS_ORDER_TYPE_DESC</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@
<option value="a.id DESC">JGRID_HEADING_ID_DESC</option>
<option value="a.state ASC">JSTATUS_ASC</option>
<option value="a.state DESC">JSTATUS_DESC</option>
<option value="a.title ASC">JGLOBAL_TITLE_ASC</option>
<option value="a.title DESC">JGLOBAL_TITLE_DESC</option>
<option value="a.description ASC">JDESCRIPTION_ASC</option>
<option value="a.description DESC">JDESCRIPTION_DESC</option>
<option value="a.ordering ASC">JGRID_HEADING_ORDERING_ASC</option>
<option value="a.ordering DESC">JGRID_HEADING_ORDERING_DESC</option>
</field>
Expand All @@ -48,4 +44,4 @@
onchange="this.form.submit();"
/>
</fields>
</form>
</form>
46 changes: 36 additions & 10 deletions administrator/components/com_guidedtours/src/Model/StepsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\ListModel;
use Joomla\Database\DatabaseQuery;
use Joomla\Database\ParameterType;
use Joomla\Utilities\ArrayHelper;

Expand Down Expand Up @@ -51,6 +52,38 @@ public function __construct($config = [])
parent::__construct($config);
}

/**
* Provide a query to be used to evaluate if this is an Empty State, can be overridden in the model to provide granular control.
*
* @return DatabaseQuery
*
* @since 4.0.0
*/
protected function getEmptyStateQuery()
{
$query = clone $this->_getListQuery();

if ($query instanceof DatabaseQuery) {
$query->clear('bounded')
->clear('group')
->clear('having')
->clear('join')
->clear('values')
->clear('where');

// override of ListModel to keep the tour id filter
$db = $this->getDbo();
$tour_id = $this->getState('filter.tour_id');
if ($tour_id) {
$tour_id = (int) $tour_id;
$query->where($db->quoteName('a.tour_id') . ' = :tour_id')
->bind(':tour_id', $tour_id, ParameterType::INTEGER);
}
}

return $query;
}

/**
* Method to get a table object, load it if necessary.
*
Expand Down Expand Up @@ -90,7 +123,7 @@ protected function populateState($ordering = 'a.id', $direction = 'asc')
$tour_id = $app->getUserState('com_guidedtours.tour_id');
}

$this->setState('tour_id', $tour_id);
$this->setState('filter.tour_id', $tour_id);

// Keep the tour_id for adding new visits
$app->setUserState('com_guidedtours.tour_id', $tour_id);
Expand Down Expand Up @@ -165,14 +198,7 @@ protected function getListQuery()
);
$query->from('#__guidedtour_steps AS a');

/**
* The tour id should be passed in url or hidden form variables
*/

/**
* Filter Tour ID by levels
*/
$tour_id = $this->getState('filter.tour_id');
$tour_id = $this->getState('filter.tour_id');

if (is_numeric($tour_id)) {
$tour_id = (int) $tour_id;
Expand Down Expand Up @@ -239,7 +265,7 @@ public function getItems()
$lang->load('com_guidedtours.sys', JPATH_ADMINISTRATOR);

if ($items != false) {
foreach($items as $item) {
foreach ($items as $item) {
$item->title = Text::_($item->title);
$item->description = Text::_($item->description);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function getItems()
$lang->load('com_guidedtours.sys', JPATH_ADMINISTRATOR);

if ($items != false) {
foreach($items as $item) {
foreach ($items as $item) {
$item->title = Text::_($item->title);
$item->description = Text::_($item->description);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ class HtmlView extends BaseHtmlView
*/
public $activeFilters;

/**
* Is this view an Empty State
*
* @var boolean
*
* @since 4.0.0
*/
private $isEmptyState = false;

/**
* Display the view.
*
Expand All @@ -77,6 +86,10 @@ public function display($tpl = null)
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');

if (!\count($this->items) && $this->isEmptyState = $this->get('IsEmptyState')) {
$this->setLayout('emptystate');
}

// Check for errors.
if (\count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
Expand All @@ -101,8 +114,8 @@ protected function addToolbar()

$toolbar = Toolbar::getInstance('toolbar');
$tour_id = $this->state->get('tour_id');
$title = GuidedtoursHelper::getTourTitle($this->state->get('tour_id'))->title;
ToolbarHelper::title(Text::_('COM_GUIDEDTOURS_STEPS_LIST') . ' : ' . $title);
$title = GuidedtoursHelper::getTourTitle($this->state->get('filter.tour_id'))->title;
ToolbarHelper::title(Text::sprintf('COM_GUIDEDTOURS_STEPS_LIST', Text::_($title)), 'map-signs');
$arrow = Factory::getLanguage()->isRtl() ? 'arrow-right' : 'arrow-left';

ToolbarHelper::link(
Expand All @@ -115,7 +128,7 @@ protected function addToolbar()
$toolbar->addNew('step.add');
}

if ($canDo->get('core.edit.state')) {
if (!$this->isEmptyState && $canDo->get('core.edit.state')) {
$dropdown = $toolbar->dropdownButton('status-group')
->text('JTOOLBAR_CHANGE_STATUS')
->toggleSplit(false)
Expand All @@ -136,7 +149,7 @@ protected function addToolbar()
}
}

if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
if (!$this->isEmptyState && $this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
$toolbar->delete('steps.delete')
->text('JTOOLBAR_EMPTY_TRASH')
->message('JGLOBAL_CONFIRM_DELETE')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function addToolbar()
// Get the toolbar object instance
$toolbar = Toolbar::getInstance('toolbar');

ToolbarHelper::title(Text::_('Guided Tour - List of Tours'), 'tours');
ToolbarHelper::title(Text::_('COM_GUIDEDTOURS_TOURS_LIST'), 'map-signs');

$canDo = ContentHelper::getActions('com_guidedtours');

Expand Down
20 changes: 4 additions & 16 deletions administrator/components/com_guidedtours/tmpl/steps/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,10 @@
); ?>
</th>
<th scope="col">
<?php echo HTMLHelper::_(
'searchtools.sort',
'COM_GUIDEDTOURS_STEP_TITLE',
'a.title',
$listDirn,
$listOrder
); ?>
<?php echo Text::_('COM_GUIDEDTOURS_STEP_TITLE'); ?>
</th>
<th scope="col">
<?php echo HTMLHelper::_(
'searchtools.sort',
'COM_GUIDEDTOURS_DESCRIPTION',
'a.description',
$listDirn,
$listOrder
); ?>
<?php echo Text::_('COM_GUIDEDTOURS_DESCRIPTION'); ?>
</th>
<th scope="col">
<?php echo HTMLHelper::_(
Expand All @@ -144,9 +132,9 @@

<!-- Table body begins -->
<tbody <?php if ($saveOrder) :
?> class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="
?> class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="
<?php echo strtolower($listDirn); ?>" data-nested="true" <?php
endif; ?>
endif; ?>
<?php foreach ($this->items as $i => $item) :
$canCreate = $user->authorise('core.create', 'com_guidedtours');
$canEdit = $user->authorise('core.edit', 'com_guidedtours');
Expand Down
28 changes: 28 additions & 0 deletions administrator/components/com_guidedtours/tmpl/steps/emptystate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* @package Joomla.Administrator
* @subpackage com_contact
*
* @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Layout\LayoutHelper;

$displayData = [
'textPrefix' => 'COM_GUIDEDTOURS_STEPS',
'formURL' => 'index.php?option=com_guidedtours&view=steps',
'icon' => 'icon-map-signs',
];

$user = Factory::getApplication()->getIdentity();

if ($user->authorise('core.create', 'com_guidedtours')) {
$displayData['createURL'] = 'index.php?option=com_guidedtours&task=step.add';
}

echo LayoutHelper::render('joomla.content.emptystate', $displayData);
16 changes: 2 additions & 14 deletions administrator/components/com_guidedtours/tmpl/tours/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,10 @@
); ?>
</th>
<th scope="col">
<?php echo HTMLHelper::_(
'searchtools.sort',
'COM_GUIDEDTOURS_TOUR_TITLE',
'a.title',
$listDirn,
$listOrder
); ?>
<?php echo Text::_('COM_GUIDEDTOURS_TOUR_TITLE'); ?>
</th>
<th scope="col">
<?php echo HTMLHelper::_(
'searchtools.sort',
'COM_GUIDEDTOURS_DESCRIPTION',
'a.description',
$listDirn,
$listOrder
); ?>
<?php echo Text::_('COM_GUIDEDTOURS_DESCRIPTION'); ?>
</th>
<th scope="col" class="w-10 text-center d-none d-md-table-cell">
<?php echo Text::_('COM_GUIDEDTOURS_STEPS'); ?>
Expand Down
41 changes: 24 additions & 17 deletions administrator/language/en-GB/com_guidedtours.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

COM_GUIDEDTOURS="Guided Tours"
COM_GUIDEDTOURS_BASIC_STEP="Basic Step"
COM_GUIDEDTOURS_DESCRIPTION="Description"
COM_GUIDEDTOURS_DESCRIPTION_ASC="Description ascending" 
COM_GUIDEDTOURS_DESCRIPTION_DESC="Description descending"
COM_GUIDEDTOURS_DESCRIPTION="Description"
COM_GUIDEDTOURS_ERROR_TOUR_NOT_FOUND="Tour not found!"
COM_GUIDEDTOURS_EXTENSIONS_DESC="Will show the tour only for selected extensions. If used tours won't be displayed at other extensions."
COM_GUIDEDTOURS_EXTENSIONS_LABEL="Component Selector"
Expand All @@ -16,11 +16,15 @@ COM_GUIDEDTOURS_FIELD_OPTION_CENTER="Centered"
COM_GUIDEDTOURS_FIELD_OPTION_LEFT="Left"
COM_GUIDEDTOURS_FIELD_OPTION_RIGHT="Right"
COM_GUIDEDTOURS_FIELD_OPTION_TOP="Top"
COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVE_STEP="Interactive"
COM_GUIDEDTOURS_FIELD_VALUE_NEXT_STEP="Next"
COM_GUIDEDTOURS_FIELD_VALUE_REDIRECT="Redirect"
COM_GUIDEDTOURS_FILTER_SEARCH_DESC="Search in id, title and description. Prefix with ID: to search for tour ID or DESCRIPTION: to search only description text."
COM_GUIDEDTOURS_GUIDEDTOUR_STEPS_PAGE_TITLE="Guided Tour - List of Steps"
COM_GUIDEDTOURS_GUIDEDTOURS_LABEL_DESCRIPTION="Description"
COM_GUIDEDTOURS_GUIDEDTOURS_PAGE_TITLE="Guided Tours - List of Tours"
COM_GUIDEDTOURS_GUIDEDTOURS_TABLE_CAPTION="List of Tours"
COM_GUIDEDTOURS_INTERACTIVE_STEP_DESC="Click on the type of interactive step which you want to select"
COM_GUIDEDTOURS_N_ITEMS_DELETED_1="Tours deleted."
COM_GUIDEDTOURS_N_ITEMS_DELETED="%s tours deleted."
COM_GUIDEDTOURS_N_ITEMS_PUBLISHED_1="Tours enabled."
Expand All @@ -31,6 +35,10 @@ COM_GUIDEDTOURS_N_ITEMS_UNPUBLISHED_1="Tours disabled."
COM_GUIDEDTOURS_N_ITEMS_UNPUBLISHED="%s tours disabled."
COM_GUIDEDTOURS_N_ITEMS_ARCHIVED_1="Tours archived."
COM_GUIDEDTOURS_N_ITEMS_ARCHIVED="%s Tours archived."
COM_GUIDEDTOURS_ORDER_DESCRIPTION_ASC="Description ascending"
COM_GUIDEDTOURS_ORDER_DESCRIPTION_DESC="Description descending"
COM_GUIDEDTOURS_ORDER_TYPE_ASC="Type ascending"
COM_GUIDEDTOURS_ORDER_TYPE_DESC="Type descending"
COM_GUIDEDTOURS_POSITION_DESC="Add the Position where you want to display your step. e.g. Bottom, Top, Right, Left, Centered"
COM_GUIDEDTOURS_POSITION_LABEL="Position"
COM_GUIDEDTOURS_RULES_TAB="Permissions"
Expand All @@ -41,29 +49,28 @@ COM_GUIDEDTOURS_STEP_FILTER_SEARCH_DESC="Search in id, title and description. Pr
COM_GUIDEDTOURS_STEP_ID="ID"
COM_GUIDEDTOURS_STEP_TITLE="Title"
COM_GUIDEDTOURS_STEP_TYPE="Type"
COM_GUIDEDTOURS_STEP_TYPE_NEXT_STEP="Next step"
COM_GUIDEDTOURS_STEP_TYPE_NEXT_STEP="Next"
COM_GUIDEDTOURS_STEP_TYPE_REDIRECT="Redirect"
COM_GUIDEDTOURS_STEP_TYPE_INTERACTIVE_STEP="Interactive step"
COM_GUIDEDTOURS_STEP_TYPE_INTERACTIVE_STEP="Interactive"
COM_GUIDEDTOURS_STEPS="Steps"
COM_GUIDEDTOURS_STEPS_LIST="Guided Tours"
COM_GUIDEDTOURS_STEPS_EMPTYSTATE_CONTENT="A tour can only be functional if steps are created."
COM_GUIDEDTOURS_STEPS_EMPTYSTATE_TITLE="No step for this tour has been created yet."
COM_GUIDEDTOURS_STEPS_EMPTYSTATE_BUTTON_ADD="Add your first step"
COM_GUIDEDTOURS_STEPS_LIST="Guided Tour: %s"
COM_GUIDEDTOURS_TARGET_DESC="Add the target item to attach your step element to. Options: .classname, #id or leave blank for a centered step."
COM_GUIDEDTOURS_TARGET_LABEL="Target"
COM_GUIDEDTOURS_TITLE="Guided Tours"
COM_GUIDEDTOURS_TOUR_ID="ID"
COM_GUIDEDTOURS_TOUR_TITLE="Tour Title"
COM_GUIDEDTOURS_TYPE_REDIRECT_URL_DESC="Enter the Relative URL of the page from where you want to Start the Tour e.g administrator/index.php?option=com_guidedtours&view=tours for guided tour relative URL."
COM_GUIDEDTOURS_TYPE_REDIRECT_URL_LABEL="URL"
COM_GUIDEDTOURS_XML_DESCRIPTION="Component for managing Guided Tours functionality"
MOD_MENU_MANAGE_GUIDEDTOURS="Guided Tours"
COM_GUIDEDTOURS_URL_LABEL="URL"
COM_GUIDEDTOURS_URL_DESC="Enter the Relative URL of the page from where you want to Start the Tour e.g administrator/index.php?option=com_guidedtours&view=tours for guided tour relative URL."
COM_GUIDEDTOURS_TOUR_TITLE="Title"
COM_GUIDEDTOURS_TOURS_LIST="Guided Tours"
COM_GUIDEDTOURS_TYPE_LABEL="Type"
COM_GUIDEDTOURS_TYPE_DESC="Click on the type which you want to select for the tour"
COM_GUIDEDTOURS_FIELD_VALUE_REDIRECT="Redirect"
COM_GUIDEDTOURS_FIELD_VALUE_NEXT_STEP="Next"
COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVE_STEP="Interactive"
COM_GUIDEDTOURS_INTERACTIVE_STEP_DESC="Click on the type of interactive step which you want to select"
COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_LABEL="Interactive Step"
COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_BUTTON_LABEL="Button"
COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_TEXT_FIELD_LABEL="Text Field"
COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_LABEL="Interactive Step"
COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_OTHERS_LABEL="Others"
COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_TEXT_FIELD_LABEL="Text Field"
COM_GUIDEDTOURS_TYPE_REDIRECT_URL_DESC="Enter the Relative URL of the page from where you want to Start the Tour e.g administrator/index.php?option=com_guidedtours&view=tours for guided tour relative URL."
COM_GUIDEDTOURS_TYPE_REDIRECT_URL_LABEL="URL"
COM_GUIDEDTOURS_URL_LABEL="URL"
COM_GUIDEDTOURS_URL_DESC="Enter the Relative URL of the page from where you want to Start the Tour e.g administrator/index.php?option=com_guidedtours&view=tours for guided tour relative URL."
COM_GUIDEDTOURS_XML_DESCRIPTION="Component for managing Guided Tours functionality"
4 changes: 2 additions & 2 deletions administrator/language/en-GB/com_guidedtours.sys.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
; GNU General Public License version 2 or later; see LICENSE.txt
; Note : All ini files need to be saved as UTF-8

COM_GUIDEDTOURS="Guided Tour"
COM_GUIDEDTOURS="Guided Tours"
COM_GUIDEDTOURS_ERROR_TOUR_NOT_FOUND="Tour not found!"
COM_GUIDEDTOURS_GUIDEDTOUR_STEPS_PAGE_TITLE="Guided Tours - List of Steps"
COM_GUIDEDTOURS_GUIDEDTOURS_PAGE_TITLE="Guided Tours - List of Tours"
COM_GUIDEDTOURS_GUIDEDTOURS_TABLE_CAPTION="List of Tours"
COM_GUIDEDTOURS_XML_DESCRIPTION="Component for managing Guided Tours functionality in Joomla 4"

COM_GUIDEDTOURS_TOUR_GUIDEDTOURS_TITLE="How to create a guided tour for the Joomla backend?"
COM_GUIDEDTOURS_TOUR_GUIDEDTOURS_TITLE="How to create a guided tour?"
COM_GUIDEDTOURS_TOUR_GUIDEDTOURS_DESCRIPTION="<p>This tour will show you how you can create a guided tour for the Joomla backend.</p>"

COM_GUIDEDTOURS_TOUR_GUIDEDTOURS_STEP_NEW_TITLE="Click the 'New' button"
Expand Down
2 changes: 1 addition & 1 deletion administrator/language/en-GB/mod_menu.ini
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ MOD_MENU_LOGOUT="Logout"
MOD_MENU_MAINTAIN="Maintenance"
MOD_MENU_MANAGE="Manage"
MOD_MENU_MANAGE_EXTENSIONS="Extensions"
MOD_MENU_MANAGE_GUIDEDTOURS="Guided Tours"
MOD_MENU_MANAGE_LANGUAGES="Languages"
MOD_MENU_MANAGE_LANGUAGES_CONTENT="Content Languages"
MOD_MENU_MANAGE_LANGUAGES_OVERRIDES="Language Overrides"
MOD_MENU_MANAGE_PLUGINS="Plugins"
MOD_MENU_MANAGE_REDIRECTS="Redirects"
MOD_MENU_MANAGE_SCHEDULED_TASKS="Scheduled Tasks"
MOD_MENU_MANAGE_GUIDEDTOURS="Guided Tour"
MOD_MENU_MASS_MAIL_USERS="Mass Mail Users"
MOD_MENU_MEDIA_MANAGER="Media"
MOD_MENU_MENU_MANAGER="Manage"
Expand Down
Loading

0 comments on commit dcccbe9

Please sign in to comment.