-
Notifications
You must be signed in to change notification settings - Fork 46
Feature #184273 feat: Conditional fields implementation #363
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
Open
KishoriBKarale
wants to merge
13
commits into
techjoomla:release-2.0.2
Choose a base branch
from
KishoriBKarale:ConditionalField
base: release-2.0.2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
8b7aca0
Feature #184273 feat: Conditional fields implementation
a65fffc
Feature #184273 feat: Conditional fields implementation
a11d817
Feature #184273 feat: Conditional fields implementation
314f34a
Feature #184273 feat: Conditional fields implementation
342c143
Feature #184273 feat: Conditional fields implementation
835426c
Feature #184273 feat: Updated MR
6014e20
Task #192634 chore: Updated MR for hide functionality
7ff5778
Feature #184273 feat: Resolved comments
a01d663
Feature #184273 feat: comments resolved
e1d44a0
Feature #184273 feat: comments resolved
de1a37e
Feature #184273 feat: Conditional fields implementation
9224ede
Feature #184273 feat: Conditional fields implementation
3097249
Feature #192755 feat: UCM - Conditional Fields Integration
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| <?php | ||
| /** | ||
| * @package Tjfields | ||
| * @author Techjoomla <[email protected]> | ||
| * @copyright Copyright (c) 2009-2023 TechJoomla. All rights reserved. | ||
| * @license GNU General Public License version 2 or later. | ||
| */ | ||
|
|
||
| // No direct access | ||
| defined('_JEXEC') or die(); | ||
| use Joomla\CMS\Factory; | ||
| use Joomla\CMS\Response\JsonResponse; | ||
| use Joomla\CMS\MVC\Controller\FormController; | ||
|
|
||
| jimport('joomla.application.component.controllerform'); | ||
|
|
||
| /** | ||
| * Country form controller class. | ||
| * | ||
| * @package Tjfields | ||
| * @subpackage com_tjfields | ||
| * @since 2.2 | ||
| */ | ||
| class TjfieldsControllerCondition extends FormController | ||
| { | ||
| /** | ||
| * The extension for which the countries apply. | ||
| * | ||
| * @var string | ||
| * @since 1.6 | ||
| */ | ||
| protected $client; | ||
|
|
||
| /** | ||
| * Constructor. | ||
| * | ||
| * @param array $config An optional associative array of configuration settings. | ||
| * | ||
| * @since 1.6 | ||
| * @see JController | ||
| */ | ||
| public function __construct($config = array()) | ||
| { | ||
| parent::__construct($config); | ||
| $this->view_list = 'conditions'; | ||
|
|
||
| $this->input = Factory::getApplication()->input; | ||
|
|
||
| if (empty($this->client)) | ||
| { | ||
| $this->client = $this->input->get('client', ''); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets the URL arguments to append to an item redirect. | ||
| * | ||
| * @param integer $recordId The primary key id for the item. | ||
| * @param string $urlVar The name of the URL variable for the id. | ||
| * | ||
| * @return string The arguments to append to the redirect URL. | ||
| * | ||
| * @since 1.6 | ||
| */ | ||
| protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') | ||
| { | ||
| $append = parent::getRedirectToItemAppend($recordId); | ||
| $append .= '&client=' . $this->client; | ||
|
|
||
| return $append; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the URL arguments to append to a list redirect. | ||
| * | ||
| * @return string The arguments to append to the redirect URL. | ||
| * | ||
| * @since 1.6 | ||
| */ | ||
| protected function getRedirectToListAppend() | ||
| { | ||
| $append = parent::getRedirectToListAppend(); | ||
| $append .= '&client=' . $this->client; | ||
|
|
||
| return $append; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the URL arguments to append to a list redirect. | ||
| * | ||
| * @return string The arguments to append to the redirect URL. | ||
| * | ||
| * @since 1.6 | ||
| */ | ||
| public function getFieldsOptions() | ||
| { | ||
| $app = Factory::getApplication(); | ||
| $fieldId = $app->input->get('fieldId', 0, 'INT'); | ||
|
|
||
| $db = Factory::getDbo(); | ||
| $query = $db->getQuery(true); | ||
|
|
||
| // Select the required fields from the table. | ||
| $query->select('t.id AS value, t.options AS text'); | ||
| $query->from('`#__tjfields_options` AS t'); | ||
| $query->order($db->escape('t.ordering ASC')); | ||
| $query->where('t.field_id = ' . (int) $fieldId); | ||
|
|
||
| $db->setQuery($query); | ||
|
|
||
| // Get all countries. | ||
| $fieldOptions = $db->loadObjectList(); | ||
|
|
||
| echo new JsonResponse($fieldOptions); | ||
| $app->close(); | ||
|
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| <?php | ||
| /** | ||
| * @package Tjfields | ||
| * @author Techjoomla <[email protected]> | ||
| * @copyright Copyright (c) 2009-2023 TechJoomla. All rights reserved. | ||
| * @license GNU General Public License version 2 or later. | ||
| */ | ||
|
|
||
| // No direct access. | ||
| defined('_JEXEC') or die(); | ||
| use Joomla\CMS\Factory; | ||
| use Joomla\CMS\MVC\Controller\AdminController; | ||
| use Joomla\CMS\Log\Log; | ||
| use Joomla\CMS\Language\Text; | ||
| use Joomla\CMS\Session\Session; | ||
| use Joomla\Utilities\ArrayHelper; | ||
|
|
||
| jimport('joomla.application.component.controlleradmin'); | ||
|
|
||
| /** | ||
| * Countries list controller class. | ||
| * | ||
| * @package Tjfields | ||
| * @subpackage com_tjfields | ||
| * @since 2.2 | ||
| */ | ||
| class TjfieldsControllerConditions extends AdminController | ||
| { | ||
| /** | ||
| * Proxy for getModel. | ||
| * | ||
| * @param string $name The name of the model. | ||
| * @param string $prefix The prefix for the PHP class name. | ||
| * @param array $config A named array of configuration variables. | ||
| * | ||
| * @return JModel | ||
| * | ||
| * @since 1.6 | ||
| */ | ||
| public function getModel($name = 'Condition', $prefix = 'TjfieldsModel', $config = array('ignore_request' => true)) | ||
| { | ||
| $model = parent::getModel($name, $prefix, $config); | ||
|
|
||
| return $model; | ||
| } | ||
|
|
||
| /** | ||
| * Method to publish records. | ||
| * | ||
| * @return void | ||
| * | ||
| * @since 3.0 | ||
| */ | ||
| public function publish() | ||
| { | ||
| $client = Factory::getApplication()->input->get('client', '', 'STRING'); | ||
| $cid = Factory::getApplication()->input->get('cid', array(), 'array'); | ||
| $data = array( | ||
| 'publish' => 1, | ||
| 'unpublish' => 0 | ||
| ); | ||
|
|
||
| $task = $this->getTask(); | ||
| $value = JArrayHelper::getValue($data, $task, 0, 'int'); | ||
|
KishoriBKarale marked this conversation as resolved.
Outdated
|
||
|
|
||
| // Get some variables from the request | ||
| if (empty($cid)) | ||
| { | ||
| Log::add(Text::_('COM_TJFIELDS_NO_CONDITIONS_SELECTED'), Log::WARNING, 'jerror'); | ||
| } | ||
| else | ||
| { | ||
| // Get the model. | ||
| $model = $this->getModel(); | ||
|
|
||
| // Make sure the item ids are integers | ||
| JArrayHelper::toInteger($cid); | ||
|
KishoriBKarale marked this conversation as resolved.
Outdated
|
||
|
|
||
| // Publish the items. | ||
| try | ||
| { | ||
| $model->publish($cid, $value); | ||
|
|
||
| if ($value === 1) | ||
| { | ||
| $ntext = 'COM_TJFIELDS_N_CONDITIONS_PUBLISHED'; | ||
| } | ||
| elseif ($value === 0) | ||
| { | ||
| $ntext = 'COM_TJFIELDS_N_CONDITIONS_UNPUBLISHED'; | ||
| } | ||
|
|
||
| // Generate xml here | ||
| $TjfieldsHelper = new TjfieldsHelper; | ||
| $client_form = explode('.', $client); | ||
| $client_type = $client_form[1]; | ||
|
|
||
| $data = array(); | ||
| $data['client'] = $client; | ||
| $data['client_type'] = $client_type; | ||
| $TjfieldsHelper->generateXml($data); | ||
|
|
||
| $this->setMessage(Text::plural($ntext, count($cid))); | ||
| } | ||
| catch (Exception $e) | ||
| { | ||
| $this->setMessage($e->getMessage(), 'error'); | ||
| } | ||
| } | ||
|
|
||
| $this->setRedirect('index.php?option=com_tjfields&view=conditions&client=' . $client); | ||
| } | ||
|
|
||
| public function delete() | ||
| { | ||
| //GET CLIENT AND CLIENT TYPE | ||
| $app = Factory::getApplication(); | ||
| $input = $app->input; | ||
| $client = $input->get('client','','STRING'); | ||
| $client_form = explode('.',$client); | ||
| $client_type = $client_form[1]; | ||
|
|
||
| // Get items to remove from the request. | ||
| $cid = $app->input->get('cid', array(), 'array'); | ||
|
|
||
| if (!is_array($cid) || count($cid) < 1) | ||
| { | ||
| Log::add(Text::_($this->text_prefix . '_NO_ITEM_SELECTED'), Log::WARNING, 'jerror'); | ||
| } | ||
| else | ||
| { | ||
| // Get the model. | ||
| $model = $this->getModel(); | ||
|
|
||
| // Make sure the item ids are integers | ||
| ArrayHelper::toInteger($cid); | ||
|
|
||
| // Remove the items. | ||
| if ($model->delete($cid)) | ||
| { | ||
| $TjfieldsHelper = new TjfieldsHelper(); | ||
| $data = array(); | ||
| $data['client'] = $client; | ||
| $data['client_type'] = $client_type; | ||
| $TjfieldsHelper->generateXml($data); | ||
| $ntext = $this->text_prefix . '_N_ITEMS_DELETED'; | ||
| } | ||
| else | ||
| { | ||
| $this->setMessage($model->getError()); | ||
| } | ||
| } | ||
|
|
||
| $this->setMessage(Text::plural($ntext, count($cid))); | ||
| $this->setRedirect('index.php?option=com_tjfields&view=conditions&client='.$client, false); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.