Skip to content

Commit

Permalink
Merge branch '5.1-dev' of https://github.com/joomla/joomla-cms into m…
Browse files Browse the repository at this point in the history
…od-version
  • Loading branch information
joomlaweby committed Feb 19, 2024
2 parents 8e95676 + 416bcef commit f6aea95
Show file tree
Hide file tree
Showing 15 changed files with 322 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `#__guidedtour_steps` ADD COLUMN `params` text NULL /** CAN FAIL **/;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE "#__guidedtour_steps" ADD COLUMN "params" text NULL /** CAN FAIL **/;
45 changes: 45 additions & 0 deletions administrator/components/com_guidedtours/forms/step.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
>
<option value="1">COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVESTEP_TYPE_FORM_SUBMIT</option>
<option value="2">COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVESTEP_TYPE_TEXT_FIELD</option>
<option value="5">COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVESTEP_TYPE_CHECKBOX_RADIO_FIELD</option>
<option value="6">COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVESTEP_TYPE_SELECT_LIST</option>
<option value="4">COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVESTEP_TYPE_BUTTON</option>
<option value="3">COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVESTEP_TYPE_OTHER</option>
</field>
Expand Down Expand Up @@ -189,4 +191,47 @@
maxlength="255"
/>

<fields name="params">

<fieldset name="options">

<fieldset name="targetvalues" label="COM_GUIDEDTOURS_STEP_TARGETVALUES_HEADING">
<field
name="notetarget"
type="note"
class="alert alert-info"
description="COM_GUIDEDTOURS_STEP_TARGETNOTE_MESSAGE"
showon=".type!:2[OR].interactive_type!:2,5,6" />

<field
name="required"
type="radio"
label="COM_GUIDEDTOURS_TYPE_INPUT_REQUIRED_LABEL"
description="COM_GUIDEDTOURS_TYPE_INPUT_REQUIRED_DESC"
showon=".type:2[AND].interactive_type:2,5,6"
layout="joomla.form.field.radio.switcher"
filter="integer"
validate="options"
default="1"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>

<field
name="requiredvalue"
type="textarea"
label="COM_GUIDEDTOURS_TYPE_INPUT_REQUIREDVALUE_LABEL"
description="COM_GUIDEDTOURS_TYPE_INPUT_REQUIREDVALUE_DESC"
showon=".type:2[AND].interactive_type:2,6[AND]required:1"
filter="safehtml"
cols="80"
rows="3"
default=""
/>

</fieldset>
</fieldset>
</fields>

</form>
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ class GuidedtoursComponent extends MVCComponent implements BootableExtensionInte
*/
public const STEP_INTERACTIVETYPE_OTHER = 3;

/**
* An interactive step for checkbox/radio fields
*
* @since __DEPLOY_VERSION__
*/
public const STEP_INTERACTIVETYPE_CHECKBOX_RADIO = 5;

/**
* An interactive step for select element fields
*
* @since __DEPLOY_VERSION__
*/
public const STEP_INTERACTIVETYPE_SELECT = 6;

/**
* Booting the extension. This is the function to set up the environment of the extension like
* registering new class loaders, etc.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Joomla\Component\Guidedtours\Administrator\Helper\GuidedtoursHelper;
use Joomla\Database\DatabaseQuery;
use Joomla\Database\ParameterType;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;

// phpcs:disable PSR1.Files.SideEffects
Expand Down Expand Up @@ -248,6 +249,13 @@ public function getItems()

$item->title = Text::_($item->title);
$item->description = Text::_($item->description);

if (isset($item->params)) {
$params = new Registry($item->params);
if (!empty($item->params->requiredvalue)) {
$item->params->requiredvalue = Text::_($item->params->requiredvalue);
}
}
}

return $items;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ public function duplicate(&$pks)
'checked_out_time',
'checked_out',
'language',
'params',
'note',
]
)
Expand Down Expand Up @@ -400,6 +401,7 @@ public function duplicate(&$pks)
$db->quoteName('modified'),
$db->quoteName('modified_by'),
$db->quoteName('language'),
$db->quoteName('params'),
$db->quoteName('note'),
]
);
Expand All @@ -421,6 +423,7 @@ public function duplicate(&$pks)
ParameterType::INTEGER,
ParameterType::STRING,
ParameterType::STRING,
ParameterType::STRING,
];

$query->values(
Expand All @@ -442,6 +445,7 @@ public function duplicate(&$pks)
$date,
$user->id,
$step->language,
$step->params,
$step->note,
],
$dataTypes
Expand Down
23 changes: 23 additions & 0 deletions administrator/components/com_guidedtours/src/Table/StepTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Joomla\CMS\User\CurrentUserTrait;
use Joomla\Database\DatabaseDriver;
use Joomla\Event\DispatcherInterface;
use Joomla\Registry\Registry;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -51,6 +52,28 @@ public function __construct(DatabaseDriver $db, DispatcherInterface $dispatcher
parent::__construct('#__guidedtour_steps', 'id', $db, $dispatcher);
}

/**
* Overloaded bind function.
*
* @param array $array named array
* @param string $ignore An optional array or space separated list of properties
* to ignore while binding.
*
* @return mixed Null if operation was satisfactory, otherwise returns an error
*
* @see Table::bind()
* @since __DEPLOY_VERSION__
*/
public function bind($array, $ignore = '')
{
if (isset($array['params']) && \is_array($array['params'])) {
$registry = new Registry($array['params']);
$array['params'] = (string) $registry;
}

return parent::bind($array, $ignore);
}

/**
* Stores a step.
*
Expand Down
9 changes: 7 additions & 2 deletions administrator/components/com_guidedtours/tmpl/step/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('keepalive')
->useScript('form.validate');
->useScript('form.validate')
->useScript('com_guidedtours.tour-edit');

if (empty($this->item->tour_id)) {
throw new GenericDataException("\nThe Tour id was not set!\n", 500);
}

$lang = $this->getLanguage()->getTag();

$this->useCoreUI = true;
?>

<form action="<?php echo Route::_('index.php?option=com_guidedtours&view=step&layout=edit&id=' .
Expand Down Expand Up @@ -79,14 +82,16 @@
</div>
<?php echo HTMLHelper::_('uitab.endTab'); ?>

<?php echo LayoutHelper::render('joomla.edit.params', $this); ?>

<?php echo HTMLHelper::_('uitab.addTab', 'myTab', 'publishing', Text::_('JGLOBAL_FIELDSET_PUBLISHING')); ?>
<div class="row">
<div class="col-12 col-lg-8">
<fieldset id="fieldset-publishingdata" class="options-form">
<legend><?php echo Text::_('JGLOBAL_FIELDSET_PUBLISHING'); ?></legend>
<div>
<?php
$this->fields = [];
$this->fields = [];
$this->hidden_fields = [];
echo LayoutHelper::render('joomla.edit.publishingdata', $this); ?>
</div>
Expand Down
10 changes: 9 additions & 1 deletion administrator/language/en-GB/com_guidedtours.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ COM_GUIDEDTOURS_EXTENSIONS_DESC="Restrict the tour to be displayed only when the
COM_GUIDEDTOURS_EXTENSIONS_LABEL="Component Selector"
COM_GUIDEDTOURS_FIELD_NOTE_LABEL="Note"
COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVESTEP_TYPE_BUTTON="Button"
COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVESTEP_TYPE_CHECKBOX_RADIO_FIELD="Checkbox/Radio"
COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVESTEP_TYPE_FORM_SUBMIT="Form Submit"
COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVESTEP_TYPE_OTHER="Other"
COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVESTEP_TYPE_SELECT_LIST="Select List"
COM_GUIDEDTOURS_FIELD_VALUE_INTERACTIVESTEP_TYPE_TEXT_FIELD="Text Field"
COM_GUIDEDTOURS_FIELD_VALUE_STEP_TYPE_INTERACTIVE="Interactive"
COM_GUIDEDTOURS_FIELD_VALUE_STEP_TYPE_NEXT="Next"
Expand Down Expand Up @@ -49,6 +51,8 @@ COM_GUIDEDTOURS_STEP_FILTER_SEARCH_LABEL="Search Steps"
COM_GUIDEDTOURS_STEP_NEW_STEP="New Step"
COM_GUIDEDTOURS_STEP_POSITION_DESC="Select the position of the step popup, relative to the element it points to."
COM_GUIDEDTOURS_STEP_POSITION_LABEL="Position"
COM_GUIDEDTOURS_STEP_TARGETNOTE_MESSAGE="When a step is identified as interactive, specific interactive options might carry extra parameters for the user's interaction with a target."
COM_GUIDEDTOURS_STEP_TARGETVALUES_HEADING="Target Value Options"
COM_GUIDEDTOURS_STEP_TITLE="Title"
COM_GUIDEDTOURS_STEP_TITLE_TRANSLATION="Title (%s)"
COM_GUIDEDTOURS_STEP_TARGET_DESC="The target element the step will be attached to. Options: .classname, #id, any selector following the CSS syntax (make sure it is a focusable element if the step is interactive), or leave blank for a centered step."
Expand All @@ -74,7 +78,11 @@ COM_GUIDEDTOURS_TOURS_LIST="Guided Tours"
COM_GUIDEDTOURS_TOURS_LIST_EMPTYSTATE_BUTTON_ADD="Add your first tour"
COM_GUIDEDTOURS_TOURS_LIST_EMPTYSTATE_CONTENT="Create a tour to make it functional."
COM_GUIDEDTOURS_TOURS_LIST_EMPTYSTATE_TITLE="No tours have been created yet."
COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_DESC="Select <em>Form Submit</em> to submit a form, <em>Text Field</em> for user input, <em>Button</em> for buttons, or <em>Other</em> for any other interaction."
COM_GUIDEDTOURS_TYPE_INPUT_REQUIRED_DESC="Enable if the user is required to provide a value, activate a radio button or check a box to move forward to the next step of the tour."
COM_GUIDEDTOURS_TYPE_INPUT_REQUIRED_LABEL="Required"
COM_GUIDEDTOURS_TYPE_INPUT_REQUIREDVALUE_DESC="The exact value to be entered, including case and punctuation, to move forward to the next step (if the target is a list of items, use the value of the select's option element)."
COM_GUIDEDTOURS_TYPE_INPUT_REQUIREDVALUE_LABEL="Required Value"
COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_DESC="Select <em>Form Submit</em> to submit a form, <em>Text Field</em> for user input, <em>Button</em> for buttons, <em>Checkbox/Radio</em> or <em>Select List</em> for selection, or <em>Other</em> for any other interaction."
COM_GUIDEDTOURS_TYPE_INTERACTIVE_STEP_LABEL="Interactive Type"
COM_GUIDEDTOURS_TYPE_REDIRECT_URL_DESC="Enter the relative URL of the page you want the step to redirect to, eg administrator/index.php?option=com_guidedtours&view=tours for the tours' list page."
COM_GUIDEDTOURS_TYPE_REDIRECT_URL_LABEL="Relative URL"
Expand Down
21 changes: 21 additions & 0 deletions build/media_source/com_guidedtours/joomla.asset.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json",
"name": "com_guidedtours",
"version": "4.0.0",
"description": "Joomla CMS",
"license": "GPL-2.0-or-later",
"assets": [
{
"name": "com_guidedtours.tour-edit",
"type": "script",
"uri": "com_guidedtours/tour-edit.min.js",
"dependencies": [
"core"
],
"attributes": {
"type": "module",
"defer": true
}
}
]
}
37 changes: 37 additions & 0 deletions build/media_source/com_guidedtours/js/tour-edit.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

(() => {
'use strict';

// before 'joomla:showon-processed' is implemented in Showon we must use more frequent 'joomla:showon-show' and'joomla:showon-hide' events
['joomla:showon-show', 'joomla:showon-hide'].forEach((eventType) => {
document.addEventListener(eventType, () => {
document.querySelectorAll('#guidedtour-dates-form fieldset').forEach((fieldset) => {
// Only hide fieldsets containing field control-group i.e. not radio selectors etc. that may use fieldsets
if (fieldset.querySelectorAll(':scope .control-group').length === 0) {
return;
}
const visibleChildren = fieldset.querySelectorAll(':scope .control-group:not(.hidden)');
if (visibleChildren.length) {
fieldset.classList.remove('hidden');
} else {
fieldset.classList.add('hidden');
}
});
document.querySelectorAll('#guidedtour-dates-form joomla-tab-element').forEach((tabelement) => {
const tabLabel = document.querySelector(`button[aria-controls="${tabelement.id}"]`);
if (tabLabel) {
const visibleChildren = tabelement.querySelectorAll(':scope .control-group:not(.hidden)');
if (visibleChildren.length) {
tabLabel.removeAttribute('hidden');
} else {
tabLabel.setAttribute('hidden', 'hidden');
}
}
});
});
});
})();

0 comments on commit f6aea95

Please sign in to comment.