From b5c57aca320b65552ea8a8c6bf940f5dcd1a85fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 11 Mar 2020 17:22:56 +0530 Subject: [PATCH 01/42] Task #158681 feat: Update UCM code to use access file in includes to check permissions --- .../com_tjucm/site/controllers/item.php | 12 +- .../com_tjucm/site/includes/access.php | 248 ++++++++++++++++++ .../com_tjucm/site/layouts/list/list.php | 52 ++-- src/components/com_tjucm/site/models/item.php | 28 +- .../com_tjucm/site/models/itemform.php | 20 +- .../com_tjucm/site/models/items.php | 47 +--- src/components/com_tjucm/site/tjucm.php | 1 + .../site/views/item/tmpl/default.php | 6 +- .../site/views/itemform/view.html.php | 30 +-- .../site/views/items/tmpl/default.php | 40 +-- .../site/views/items/tmpl/default_filters.php | 32 ++- .../com_tjucm/site/views/items/view.html.php | 22 +- 12 files changed, 358 insertions(+), 180 deletions(-) create mode 100644 src/components/com_tjucm/site/includes/access.php diff --git a/src/components/com_tjucm/site/controllers/item.php b/src/components/com_tjucm/site/controllers/item.php index ab40ac17..82ae26cd 100644 --- a/src/components/com_tjucm/site/controllers/item.php +++ b/src/components/com_tjucm/site/controllers/item.php @@ -93,7 +93,6 @@ public function edit() // Get the model. $model = $this->getModel('Item', 'TjucmModel'); - // Check out the item if ($editId) @@ -133,12 +132,10 @@ public function publish() $tjUcmFrontendHelper = new TjucmHelpersTjucm; // Checking if the user can remove object - $user = JFactory::getUser(); - $canEdit = $user->authorise('core.type.edititem', 'com_tjucm.type.edititem' . $this->ucmTypeId); - $canChange = $user->authorise('core.type.edititemstate', 'com_tjucm.type.' . $this->ucmTypeId); + $canEdit = $this->canEdit($this->ucmTypeId); + $canEditState = $this->canEditState($this->ucmTypeId); - - if ($canEdit || $canChange) + if ($canEdit || $canEditState) { $model = $this->getModel('Item', 'TjucmModel'); @@ -193,8 +190,7 @@ public function remove() $app = JFactory::getApplication(); // Checking if the user can remove object - $user = JFactory::getUser(); - $canDelete = $user->authorise('core.type.deleteitem', 'com_tjucm.type.' . $this->ucmTypeId); + $canDelete = $this->canDelete($this->ucmTypeId); if ($canDelete) { diff --git a/src/components/com_tjucm/site/includes/access.php b/src/components/com_tjucm/site/includes/access.php new file mode 100644 index 00000000..fae18e20 --- /dev/null +++ b/src/components/com_tjucm/site/includes/access.php @@ -0,0 +1,248 @@ + + * @copyright Copyright (C) 2009 - 2020 Techjoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +defined('_JEXEC') or die(); + +use Joomla\CMS\Factory; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Table\Table; +use Joomla\String\StringHelper; + +require_once JPATH_SITE . '/components/com_tjucm/includes/defines.php'; + +/** + * Tjucm factory class. + * + * This class perform the helpful operation required to Tjucm package + * + * @since __DEPLOY_VERSION__ + */ +class TjucmAccess +{ + public static function canCreate($ucmTypeId) + { + if (TjucmAccess::hasCluster($ucmTypeId)) + { + // Get com_subusers component status + $subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled; + + // Check user have permission to edit record of assigned cluster + if ($subUserExist) + { + JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); + + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.createitem'); + } + } + else + { + return JFactory::getUser()->authorise('core.type.createitem', 'com_tjucm.type.' . $ucmTypeId); + } + } + + public static function canImport($ucmTypeId) + { + if (TjucmAccess::hasCluster($ucmTypeId)) + { + // Get com_subusers component status + $subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled; + + // Check user have permission to edit record of assigned cluster + if ($subUserExist) + { + JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); + + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.importitem'); + } + } + else + { + return JFactory::getUser()->authorise('core.type.importitem', 'com_tjucm.type.' . $ucmTypeId); + } + } + + public static function canView($ucmTypeId, $contentId) + { + JLoader::import('components.com_tjucm.tables.item', JPATH_ADMINISTRATOR); + $itemTable = JTable::getInstance('Item', 'TjucmTable', array('dbo', JFactory::getDbo())); + $itemTable->load($contentId); + + if (JFactory::getUser()->id == $itemTable->created_by) + { + return true; + } + + JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); + + if (TjucmAccess::hasCluster($ucmTypeId)) + { + if (RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewallitem')) + { + return true; + } + + // Get com_subusers component status + $subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled; + + // Check user have permission to edit record of assigned cluster + if ($subUserExist) + { + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewitem', $itemTable->cluster_id); + } + } + else + { + return JFactory::getUser()->authorise('core.type.viewitem', 'com_tjucm.type.' . $ucmTypeId); + } + } + + public static function canEdit($ucmTypeId, $contentId) + { + if (TjucmAccess::hasCluster($ucmTypeId)) + { + // Get com_subusers component status + $subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled; + + // Check user have permission to edit record of assigned cluster + if ($subUserExist) + { + JLoader::import("components.com_subusers.includes.rbacl", JPATH_ADMINISTRATOR); + JLoader::import('components.com_tjucm.tables.item', JPATH_ADMINISTRATOR); + $itemTable = JTable::getInstance('Item', 'TjucmTable', array('dbo', JFactory::getDbo())); + $itemTable->load($contentId); + + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.edititem', $itemTable->cluster_id); + } + } + else + { + return JFactory::getUser()->authorise('core.type.edititem', 'com_tjucm.type.' . $ucmTypeId); + } + } + + public static function canEditState($ucmTypeId, $contentId) + { + if (TjucmAccess::hasCluster($ucmTypeId)) + { + // Get com_subusers component status + $subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled; + + // Check user have permission to edit record of assigned cluster + if ($subUserExist) + { + JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); + JLoader::import('components.com_tjucm.tables.item', JPATH_ADMINISTRATOR); + $itemTable = JTable::getInstance('Item', 'TjucmTable', array('dbo', JFactory::getDbo())); + $itemTable->load($contentId); + + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.edititemstate', $itemTable->cluster_id); + } + } + else + { + return JFactory::getUser()->authorise('core.type.edititemstate', 'com_tjucm.type.' . $ucmTypeId); + } + } + + public static function canEditOwn($ucmTypeId, $contentId) + { + if (TjucmAccess::hasCluster($ucmTypeId)) + { + // Get com_subusers component status + $subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled; + + // Check user have permission to edit record of assigned cluster + if ($subUserExist) + { + JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); + JLoader::import('components.com_tjucm.tables.item', JPATH_ADMINISTRATOR); + $itemTable = JTable::getInstance('Item', 'TjucmTable', array('dbo', JFactory::getDbo())); + $itemTable->load($contentId); + + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.editownitem', $itemTable->cluster_id); + } + } + else + { + return JFactory::getUser()->authorise('core.type.editownitem', 'com_tjucm.type.' . $ucmTypeId); + } + } + + public static function canDelete($ucmTypeId, $contentId) + { + if (TjucmAccess::hasCluster($ucmTypeId)) + { + // Get com_subusers component status + $subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled; + + // Check user have permission to edit record of assigned cluster + if ($subUserExist) + { + JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); + JLoader::import('components.com_tjucm.tables.item', JPATH_ADMINISTRATOR); + $itemTable = JTable::getInstance('Item', 'TjucmTable', array('dbo', JFactory::getDbo())); + $itemTable->load($contentId); + + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.deleteitem', $itemTable->cluster_id); + } + } + else + { + return JFactory::getUser()->authorise('core.type.deleteitem', 'com_tjucm.type.' . $ucmTypeId); + } + } + + public static function canDeleteOwn($ucmTypeId, $contentId) + { + if (TjucmAccess::hasCluster($ucmTypeId)) + { + // Get com_subusers component status + $subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled; + + // Check user have permission to edit record of assigned cluster + if ($subUserExist) + { + JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); + JLoader::import('components.com_tjucm.tables.item', JPATH_ADMINISTRATOR); + $itemTable = JTable::getInstance('Item', 'TjucmTable', array('dbo', JFactory::getDbo())); + $itemTable->load($contentId); + + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.deleteownitem', $itemTable->cluster_id); + } + } + else + { + return JFactory::getUser()->authorise('core.type.deleteownitem', 'com_tjucm.type.' . $ucmTypeId); + } + } + + public static function hasCluster($ucmTypeId, $contentId) + { + if (ComponentHelper::getComponent('com_cluster', true)->enabled) + { + JLoader::import('components.com_tjucm.tables.type', JPATH_ADMINISTRATOR); + $typeTable = JTable::getInstance('Type', 'TjucmTable', array('dbo', JFactory::getDbo())); + $typeTable->load($ucmTypeId); + + JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR); + $fieldTable = JTable::getInstance('Field', 'TjfieldsTable', array('dbo', JFactory::getDbo())); + $fieldTable->load(array('client' => $typeTable->unique_identifier, 'type' => 'cluster', 'state' => 1)); + + if ($fieldTable->id) + { + return true; + } + } + + return false; + } +} diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 6ff9d6a7..fff66bbd 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -55,11 +55,11 @@ $appendUrl = ''; $csrf = "&" . Session::getFormToken() . '=1'; -$canEditOwn = $user->authorise('core.type.editownitem', 'com_tjucm.type.' . $ucmTypeId); -$canDeleteOwn = $user->authorise('core.type.deleteownitem', 'com_tjucm.type.' . $ucmTypeId); -$canChange = $user->authorise('core.type.edititemstate', 'com_tjucm.type.' . $ucmTypeId); -$canEdit = $user->authorise('core.type.edititem', 'com_tjucm.type.' . $ucmTypeId); -$canDelete = $user->authorise('core.type.deleteitem', 'com_tjucm.type.' . $ucmTypeId); +$canEditOwn = TjucmAccess::canEditOwn($ucmTypeId, $item->id); +$canDeleteOwn = TjucmAccess::canDeleteOwn($ucmTypeId, $item->id); +$canEditState = TjucmAccess::canEditState($ucmTypeId, $item->id); +$canEdit = TjucmAccess::canEdit($ucmTypeId, $item->id); +$canDelete = TjucmAccess::canDelete($ucmTypeId, $item->id); if (!empty($created_by)) { @@ -100,10 +100,10 @@ state)) { - $class = ($canChange) ? 'active' : 'disabled'; ?> + $class = ($canEditState) ? 'active' : 'disabled'; ?> id . '&state=' . (($item->state + 1) % 2) . $appendUrl . $csrf : '#'; ?>"> state == 1) @@ -170,34 +170,28 @@ + + + - - + | - | - - | - - - - - id . $appendUrl . $csrf; ?>" + class="delete-button" type="button" + title=""> | + + + + diff --git a/src/components/com_tjucm/site/models/item.php b/src/components/com_tjucm/site/models/item.php index 8d7c199f..4715d402 100644 --- a/src/components/com_tjucm/site/models/item.php +++ b/src/components/com_tjucm/site/models/item.php @@ -44,7 +44,6 @@ class TjucmModelItem extends JModelAdmin protected function populateState() { $app = JFactory::getApplication('com_tjucm'); - $user = JFactory::getUser(); // Load state from the request. $id = $app->input->getInt('id'); @@ -83,9 +82,7 @@ protected function populateState() $this->setState('ucmType.id', $ucmId); // Check published state - if ((!$user->authorise('core.type.edititem', 'com_tjucm.type.' . $ucmId)) - && (!$user->authorise('core.type.editownitem', 'com_tjucm.type.' . $ucmId)) - && (!$user->authorise('core.type.edititemstate', 'com_tjucm.type.' . $ucmId))) + if ((!TjucmAccess::canEdit($ucmId, $id)) && (!TjucmAccess::canEditOwn($ucmId, $id)) && (!TjucmAccess::canEditState($ucmId, $id))) { $this->setState('filter.published', 1); $this->setState('fileter.archived', 2); @@ -173,8 +170,6 @@ public function getItem($pk = null) */ public function &getData($id = null) { - $user = JFactory::getUser(); - $this->item = false; if (empty($id)) @@ -184,7 +179,7 @@ public function &getData($id = null) // Get UCM type id (Get if user is autorised to edit the items for this UCM type) $ucmTypeId = $this->getState('ucmType.id'); - $canView = $user->authorise('core.type.viewitem', 'com_tjucm.type.' . $ucmTypeId); + $canView = TjucmAccess::canView($ucmTypeId, $id); // Get a level row instance. $table = $this->getTable(); @@ -214,7 +209,7 @@ public function &getData($id = null) if (!empty($this->item->id)) { - if ($canView || ($this->item->created_by == $user->id)) + if ($canView || ($this->item->created_by == JFactory::getUser()->id)) { $this->item->params->set('access-view', true); } @@ -274,8 +269,7 @@ public function delete(&$id) $app = JFactory::getApplication('com_tjucm'); $ucmTypeId = $this->getState('ucmType.id'); - $user = JFactory::getUser(); - $canDelete = $user->authorise('core.type.deleteitem', 'com_tjucm.type.' . $ucmTypeId); + $canDelete = TjucmAccess::canDelete($ucmTypeId, $id); if ($canDelete) { @@ -290,18 +284,4 @@ public function delete(&$id) return false; } } - - /** - * Method to check if a user has permissions to view ucm items of given type - * - * @param int $typeId Type Id - * - * @return boolean - */ - public function canView($typeId) - { - $user = JFactory::getUser(); - - return $user->authorise('core.type.viewitem', 'com_tjucm.type.' . $typeId); - } } diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index 5ccbb910..d6e26a8e 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -102,9 +102,7 @@ protected function populateState() $this->setState('ucmType.id', $ucmId); // Check published state - if ((!$user->authorise('core.type.edititem', 'com_tjucm.type.' . $ucmId)) - && (!$user->authorise('core.type.editownitem', 'com_tjucm.type.' . $ucmId)) - && (!$user->authorise('core.type.edititemstate', 'com_tjucm.type.' . $ucmId))) + if ((!TjucmAccess::canEdit($ucmId, $id)) && (!TjucmAccess::canEditOwn($ucmId, $id)) && (!TjucmAccess::canEditState($ucmId, $id))) { $this->setState('filter.published', 1); $this->setState('fileter.archived', 2); @@ -144,9 +142,9 @@ public function &getData($id = null) // Get UCM type id (Get if user is autorised to edit the items for this UCM type) $ucmTypeId = $this->getState('ucmType.id'); - $canEdit = $user->authorise('core.type.edititem', 'com_tjucm.type.' . $ucmTypeId); - $canEditOwn = $user->authorise('core.type.editownitem', 'com_tjucm.type.' . $ucmTypeId); - $canCreate = $user->authorise('core.type.createitem', 'com_tjucm.type.' . $ucmTypeId); + $canEdit = TjucmAccess::canEdit($ucmTypeId, $id); + $canEditOwn = TjucmAccess::canEditOwn($ucmTypeId, $id); + $canCreate = TjucmAccess::canCreate($ucmTypeId); // Get a level row instance. $table = $this->getTable(); @@ -541,7 +539,7 @@ public function save($data) $allowedCount = $ucmTypeParams->get('allowed_count', 0, 'INT'); // Check if the user is allowed to add record for given UCM type - $canAdd = $user->authorise('core.type.createitem', 'com_tjucm.type.' . $data['type_id']); + $canAdd = TjucmAccess::canCreate($data['type_id']); if (!$canAdd) { @@ -566,8 +564,8 @@ public function save($data) else { // Check if the user can edit this record - $canEdit = $user->authorise('core.type.edititem', 'com_tjucm.type.' . $data['type_id']); - $canEditOwn = $user->authorise('core.type.editownitem', 'com_tjucm.type.' . $data['type_id']); + $canEdit = TjucmAccess::canEdit($data['type_id'], $data['id']); + $canEditOwn = TjucmAccess::canEditOwn($data['type_id'], $data['id']); $itemTable = $this->getTable(); $itemTable->load(array('id' => $data['id'])); @@ -664,8 +662,8 @@ public function delete(&$contentId) $user = JFactory::getUser(); $table = $this->getTable(); $table->load($contentId); - $canDelete = $user->authorise('core.type.deleteitem', 'com_tjucm.type.' . $table->type_id); - $canDeleteown = $user->authorise('core.type.deleteownitem', 'com_tjucm.type.' . $table->type_id); + $canDelete = TjucmAccess::canDelete($table->type_id, $contentId); + $canDeleteown = TjucmAccess::canDeleteOwn($table->type_id, $contentId); $deleteOwn = false; diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 7a48084a..786c31b6 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -145,13 +145,6 @@ protected function populateState($ordering = "a.id", $direction = "DESC") $this->setState("ucmType.id", $typeId); $createdBy = $app->input->get('created_by', "", "INT"); - $canView = $user->authorise('core.type.viewitem', 'com_tjucm.type.' . $typeId); - - if (!$canView) - { - $createdBy = $user->id; - } - $this->setState("created_by", $createdBy); if ($this->getUserStateFromRequest($this->context . $ucmType . '.filter.order', 'filter_order', '', 'string')) @@ -241,18 +234,21 @@ protected function getListQuery() if ($fieldTable->id) { - JFormHelper::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models/fields/'); - $cluster = JFormHelper::loadFieldType('cluster', false); - $clusterList = $cluster->getOptionsExternally(); + JLoader::import("/components/com_cluster/includes/cluster", JPATH_ADMINISTRATOR); + $clustersModel = ClusterFactory::model('Clusters', array('ignore_request' => true)); + $clusters = $clustersModel->getItems(); $usersClusters = array(); - if (!empty($clusterList)) + if (!empty($clusters)) { - foreach ($clusterList as $clusterList) + foreach ($clusters as $clusterList) { - if (!empty($clusterList->value)) + if (!empty($clusterList->id)) { - $usersClusters[] = $clusterList->value; + if (TjucmAccess::canView($ucmTypeId, $clusterList->id)) + { + $usersClusters[] = $clusterList->id; + } } } } @@ -286,6 +282,7 @@ protected function getListQuery() { $query->where($db->quoteName('a.draft') . ' = ' . $draft); } + // Search by content id $search = $this->getState($client . '.filter.search'); @@ -511,28 +508,6 @@ public function getFields() */ public function getItems() { - $typeId = $this->getState('ucmType.id'); - $createdBy = $this->getState('created_by', ''); - - JLoader::import('components.com_tjucm.models.item', JPATH_SITE); - $itemModel = new TjucmModelItem; - $canView = $itemModel->canView($typeId); - $user = JFactory::getUser(); - - // If user is not allowed to view the records and if the created_by is not the logged in user then do not show the records - if (!$canView) - { - if (!empty($createdBy) && $createdBy == $user->id) - { - $canView = true; - } - } - - if (!$canView) - { - return false; - } - $items = parent::getItems(); $itemsArray = (array) $items; $contentIds = array_column($itemsArray, 'id'); diff --git a/src/components/com_tjucm/site/tjucm.php b/src/components/com_tjucm/site/tjucm.php index 4946512b..5d6cf2d3 100644 --- a/src/components/com_tjucm/site/tjucm.php +++ b/src/components/com_tjucm/site/tjucm.php @@ -34,6 +34,7 @@ TjucmHelpersTjucm::getLanguageConstantForJs(); // Initialise UCM +JLoader::register('TjucmAccess', JPATH_SITE . '/components/com_tjucm/includes/access.php'); JLoader::register('TJUCM', JPATH_SITE . '/components/com_tjucm/includes/tjucm.php'); TJUCM::init(); diff --git a/src/components/com_tjucm/site/views/item/tmpl/default.php b/src/components/com_tjucm/site/views/item/tmpl/default.php index 5d848ca9..c4d06df0 100644 --- a/src/components/com_tjucm/site/views/item/tmpl/default.php +++ b/src/components/com_tjucm/site/views/item/tmpl/default.php @@ -42,7 +42,7 @@
authorise('core.type.edititem', 'com_tjucm.type.' . $this->ucmTypeId)) || ($user->authorise('core.type.editownitem', 'com_tjucm.type.' . $this->ucmTypeId) && JFactory::getUser()->id == $this->item->created_by)) + if ((TjucmAccess::canEdit($this->ucmTypeId, $this->item->id)) || (TjucmAccess::canEditOwn($this->ucmTypeId, $this->item->id) && JFactory::getUser()->id == $this->item->created_by)) { $redirectURL = JRoute::_('index.php?option=com_tjucm&task=item.edit&id=' . $this->item->id . '&client=' . $this->client, false); ?> @@ -52,12 +52,12 @@ $deleteOwn = false; - if ($user->authorise('core.type.deleteownitem', 'com_tjucm.type.' . $this->ucmTypeId)) + if (TjucmAccess::canDeleteOwn($this->ucmTypeId, $this->item->id)) { $deleteOwn = (JFactory::getUser()->id == $this->item->created_by ? true : false); } - if ($user->authorise('core.type.deleteitem', 'com_tjucm.type.' . $this->ucmTypeId) || $deleteOwn) + if (TjucmAccess::canDelete($this->ucmTypeId, $this->item->id) || $deleteOwn) { $redirectURL = JRoute::_('index.php?option=com_tjucm&task=itemform.remove&id=' . $this->item->id . '&client=' . $this->client . "&" . JSession::getFormToken() . '=1', false); ?> diff --git a/src/components/com_tjucm/site/views/itemform/view.html.php b/src/components/com_tjucm/site/views/itemform/view.html.php index 6f8e5301..7a53c3f1 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -128,28 +128,6 @@ public function display($tpl = null) $clusterId = $this->item->cluster_id; } - // Get com_cluster component status - if (ComponentHelper::getComponent('com_cluster', true)->enabled) - { - // Get com_subusers component status - $subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled; - - // Check user have permission to edit record of assigned cluster - if ($subUserExist && !empty($clusterId) && !$user->authorise('core.manageall', 'com_cluster')) - { - JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); - - // Check user has permission for mentioned cluster - if (!RBACL::authorise($user->id, 'com_cluster', 'core.manage', $clusterId)) - { - $app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error'); - $app->setHeader('status', 403, true); - - return; - } - } - } - // Get a copy record id $this->copyRecId = (int) $app->getUserState('com_tjucm.edit.itemform.data.copy_id', 0); @@ -232,6 +210,14 @@ public function display($tpl = null) $typeTable->load(array('unique_identifier' => $this->client)); $typeParams = json_decode($typeTable->params); + if (!TjucmAccess::canEdit($typeTable->id, $this->item->id)) + { + $app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error'); + $app->setHeader('status', 403, true); + + return; + } + // Check if the UCM type is unpublished if ($typeTable->state == "0") { diff --git a/src/components/com_tjucm/site/views/items/tmpl/default.php b/src/components/com_tjucm/site/views/items/tmpl/default.php index be991251..1874f7c1 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -190,21 +190,15 @@ function copyItem() } ?> - + canEdit || $this->canDelete) - { ?> -
items)) - { - echo $this->pagination->getListFooter(); - } + if (!empty($this->items)) + { + echo $this->pagination->getListFooter(); + } ?>
@@ -327,22 +321,16 @@ class="btn btn-success btn-small"> -canDelete) -{ - ?> - - diff --git a/src/components/com_tjucm/site/views/items/tmpl/default_filters.php b/src/components/com_tjucm/site/views/items/tmpl/default_filters.php index c2391ce9..524301b4 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default_filters.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default_filters.php @@ -46,7 +46,6 @@ $db = JFactory::getDbo(); // Check if com_cluster component is installed - if (ComponentHelper::getComponent('com_cluster', true)->enabled) { JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR); @@ -55,9 +54,34 @@ if ($fieldTable->id) { - JFormHelper::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models/fields/'); - $cluster = JFormHelper::loadFieldType('cluster', false); - $this->clusterList = $cluster->getOptionsExternally(); + JLoader::import("/components/com_cluster/includes/cluster", JPATH_ADMINISTRATOR); + $clustersModel = ClusterFactory::model('Clusters', array('ignore_request' => true)); + $clusters = $clustersModel->getItems(); + $usersClusters = array(); + + $clusterObj = new stdclass; + $clusterObj->text = JText::_("COM_TJFIELDS_OWNERSHIP_CLUSTER"); + $clusterObj->value = ""; + + $usersClusters[] = $clusterObj; + + if (!empty($clusters)) + { + foreach ($clusters as $clusterList) + { + if (TjucmAccess::canView($this->ucmTypeId, $clusterList->id)) + { + if (!empty($clusterList->id)) + { + $clusterObj = new stdclass; + $clusterObj->text = $clusterList->name; + $clusterObj->value = $clusterList->id; + + $usersClusters[] = $clusterObj; + } + } + } + } ?> +
- id, 'com_cluster', 'core.viewitem', $clusterList->id)) + if (RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewitem', $clusterList->id) || RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewallitem')) { if (!empty($clusterList->id)) { @@ -87,7 +86,7 @@ From 695add3bc5f59ee40c7991532c59e1e633f58587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 1 Apr 2020 18:19:40 +0530 Subject: [PATCH 20/42] Bug #159554 fix: Loader is missing when the form is submitted to save the record --- src/components/com_tjucm/site/views/itemform/tmpl/default.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/com_tjucm/site/views/itemform/tmpl/default.php b/src/components/com_tjucm/site/views/itemform/tmpl/default.php index 9b02b752..a2d05328 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/default.php +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default.php @@ -220,6 +220,9 @@ } ?> +
+ +
From c2db0cf92b3001122513a57184333a142152a45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 1 Apr 2020 18:22:38 +0530 Subject: [PATCH 21/42] Bug #159554 fix: Loader is missing when the form is submitted to save the record --- src/components/com_tjucm/media/css/tjucm.css | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/com_tjucm/media/css/tjucm.css b/src/components/com_tjucm/media/css/tjucm.css index 5641015a..325dc8f4 100644 --- a/src/components/com_tjucm/media/css/tjucm.css +++ b/src/components/com_tjucm/media/css/tjucm.css @@ -22,3 +22,12 @@ width:200px !important; .tjucm-wrapper .tj-wordwrap{ word-break: break-word; } + +#item-form #tjucm_loader{ + height:auto; + position:absolute; + top:45%; + left:45%; + opacity: 0.5; + display:none; +} From 31c38b001078a355b7ecff5629c2bc5fd69cf8b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 1 Apr 2020 18:26:28 +0530 Subject: [PATCH 22/42] Bug #159554 fix: Loader is missing when the form is submitted to save the record --- src/components/com_tjucm/tjucm.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/com_tjucm/tjucm.xml b/src/components/com_tjucm/tjucm.xml index 5073f11b..84b8bb21 100644 --- a/src/components/com_tjucm/tjucm.xml +++ b/src/components/com_tjucm/tjucm.xml @@ -41,6 +41,7 @@ js css + gif en-GB/en-GB.com_tjucm.ini From 874c456a58b021fc8c3de5eb7d93c4d67020c28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 1 Apr 2020 18:42:47 +0530 Subject: [PATCH 23/42] Bug #159554 fix: Loader is missing when the form is submitted to save the record --- .../com_tjucm/site/models/itemform.php | 20 ++++++------- .../en-GB/en-GB.plg_actionlog_tjucm.ini | 29 ++++++++++--------- src/plugins/actionlog/tjucm/tjucm.php | 14 ++++----- 3 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index 893333d3..d8c69dcb 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -698,13 +698,13 @@ public function delete(&$contentId) { $table->load($subFormContentId); + // Plugin trigger on before item delete + JPluginHelper::importPlugin('actionlog'); + $dispatcher = JDispatcher::getInstance(); + $dispatcher->trigger('tjUcmOnBeforeDeleteItem', array($subFormContentId, $table->client)); + if ($table->delete($subFormContentId) === true) { - // Plugin trigger on before item delete - JPluginHelper::importPlugin('actionlog'); - $dispatcher = JDispatcher::getInstance(); - $dispatcher->trigger('tjUcmOnBeforeDeleteItem', array($subFormContentId, $table->client)); - $this->deleteExtraFieldsData($subFormContentId, $table->client); // Plugin trigger on after item delete @@ -718,13 +718,13 @@ public function delete(&$contentId) // Delete parent record $table->load($id); + // Plugin trigger on before item delete + JPluginHelper::importPlugin('actionlog'); + $dispatcher = JDispatcher::getInstance(); + $dispatcher->trigger('tjUcmOnBeforeDeleteItem', array($id, $table->client)); + if ($table->delete($id) === true) { - // Plugin trigger on before item delete - JPluginHelper::importPlugin('actionlog'); - $dispatcher = JDispatcher::getInstance(); - $dispatcher->trigger('tjUcmOnBeforeDeleteItem', array($id, $table->client)); - $this->deleteExtraFieldsData($id, $table->client); // Plugin trigger on after item delete diff --git a/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini b/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini index 130aba4b..b202307a 100644 --- a/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini +++ b/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini @@ -17,17 +17,20 @@ PLG_ACTIONLOG_TJUCM_LOG_ACTION_ITEM_DELETE="Log action for item delete?" PLG_ACTIONLOG_TJUCM_LOG_ACTION_ITEM_SAVE="Log action for item creation?" PLG_ACTIONLOG_TJUCM_LOG_ACTION_ITEM_DATA_SAVE="Log action for item data add/update?" -PLG_ACTIONLOG_TJUCM_TYPE_ADDED="User {username} added a new UCM type {title} " -PLG_ACTIONLOG_TJUCM_TYPE_UPDATED="User {username} updated the UCM type {title} " -PLG_ACTIONLOG_TJUCM_TYPE_DELETED="User {username} deleted the UCM type \"{title}\" " -PLG_ACTIONLOGS_TJUCM_TYPE_UNPUBLISHED="User {username} unpublished the UCM type {title} " -PLG_ACTIONLOGS_TJUCM_TYPE_PUBLISHED="User {username} published the UCM type {title} " -PLG_ACTIONLOGS_TJUCM_TYPE_ARCHIVED="User {username} archived the UCM type {title} of client \"{identifier}\" " -PLG_ACTIONLOGS_TJUCM_TYPE_TRASHED="User {username} trashed the UCM type {title} " -PLG_ACTIONLOG_TJUCM_TYPE_EXPORTED="User {username} exported the UCM type {title} " -PLG_ACTIONLOG_TJUCM_TYPE_IMPORTED="User {username} imported the UCM type {title} " +PLG_ACTIONLOG_TJUCM_TYPE_ADDED="{username} added a new UCM type {title} " +PLG_ACTIONLOG_TJUCM_TYPE_UPDATED="{username} updated the UCM type {title} " +PLG_ACTIONLOG_TJUCM_TYPE_DELETED="{username} deleted the UCM type \"{title}\"" +PLG_ACTIONLOGS_TJUCM_TYPE_UNPUBLISHED="{username} unpublished the UCM type {title} " +PLG_ACTIONLOGS_TJUCM_TYPE_PUBLISHED="{username} published the UCM type {title} " +PLG_ACTIONLOGS_TJUCM_TYPE_ARCHIVED="{username} archived the UCM type {title} of client \"{identifier}\"" +PLG_ACTIONLOGS_TJUCM_TYPE_TRASHED="{username} trashed the UCM type {title}" +PLG_ACTIONLOG_TJUCM_TYPE_EXPORTED="{username} exported the UCM type {title}" +PLG_ACTIONLOG_TJUCM_TYPE_IMPORTED="{username} imported the UCM type {title}" -PLG_ACTIONLOG_TJUCM_ITEM_DELETED="User {username} has deleted an item from '\"{title}\"'" -PLG_ACTIONLOG_TJUCM_ITEM_ADDED="User {username} has added an item in '\"{title}\"'" -PLG_ACTIONLOG_TJUCM_ITEM_DATA_ADDED="User {username} has added data in item of '\"{title}\"'" -PLG_ACTIONLOG_TJUCM_ITEM_DATA_EDIT="User {username} has updated data in item of '\"{title}\"'" \ No newline at end of file +PLG_ACTIONLOG_TJUCM_ITEM_DELETED="{username} has deleted a record from {title}" +PLG_ACTIONLOG_TJUCM_ITEM_ADDED="{username} has added a record in {title}" +PLG_ACTIONLOG_TJUCM_ITEM_DATA_ADDED="{username} has added a record in {title}" +PLG_ACTIONLOG_TJUCM_ITEM_DATA_EDIT="{username} has updated a record in {title}" +PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_EDIT="{username} from {cluster_title} has updated a record in {title}" +PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_ADDED="{username} from {cluster_title} has added a record in {title}" +PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DELETED="{username} from {cluster_title} has deleted an item from {title}" diff --git a/src/plugins/actionlog/tjucm/tjucm.php b/src/plugins/actionlog/tjucm/tjucm.php index 4195f4ee..732eff1b 100644 --- a/src/plugins/actionlog/tjucm/tjucm.php +++ b/src/plugins/actionlog/tjucm/tjucm.php @@ -115,7 +115,7 @@ public function tjUcmOnAfterTypeSave($type, $isNew) 'id' => $type['typeId'], 'title' => $type['title'], 'userid' => $user->id, - 'username' => $user->username, + 'username' => ucfirst($user->username), 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, 'typelink' => 'index.php?option=com_tjucm&view=type&layout=edit&id=' . $type['typeId'], ); @@ -152,7 +152,7 @@ public function tjUcmOnAfterTypeDelete($context, $table) 'title' => $table->title, 'identifier' => $table->unique_identifier, 'userid' => $user->id, - 'username' => $user->username, + 'username' => ucfirst($user->username), 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, ); @@ -186,7 +186,7 @@ public function tjUcmOnAfterTypeChangeState($context, $pks, $value) $context = Factory::getApplication()->input->get('option'); $jUser = Factory::getUser(); $userId = $jUser->id; - $userName = $jUser->username; + $userName = ucfirst($jUser->username); switch ($value) { @@ -265,7 +265,7 @@ public function tjucmOnAfterSaveItem($item, $isNew) 'id' => $item['id'], 'title' => $tjucmTableType->title, 'userid' => $user->id, - 'username' => $user->username, + 'username' => ucfirst($user->username), 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, ); @@ -313,7 +313,7 @@ public function tjucmOnBeforeSaveItemData($recordId, $client, $data) 'id' => $recordId, 'title' => $tjucmTableType->title, 'userid' => $user->id, - 'username' => $user->username, + 'username' => ucfirst($user->username), 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, ); @@ -333,7 +333,7 @@ public function tjucmOnBeforeSaveItemData($recordId, $client, $data) * * @since __DEPLOY__VERSION__ */ - public function tjUcmOnAfterDeleteItem($item, $client) + public function tjUcmOnBeforeDeleteItem($item, $client) { if (!$this->params->get('TjUcmOnAfterItemDelete', 1)) { @@ -353,7 +353,7 @@ public function tjUcmOnAfterDeleteItem($item, $client) 'id' => $item, 'title' => $tjucmTableType->title, 'userid' => $user->id, - 'username' => $user->username, + 'username' => ucfirst($user->username), 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, ); From d9d2f0b38821c808cdf4daf87a9932b50126a254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 1 Apr 2020 18:46:55 +0530 Subject: [PATCH 24/42] Bug #159554 fix: Loader is missing when the form is submitted to save the record --- .../tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini b/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini index b202307a..a101ad21 100644 --- a/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini +++ b/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini @@ -33,4 +33,4 @@ PLG_ACTIONLOG_TJUCM_ITEM_DATA_ADDED="{username} has added a record in {title}" PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_EDIT="{username} from {cluster_title} has updated a record in {title}" PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_ADDED="{username} from {cluster_title} has added a record in {title}" -PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DELETED="{username} from {cluster_title} has deleted an item from {title}" +PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DELETED="{username} from {cluster_title} has deleted a record from {title}" From b4cc8206aea7e3898f8a1b556c855130787b1edc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 1 Apr 2020 18:51:30 +0530 Subject: [PATCH 25/42] Bug #159554 fix: Loader is missing when the form is submitted to save the record --- src/plugins/actionlog/tjucm/tjucm.php | 87 ++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 15 deletions(-) diff --git a/src/plugins/actionlog/tjucm/tjucm.php b/src/plugins/actionlog/tjucm/tjucm.php index 732eff1b..5b553205 100644 --- a/src/plugins/actionlog/tjucm/tjucm.php +++ b/src/plugins/actionlog/tjucm/tjucm.php @@ -13,6 +13,7 @@ JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR . '/components/com_actionlogs/helpers/actionlogs.php'); +use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Factory; use Joomla\CMS\MVC\Model\BaseDatabaseModel; @@ -290,7 +291,7 @@ public function tjucmOnAfterSaveItem($item, $isNew) */ public function tjucmOnBeforeSaveItemData($recordId, $client, $data) { - if (!$this->params->get('tjucmOnAfterSaveItemData', 1)) + if (!$this->params->get('tjucmOnAfterSaveItemData', 1) || empty($recordId)) { return; } @@ -306,15 +307,45 @@ public function tjucmOnBeforeSaveItemData($recordId, $client, $data) $fieldValue = Table::getInstance('FieldsValue', 'TjfieldsTable', array()); $fieldValue->load(array('content_id' => $recordId, 'client' => $client)); - $messageLanguageKey = ($fieldValue->id) ? 'PLG_ACTIONLOG_TJUCM_ITEM_DATA_EDIT' : 'PLG_ACTIONLOG_TJUCM_ITEM_DATA_ADDED'; + $clusterId = ""; + $clusterTitle = ""; + + if (ComponentHelper::getComponent('com_cluster', true)->enabled) + { + $clusterField = str_replace(".", "_", $client) . '_clusterclusterid'; + + if ($data[$clusterField]) + { + JLoader::import('components.com_cluster.tables.clusters', JPATH_ADMINISTRATOR); + $clusterTable = Table::getInstance('Clusters', 'ClusterTable', array()); + $clusterTable->load($data[$clusterField]); + $clusterId = $tjucmTableItem->cluster_id; + $clusterTitle = $clusterTable->name; + } + + $messageLanguageKey = ($fieldValue->id) ? 'PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_EDIT' : 'PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_ADDED'; + } + else + { + $messageLanguageKey = ($fieldValue->id) ? 'PLG_ACTIONLOG_TJUCM_ITEM_DATA_EDIT' : 'PLG_ACTIONLOG_TJUCM_ITEM_DATA_ADDED'; + } + + JLoader::import('components.com_tjucm.helpers.tjucm', JPATH_SITE); + $tjUcmFrontendHelper = new TjucmHelpersTjucm; + $link = 'index.php?option=com_tjucm&view=item&client=' . $client . '&id=' . $recordId; + $itemId = $tjUcmFrontendHelper->getItemId($link); + $link = JRoute::_($link . '&Itemid=' . $itemId, false); $message = array( - 'action' => 'add', - 'id' => $recordId, - 'title' => $tjucmTableType->title, - 'userid' => $user->id, - 'username' => ucfirst($user->username), - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'action' => 'add', + 'id' => $recordId, + 'title' => $tjucmTableType->title, + 'cluster_id' => $clusterId, + 'cluster_title' => $clusterTitle, + 'userid' => $user->id, + 'username' => ucfirst($user->name), + 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'item_link' => $link, ); $this->addLog(array($message), $messageLanguageKey, $context, $user->id); @@ -347,14 +378,40 @@ public function tjUcmOnBeforeDeleteItem($item, $client) $context = Factory::getApplication()->input->get('option'); $user = Factory::getUser(); - $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_ITEM_DELETED'; + $clusterId = ""; + $clusterTitle = ""; + + if (ComponentHelper::getComponent('com_cluster', true)->enabled) + { + JLoader::import('components.com_tjucm.tables.item', JPATH_ADMINISTRATOR); + $tjucmTableItem = Table::getInstance('Item', 'TjucmTable', array()); + $tjucmTableItem->load($recordId); + + if ($tjucmTableItem->cluster_id) + { + JLoader::import('components.com_cluster.tables.clusters', JPATH_ADMINISTRATOR); + $clusterTable = Table::getInstance('Clusters', 'ClusterTable', array()); + $clusterTable->load($tjucmTableItem->cluster_id); + $clusterId = $tjucmTableItem->cluster_id; + $clusterTitle = $clusterTable->name; + } + + $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DELETED'; + } + else + { + $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_ITEM_DELETED'; + } + $message = array( - 'action' => 'delete', - 'id' => $item, - 'title' => $tjucmTableType->title, - 'userid' => $user->id, - 'username' => ucfirst($user->username), - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'action' => 'delete', + 'id' => $item, + 'title' => $tjucmTableType->title, + 'cluster_id' => $clusterId, + 'cluster_title' => $clusterTitle, + 'userid' => $user->id, + 'username' => ucfirst($user->name), + 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, ); $this->addLog(array($message), $messageLanguageKey, $context, $user->id); From f258c6c84783a7133c41fb2df1a8bfb6891e0eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Thu, 2 Apr 2020 10:38:51 +0530 Subject: [PATCH 26/42] Bug #159554 fix: Loader is missing when the form is submitted to save the record --- src/plugins/actionlog/tjucm/tjucm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/actionlog/tjucm/tjucm.php b/src/plugins/actionlog/tjucm/tjucm.php index 5b553205..65415798 100644 --- a/src/plugins/actionlog/tjucm/tjucm.php +++ b/src/plugins/actionlog/tjucm/tjucm.php @@ -385,7 +385,7 @@ public function tjUcmOnBeforeDeleteItem($item, $client) { JLoader::import('components.com_tjucm.tables.item', JPATH_ADMINISTRATOR); $tjucmTableItem = Table::getInstance('Item', 'TjucmTable', array()); - $tjucmTableItem->load($recordId); + $tjucmTableItem->load($item); if ($tjucmTableItem->cluster_id) { From e8f5a66acbbf7cf9455adb8643a65062e518b7dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Thu, 2 Apr 2020 18:08:12 +0530 Subject: [PATCH 27/42] Bug #159554 fix: Loader is missing when the form is submitted to save the record --- src/components/com_tjucm/site/models/items.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 786c31b6..d41b5a62 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -482,6 +482,8 @@ public function getFields() $fieldsModel = JModelLegacy::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); $fieldsModel->setState('filter.showonlist', 1); $fieldsModel->setState('filter.state', 1); + $fieldsModel->setState('list.ordering', 'ordering'); + $fieldsModel->setState('list.direction', 'ASC'); $client = $this->getState('ucm.client'); if (!empty($client)) From ec33fad7202c0026896ac9ada3b9419b151d9ff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 3 Apr 2020 16:21:09 +0530 Subject: [PATCH 28/42] Bug #159554 fix: Loader is missing when the form is submitted to save the record --- .../site/views/item/tmpl/default.php | 11 ++ .../com_tjucm/site/views/item/view.html.php | 1 + .../en-GB/en-GB.plg_actionlog_tjucm.ini | 3 + src/plugins/actionlog/tjucm/tjucm.php | 130 ++++++++++++++---- 4 files changed, 118 insertions(+), 27 deletions(-) diff --git a/src/components/com_tjucm/site/views/item/tmpl/default.php b/src/components/com_tjucm/site/views/item/tmpl/default.php index c4d06df0..ecf92def 100644 --- a/src/components/com_tjucm/site/views/item/tmpl/default.php +++ b/src/components/com_tjucm/site/views/item/tmpl/default.php @@ -16,6 +16,17 @@ if ($this->form_extra) { + if (isset($this->title)) + { + ?> + + load(array('unique_identifier' => $this->client)); $typeParams = json_decode($typeTable->params); + $this->title = $typeTable->title; if (isset($typeParams->details_layout) && !empty($typeParams->details_layout)) { diff --git a/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini b/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini index a101ad21..a4f8ceff 100644 --- a/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini +++ b/src/plugins/actionlog/tjucm/language/en-GB/en-GB.plg_actionlog_tjucm.ini @@ -34,3 +34,6 @@ PLG_ACTIONLOG_TJUCM_ITEM_DATA_EDIT="{username} has updated a record in {title}" PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_ADDED="{username} from {cluster_title} has added a record in {title}" PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DELETED="{username} from {cluster_title} has deleted a record from {title}" +PLG_ACTIONLOG_TJUCM_OTHER_CLUSTER_ITEM_DATA_EDIT="{username} from {cluster_title} has updated a record in {title} for {owner_cluster_title}" +PLG_ACTIONLOG_TJUCM_OTHER_CLUSTER_ITEM_DATA_ADDED="{username} from {cluster_title} has added a record in {title} for {owner_cluster_title}" +PLG_ACTIONLOG_TJUCM_OTHER_CLUSTER_ITEM_DELETED="{username} from {cluster_title} has deleted a record from {title} for {owner_cluster_title}" diff --git a/src/plugins/actionlog/tjucm/tjucm.php b/src/plugins/actionlog/tjucm/tjucm.php index 65415798..cd422570 100644 --- a/src/plugins/actionlog/tjucm/tjucm.php +++ b/src/plugins/actionlog/tjucm/tjucm.php @@ -309,21 +309,57 @@ public function tjucmOnBeforeSaveItemData($recordId, $client, $data) $clusterId = ""; $clusterTitle = ""; + $ownerClusterId = ""; + $ownerClusterTitle = ""; if (ComponentHelper::getComponent('com_cluster', true)->enabled) { $clusterField = str_replace(".", "_", $client) . '_clusterclusterid'; + JLoader::import('components.com_cluster.models.clusteruser', JPATH_ADMINISTRATOR); + $clusterUserModel = JModelLegacy::getInstance('ClusterUser', 'ClusterModel'); + $usersClusters = $clusterUserModel->getUsersClusters($user->id); + if ($data[$clusterField]) { + $editingRecordOfOtherCluster = true; + + // Check if user belongs to the cluster who has created the record or not + foreach ($usersClusters as $usersCluster) + { + if ($usersCluster->cluster_id == $data[$clusterField]) + { + // If user is not part of cluster who owns the record then he is editing record on behalf or other cluster + $editingRecordOfOtherCluster = false; + + break; + } + } + JLoader::import('components.com_cluster.tables.clusters', JPATH_ADMINISTRATOR); $clusterTable = Table::getInstance('Clusters', 'ClusterTable', array()); - $clusterTable->load($data[$clusterField]); - $clusterId = $tjucmTableItem->cluster_id; - $clusterTitle = $clusterTable->name; - } - $messageLanguageKey = ($fieldValue->id) ? 'PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_EDIT' : 'PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_ADDED'; + if ($editingRecordOfOtherCluster) + { + $clusterTable->load($usersClusters[0]->cluster_id); + $clusterId = $usersClusters[0]->cluster_id; + $clusterTitle = $clusterTable->name; + + $clusterTable->load($data[$clusterField]); + $ownerClusterId = $data[$clusterField]; + $ownerClusterTitle = $clusterTable->name; + + $messageLanguageKey = ($fieldValue->id) ? 'PLG_ACTIONLOG_TJUCM_OTHER_CLUSTER_ITEM_DATA_EDIT' : 'PLG_ACTIONLOG_TJUCM_OTHER_CLUSTER_ITEM_DATA_ADDED'; + } + else + { + $clusterTable->load($data[$clusterField]); + $clusterId = $tjucmTableItem->cluster_id; + $clusterTitle = $clusterTable->name; + + $messageLanguageKey = ($fieldValue->id) ? 'PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_EDIT' : 'PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DATA_ADDED'; + } + } } else { @@ -337,15 +373,17 @@ public function tjucmOnBeforeSaveItemData($recordId, $client, $data) $link = JRoute::_($link . '&Itemid=' . $itemId, false); $message = array( - 'action' => 'add', - 'id' => $recordId, - 'title' => $tjucmTableType->title, - 'cluster_id' => $clusterId, - 'cluster_title' => $clusterTitle, - 'userid' => $user->id, - 'username' => ucfirst($user->name), - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, - 'item_link' => $link, + 'action' => 'add', + 'id' => $recordId, + 'title' => $tjucmTableType->title, + 'cluster_id' => $clusterId, + 'cluster_title' => $clusterTitle, + 'owner_cluster_id' => $ownerClusterId, + 'owner_cluster_title' => $ownerClusterTitle, + 'userid' => $user->id, + 'username' => ucfirst($user->name), + 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'item_link' => $link, ); $this->addLog(array($message), $messageLanguageKey, $context, $user->id); @@ -380,6 +418,8 @@ public function tjUcmOnBeforeDeleteItem($item, $client) $clusterId = ""; $clusterTitle = ""; + $ownerClusterId = ""; + $ownerClusterTitle = ""; if (ComponentHelper::getComponent('com_cluster', true)->enabled) { @@ -387,16 +427,50 @@ public function tjUcmOnBeforeDeleteItem($item, $client) $tjucmTableItem = Table::getInstance('Item', 'TjucmTable', array()); $tjucmTableItem->load($item); + JLoader::import('components.com_cluster.models.clusteruser', JPATH_ADMINISTRATOR); + $clusterUserModel = JModelLegacy::getInstance('ClusterUser', 'ClusterModel'); + $usersClusters = $clusterUserModel->getUsersClusters($user->id); + + $deletingRecordOfOtherCluster = true; + + // Check if user belongs to the cluster who has created the record or not + foreach ($usersClusters as $usersCluster) + { + if ($usersCluster->cluster_id == $tjucmTableItem->cluster_id) + { + // If user is not part of cluster who owns the record then he is editing record on behalf or other cluster + $deletingRecordOfOtherCluster = false; + + break; + } + } + if ($tjucmTableItem->cluster_id) { JLoader::import('components.com_cluster.tables.clusters', JPATH_ADMINISTRATOR); $clusterTable = Table::getInstance('Clusters', 'ClusterTable', array()); - $clusterTable->load($tjucmTableItem->cluster_id); - $clusterId = $tjucmTableItem->cluster_id; - $clusterTitle = $clusterTable->name; - } - $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DELETED'; + if ($deletingRecordOfOtherCluster) + { + $clusterTable->load($usersClusters[0]->cluster_id); + $clusterId = $usersClusters[0]->cluster_id; + $clusterTitle = $clusterTable->name; + + $clusterTable->load($tjucmTableItem->cluster_id); + $ownerClusterId = $tjucmTableItem->cluster_id; + $ownerClusterTitle = $clusterTable->name; + + $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_OTHER_CLUSTER_ITEM_DELETED'; + } + else + { + $clusterTable->load($tjucmTableItem->cluster_id); + $clusterId = $tjucmTableItem->cluster_id; + $clusterTitle = $clusterTable->name; + + $messageLanguageKey = 'PLG_ACTIONLOG_TJUCM_CLUSTER_ITEM_DELETED'; + } + } } else { @@ -404,14 +478,16 @@ public function tjUcmOnBeforeDeleteItem($item, $client) } $message = array( - 'action' => 'delete', - 'id' => $item, - 'title' => $tjucmTableType->title, - 'cluster_id' => $clusterId, - 'cluster_title' => $clusterTitle, - 'userid' => $user->id, - 'username' => ucfirst($user->name), - 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, + 'action' => 'delete', + 'id' => $item, + 'title' => $tjucmTableType->title, + 'cluster_id' => $clusterId, + 'cluster_title' => $clusterTitle, + 'owner_cluster_id' => $ownerClusterId, + 'owner_cluster_title' => $ownerClusterTitle, + 'userid' => $user->id, + 'username' => ucfirst($user->name), + 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, ); $this->addLog(array($message), $messageLanguageKey, $context, $user->id); From 2448efdf45e7232d59b7a41d03957a74cca5a3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 6 Apr 2020 14:12:31 +0530 Subject: [PATCH 29/42] Bug #156605 fix: The dropdown of tjlist type field didn't get reset. It shows old value as it is --- src/components/com_tjucm/media/js/ui/itemform.js | 7 +++++-- src/components/com_tjucm/media/js/ui/itemform.min.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index ff2f7a0c..c8b73a36 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -823,7 +823,7 @@ var tjUcmItemForm = { /* Reset the variable*/ tjUcmFormSubmitCallingButtonId = ''; - jQuery('input[type="checkbox"]').each(function (){ + jQuery('#item-form input[type="checkbox"]').each(function (){ if (jQuery(this).prop('checked') == true) { tjUcmItemFormData.append(jQuery(this).attr('name'), 1); @@ -834,6 +834,10 @@ var tjUcmItemForm = { } }); + jQuery('#item-form select').each(function (){ + tjUcmItemFormData.append(jQuery(this).attr('name'), jQuery(this).val()); + }); + /* Do not show draft save msg if the save is triggered as per bitrate config*/ if (tjUcmSaveFormInDraftWithNoMsg !== undefined) { @@ -905,7 +909,6 @@ var tjUcmItemForm = { /* Disable the save button till the record is saved*/ jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', true); - tjUcmItemForm.getUcmParentRecordId(1, function (){ tjUcmSectionFormData.delete('task'); tjUcmSectionFormData.delete('option'); diff --git a/src/components/com_tjucm/media/js/ui/itemform.min.js b/src/components/com_tjucm/media/js/ui/itemform.min.js index 26eb050d..475185f2 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.min.js +++ b/src/components/com_tjucm/media/js/ui/itemform.min.js @@ -1 +1 @@ -var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=new Array,tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=new Array,tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var e=Number(jQuery("#itemState").val()),t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1===e){var a=jQuery("#item-form #tjucm-autosave").val();t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){if(tjUcmCurrentAutoSaveState=1,jQuery("#item-form").on("change select",":input",function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .field-calendar input:text").blur(function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .js-editor-tinymce").length>0){var i=Joomla.getOptions("plg_editor_tinymce");null!=i&&jQuery.each(i.tinyMCE,function(e,t){if(jQuery("#item-form #jform_"+e).length){var r=jQuery("#jform_"+e+"_ifr").contents().find("body").html();tjUcmTinyMCEFieldIds[e]=r}else if(0==jQuery("#item-form #jform_"+e).length&&"default"!=e){var a=jQuery("textarea[id$='__"+e+"']");a.length&&jQuery.each(a,function(e,t){var r=jQuery(t).attr("id"),a=jQuery("#"+r+"_ifr").contents().find("body").html(),i=r.replace("jform_","");tjUcmTinyMCEFieldIds[i]=a})}})}jQuery("#item-form .wf-editor-container").length>0&&setTimeout(function(){jQuery("#item-form .mceIframeContainer iframe").each(function(){var e=jQuery(this).attr("id"),t=e.replace("jform_","").replace("_ifr",""),r=jQuery("#"+e).contents().find("body").html();tjUcmJCEFieldIds[t]=r})},2e3),1==a&&1==t&&void 0!==r&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){for(var e in(jQuery("#item-form").hasClass("dirty")||0===tjUcmFormSavedByBitRateConfig)&&(tjUcmFormSavedByBitRateConfig=1,jQuery("#tjUcmSectionDraftSave").click()),tjUcmJCEFieldIds)if(tjUcmJCEFieldIds.hasOwnProperty(e)){var t=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmJCEFieldIds[e]!=t){var r=jQuery("#jform_"+e);r.length&&(r.val(t),tjUcmJCEFieldIds[e]=t,tjUcmItemForm.onUcmFormChange(r))}}if(jQuery("#item-form .js-editor-tinymce").length>0)for(var e in tjUcmTinyMCEFieldIds)if(tjUcmTinyMCEFieldIds.hasOwnProperty(e)){var a=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmTinyMCEFieldIds[e]!=a){var i=jQuery("#jform_"+e);i.length&&(i.val(a),tjUcmTinyMCEFieldIds[e]=a,tjUcmItemForm.onUcmFormChange(i))}}},1e3*r)}}else jQuery("#tjucm-auto-save-disabled-msg").show();jQuery("#tjucm_myTabTabs a").on("click",function(){jQuery(this).parent().next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(this).parent().prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0)}),jQuery(document).on("subform-row-add",function(e,t){var r,a=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")&&(r=jQuery(t).find(".js-editor-tinymce textarea").attr("id"))){var i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}if(jQuery(t).find(".wf-editor-container textarea")&&(r=jQuery(t).find(".wf-editor-container textarea").attr("id"))){i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}jQuery.each(tjucmRelatedFieldUpdatedOptions,function(e,r){if(r.templateId){var i=r.templateId.replace("XXX_XXX",a);jQuery(t).find("#"+i).html(""),jQuery.each(r.options,function(e,r){jQuery(t).find("#"+i).append('")}),jQuery(t).find("#"+i).trigger("liszt:updated")}})}),jQuery("#next_button, #previous_button").on("click",function(){if("next_button"==jQuery(this).attr("id")?tjUcmClickedOnNext=1:tjUcmClickedOnPrev=1,jQuery("#item-form").hasClass("dirty"))if(tjUcmCurrentAutoSaveState){var e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(e,t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(t,a){var i=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==i){var n=new FormData;""!=r&&n.append("client",r),n.append(Joomla.getOptions("csrf.token"),1);n.append("draft",e),com_tjucm.Services.Item.create(n,function(e,r){if(r=JSON.parse(r),null==e)if(null!==r.data&&jQuery.isNumeric(r.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(r.data.id);var i=window.location.href.split("#")[0],n=-1===i.indexOf("?")?"?":"&",o="id="+r.data.id;i.indexOf(o)>=0||(i+=n+o),history.pushState(null,null,i),t(r.data.id)}else a(r)})}else jQuery.isNumeric(i)&&0!=i&&t(i)}).then(function(e){t(e)}).catch(function(e){return console.log(e),!1})},onUcmFormChange:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(e,r,t)})},initUcmFormFieldDataSave:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a="",i=new FormData;if(i.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(e).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(e).parent().parent().parent().parent().attr("data-base-name")){var n=jQuery(e).parent().parent().parent().attr("data-base-name");null==n&&(n=jQuery(e).parent().parent().parent().parent().attr("data-base-name"));var o=jQuery(e).attr("id"),m="com_tjucm."+(a=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),u=jQuery("#"+a).val();if(""==u){i.append("parent_id",r),i.append("client",m),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,u){if(u=JSON.parse(u),null==o)return null!==u.data&&jQuery.isNumeric(u.data.id)&&jQuery("#"+a).val(u.data.id),i.append("jform["+n+"]",m),i.append("client",t),i.append("recordid",r),com_tjucm.Services.Item.saveFieldData(i,function(t,r){var a=jQuery(e).attr("name"),i="[]"==a.slice(-2)?"[]":"",n="jform["+jQuery(e).attr("id").split("__").pop()+"]"+i;"radio"==jQuery(e).attr("type")&&(n="jform["+jQuery(e).attr("name").split("][").pop()),jQuery(e).attr("name",n),tjUcmItemForm.saveUcmFormFieldData(m,u.data.id,e),jQuery(e).attr("name",a)}),!0})}else{if(jQuery.isNumeric(u)&&0!=u){var c=jQuery(e).attr("name"),l="[]"==c.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(m,u,e),jQuery(e).attr("name",c),!0}null==u&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(t,r,e),!0},saveUcmFormFieldData:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a=new FormData;return a.append(Joomla.getOptions("csrf.token"),1),a.append("client",e),a.append("recordid",t),"checkbox"==jQuery(r).attr("type")?1==jQuery(r).prop("checked")?a.append(jQuery(r).attr("name"),1):a.append(jQuery(r).attr("name"),0):jQuery(r).hasClass("tjfieldTjList")?(""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val()),""!=jQuery("input#"+jQuery(r).attr("id")).val()&&null!=jQuery("input#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("input#"+jQuery(r).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(r).attr("id")).data("role")?(""!=jQuery("#"+jQuery(r).attr("id")).val()&&null!=jQuery("#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("#"+jQuery(r).attr("id")).val()),""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val())):"file"!=jQuery(r).attr("type")?a.append(jQuery(r).attr("name"),jQuery(r).val()):a.append(jQuery(r).attr("name"),jQuery(r)[0].files[0]),""!=jQuery(r).attr("name")&&null!=jQuery(r).attr("name")&&com_tjucm.Services.Item.saveFieldData(a,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(e,t){if(jQuery("#item-form #tjucm_loader").hide(),t=JSON.parse(t),jQuery("#item-form").removeClass("dirty"),null==t)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=t.data&&t.data.childContentIds&&jQuery.each(t.data.childContentIds,function(e,t){jQuery("#"+e).val(t)}),t.data&&tjUcmFormFinalSave&&(jQuery("#tjucm-auto-save-disabled-msg").show(),jQuery("#itemState").val(0),jQuery("#tjUcmSectionDraftSave").remove(),tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click")),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click")),tjUcmItemForm.setVisibilityOfNavigationButtons(),t.data){var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(r,a)}tjUcmItemForm.renderResponseMessages(t)},renderResponseMessages:function(e){null!=e&&(null!==e.message&&(e.data?Joomla.renderMessages({success:[e.message]}):Joomla.renderMessages({error:[e.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==e.messages&&null!==e.messages.error&&(jQuery.each(e.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(e,t){var r=new FormData;r.append("client",e),r.append("content_id",t),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(r,function(e,t){if(t=JSON.parse(t),""==(tjucmRelatedFieldUpdatedOptions=t.data))return!1;jQuery.each(t.data,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")})})},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),void 0===event?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?event.target.id:"tjUcmSectionDraftSave";var e=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(!document.formvalidator.isValid(document.getElementById("item-form")))return tjUcmItemForm.setVisibilityOfNavigationButtons(),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),!1;jQuery("#system-message-container").html(""),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),e=0}jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()}),tjUcmItemForm.getUcmParentRecordId(e,function(){var e=document.getElementById("item-form"),t=new FormData(e);t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&t.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery('input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?t.append(jQuery(this).attr("name"),1):t.append(jQuery(this).attr("name"),0)}),void 0!==tjUcmSaveFormInDraftWithNoMsg&&(tjUcmSaveFormInDraftWithNoMsg=void 0,t.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()})},saveSectionData:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var t=new FormData,r=jQuery(e).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(r))return jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),r.length&&r.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&t.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?1==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&t.append(jQuery(this).attr("name"),jQuery(this).val())}),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(){t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),t.append("tjUcmFormSection",jQuery("a[href='"+e+"']").html()),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)})},validateSection:function(e){var t,r,a,i,n,o=!0,m=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),r={error:[]},i=m.length-1;i>=0;i--)(a=jQuery(m[i]).data("label"))&&r.error.push(t+a.text().replace("*",""));Joomla.renderMessages(r)}return o},setVisibilityOfNavigationButtons:function(){var e=jQuery("#tjucm_myTabTabs").find("li.active");jQuery(e).length&&(jQuery(e).next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(e).prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0))}};function steppedFormSave(e,t,r){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(e){this.click()});var a=jQuery("#"+e),i=!1;if(jQuery("#form_status").val(t),"save"==t){if(!document.formvalidator.isValid("#item-form"))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return a&&jQuery(a).ajaxSubmit({datatype:"JSON",async:!1,success:function(e){var a=JSON.parse(e);if(null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.data){jQuery("#recordId").val(a.data.id),"save"==t?(jQuery("#tjUcmSectionFinalSave").attr("disabled","disabled"),Joomla.renderMessages({success:[Joomla.JText._("COM_TJUCM_MSG_ON_SAVED_FORM")]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").offset().top-40},"slow")):(i=!0,"1"===r&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var n=window.location.href.split("#")[0],o=-1===n.indexOf("?")?"?":"&",m="id="+a.data.id;jQuery.each(a.data.childContentIds,function(e,t){jQuery("input[name='"+t.elementName+"']").val(t.content_id)}),tjucmRelatedFieldUpdatedOptions=a.data.relatedFieldOptions,jQuery.each(a.data.relatedFieldOptions,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")}),n.indexOf(m)>=0||(n+=o+m),history.pushState(null,null,n)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(e){this.click()})}}),i}function itemformactions(e,t){var r=jQuery("ul#tjucm_myTabTabs").find("li.active a");null==jQuery(r).next("li")?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),null==jQuery(r).prev("li")?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),next?jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"):jQuery("#tjucm_myTabTabs > .active").next("li").prev("a").trigger("click");var a=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),i=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");null==a?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),null==i?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==t&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==t&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} \ No newline at end of file +var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=new Array,tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=new Array,tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var e=Number(jQuery("#itemState").val()),t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1===e){var a=jQuery("#item-form #tjucm-autosave").val();t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){if(tjUcmCurrentAutoSaveState=1,jQuery("#item-form").on("change select",":input",function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .field-calendar input:text").blur(function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .js-editor-tinymce").length>0){var i=Joomla.getOptions("plg_editor_tinymce");null!=i&&jQuery.each(i.tinyMCE,function(e,t){if(jQuery("#item-form #jform_"+e).length){var r=jQuery("#jform_"+e+"_ifr").contents().find("body").html();tjUcmTinyMCEFieldIds[e]=r}else if(0==jQuery("#item-form #jform_"+e).length&&"default"!=e){var a=jQuery("textarea[id$='__"+e+"']");a.length&&jQuery.each(a,function(e,t){var r=jQuery(t).attr("id"),a=jQuery("#"+r+"_ifr").contents().find("body").html(),i=r.replace("jform_","");tjUcmTinyMCEFieldIds[i]=a})}})}jQuery("#item-form .wf-editor-container").length>0&&setTimeout(function(){jQuery("#item-form .mceIframeContainer iframe").each(function(){var e=jQuery(this).attr("id"),t=e.replace("jform_","").replace("_ifr",""),r=jQuery("#"+e).contents().find("body").html();tjUcmJCEFieldIds[t]=r})},2e3),1==a&&1==t&&void 0!==r&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){for(var e in(jQuery("#item-form").hasClass("dirty")||0===tjUcmFormSavedByBitRateConfig)&&(tjUcmFormSavedByBitRateConfig=1,jQuery("#tjUcmSectionDraftSave").click()),tjUcmJCEFieldIds)if(tjUcmJCEFieldIds.hasOwnProperty(e)){var t=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmJCEFieldIds[e]!=t){var r=jQuery("#jform_"+e);r.length&&(r.val(t),tjUcmJCEFieldIds[e]=t,tjUcmItemForm.onUcmFormChange(r))}}if(jQuery("#item-form .js-editor-tinymce").length>0)for(var e in tjUcmTinyMCEFieldIds)if(tjUcmTinyMCEFieldIds.hasOwnProperty(e)){var a=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmTinyMCEFieldIds[e]!=a){var i=jQuery("#jform_"+e);i.length&&(i.val(a),tjUcmTinyMCEFieldIds[e]=a,tjUcmItemForm.onUcmFormChange(i))}}},1e3*r)}}else jQuery("#tjucm-auto-save-disabled-msg").show();jQuery("#tjucm_myTabTabs a").on("click",function(){jQuery(this).parent().next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(this).parent().prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0)}),jQuery(document).on("subform-row-add",function(e,t){var r,a=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")&&(r=jQuery(t).find(".js-editor-tinymce textarea").attr("id"))){var i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}if(jQuery(t).find(".wf-editor-container textarea")&&(r=jQuery(t).find(".wf-editor-container textarea").attr("id"))){i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}jQuery.each(tjucmRelatedFieldUpdatedOptions,function(e,r){if(r.templateId){var i=r.templateId.replace("XXX_XXX",a);jQuery(t).find("#"+i).html(""),jQuery.each(r.options,function(e,r){jQuery(t).find("#"+i).append('")}),jQuery(t).find("#"+i).trigger("liszt:updated")}})}),jQuery("#next_button, #previous_button").on("click",function(){if("next_button"==jQuery(this).attr("id")?tjUcmClickedOnNext=1:tjUcmClickedOnPrev=1,jQuery("#item-form").hasClass("dirty"))if(tjUcmCurrentAutoSaveState){var e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(e,t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(t,a){var i=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==i){var n=new FormData;""!=r&&n.append("client",r),n.append(Joomla.getOptions("csrf.token"),1);n.append("draft",e),com_tjucm.Services.Item.create(n,function(e,r){if(r=JSON.parse(r),null==e)if(null!==r.data&&jQuery.isNumeric(r.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(r.data.id);var i=window.location.href.split("#")[0],n=-1===i.indexOf("?")?"?":"&",o="id="+r.data.id;i.indexOf(o)>=0||(i+=n+o),history.pushState(null,null,i),t(r.data.id)}else a(r)})}else jQuery.isNumeric(i)&&0!=i&&t(i)}).then(function(e){t(e)}).catch(function(e){return console.log(e),!1})},onUcmFormChange:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(e,r,t)})},initUcmFormFieldDataSave:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a="",i=new FormData;if(i.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(e).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(e).parent().parent().parent().parent().attr("data-base-name")){var n=jQuery(e).parent().parent().parent().attr("data-base-name");null==n&&(n=jQuery(e).parent().parent().parent().parent().attr("data-base-name"));var o=jQuery(e).attr("id"),m="com_tjucm."+(a=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),u=jQuery("#"+a).val();if(""==u){i.append("parent_id",r),i.append("client",m),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,u){if(u=JSON.parse(u),null==o)return null!==u.data&&jQuery.isNumeric(u.data.id)&&jQuery("#"+a).val(u.data.id),i.append("jform["+n+"]",m),i.append("client",t),i.append("recordid",r),com_tjucm.Services.Item.saveFieldData(i,function(t,r){var a=jQuery(e).attr("name"),i="[]"==a.slice(-2)?"[]":"",n="jform["+jQuery(e).attr("id").split("__").pop()+"]"+i;"radio"==jQuery(e).attr("type")&&(n="jform["+jQuery(e).attr("name").split("][").pop()),jQuery(e).attr("name",n),tjUcmItemForm.saveUcmFormFieldData(m,u.data.id,e),jQuery(e).attr("name",a)}),!0})}else{if(jQuery.isNumeric(u)&&0!=u){var c=jQuery(e).attr("name"),l="[]"==c.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(m,u,e),jQuery(e).attr("name",c),!0}null==u&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(t,r,e),!0},saveUcmFormFieldData:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a=new FormData;return a.append(Joomla.getOptions("csrf.token"),1),a.append("client",e),a.append("recordid",t),"checkbox"==jQuery(r).attr("type")?1==jQuery(r).prop("checked")?a.append(jQuery(r).attr("name"),1):a.append(jQuery(r).attr("name"),0):jQuery(r).hasClass("tjfieldTjList")?(""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val()),""!=jQuery("input#"+jQuery(r).attr("id")).val()&&null!=jQuery("input#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("input#"+jQuery(r).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(r).attr("id")).data("role")?(""!=jQuery("#"+jQuery(r).attr("id")).val()&&null!=jQuery("#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("#"+jQuery(r).attr("id")).val()),""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val())):"file"!=jQuery(r).attr("type")?a.append(jQuery(r).attr("name"),jQuery(r).val()):a.append(jQuery(r).attr("name"),jQuery(r)[0].files[0]),""!=jQuery(r).attr("name")&&null!=jQuery(r).attr("name")&&com_tjucm.Services.Item.saveFieldData(a,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(e,t){if(jQuery("#item-form #tjucm_loader").hide(),t=JSON.parse(t),jQuery("#item-form").removeClass("dirty"),null==t)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=t.data&&t.data.childContentIds&&jQuery.each(t.data.childContentIds,function(e,t){jQuery("#"+e).val(t)}),t.data&&tjUcmFormFinalSave&&(jQuery("#tjucm-auto-save-disabled-msg").show(),jQuery("#itemState").val(0),jQuery("#tjUcmSectionDraftSave").remove(),tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click")),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click")),tjUcmItemForm.setVisibilityOfNavigationButtons(),t.data){var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(r,a)}tjUcmItemForm.renderResponseMessages(t)},renderResponseMessages:function(e){null!=e&&(null!==e.message&&(e.data?Joomla.renderMessages({success:[e.message]}):Joomla.renderMessages({error:[e.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==e.messages&&null!==e.messages.error&&(jQuery.each(e.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(e,t){var r=new FormData;r.append("client",e),r.append("content_id",t),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(r,function(e,t){if(t=JSON.parse(t),""==(tjucmRelatedFieldUpdatedOptions=t.data))return!1;jQuery.each(t.data,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")})})},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),void 0===event?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?event.target.id:"tjUcmSectionDraftSave";var e=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(!document.formvalidator.isValid(document.getElementById("item-form")))return tjUcmItemForm.setVisibilityOfNavigationButtons(),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),!1;jQuery("#system-message-container").html(""),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),e=0}jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()}),tjUcmItemForm.getUcmParentRecordId(e,function(){var e=document.getElementById("item-form"),t=new FormData(e);t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&t.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery('#item-form input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?t.append(jQuery(this).attr("name"),1):t.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){t.append(jQuery(this).attr("name"),jQuery(this).val())}),void 0!==tjUcmSaveFormInDraftWithNoMsg&&(tjUcmSaveFormInDraftWithNoMsg=void 0,t.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()})},saveSectionData:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var t=new FormData,r=jQuery(e).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(r))return jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),r.length&&r.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&t.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?1==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&t.append(jQuery(this).attr("name"),jQuery(this).val())}),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(){t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),t.append("tjUcmFormSection",jQuery("a[href='"+e+"']").html()),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)})},validateSection:function(e){var t,r,a,i,n,o=!0,m=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),r={error:[]},i=m.length-1;i>=0;i--)(a=jQuery(m[i]).data("label"))&&r.error.push(t+a.text().replace("*",""));Joomla.renderMessages(r)}return o},setVisibilityOfNavigationButtons:function(){var e=jQuery("#tjucm_myTabTabs").find("li.active");jQuery(e).length&&(jQuery(e).next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(e).prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0))}};function steppedFormSave(e,t,r){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(e){this.click()});var a=jQuery("#"+e),i=!1;if(jQuery("#form_status").val(t),"save"==t){if(!document.formvalidator.isValid("#item-form"))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return a&&jQuery(a).ajaxSubmit({datatype:"JSON",async:!1,success:function(e){var a=JSON.parse(e);if(null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.data){jQuery("#recordId").val(a.data.id),"save"==t?(jQuery("#tjUcmSectionFinalSave").attr("disabled","disabled"),Joomla.renderMessages({success:[Joomla.JText._("COM_TJUCM_MSG_ON_SAVED_FORM")]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").offset().top-40},"slow")):(i=!0,"1"===r&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var n=window.location.href.split("#")[0],o=-1===n.indexOf("?")?"?":"&",m="id="+a.data.id;jQuery.each(a.data.childContentIds,function(e,t){jQuery("input[name='"+t.elementName+"']").val(t.content_id)}),tjucmRelatedFieldUpdatedOptions=a.data.relatedFieldOptions,jQuery.each(a.data.relatedFieldOptions,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")}),n.indexOf(m)>=0||(n+=o+m),history.pushState(null,null,n)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(e){this.click()})}}),i}function itemformactions(e,t){var r=jQuery("ul#tjucm_myTabTabs").find("li.active a");null==jQuery(r).next("li")?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),null==jQuery(r).prev("li")?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),next?jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"):jQuery("#tjucm_myTabTabs > .active").next("li").prev("a").trigger("click");var a=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),i=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");null==a?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),null==i?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==t&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==t&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} \ No newline at end of file From bc09d06e82357008daf613ba0bcd07cc90ae4560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 6 Apr 2020 18:09:35 +0530 Subject: [PATCH 30/42] Bug #156605 fix: The dropdown of tjlist type field didn't get reset. It shows old value as it is --- src/components/com_tjucm/site/views/item/tmpl/default.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/views/item/tmpl/default.php b/src/components/com_tjucm/site/views/item/tmpl/default.php index ecf92def..a1e30e63 100644 --- a/src/components/com_tjucm/site/views/item/tmpl/default.php +++ b/src/components/com_tjucm/site/views/item/tmpl/default.php @@ -13,6 +13,7 @@ JText::script('COM_TJUCM_DELETE_MESSAGE'); $user = JFactory::getUser(); +$tjUcmFrontendHelper = new TjucmHelpersTjucm; if ($this->form_extra) { @@ -75,6 +76,10 @@ client; + $itemId = $tjUcmFrontendHelper->getItemId($link); ?> + - + \ No newline at end of file From 5b4a018f7f2547b62be52fa18b2d6aa18a8abe09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 13 Apr 2020 18:40:40 +0530 Subject: [PATCH 31/42] Task #159950 feat: Date range filters to filter records as per the creation datre of records --- .../com_tjucm/site/models/items.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index d41b5a62..a483249f 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -157,6 +157,26 @@ protected function populateState($ordering = "a.id", $direction = "DESC") $direction = $this->getUserStateFromRequest($this->context . $ucmType . '.filter.order_Dir', 'filter_order_Dir', '', 'string'); } + $fromDate = $this->getUserStateFromRequest($this->context . '.fromDate', 'fromDate', '', 'STRING'); + $toDate = $this->getUserStateFromRequest($this->context . '.toDate', 'toDate', '', 'STRING'); + + if (!empty($fromDate) || !empty($toDate)) + { + $fromDate = empty($fromDate) ? JFactory::getDate('now -1 month')->toSql() : JFactory::getDate($fromDate)->toSql(); + $toDate = empty($toDate) ? JFactory::getDate('now')->toSql() : JFactory::getDate($toDate)->toSql(); + + // If from date is less than to date then swipe the dates + if ($fromDate > $toDate) + { + $tmpDate = $fromDate; + $fromDate = $toDate; + $toDate = $tmpDate; + } + + $this->setState($ucmType . ".filter.fromDate", $fromDate); + $this->setState($ucmType . ".filter.toDate", $toDate); + } + // List state information. parent::populateState($ordering, $direction); } @@ -296,6 +316,14 @@ protected function getListQuery() } } + $fromDate = $this->getState($client . '.filter.fromDate'); + $toDate = $this->getState($client . '.filter.toDate'); + + if (!empty($fromDate) || !empty($toDate)) + { + $query->where('DATE(' . $db->quoteName('a.created_date') . ') ' . ' BETWEEN ' . $db->quote($fromDate) . ' AND ' . $db->quote($toDate)); + } + // Search on fields data $filteredItemIds = $this->filterContent($client); From 18117a5ae4498386173e3698d2a05f137968cca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 22 Apr 2020 19:45:27 +0530 Subject: [PATCH 32/42] Task #159950 fix: Date range filters to filter records as per the creation datre of records --- src/components/com_tjucm/site/models/itemform.php | 2 ++ src/components/com_tjucm/site/models/items.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index d8c69dcb..5b399d7c 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -22,6 +22,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\Registry\Registry; +JLoader::register('TjucmAccess', JPATH_SITE . '/components/com_tjucm/includes/access.php'); + /** * Tjucm model. * diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index a483249f..03b24d34 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -284,7 +284,7 @@ protected function getListQuery() } // Filter by published state - $published = $this->getState('filter.state'); + $published = $this->getState('filter.state', ''); if (is_numeric($published)) { @@ -292,7 +292,7 @@ protected function getListQuery() } elseif ($published === '') { - $query->where(($db->quoteName('(a.state) ') . ' IN (0, 1)')); + $query->where(($db->quoteName('a.state') . ' IN (0, 1)')); } // Filter by draft status From 344a77d7080909ac89b74e4f72f30fc768388b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Thu, 23 Apr 2020 12:47:39 +0530 Subject: [PATCH 33/42] Bug #159554 fix: Loader is missing when the form is submitted to save the record --- src/components/com_tjucm/media/js/ui/itemform.js | 8 ++++---- src/components/com_tjucm/media/js/ui/itemform.min.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index c8b73a36..23e6a8e2 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -732,10 +732,6 @@ var tjUcmItemForm = { /* Disable the action buttons before performing the action*/ jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', true); - /* Show loader when record is saved*/ - jQuery("#item-form #tjucm_loader").show(); - jQuery("html, body").animate({scrollTop: jQuery("#item-form #tjucm_loader").position().top}, "slow"); - /* In case of save through bitrate setting event will be undefined*/ if (event === undefined) { @@ -795,6 +791,10 @@ var tjUcmItemForm = { this.click(); }); + /* Show loader when record is saved*/ + jQuery("#item-form #tjucm_loader").show(); + jQuery("html, body").animate({scrollTop: jQuery("#item-form #tjucm_loader").position().top}, "slow"); + tjUcmItemForm.getUcmParentRecordId(tjUcmSaveRecordAsDraft, function (){ var tjUcmForm = document.getElementById('item-form'); var tjUcmItemFormData = new FormData(tjUcmForm); diff --git a/src/components/com_tjucm/media/js/ui/itemform.min.js b/src/components/com_tjucm/media/js/ui/itemform.min.js index 475185f2..f826728c 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.min.js +++ b/src/components/com_tjucm/media/js/ui/itemform.min.js @@ -1 +1 @@ -var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=new Array,tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=new Array,tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var e=Number(jQuery("#itemState").val()),t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1===e){var a=jQuery("#item-form #tjucm-autosave").val();t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){if(tjUcmCurrentAutoSaveState=1,jQuery("#item-form").on("change select",":input",function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .field-calendar input:text").blur(function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .js-editor-tinymce").length>0){var i=Joomla.getOptions("plg_editor_tinymce");null!=i&&jQuery.each(i.tinyMCE,function(e,t){if(jQuery("#item-form #jform_"+e).length){var r=jQuery("#jform_"+e+"_ifr").contents().find("body").html();tjUcmTinyMCEFieldIds[e]=r}else if(0==jQuery("#item-form #jform_"+e).length&&"default"!=e){var a=jQuery("textarea[id$='__"+e+"']");a.length&&jQuery.each(a,function(e,t){var r=jQuery(t).attr("id"),a=jQuery("#"+r+"_ifr").contents().find("body").html(),i=r.replace("jform_","");tjUcmTinyMCEFieldIds[i]=a})}})}jQuery("#item-form .wf-editor-container").length>0&&setTimeout(function(){jQuery("#item-form .mceIframeContainer iframe").each(function(){var e=jQuery(this).attr("id"),t=e.replace("jform_","").replace("_ifr",""),r=jQuery("#"+e).contents().find("body").html();tjUcmJCEFieldIds[t]=r})},2e3),1==a&&1==t&&void 0!==r&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){for(var e in(jQuery("#item-form").hasClass("dirty")||0===tjUcmFormSavedByBitRateConfig)&&(tjUcmFormSavedByBitRateConfig=1,jQuery("#tjUcmSectionDraftSave").click()),tjUcmJCEFieldIds)if(tjUcmJCEFieldIds.hasOwnProperty(e)){var t=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmJCEFieldIds[e]!=t){var r=jQuery("#jform_"+e);r.length&&(r.val(t),tjUcmJCEFieldIds[e]=t,tjUcmItemForm.onUcmFormChange(r))}}if(jQuery("#item-form .js-editor-tinymce").length>0)for(var e in tjUcmTinyMCEFieldIds)if(tjUcmTinyMCEFieldIds.hasOwnProperty(e)){var a=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmTinyMCEFieldIds[e]!=a){var i=jQuery("#jform_"+e);i.length&&(i.val(a),tjUcmTinyMCEFieldIds[e]=a,tjUcmItemForm.onUcmFormChange(i))}}},1e3*r)}}else jQuery("#tjucm-auto-save-disabled-msg").show();jQuery("#tjucm_myTabTabs a").on("click",function(){jQuery(this).parent().next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(this).parent().prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0)}),jQuery(document).on("subform-row-add",function(e,t){var r,a=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")&&(r=jQuery(t).find(".js-editor-tinymce textarea").attr("id"))){var i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}if(jQuery(t).find(".wf-editor-container textarea")&&(r=jQuery(t).find(".wf-editor-container textarea").attr("id"))){i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}jQuery.each(tjucmRelatedFieldUpdatedOptions,function(e,r){if(r.templateId){var i=r.templateId.replace("XXX_XXX",a);jQuery(t).find("#"+i).html(""),jQuery.each(r.options,function(e,r){jQuery(t).find("#"+i).append('")}),jQuery(t).find("#"+i).trigger("liszt:updated")}})}),jQuery("#next_button, #previous_button").on("click",function(){if("next_button"==jQuery(this).attr("id")?tjUcmClickedOnNext=1:tjUcmClickedOnPrev=1,jQuery("#item-form").hasClass("dirty"))if(tjUcmCurrentAutoSaveState){var e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(e,t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(t,a){var i=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==i){var n=new FormData;""!=r&&n.append("client",r),n.append(Joomla.getOptions("csrf.token"),1);n.append("draft",e),com_tjucm.Services.Item.create(n,function(e,r){if(r=JSON.parse(r),null==e)if(null!==r.data&&jQuery.isNumeric(r.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(r.data.id);var i=window.location.href.split("#")[0],n=-1===i.indexOf("?")?"?":"&",o="id="+r.data.id;i.indexOf(o)>=0||(i+=n+o),history.pushState(null,null,i),t(r.data.id)}else a(r)})}else jQuery.isNumeric(i)&&0!=i&&t(i)}).then(function(e){t(e)}).catch(function(e){return console.log(e),!1})},onUcmFormChange:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(e,r,t)})},initUcmFormFieldDataSave:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a="",i=new FormData;if(i.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(e).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(e).parent().parent().parent().parent().attr("data-base-name")){var n=jQuery(e).parent().parent().parent().attr("data-base-name");null==n&&(n=jQuery(e).parent().parent().parent().parent().attr("data-base-name"));var o=jQuery(e).attr("id"),m="com_tjucm."+(a=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),u=jQuery("#"+a).val();if(""==u){i.append("parent_id",r),i.append("client",m),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,u){if(u=JSON.parse(u),null==o)return null!==u.data&&jQuery.isNumeric(u.data.id)&&jQuery("#"+a).val(u.data.id),i.append("jform["+n+"]",m),i.append("client",t),i.append("recordid",r),com_tjucm.Services.Item.saveFieldData(i,function(t,r){var a=jQuery(e).attr("name"),i="[]"==a.slice(-2)?"[]":"",n="jform["+jQuery(e).attr("id").split("__").pop()+"]"+i;"radio"==jQuery(e).attr("type")&&(n="jform["+jQuery(e).attr("name").split("][").pop()),jQuery(e).attr("name",n),tjUcmItemForm.saveUcmFormFieldData(m,u.data.id,e),jQuery(e).attr("name",a)}),!0})}else{if(jQuery.isNumeric(u)&&0!=u){var c=jQuery(e).attr("name"),l="[]"==c.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(m,u,e),jQuery(e).attr("name",c),!0}null==u&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(t,r,e),!0},saveUcmFormFieldData:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a=new FormData;return a.append(Joomla.getOptions("csrf.token"),1),a.append("client",e),a.append("recordid",t),"checkbox"==jQuery(r).attr("type")?1==jQuery(r).prop("checked")?a.append(jQuery(r).attr("name"),1):a.append(jQuery(r).attr("name"),0):jQuery(r).hasClass("tjfieldTjList")?(""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val()),""!=jQuery("input#"+jQuery(r).attr("id")).val()&&null!=jQuery("input#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("input#"+jQuery(r).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(r).attr("id")).data("role")?(""!=jQuery("#"+jQuery(r).attr("id")).val()&&null!=jQuery("#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("#"+jQuery(r).attr("id")).val()),""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val())):"file"!=jQuery(r).attr("type")?a.append(jQuery(r).attr("name"),jQuery(r).val()):a.append(jQuery(r).attr("name"),jQuery(r)[0].files[0]),""!=jQuery(r).attr("name")&&null!=jQuery(r).attr("name")&&com_tjucm.Services.Item.saveFieldData(a,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(e,t){if(jQuery("#item-form #tjucm_loader").hide(),t=JSON.parse(t),jQuery("#item-form").removeClass("dirty"),null==t)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=t.data&&t.data.childContentIds&&jQuery.each(t.data.childContentIds,function(e,t){jQuery("#"+e).val(t)}),t.data&&tjUcmFormFinalSave&&(jQuery("#tjucm-auto-save-disabled-msg").show(),jQuery("#itemState").val(0),jQuery("#tjUcmSectionDraftSave").remove(),tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click")),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click")),tjUcmItemForm.setVisibilityOfNavigationButtons(),t.data){var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(r,a)}tjUcmItemForm.renderResponseMessages(t)},renderResponseMessages:function(e){null!=e&&(null!==e.message&&(e.data?Joomla.renderMessages({success:[e.message]}):Joomla.renderMessages({error:[e.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==e.messages&&null!==e.messages.error&&(jQuery.each(e.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(e,t){var r=new FormData;r.append("client",e),r.append("content_id",t),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(r,function(e,t){if(t=JSON.parse(t),""==(tjucmRelatedFieldUpdatedOptions=t.data))return!1;jQuery.each(t.data,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")})})},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),void 0===event?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?event.target.id:"tjUcmSectionDraftSave";var e=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(!document.formvalidator.isValid(document.getElementById("item-form")))return tjUcmItemForm.setVisibilityOfNavigationButtons(),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),!1;jQuery("#system-message-container").html(""),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),e=0}jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()}),tjUcmItemForm.getUcmParentRecordId(e,function(){var e=document.getElementById("item-form"),t=new FormData(e);t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&t.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery('#item-form input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?t.append(jQuery(this).attr("name"),1):t.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){t.append(jQuery(this).attr("name"),jQuery(this).val())}),void 0!==tjUcmSaveFormInDraftWithNoMsg&&(tjUcmSaveFormInDraftWithNoMsg=void 0,t.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()})},saveSectionData:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var t=new FormData,r=jQuery(e).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(r))return jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),r.length&&r.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&t.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?1==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&t.append(jQuery(this).attr("name"),jQuery(this).val())}),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(){t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),t.append("tjUcmFormSection",jQuery("a[href='"+e+"']").html()),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)})},validateSection:function(e){var t,r,a,i,n,o=!0,m=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),r={error:[]},i=m.length-1;i>=0;i--)(a=jQuery(m[i]).data("label"))&&r.error.push(t+a.text().replace("*",""));Joomla.renderMessages(r)}return o},setVisibilityOfNavigationButtons:function(){var e=jQuery("#tjucm_myTabTabs").find("li.active");jQuery(e).length&&(jQuery(e).next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(e).prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0))}};function steppedFormSave(e,t,r){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(e){this.click()});var a=jQuery("#"+e),i=!1;if(jQuery("#form_status").val(t),"save"==t){if(!document.formvalidator.isValid("#item-form"))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return a&&jQuery(a).ajaxSubmit({datatype:"JSON",async:!1,success:function(e){var a=JSON.parse(e);if(null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.data){jQuery("#recordId").val(a.data.id),"save"==t?(jQuery("#tjUcmSectionFinalSave").attr("disabled","disabled"),Joomla.renderMessages({success:[Joomla.JText._("COM_TJUCM_MSG_ON_SAVED_FORM")]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").offset().top-40},"slow")):(i=!0,"1"===r&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var n=window.location.href.split("#")[0],o=-1===n.indexOf("?")?"?":"&",m="id="+a.data.id;jQuery.each(a.data.childContentIds,function(e,t){jQuery("input[name='"+t.elementName+"']").val(t.content_id)}),tjucmRelatedFieldUpdatedOptions=a.data.relatedFieldOptions,jQuery.each(a.data.relatedFieldOptions,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")}),n.indexOf(m)>=0||(n+=o+m),history.pushState(null,null,n)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(e){this.click()})}}),i}function itemformactions(e,t){var r=jQuery("ul#tjucm_myTabTabs").find("li.active a");null==jQuery(r).next("li")?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),null==jQuery(r).prev("li")?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),next?jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"):jQuery("#tjucm_myTabTabs > .active").next("li").prev("a").trigger("click");var a=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),i=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");null==a?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),null==i?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==t&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==t&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} \ No newline at end of file +var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=new Array,tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=new Array,tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var e=Number(jQuery("#itemState").val()),t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1===e){var a=jQuery("#item-form #tjucm-autosave").val();t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){if(tjUcmCurrentAutoSaveState=1,jQuery("#item-form").on("change select",":input",function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .field-calendar input:text").blur(function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .js-editor-tinymce").length>0){var i=Joomla.getOptions("plg_editor_tinymce");null!=i&&jQuery.each(i.tinyMCE,function(e,t){if(jQuery("#item-form #jform_"+e).length){var r=jQuery("#jform_"+e+"_ifr").contents().find("body").html();tjUcmTinyMCEFieldIds[e]=r}else if(0==jQuery("#item-form #jform_"+e).length&&"default"!=e){var a=jQuery("textarea[id$='__"+e+"']");a.length&&jQuery.each(a,function(e,t){var r=jQuery(t).attr("id"),a=jQuery("#"+r+"_ifr").contents().find("body").html(),i=r.replace("jform_","");tjUcmTinyMCEFieldIds[i]=a})}})}jQuery("#item-form .wf-editor-container").length>0&&setTimeout(function(){jQuery("#item-form .mceIframeContainer iframe").each(function(){var e=jQuery(this).attr("id"),t=e.replace("jform_","").replace("_ifr",""),r=jQuery("#"+e).contents().find("body").html();tjUcmJCEFieldIds[t]=r})},2e3),1==a&&1==t&&void 0!==r&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){for(var e in(jQuery("#item-form").hasClass("dirty")||0===tjUcmFormSavedByBitRateConfig)&&(tjUcmFormSavedByBitRateConfig=1,jQuery("#tjUcmSectionDraftSave").click()),tjUcmJCEFieldIds)if(tjUcmJCEFieldIds.hasOwnProperty(e)){var t=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmJCEFieldIds[e]!=t){var r=jQuery("#jform_"+e);r.length&&(r.val(t),tjUcmJCEFieldIds[e]=t,tjUcmItemForm.onUcmFormChange(r))}}if(jQuery("#item-form .js-editor-tinymce").length>0)for(var e in tjUcmTinyMCEFieldIds)if(tjUcmTinyMCEFieldIds.hasOwnProperty(e)){var a=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmTinyMCEFieldIds[e]!=a){var i=jQuery("#jform_"+e);i.length&&(i.val(a),tjUcmTinyMCEFieldIds[e]=a,tjUcmItemForm.onUcmFormChange(i))}}},1e3*r)}}else jQuery("#tjucm-auto-save-disabled-msg").show();jQuery("#tjucm_myTabTabs a").on("click",function(){jQuery(this).parent().next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(this).parent().prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0)}),jQuery(document).on("subform-row-add",function(e,t){var r,a=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")&&(r=jQuery(t).find(".js-editor-tinymce textarea").attr("id"))){var i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}if(jQuery(t).find(".wf-editor-container textarea")&&(r=jQuery(t).find(".wf-editor-container textarea").attr("id"))){i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}jQuery.each(tjucmRelatedFieldUpdatedOptions,function(e,r){if(r.templateId){var i=r.templateId.replace("XXX_XXX",a);jQuery(t).find("#"+i).html(""),jQuery.each(r.options,function(e,r){jQuery(t).find("#"+i).append('")}),jQuery(t).find("#"+i).trigger("liszt:updated")}})}),jQuery("#next_button, #previous_button").on("click",function(){if("next_button"==jQuery(this).attr("id")?tjUcmClickedOnNext=1:tjUcmClickedOnPrev=1,jQuery("#item-form").hasClass("dirty"))if(tjUcmCurrentAutoSaveState){var e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(e,t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(t,a){var i=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==i){var n=new FormData;""!=r&&n.append("client",r),n.append(Joomla.getOptions("csrf.token"),1);n.append("draft",e),com_tjucm.Services.Item.create(n,function(e,r){if(r=JSON.parse(r),null==e)if(null!==r.data&&jQuery.isNumeric(r.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(r.data.id);var i=window.location.href.split("#")[0],n=-1===i.indexOf("?")?"?":"&",o="id="+r.data.id;i.indexOf(o)>=0||(i+=n+o),history.pushState(null,null,i),t(r.data.id)}else a(r)})}else jQuery.isNumeric(i)&&0!=i&&t(i)}).then(function(e){t(e)}).catch(function(e){return console.log(e),!1})},onUcmFormChange:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(e,r,t)})},initUcmFormFieldDataSave:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a="",i=new FormData;if(i.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(e).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(e).parent().parent().parent().parent().attr("data-base-name")){var n=jQuery(e).parent().parent().parent().attr("data-base-name");null==n&&(n=jQuery(e).parent().parent().parent().parent().attr("data-base-name"));var o=jQuery(e).attr("id"),m="com_tjucm."+(a=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),u=jQuery("#"+a).val();if(""==u){i.append("parent_id",r),i.append("client",m),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,u){if(u=JSON.parse(u),null==o)return null!==u.data&&jQuery.isNumeric(u.data.id)&&jQuery("#"+a).val(u.data.id),i.append("jform["+n+"]",m),i.append("client",t),i.append("recordid",r),com_tjucm.Services.Item.saveFieldData(i,function(t,r){var a=jQuery(e).attr("name"),i="[]"==a.slice(-2)?"[]":"",n="jform["+jQuery(e).attr("id").split("__").pop()+"]"+i;"radio"==jQuery(e).attr("type")&&(n="jform["+jQuery(e).attr("name").split("][").pop()),jQuery(e).attr("name",n),tjUcmItemForm.saveUcmFormFieldData(m,u.data.id,e),jQuery(e).attr("name",a)}),!0})}else{if(jQuery.isNumeric(u)&&0!=u){var c=jQuery(e).attr("name"),l="[]"==c.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(m,u,e),jQuery(e).attr("name",c),!0}null==u&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(t,r,e),!0},saveUcmFormFieldData:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a=new FormData;return a.append(Joomla.getOptions("csrf.token"),1),a.append("client",e),a.append("recordid",t),"checkbox"==jQuery(r).attr("type")?1==jQuery(r).prop("checked")?a.append(jQuery(r).attr("name"),1):a.append(jQuery(r).attr("name"),0):jQuery(r).hasClass("tjfieldTjList")?(""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val()),""!=jQuery("input#"+jQuery(r).attr("id")).val()&&null!=jQuery("input#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("input#"+jQuery(r).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(r).attr("id")).data("role")?(""!=jQuery("#"+jQuery(r).attr("id")).val()&&null!=jQuery("#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("#"+jQuery(r).attr("id")).val()),""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val())):"file"!=jQuery(r).attr("type")?a.append(jQuery(r).attr("name"),jQuery(r).val()):a.append(jQuery(r).attr("name"),jQuery(r)[0].files[0]),""!=jQuery(r).attr("name")&&null!=jQuery(r).attr("name")&&com_tjucm.Services.Item.saveFieldData(a,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(e,t){if(jQuery("#item-form #tjucm_loader").hide(),t=JSON.parse(t),jQuery("#item-form").removeClass("dirty"),null==t)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=t.data&&t.data.childContentIds&&jQuery.each(t.data.childContentIds,function(e,t){jQuery("#"+e).val(t)}),t.data&&tjUcmFormFinalSave&&(jQuery("#tjucm-auto-save-disabled-msg").show(),jQuery("#itemState").val(0),jQuery("#tjUcmSectionDraftSave").remove(),tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click")),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click")),tjUcmItemForm.setVisibilityOfNavigationButtons(),t.data){var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(r,a)}tjUcmItemForm.renderResponseMessages(t)},renderResponseMessages:function(e){null!=e&&(null!==e.message&&(e.data?Joomla.renderMessages({success:[e.message]}):Joomla.renderMessages({error:[e.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==e.messages&&null!==e.messages.error&&(jQuery.each(e.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(e,t){var r=new FormData;r.append("client",e),r.append("content_id",t),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(r,function(e,t){if(t=JSON.parse(t),""==(tjucmRelatedFieldUpdatedOptions=t.data))return!1;jQuery.each(t.data,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")})})},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),void 0===event?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?event.target.id:"tjUcmSectionDraftSave";var e=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(!document.formvalidator.isValid(document.getElementById("item-form")))return tjUcmItemForm.setVisibilityOfNavigationButtons(),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),!1;jQuery("#system-message-container").html(""),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),e=0}jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(e,function(){var e=document.getElementById("item-form"),t=new FormData(e);t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&t.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery('#item-form input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?t.append(jQuery(this).attr("name"),1):t.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){t.append(jQuery(this).attr("name"),jQuery(this).val())}),void 0!==tjUcmSaveFormInDraftWithNoMsg&&(tjUcmSaveFormInDraftWithNoMsg=void 0,t.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()})},saveSectionData:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var t=new FormData,r=jQuery(e).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(r))return jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),r.length&&r.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&t.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?1==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&t.append(jQuery(this).attr("name"),jQuery(this).val())}),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(){t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),t.append("tjUcmFormSection",jQuery("a[href='"+e+"']").html()),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)})},validateSection:function(e){var t,r,a,i,n,o=!0,m=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),r={error:[]},i=m.length-1;i>=0;i--)(a=jQuery(m[i]).data("label"))&&r.error.push(t+a.text().replace("*",""));Joomla.renderMessages(r)}return o},setVisibilityOfNavigationButtons:function(){var e=jQuery("#tjucm_myTabTabs").find("li.active");jQuery(e).length&&(jQuery(e).next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(e).prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0))}};function steppedFormSave(e,t,r){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(e){this.click()});var a=jQuery("#"+e),i=!1;if(jQuery("#form_status").val(t),"save"==t){if(!document.formvalidator.isValid("#item-form"))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return a&&jQuery(a).ajaxSubmit({datatype:"JSON",async:!1,success:function(e){var a=JSON.parse(e);if(null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.data){jQuery("#recordId").val(a.data.id),"save"==t?(jQuery("#tjUcmSectionFinalSave").attr("disabled","disabled"),Joomla.renderMessages({success:[Joomla.JText._("COM_TJUCM_MSG_ON_SAVED_FORM")]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").offset().top-40},"slow")):(i=!0,"1"===r&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var n=window.location.href.split("#")[0],o=-1===n.indexOf("?")?"?":"&",m="id="+a.data.id;jQuery.each(a.data.childContentIds,function(e,t){jQuery("input[name='"+t.elementName+"']").val(t.content_id)}),tjucmRelatedFieldUpdatedOptions=a.data.relatedFieldOptions,jQuery.each(a.data.relatedFieldOptions,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")}),n.indexOf(m)>=0||(n+=o+m),history.pushState(null,null,n)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(e){this.click()})}}),i}function itemformactions(e,t){var r=jQuery("ul#tjucm_myTabTabs").find("li.active a");null==jQuery(r).next("li")?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),null==jQuery(r).prev("li")?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),next?jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"):jQuery("#tjucm_myTabTabs > .active").next("li").prev("a").trigger("click");var a=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),i=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");null==a?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),null==i?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==t&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==t&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} \ No newline at end of file From 0fafca2b4a63a4c9e53dbe7a068640120ebf7df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 24 Apr 2020 14:31:28 +0530 Subject: [PATCH 34/42] Task #158681 fix: Update UCM code to use access file in includes to check permissions --- .../com_tjucm/site/includes/access.php | 24 +++++++++---------- .../site/views/itemform/tmpl/default.php | 3 ++- .../site/views/items/tmpl/default_filters.php | 2 +- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/components/com_tjucm/site/includes/access.php b/src/components/com_tjucm/site/includes/access.php index 8006936e..7f698413 100644 --- a/src/components/com_tjucm/site/includes/access.php +++ b/src/components/com_tjucm/site/includes/access.php @@ -40,7 +40,7 @@ public static function canCreate($ucmTypeId) { JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); - return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.createitem'); + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.createitem.' . $ucmTypeId); } } else @@ -61,7 +61,7 @@ public static function canImport($ucmTypeId) { JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); - return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.importitem') && RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.createtitem'); + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.importitem.' . $ucmTypeId) && RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.createtitem.' . $ucmTypeId); } } else @@ -85,7 +85,7 @@ public static function canView($ucmTypeId, $contentId) if (TjucmAccess::hasCluster($ucmTypeId)) { - if (RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewallitem')) + if (RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewallitem.' . $ucmTypeId)) { return true; } @@ -96,7 +96,7 @@ public static function canView($ucmTypeId, $contentId) // Check user have permission to edit record of assigned cluster if ($subUserExist) { - return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewitem', $itemTable->cluster_id); + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewitem.' . $ucmTypeId, $itemTable->cluster_id); } } else @@ -111,7 +111,7 @@ public static function canEdit($ucmTypeId, $contentId) { JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); - if (RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.editallitem')) + if (RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.editallitem.' . $ucmTypeId)) { return true; } @@ -126,7 +126,7 @@ public static function canEdit($ucmTypeId, $contentId) $itemTable = JTable::getInstance('Item', 'TjucmTable', array('dbo', JFactory::getDbo())); $itemTable->load($contentId); - return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.edititem', $itemTable->cluster_id); + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.edititem.' . $ucmTypeId, $itemTable->cluster_id); } } else @@ -141,7 +141,7 @@ public static function canEditState($ucmTypeId, $contentId) { JLoader::import("components.com_subusers.includes.rbacl", JPATH_ADMINISTRATOR); - if (RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.editallitemstate')) + if (RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.editallitemstate.' . $ucmTypeId)) { return true; } @@ -156,7 +156,7 @@ public static function canEditState($ucmTypeId, $contentId) $itemTable = JTable::getInstance('Item', 'TjucmTable', array('dbo', JFactory::getDbo())); $itemTable->load($contentId); - return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.edititemstate', $itemTable->cluster_id); + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.edititemstate.' . $ucmTypeId, $itemTable->cluster_id); } } else @@ -180,7 +180,7 @@ public static function canEditOwn($ucmTypeId, $contentId) $itemTable = JTable::getInstance('Item', 'TjucmTable', array('dbo', JFactory::getDbo())); $itemTable->load($contentId); - return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.editownitem', $itemTable->cluster_id); + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.editownitem.' . $ucmTypeId, $itemTable->cluster_id); } } else @@ -195,7 +195,7 @@ public static function canDelete($ucmTypeId, $contentId) { JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); - if (RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.deleteallitem')) + if (RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.deleteallitem.' . $ucmTypeId)) { return true; } @@ -210,7 +210,7 @@ public static function canDelete($ucmTypeId, $contentId) $itemTable = JTable::getInstance('Item', 'TjucmTable', array('dbo', JFactory::getDbo())); $itemTable->load($contentId); - return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.deleteitem', $itemTable->cluster_id); + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.deleteitem.' . $ucmTypeId, $itemTable->cluster_id); } } else @@ -234,7 +234,7 @@ public static function canDeleteOwn($ucmTypeId, $contentId) $itemTable = JTable::getInstance('Item', 'TjucmTable', array('dbo', JFactory::getDbo())); $itemTable->load($contentId); - return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.deleteownitem', $itemTable->cluster_id); + return RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.deleteownitem.' . $ucmTypeId, $itemTable->cluster_id); } } else diff --git a/src/components/com_tjucm/site/views/itemform/tmpl/default.php b/src/components/com_tjucm/site/views/itemform/tmpl/default.php index a2d05328..744fe6db 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/default.php +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default.php @@ -125,7 +125,8 @@

title); ?>

- + id, 'com_cluster', 'core.viewitem', $clusterList->id) || RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewallitem')) + if (RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewitem.' . $this->ucmTypeId, $clusterList->id) || RBACL::check(JFactory::getUser()->id, 'com_cluster', 'core.viewallitem.' . $this->ucmTypeId)) { if (!empty($clusterList->id)) { From 649aea24ade91925ddd47f0ece3f4f4500fdae19 Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Wed, 3 Jun 2020 16:56:25 +0530 Subject: [PATCH 35/42] Bug #161524 fix: MultiSelect : Options in the list getting repeated even only use add it once --- src/components/com_tjucm/media/js/ui/itemform.js | 9 ++++++++- src/components/com_tjucm/media/js/ui/itemform.min.js | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 23e6a8e2..9f7af593 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -835,7 +835,14 @@ var tjUcmItemForm = { }); jQuery('#item-form select').each(function (){ - tjUcmItemFormData.append(jQuery(this).attr('name'), jQuery(this).val()); + if (typeOf (jQuery(this).val()) == Array) + { + tjUcmItemFormData.append(jQuery(this).attr('name'), jQuery(this).val().join()); + } + else if (jQuery(this).val()) + { + tjUcmItemFormData.append(jQuery(this).attr('name'), jQuery(this).val()); + } }); /* Do not show draft save msg if the save is triggered as per bitrate config*/ diff --git a/src/components/com_tjucm/media/js/ui/itemform.min.js b/src/components/com_tjucm/media/js/ui/itemform.min.js index f826728c..80c17922 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.min.js +++ b/src/components/com_tjucm/media/js/ui/itemform.min.js @@ -1 +1 @@ -var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=new Array,tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=new Array,tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var e=Number(jQuery("#itemState").val()),t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1===e){var a=jQuery("#item-form #tjucm-autosave").val();t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){if(tjUcmCurrentAutoSaveState=1,jQuery("#item-form").on("change select",":input",function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .field-calendar input:text").blur(function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .js-editor-tinymce").length>0){var i=Joomla.getOptions("plg_editor_tinymce");null!=i&&jQuery.each(i.tinyMCE,function(e,t){if(jQuery("#item-form #jform_"+e).length){var r=jQuery("#jform_"+e+"_ifr").contents().find("body").html();tjUcmTinyMCEFieldIds[e]=r}else if(0==jQuery("#item-form #jform_"+e).length&&"default"!=e){var a=jQuery("textarea[id$='__"+e+"']");a.length&&jQuery.each(a,function(e,t){var r=jQuery(t).attr("id"),a=jQuery("#"+r+"_ifr").contents().find("body").html(),i=r.replace("jform_","");tjUcmTinyMCEFieldIds[i]=a})}})}jQuery("#item-form .wf-editor-container").length>0&&setTimeout(function(){jQuery("#item-form .mceIframeContainer iframe").each(function(){var e=jQuery(this).attr("id"),t=e.replace("jform_","").replace("_ifr",""),r=jQuery("#"+e).contents().find("body").html();tjUcmJCEFieldIds[t]=r})},2e3),1==a&&1==t&&void 0!==r&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){for(var e in(jQuery("#item-form").hasClass("dirty")||0===tjUcmFormSavedByBitRateConfig)&&(tjUcmFormSavedByBitRateConfig=1,jQuery("#tjUcmSectionDraftSave").click()),tjUcmJCEFieldIds)if(tjUcmJCEFieldIds.hasOwnProperty(e)){var t=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmJCEFieldIds[e]!=t){var r=jQuery("#jform_"+e);r.length&&(r.val(t),tjUcmJCEFieldIds[e]=t,tjUcmItemForm.onUcmFormChange(r))}}if(jQuery("#item-form .js-editor-tinymce").length>0)for(var e in tjUcmTinyMCEFieldIds)if(tjUcmTinyMCEFieldIds.hasOwnProperty(e)){var a=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmTinyMCEFieldIds[e]!=a){var i=jQuery("#jform_"+e);i.length&&(i.val(a),tjUcmTinyMCEFieldIds[e]=a,tjUcmItemForm.onUcmFormChange(i))}}},1e3*r)}}else jQuery("#tjucm-auto-save-disabled-msg").show();jQuery("#tjucm_myTabTabs a").on("click",function(){jQuery(this).parent().next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(this).parent().prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0)}),jQuery(document).on("subform-row-add",function(e,t){var r,a=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")&&(r=jQuery(t).find(".js-editor-tinymce textarea").attr("id"))){var i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}if(jQuery(t).find(".wf-editor-container textarea")&&(r=jQuery(t).find(".wf-editor-container textarea").attr("id"))){i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}jQuery.each(tjucmRelatedFieldUpdatedOptions,function(e,r){if(r.templateId){var i=r.templateId.replace("XXX_XXX",a);jQuery(t).find("#"+i).html(""),jQuery.each(r.options,function(e,r){jQuery(t).find("#"+i).append('")}),jQuery(t).find("#"+i).trigger("liszt:updated")}})}),jQuery("#next_button, #previous_button").on("click",function(){if("next_button"==jQuery(this).attr("id")?tjUcmClickedOnNext=1:tjUcmClickedOnPrev=1,jQuery("#item-form").hasClass("dirty"))if(tjUcmCurrentAutoSaveState){var e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(e,t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(t,a){var i=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==i){var n=new FormData;""!=r&&n.append("client",r),n.append(Joomla.getOptions("csrf.token"),1);n.append("draft",e),com_tjucm.Services.Item.create(n,function(e,r){if(r=JSON.parse(r),null==e)if(null!==r.data&&jQuery.isNumeric(r.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(r.data.id);var i=window.location.href.split("#")[0],n=-1===i.indexOf("?")?"?":"&",o="id="+r.data.id;i.indexOf(o)>=0||(i+=n+o),history.pushState(null,null,i),t(r.data.id)}else a(r)})}else jQuery.isNumeric(i)&&0!=i&&t(i)}).then(function(e){t(e)}).catch(function(e){return console.log(e),!1})},onUcmFormChange:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(e,r,t)})},initUcmFormFieldDataSave:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a="",i=new FormData;if(i.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(e).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(e).parent().parent().parent().parent().attr("data-base-name")){var n=jQuery(e).parent().parent().parent().attr("data-base-name");null==n&&(n=jQuery(e).parent().parent().parent().parent().attr("data-base-name"));var o=jQuery(e).attr("id"),m="com_tjucm."+(a=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),u=jQuery("#"+a).val();if(""==u){i.append("parent_id",r),i.append("client",m),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,u){if(u=JSON.parse(u),null==o)return null!==u.data&&jQuery.isNumeric(u.data.id)&&jQuery("#"+a).val(u.data.id),i.append("jform["+n+"]",m),i.append("client",t),i.append("recordid",r),com_tjucm.Services.Item.saveFieldData(i,function(t,r){var a=jQuery(e).attr("name"),i="[]"==a.slice(-2)?"[]":"",n="jform["+jQuery(e).attr("id").split("__").pop()+"]"+i;"radio"==jQuery(e).attr("type")&&(n="jform["+jQuery(e).attr("name").split("][").pop()),jQuery(e).attr("name",n),tjUcmItemForm.saveUcmFormFieldData(m,u.data.id,e),jQuery(e).attr("name",a)}),!0})}else{if(jQuery.isNumeric(u)&&0!=u){var c=jQuery(e).attr("name"),l="[]"==c.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(m,u,e),jQuery(e).attr("name",c),!0}null==u&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(t,r,e),!0},saveUcmFormFieldData:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a=new FormData;return a.append(Joomla.getOptions("csrf.token"),1),a.append("client",e),a.append("recordid",t),"checkbox"==jQuery(r).attr("type")?1==jQuery(r).prop("checked")?a.append(jQuery(r).attr("name"),1):a.append(jQuery(r).attr("name"),0):jQuery(r).hasClass("tjfieldTjList")?(""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val()),""!=jQuery("input#"+jQuery(r).attr("id")).val()&&null!=jQuery("input#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("input#"+jQuery(r).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(r).attr("id")).data("role")?(""!=jQuery("#"+jQuery(r).attr("id")).val()&&null!=jQuery("#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("#"+jQuery(r).attr("id")).val()),""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val())):"file"!=jQuery(r).attr("type")?a.append(jQuery(r).attr("name"),jQuery(r).val()):a.append(jQuery(r).attr("name"),jQuery(r)[0].files[0]),""!=jQuery(r).attr("name")&&null!=jQuery(r).attr("name")&&com_tjucm.Services.Item.saveFieldData(a,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(e,t){if(jQuery("#item-form #tjucm_loader").hide(),t=JSON.parse(t),jQuery("#item-form").removeClass("dirty"),null==t)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=t.data&&t.data.childContentIds&&jQuery.each(t.data.childContentIds,function(e,t){jQuery("#"+e).val(t)}),t.data&&tjUcmFormFinalSave&&(jQuery("#tjucm-auto-save-disabled-msg").show(),jQuery("#itemState").val(0),jQuery("#tjUcmSectionDraftSave").remove(),tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click")),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click")),tjUcmItemForm.setVisibilityOfNavigationButtons(),t.data){var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(r,a)}tjUcmItemForm.renderResponseMessages(t)},renderResponseMessages:function(e){null!=e&&(null!==e.message&&(e.data?Joomla.renderMessages({success:[e.message]}):Joomla.renderMessages({error:[e.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==e.messages&&null!==e.messages.error&&(jQuery.each(e.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(e,t){var r=new FormData;r.append("client",e),r.append("content_id",t),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(r,function(e,t){if(t=JSON.parse(t),""==(tjucmRelatedFieldUpdatedOptions=t.data))return!1;jQuery.each(t.data,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")})})},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),void 0===event?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?event.target.id:"tjUcmSectionDraftSave";var e=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(!document.formvalidator.isValid(document.getElementById("item-form")))return tjUcmItemForm.setVisibilityOfNavigationButtons(),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),!1;jQuery("#system-message-container").html(""),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),e=0}jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(e,function(){var e=document.getElementById("item-form"),t=new FormData(e);t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&t.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery('#item-form input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?t.append(jQuery(this).attr("name"),1):t.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){t.append(jQuery(this).attr("name"),jQuery(this).val())}),void 0!==tjUcmSaveFormInDraftWithNoMsg&&(tjUcmSaveFormInDraftWithNoMsg=void 0,t.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()})},saveSectionData:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var t=new FormData,r=jQuery(e).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(r))return jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),r.length&&r.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&t.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?1==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&t.append(jQuery(this).attr("name"),jQuery(this).val())}),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(){t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),t.append("tjUcmFormSection",jQuery("a[href='"+e+"']").html()),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)})},validateSection:function(e){var t,r,a,i,n,o=!0,m=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),r={error:[]},i=m.length-1;i>=0;i--)(a=jQuery(m[i]).data("label"))&&r.error.push(t+a.text().replace("*",""));Joomla.renderMessages(r)}return o},setVisibilityOfNavigationButtons:function(){var e=jQuery("#tjucm_myTabTabs").find("li.active");jQuery(e).length&&(jQuery(e).next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(e).prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0))}};function steppedFormSave(e,t,r){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(e){this.click()});var a=jQuery("#"+e),i=!1;if(jQuery("#form_status").val(t),"save"==t){if(!document.formvalidator.isValid("#item-form"))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return a&&jQuery(a).ajaxSubmit({datatype:"JSON",async:!1,success:function(e){var a=JSON.parse(e);if(null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.data){jQuery("#recordId").val(a.data.id),"save"==t?(jQuery("#tjUcmSectionFinalSave").attr("disabled","disabled"),Joomla.renderMessages({success:[Joomla.JText._("COM_TJUCM_MSG_ON_SAVED_FORM")]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").offset().top-40},"slow")):(i=!0,"1"===r&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var n=window.location.href.split("#")[0],o=-1===n.indexOf("?")?"?":"&",m="id="+a.data.id;jQuery.each(a.data.childContentIds,function(e,t){jQuery("input[name='"+t.elementName+"']").val(t.content_id)}),tjucmRelatedFieldUpdatedOptions=a.data.relatedFieldOptions,jQuery.each(a.data.relatedFieldOptions,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")}),n.indexOf(m)>=0||(n+=o+m),history.pushState(null,null,n)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(e){this.click()})}}),i}function itemformactions(e,t){var r=jQuery("ul#tjucm_myTabTabs").find("li.active a");null==jQuery(r).next("li")?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),null==jQuery(r).prev("li")?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),next?jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"):jQuery("#tjucm_myTabTabs > .active").next("li").prev("a").trigger("click");var a=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),i=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");null==a?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),null==i?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==t&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==t&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} \ No newline at end of file +var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=new Array,tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=new Array,tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var e=Number(jQuery("#itemState").val()),t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1===e){var a=jQuery("#item-form #tjucm-autosave").val();t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){if(tjUcmCurrentAutoSaveState=1,jQuery("#item-form").on("change select",":input",function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .field-calendar input:text").blur(function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .js-editor-tinymce").length>0){var i=Joomla.getOptions("plg_editor_tinymce");null!=i&&jQuery.each(i.tinyMCE,function(e,t){if(jQuery("#item-form #jform_"+e).length){var r=jQuery("#jform_"+e+"_ifr").contents().find("body").html();tjUcmTinyMCEFieldIds[e]=r}else if(0==jQuery("#item-form #jform_"+e).length&&"default"!=e){var a=jQuery("textarea[id$='__"+e+"']");a.length&&jQuery.each(a,function(e,t){var r=jQuery(t).attr("id"),a=jQuery("#"+r+"_ifr").contents().find("body").html(),i=r.replace("jform_","");tjUcmTinyMCEFieldIds[i]=a})}})}jQuery("#item-form .wf-editor-container").length>0&&setTimeout(function(){jQuery("#item-form .mceIframeContainer iframe").each(function(){var e=jQuery(this).attr("id"),t=e.replace("jform_","").replace("_ifr",""),r=jQuery("#"+e).contents().find("body").html();tjUcmJCEFieldIds[t]=r})},2e3),1==a&&1==t&&void 0!==r&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){for(var e in(jQuery("#item-form").hasClass("dirty")||0===tjUcmFormSavedByBitRateConfig)&&(tjUcmFormSavedByBitRateConfig=1,jQuery("#tjUcmSectionDraftSave").click()),tjUcmJCEFieldIds)if(tjUcmJCEFieldIds.hasOwnProperty(e)){var t=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmJCEFieldIds[e]!=t){var r=jQuery("#jform_"+e);r.length&&(r.val(t),tjUcmJCEFieldIds[e]=t,tjUcmItemForm.onUcmFormChange(r))}}if(jQuery("#item-form .js-editor-tinymce").length>0)for(var e in tjUcmTinyMCEFieldIds)if(tjUcmTinyMCEFieldIds.hasOwnProperty(e)){var a=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmTinyMCEFieldIds[e]!=a){var i=jQuery("#jform_"+e);i.length&&(i.val(a),tjUcmTinyMCEFieldIds[e]=a,tjUcmItemForm.onUcmFormChange(i))}}},1e3*r)}}else jQuery("#tjucm-auto-save-disabled-msg").show();jQuery("#tjucm_myTabTabs a").on("click",function(){jQuery(this).parent().next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(this).parent().prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0)}),jQuery(document).on("subform-row-add",function(e,t){var r,a=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")&&(r=jQuery(t).find(".js-editor-tinymce textarea").attr("id"))){var i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}if(jQuery(t).find(".wf-editor-container textarea")&&(r=jQuery(t).find(".wf-editor-container textarea").attr("id"))){i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}jQuery.each(tjucmRelatedFieldUpdatedOptions,function(e,r){if(r.templateId){var i=r.templateId.replace("XXX_XXX",a);jQuery(t).find("#"+i).html(""),jQuery.each(r.options,function(e,r){jQuery(t).find("#"+i).append('")}),jQuery(t).find("#"+i).trigger("liszt:updated")}})}),jQuery("#next_button, #previous_button").on("click",function(){if("next_button"==jQuery(this).attr("id")?tjUcmClickedOnNext=1:tjUcmClickedOnPrev=1,jQuery("#item-form").hasClass("dirty"))if(tjUcmCurrentAutoSaveState){var e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(e,t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(t,a){var i=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==i){var n=new FormData;""!=r&&n.append("client",r),n.append(Joomla.getOptions("csrf.token"),1);n.append("draft",e),com_tjucm.Services.Item.create(n,function(e,r){if(r=JSON.parse(r),null==e)if(null!==r.data&&jQuery.isNumeric(r.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(r.data.id);var i=window.location.href.split("#")[0],n=-1===i.indexOf("?")?"?":"&",o="id="+r.data.id;i.indexOf(o)>=0||(i+=n+o),history.pushState(null,null,i),t(r.data.id)}else a(r)})}else jQuery.isNumeric(i)&&0!=i&&t(i)}).then(function(e){t(e)}).catch(function(e){return console.log(e),!1})},onUcmFormChange:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(e,r,t)})},initUcmFormFieldDataSave:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a="",i=new FormData;if(i.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(e).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(e).parent().parent().parent().parent().attr("data-base-name")){var n=jQuery(e).parent().parent().parent().attr("data-base-name");null==n&&(n=jQuery(e).parent().parent().parent().parent().attr("data-base-name"));var o=jQuery(e).attr("id"),m="com_tjucm."+(a=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),u=jQuery("#"+a).val();if(""==u){i.append("parent_id",r),i.append("client",m),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,u){if(u=JSON.parse(u),null==o)return null!==u.data&&jQuery.isNumeric(u.data.id)&&jQuery("#"+a).val(u.data.id),i.append("jform["+n+"]",m),i.append("client",t),i.append("recordid",r),com_tjucm.Services.Item.saveFieldData(i,function(t,r){var a=jQuery(e).attr("name"),i="[]"==a.slice(-2)?"[]":"",n="jform["+jQuery(e).attr("id").split("__").pop()+"]"+i;"radio"==jQuery(e).attr("type")&&(n="jform["+jQuery(e).attr("name").split("][").pop()),jQuery(e).attr("name",n),tjUcmItemForm.saveUcmFormFieldData(m,u.data.id,e),jQuery(e).attr("name",a)}),!0})}else{if(jQuery.isNumeric(u)&&0!=u){var c=jQuery(e).attr("name"),l="[]"==c.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(m,u,e),jQuery(e).attr("name",c),!0}null==u&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(t,r,e),!0},saveUcmFormFieldData:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a=new FormData;return a.append(Joomla.getOptions("csrf.token"),1),a.append("client",e),a.append("recordid",t),"checkbox"==jQuery(r).attr("type")?1==jQuery(r).prop("checked")?a.append(jQuery(r).attr("name"),1):a.append(jQuery(r).attr("name"),0):jQuery(r).hasClass("tjfieldTjList")?(""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val()),""!=jQuery("input#"+jQuery(r).attr("id")).val()&&null!=jQuery("input#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("input#"+jQuery(r).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(r).attr("id")).data("role")?(""!=jQuery("#"+jQuery(r).attr("id")).val()&&null!=jQuery("#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("#"+jQuery(r).attr("id")).val()),""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val())):"file"!=jQuery(r).attr("type")?a.append(jQuery(r).attr("name"),jQuery(r).val()):a.append(jQuery(r).attr("name"),jQuery(r)[0].files[0]),""!=jQuery(r).attr("name")&&null!=jQuery(r).attr("name")&&com_tjucm.Services.Item.saveFieldData(a,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(e,t){if(jQuery("#item-form #tjucm_loader").hide(),t=JSON.parse(t),jQuery("#item-form").removeClass("dirty"),null==t)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=t.data&&t.data.childContentIds&&jQuery.each(t.data.childContentIds,function(e,t){jQuery("#"+e).val(t)}),t.data&&tjUcmFormFinalSave&&(jQuery("#tjucm-auto-save-disabled-msg").show(),jQuery("#itemState").val(0),jQuery("#tjUcmSectionDraftSave").remove(),tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click")),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click")),tjUcmItemForm.setVisibilityOfNavigationButtons(),t.data){var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(r,a)}tjUcmItemForm.renderResponseMessages(t)},renderResponseMessages:function(e){null!=e&&(null!==e.message&&(e.data?Joomla.renderMessages({success:[e.message]}):Joomla.renderMessages({error:[e.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==e.messages&&null!==e.messages.error&&(jQuery.each(e.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(e,t){var r=new FormData;r.append("client",e),r.append("content_id",t),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(r,function(e,t){if(t=JSON.parse(t),""==(tjucmRelatedFieldUpdatedOptions=t.data))return!1;jQuery.each(t.data,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")})})},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),void 0===event?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?event.target.id:"tjUcmSectionDraftSave";var e=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(!document.formvalidator.isValid(document.getElementById("item-form")))return tjUcmItemForm.setVisibilityOfNavigationButtons(),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),!1;jQuery("#system-message-container").html(""),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),e=0}jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(e,function(){var e=document.getElementById("item-form"),t=new FormData(e);t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&t.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery('#item-form input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?t.append(jQuery(this).attr("name"),1):t.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){typeOf(jQuery(this).val())==Array?t.append(jQuery(this).attr("name"),jQuery(this).val().join()):jQuery(this).val()&&t.append(jQuery(this).attr("name"),jQuery(this).val())}),void 0!==tjUcmSaveFormInDraftWithNoMsg&&(tjUcmSaveFormInDraftWithNoMsg=void 0,t.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()})},saveSectionData:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var t=new FormData,r=jQuery(e).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(r))return jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),r.length&&r.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&t.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?1==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&t.append(jQuery(this).attr("name"),jQuery(this).val())}),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(){t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),t.append("tjUcmFormSection",jQuery("a[href='"+e+"']").html()),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)})},validateSection:function(e){var t,r,a,i,n,o=!0,m=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),r={error:[]},i=m.length-1;i>=0;i--)(a=jQuery(m[i]).data("label"))&&r.error.push(t+a.text().replace("*",""));Joomla.renderMessages(r)}return o},setVisibilityOfNavigationButtons:function(){var e=jQuery("#tjucm_myTabTabs").find("li.active");jQuery(e).length&&(jQuery(e).next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(e).prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0))}};function steppedFormSave(e,t,r){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(e){this.click()});var a=jQuery("#"+e),i=!1;if(jQuery("#form_status").val(t),"save"==t){if(!document.formvalidator.isValid("#item-form"))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return a&&jQuery(a).ajaxSubmit({datatype:"JSON",async:!1,success:function(e){var a=JSON.parse(e);if(null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.data){jQuery("#recordId").val(a.data.id),"save"==t?(jQuery("#tjUcmSectionFinalSave").attr("disabled","disabled"),Joomla.renderMessages({success:[Joomla.JText._("COM_TJUCM_MSG_ON_SAVED_FORM")]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").offset().top-40},"slow")):(i=!0,"1"===r&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var n=window.location.href.split("#")[0],o=-1===n.indexOf("?")?"?":"&",m="id="+a.data.id;jQuery.each(a.data.childContentIds,function(e,t){jQuery("input[name='"+t.elementName+"']").val(t.content_id)}),tjucmRelatedFieldUpdatedOptions=a.data.relatedFieldOptions,jQuery.each(a.data.relatedFieldOptions,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")}),n.indexOf(m)>=0||(n+=o+m),history.pushState(null,null,n)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(e){this.click()})}}),i}function itemformactions(e,t){var r=jQuery("ul#tjucm_myTabTabs").find("li.active a");null==jQuery(r).next("li")?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),null==jQuery(r).prev("li")?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),next?jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"):jQuery("#tjucm_myTabTabs > .active").next("li").prev("a").trigger("click");var a=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),i=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");null==a?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),null==i?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==t&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==t&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} From 157b20d0fb6ae25101e2fdb201f53576ab9982ff Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Thu, 4 Jun 2020 19:11:15 +0530 Subject: [PATCH 36/42] Bug #156605 fix: The dropdown of tjlist type field didn't get reset. It shows old value as it is --- .../languages/site/en-GB/en-GB.com_tjucm.ini | 5 ++- .../com_tjucm/media/js/ui/itemform.js | 21 +++++---- .../com_tjucm/media/js/ui/itemform.min.js | 2 +- .../com_tjucm/site/controllers/type.php | 15 ++++--- .../com_tjucm/site/layouts/list/list.php | 3 +- .../site/views/items/tmpl/default.php | 44 ++++++++++--------- 6 files changed, 51 insertions(+), 39 deletions(-) diff --git a/src/components/com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini index 0c368d5a..7b615a8e 100644 --- a/src/components/com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini @@ -42,7 +42,6 @@ COM_TJUCM_NO_ITEM_SELECTED="No items selected" COM_TJUCM_SAVE_SUCCESS="Item successfully saved" COM_TJUCM_ITEM_ID_SELECT_LABEL="Select the item ID" COM_TJUCM_SELECT_UCM_TYPE_LBL="UCM Type" -COM_TJUCM_SELECT_UCM_TYPE_DESC="Select UCM Type" COM_TJUCM_FIELDSET_UCM_TYPE_SELECT_LABEL="UCM Config" COM_TJUCM_FILTER_SELECT_LABEL=" - Select %s - " COM_TJUCM_TEST_LABEL="Test label" @@ -209,3 +208,7 @@ COM_TJUCM_ITEMS_IMPORTED_SCUUESSFULLY="%d record(s) imported successfully" COM_TJUCM_ITEMS_IMPORT_REJECTED_RECORDS="%d invalid record(s) were not imported" COM_TJUCM_ITEMS_NO_RECORDS_TO_IMPORT="No records found to import" COM_TJUCM_ITEMS_IMPORTING_MSG="Please wait, Records are being imported..." +COM_TJUCM_LOGIN_MSG="Please login" +COM_TJUCM_SELECT_SOURCE_FORM="Select data source" +COM_TJUCM_PROCESS_DATA="Process" +COM_TJUCM_CANCEL_COPY="Cancel" diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 9f7af593..ce59afd1 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -585,13 +585,20 @@ var tjUcmItemForm = { tjUcmItemFieldFormData.append(jQuery(fieldObj).attr('name'), jQuery(fieldObj).val()); } } - else if (jQuery(fieldObj).attr('type') != 'file') + else if (jQuery(fieldObj).attr('type') == 'file') { - tjUcmItemFieldFormData.append(jQuery(fieldObj).attr('name'), jQuery(fieldObj).val()); + tjUcmItemFieldFormData.append(jQuery(fieldObj).attr('name'), jQuery(fieldObj)[0].files[0]); } else { - tjUcmItemFieldFormData.append(jQuery(fieldObj).attr('name'), jQuery(fieldObj)[0].files[0]); + if (jQuery(fieldObj).val() == null) + { + tjUcmItemFieldFormData.append(jQuery(fieldObj).attr('name'), ''); + } + else + { + tjUcmItemFieldFormData.append(jQuery(fieldObj).attr('name'), jQuery(fieldObj).val()); + } } // Call function if field name exist in request data @@ -835,13 +842,9 @@ var tjUcmItemForm = { }); jQuery('#item-form select').each(function (){ - if (typeOf (jQuery(this).val()) == Array) - { - tjUcmItemFormData.append(jQuery(this).attr('name'), jQuery(this).val().join()); - } - else if (jQuery(this).val()) + if (jQuery(this).val() == null) { - tjUcmItemFormData.append(jQuery(this).attr('name'), jQuery(this).val()); + tjUcmItemFormData.append(jQuery(this).attr('name'), ''); } }); diff --git a/src/components/com_tjucm/media/js/ui/itemform.min.js b/src/components/com_tjucm/media/js/ui/itemform.min.js index 80c17922..9aa8231e 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.min.js +++ b/src/components/com_tjucm/media/js/ui/itemform.min.js @@ -1 +1 @@ -var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=new Array,tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=new Array,tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var e=Number(jQuery("#itemState").val()),t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1===e){var a=jQuery("#item-form #tjucm-autosave").val();t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){if(tjUcmCurrentAutoSaveState=1,jQuery("#item-form").on("change select",":input",function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .field-calendar input:text").blur(function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .js-editor-tinymce").length>0){var i=Joomla.getOptions("plg_editor_tinymce");null!=i&&jQuery.each(i.tinyMCE,function(e,t){if(jQuery("#item-form #jform_"+e).length){var r=jQuery("#jform_"+e+"_ifr").contents().find("body").html();tjUcmTinyMCEFieldIds[e]=r}else if(0==jQuery("#item-form #jform_"+e).length&&"default"!=e){var a=jQuery("textarea[id$='__"+e+"']");a.length&&jQuery.each(a,function(e,t){var r=jQuery(t).attr("id"),a=jQuery("#"+r+"_ifr").contents().find("body").html(),i=r.replace("jform_","");tjUcmTinyMCEFieldIds[i]=a})}})}jQuery("#item-form .wf-editor-container").length>0&&setTimeout(function(){jQuery("#item-form .mceIframeContainer iframe").each(function(){var e=jQuery(this).attr("id"),t=e.replace("jform_","").replace("_ifr",""),r=jQuery("#"+e).contents().find("body").html();tjUcmJCEFieldIds[t]=r})},2e3),1==a&&1==t&&void 0!==r&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){for(var e in(jQuery("#item-form").hasClass("dirty")||0===tjUcmFormSavedByBitRateConfig)&&(tjUcmFormSavedByBitRateConfig=1,jQuery("#tjUcmSectionDraftSave").click()),tjUcmJCEFieldIds)if(tjUcmJCEFieldIds.hasOwnProperty(e)){var t=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmJCEFieldIds[e]!=t){var r=jQuery("#jform_"+e);r.length&&(r.val(t),tjUcmJCEFieldIds[e]=t,tjUcmItemForm.onUcmFormChange(r))}}if(jQuery("#item-form .js-editor-tinymce").length>0)for(var e in tjUcmTinyMCEFieldIds)if(tjUcmTinyMCEFieldIds.hasOwnProperty(e)){var a=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmTinyMCEFieldIds[e]!=a){var i=jQuery("#jform_"+e);i.length&&(i.val(a),tjUcmTinyMCEFieldIds[e]=a,tjUcmItemForm.onUcmFormChange(i))}}},1e3*r)}}else jQuery("#tjucm-auto-save-disabled-msg").show();jQuery("#tjucm_myTabTabs a").on("click",function(){jQuery(this).parent().next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(this).parent().prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0)}),jQuery(document).on("subform-row-add",function(e,t){var r,a=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")&&(r=jQuery(t).find(".js-editor-tinymce textarea").attr("id"))){var i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}if(jQuery(t).find(".wf-editor-container textarea")&&(r=jQuery(t).find(".wf-editor-container textarea").attr("id"))){i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}jQuery.each(tjucmRelatedFieldUpdatedOptions,function(e,r){if(r.templateId){var i=r.templateId.replace("XXX_XXX",a);jQuery(t).find("#"+i).html(""),jQuery.each(r.options,function(e,r){jQuery(t).find("#"+i).append('")}),jQuery(t).find("#"+i).trigger("liszt:updated")}})}),jQuery("#next_button, #previous_button").on("click",function(){if("next_button"==jQuery(this).attr("id")?tjUcmClickedOnNext=1:tjUcmClickedOnPrev=1,jQuery("#item-form").hasClass("dirty"))if(tjUcmCurrentAutoSaveState){var e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(e,t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(t,a){var i=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==i){var n=new FormData;""!=r&&n.append("client",r),n.append(Joomla.getOptions("csrf.token"),1);n.append("draft",e),com_tjucm.Services.Item.create(n,function(e,r){if(r=JSON.parse(r),null==e)if(null!==r.data&&jQuery.isNumeric(r.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(r.data.id);var i=window.location.href.split("#")[0],n=-1===i.indexOf("?")?"?":"&",o="id="+r.data.id;i.indexOf(o)>=0||(i+=n+o),history.pushState(null,null,i),t(r.data.id)}else a(r)})}else jQuery.isNumeric(i)&&0!=i&&t(i)}).then(function(e){t(e)}).catch(function(e){return console.log(e),!1})},onUcmFormChange:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(e,r,t)})},initUcmFormFieldDataSave:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a="",i=new FormData;if(i.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(e).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(e).parent().parent().parent().parent().attr("data-base-name")){var n=jQuery(e).parent().parent().parent().attr("data-base-name");null==n&&(n=jQuery(e).parent().parent().parent().parent().attr("data-base-name"));var o=jQuery(e).attr("id"),m="com_tjucm."+(a=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),u=jQuery("#"+a).val();if(""==u){i.append("parent_id",r),i.append("client",m),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,u){if(u=JSON.parse(u),null==o)return null!==u.data&&jQuery.isNumeric(u.data.id)&&jQuery("#"+a).val(u.data.id),i.append("jform["+n+"]",m),i.append("client",t),i.append("recordid",r),com_tjucm.Services.Item.saveFieldData(i,function(t,r){var a=jQuery(e).attr("name"),i="[]"==a.slice(-2)?"[]":"",n="jform["+jQuery(e).attr("id").split("__").pop()+"]"+i;"radio"==jQuery(e).attr("type")&&(n="jform["+jQuery(e).attr("name").split("][").pop()),jQuery(e).attr("name",n),tjUcmItemForm.saveUcmFormFieldData(m,u.data.id,e),jQuery(e).attr("name",a)}),!0})}else{if(jQuery.isNumeric(u)&&0!=u){var c=jQuery(e).attr("name"),l="[]"==c.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(m,u,e),jQuery(e).attr("name",c),!0}null==u&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(t,r,e),!0},saveUcmFormFieldData:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a=new FormData;return a.append(Joomla.getOptions("csrf.token"),1),a.append("client",e),a.append("recordid",t),"checkbox"==jQuery(r).attr("type")?1==jQuery(r).prop("checked")?a.append(jQuery(r).attr("name"),1):a.append(jQuery(r).attr("name"),0):jQuery(r).hasClass("tjfieldTjList")?(""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val()),""!=jQuery("input#"+jQuery(r).attr("id")).val()&&null!=jQuery("input#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("input#"+jQuery(r).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(r).attr("id")).data("role")?(""!=jQuery("#"+jQuery(r).attr("id")).val()&&null!=jQuery("#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("#"+jQuery(r).attr("id")).val()),""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val())):"file"!=jQuery(r).attr("type")?a.append(jQuery(r).attr("name"),jQuery(r).val()):a.append(jQuery(r).attr("name"),jQuery(r)[0].files[0]),""!=jQuery(r).attr("name")&&null!=jQuery(r).attr("name")&&com_tjucm.Services.Item.saveFieldData(a,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(e,t){if(jQuery("#item-form #tjucm_loader").hide(),t=JSON.parse(t),jQuery("#item-form").removeClass("dirty"),null==t)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=t.data&&t.data.childContentIds&&jQuery.each(t.data.childContentIds,function(e,t){jQuery("#"+e).val(t)}),t.data&&tjUcmFormFinalSave&&(jQuery("#tjucm-auto-save-disabled-msg").show(),jQuery("#itemState").val(0),jQuery("#tjUcmSectionDraftSave").remove(),tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click")),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click")),tjUcmItemForm.setVisibilityOfNavigationButtons(),t.data){var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(r,a)}tjUcmItemForm.renderResponseMessages(t)},renderResponseMessages:function(e){null!=e&&(null!==e.message&&(e.data?Joomla.renderMessages({success:[e.message]}):Joomla.renderMessages({error:[e.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==e.messages&&null!==e.messages.error&&(jQuery.each(e.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(e,t){var r=new FormData;r.append("client",e),r.append("content_id",t),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(r,function(e,t){if(t=JSON.parse(t),""==(tjucmRelatedFieldUpdatedOptions=t.data))return!1;jQuery.each(t.data,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")})})},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),void 0===event?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?event.target.id:"tjUcmSectionDraftSave";var e=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(!document.formvalidator.isValid(document.getElementById("item-form")))return tjUcmItemForm.setVisibilityOfNavigationButtons(),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),!1;jQuery("#system-message-container").html(""),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),e=0}jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(e,function(){var e=document.getElementById("item-form"),t=new FormData(e);t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&t.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery('#item-form input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?t.append(jQuery(this).attr("name"),1):t.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){typeOf(jQuery(this).val())==Array?t.append(jQuery(this).attr("name"),jQuery(this).val().join()):jQuery(this).val()&&t.append(jQuery(this).attr("name"),jQuery(this).val())}),void 0!==tjUcmSaveFormInDraftWithNoMsg&&(tjUcmSaveFormInDraftWithNoMsg=void 0,t.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()})},saveSectionData:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var t=new FormData,r=jQuery(e).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(r))return jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),r.length&&r.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&t.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?1==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&t.append(jQuery(this).attr("name"),jQuery(this).val())}),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(){t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),t.append("tjUcmFormSection",jQuery("a[href='"+e+"']").html()),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)})},validateSection:function(e){var t,r,a,i,n,o=!0,m=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),r={error:[]},i=m.length-1;i>=0;i--)(a=jQuery(m[i]).data("label"))&&r.error.push(t+a.text().replace("*",""));Joomla.renderMessages(r)}return o},setVisibilityOfNavigationButtons:function(){var e=jQuery("#tjucm_myTabTabs").find("li.active");jQuery(e).length&&(jQuery(e).next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(e).prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0))}};function steppedFormSave(e,t,r){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(e){this.click()});var a=jQuery("#"+e),i=!1;if(jQuery("#form_status").val(t),"save"==t){if(!document.formvalidator.isValid("#item-form"))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return a&&jQuery(a).ajaxSubmit({datatype:"JSON",async:!1,success:function(e){var a=JSON.parse(e);if(null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.data){jQuery("#recordId").val(a.data.id),"save"==t?(jQuery("#tjUcmSectionFinalSave").attr("disabled","disabled"),Joomla.renderMessages({success:[Joomla.JText._("COM_TJUCM_MSG_ON_SAVED_FORM")]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").offset().top-40},"slow")):(i=!0,"1"===r&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var n=window.location.href.split("#")[0],o=-1===n.indexOf("?")?"?":"&",m="id="+a.data.id;jQuery.each(a.data.childContentIds,function(e,t){jQuery("input[name='"+t.elementName+"']").val(t.content_id)}),tjucmRelatedFieldUpdatedOptions=a.data.relatedFieldOptions,jQuery.each(a.data.relatedFieldOptions,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")}),n.indexOf(m)>=0||(n+=o+m),history.pushState(null,null,n)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(e){this.click()})}}),i}function itemformactions(e,t){var r=jQuery("ul#tjucm_myTabTabs").find("li.active a");null==jQuery(r).next("li")?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),null==jQuery(r).prev("li")?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),next?jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"):jQuery("#tjucm_myTabTabs > .active").next("li").prev("a").trigger("click");var a=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),i=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");null==a?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),null==i?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==t&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==t&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} +var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=new Array,tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=new Array,tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var e=Number(jQuery("#itemState").val()),t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1===e){var a=jQuery("#item-form #tjucm-autosave").val();t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){if(tjUcmCurrentAutoSaveState=1,jQuery("#item-form").on("change select",":input",function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .field-calendar input:text").blur(function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .js-editor-tinymce").length>0){var i=Joomla.getOptions("plg_editor_tinymce");null!=i&&jQuery.each(i.tinyMCE,function(e,t){if(jQuery("#item-form #jform_"+e).length){var r=jQuery("#jform_"+e+"_ifr").contents().find("body").html();tjUcmTinyMCEFieldIds[e]=r}else if(0==jQuery("#item-form #jform_"+e).length&&"default"!=e){var a=jQuery("textarea[id$='__"+e+"']");a.length&&jQuery.each(a,function(e,t){var r=jQuery(t).attr("id"),a=jQuery("#"+r+"_ifr").contents().find("body").html(),i=r.replace("jform_","");tjUcmTinyMCEFieldIds[i]=a})}})}jQuery("#item-form .wf-editor-container").length>0&&setTimeout(function(){jQuery("#item-form .mceIframeContainer iframe").each(function(){var e=jQuery(this).attr("id"),t=e.replace("jform_","").replace("_ifr",""),r=jQuery("#"+e).contents().find("body").html();tjUcmJCEFieldIds[t]=r})},2e3),1==a&&1==t&&void 0!==r&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){for(var e in(jQuery("#item-form").hasClass("dirty")||0===tjUcmFormSavedByBitRateConfig)&&(tjUcmFormSavedByBitRateConfig=1,jQuery("#tjUcmSectionDraftSave").click()),tjUcmJCEFieldIds)if(tjUcmJCEFieldIds.hasOwnProperty(e)){var t=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmJCEFieldIds[e]!=t){var r=jQuery("#jform_"+e);r.length&&(r.val(t),tjUcmJCEFieldIds[e]=t,tjUcmItemForm.onUcmFormChange(r))}}if(jQuery("#item-form .js-editor-tinymce").length>0)for(var e in tjUcmTinyMCEFieldIds)if(tjUcmTinyMCEFieldIds.hasOwnProperty(e)){var a=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmTinyMCEFieldIds[e]!=a){var i=jQuery("#jform_"+e);i.length&&(i.val(a),tjUcmTinyMCEFieldIds[e]=a,tjUcmItemForm.onUcmFormChange(i))}}},1e3*r)}}else jQuery("#tjucm-auto-save-disabled-msg").show();jQuery("#tjucm_myTabTabs a").on("click",function(){jQuery(this).parent().next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(this).parent().prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0)}),jQuery(document).on("subform-row-add",function(e,t){var r,a=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")&&(r=jQuery(t).find(".js-editor-tinymce textarea").attr("id"))){var i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}if(jQuery(t).find(".wf-editor-container textarea")&&(r=jQuery(t).find(".wf-editor-container textarea").attr("id"))){i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}jQuery.each(tjucmRelatedFieldUpdatedOptions,function(e,r){if(r.templateId){var i=r.templateId.replace("XXX_XXX",a);jQuery(t).find("#"+i).html(""),jQuery.each(r.options,function(e,r){jQuery(t).find("#"+i).append('")}),jQuery(t).find("#"+i).trigger("liszt:updated")}})}),jQuery("#next_button, #previous_button").on("click",function(){if("next_button"==jQuery(this).attr("id")?tjUcmClickedOnNext=1:tjUcmClickedOnPrev=1,jQuery("#item-form").hasClass("dirty"))if(tjUcmCurrentAutoSaveState){var e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(e,t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(t,a){var i=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==i){var n=new FormData;""!=r&&n.append("client",r),n.append(Joomla.getOptions("csrf.token"),1);n.append("draft",e),com_tjucm.Services.Item.create(n,function(e,r){if(r=JSON.parse(r),null==e)if(null!==r.data&&jQuery.isNumeric(r.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(r.data.id);var i=window.location.href.split("#")[0],n=-1===i.indexOf("?")?"?":"&",o="id="+r.data.id;i.indexOf(o)>=0||(i+=n+o),history.pushState(null,null,i),t(r.data.id)}else a(r)})}else jQuery.isNumeric(i)&&0!=i&&t(i)}).then(function(e){t(e)}).catch(function(e){return console.log(e),!1})},onUcmFormChange:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(e,r,t)})},initUcmFormFieldDataSave:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a="",i=new FormData;if(i.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(e).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(e).parent().parent().parent().parent().attr("data-base-name")){var n=jQuery(e).parent().parent().parent().attr("data-base-name");null==n&&(n=jQuery(e).parent().parent().parent().parent().attr("data-base-name"));var o=jQuery(e).attr("id"),m="com_tjucm."+(a=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),u=jQuery("#"+a).val();if(""==u){i.append("parent_id",r),i.append("client",m),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,u){if(u=JSON.parse(u),null==o)return null!==u.data&&jQuery.isNumeric(u.data.id)&&jQuery("#"+a).val(u.data.id),i.append("jform["+n+"]",m),i.append("client",t),i.append("recordid",r),com_tjucm.Services.Item.saveFieldData(i,function(t,r){var a=jQuery(e).attr("name"),i="[]"==a.slice(-2)?"[]":"",n="jform["+jQuery(e).attr("id").split("__").pop()+"]"+i;"radio"==jQuery(e).attr("type")&&(n="jform["+jQuery(e).attr("name").split("][").pop()),jQuery(e).attr("name",n),tjUcmItemForm.saveUcmFormFieldData(m,u.data.id,e),jQuery(e).attr("name",a)}),!0})}else{if(jQuery.isNumeric(u)&&0!=u){var c=jQuery(e).attr("name"),l="[]"==c.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(m,u,e),jQuery(e).attr("name",c),!0}null==u&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(t,r,e),!0},saveUcmFormFieldData:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a=new FormData;return a.append(Joomla.getOptions("csrf.token"),1),a.append("client",e),a.append("recordid",t),"checkbox"==jQuery(r).attr("type")?1==jQuery(r).prop("checked")?a.append(jQuery(r).attr("name"),1):a.append(jQuery(r).attr("name"),0):jQuery(r).hasClass("tjfieldTjList")?(""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val()),""!=jQuery("input#"+jQuery(r).attr("id")).val()&&null!=jQuery("input#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("input#"+jQuery(r).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(r).attr("id")).data("role")?(""!=jQuery("#"+jQuery(r).attr("id")).val()&&null!=jQuery("#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("#"+jQuery(r).attr("id")).val()),""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val())):"file"==jQuery(r).attr("type")?a.append(jQuery(r).attr("name"),jQuery(r)[0].files[0]):null==jQuery(r).val()?a.append(jQuery(r).attr("name"),""):a.append(jQuery(r).attr("name"),jQuery(r).val()),""!=jQuery(r).attr("name")&&null!=jQuery(r).attr("name")&&com_tjucm.Services.Item.saveFieldData(a,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(e,t){if(jQuery("#item-form #tjucm_loader").hide(),t=JSON.parse(t),jQuery("#item-form").removeClass("dirty"),null==t)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=t.data&&t.data.childContentIds&&jQuery.each(t.data.childContentIds,function(e,t){jQuery("#"+e).val(t)}),t.data&&tjUcmFormFinalSave&&(jQuery("#tjucm-auto-save-disabled-msg").show(),jQuery("#itemState").val(0),jQuery("#tjUcmSectionDraftSave").remove(),tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click")),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click")),tjUcmItemForm.setVisibilityOfNavigationButtons(),t.data){var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(r,a)}tjUcmItemForm.renderResponseMessages(t)},renderResponseMessages:function(e){null!=e&&(null!==e.message&&(e.data?Joomla.renderMessages({success:[e.message]}):Joomla.renderMessages({error:[e.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==e.messages&&null!==e.messages.error&&(jQuery.each(e.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(e,t){var r=new FormData;r.append("client",e),r.append("content_id",t),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(r,function(e,t){if(t=JSON.parse(t),""==(tjucmRelatedFieldUpdatedOptions=t.data))return!1;jQuery.each(t.data,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")})})},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),void 0===event?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?event.target.id:"tjUcmSectionDraftSave";var e=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(!document.formvalidator.isValid(document.getElementById("item-form")))return tjUcmItemForm.setVisibilityOfNavigationButtons(),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),!1;jQuery("#system-message-container").html(""),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),e=0}jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(e,function(){var e=document.getElementById("item-form"),t=new FormData(e);t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&t.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery('#item-form input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?t.append(jQuery(this).attr("name"),1):t.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){null==jQuery(this).val()&&t.append(jQuery(this).attr("name"),"")}),void 0!==tjUcmSaveFormInDraftWithNoMsg&&(tjUcmSaveFormInDraftWithNoMsg=void 0,t.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()})},saveSectionData:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var t=new FormData,r=jQuery(e).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(r))return jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),r.length&&r.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&t.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?1==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&t.append(jQuery(this).attr("name"),jQuery(this).val())}),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(){t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),t.append("tjUcmFormSection",jQuery("a[href='"+e+"']").html()),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)})},validateSection:function(e){var t,r,a,i,n,o=!0,m=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),r={error:[]},i=m.length-1;i>=0;i--)(a=jQuery(m[i]).data("label"))&&r.error.push(t+a.text().replace("*",""));Joomla.renderMessages(r)}return o},setVisibilityOfNavigationButtons:function(){var e=jQuery("#tjucm_myTabTabs").find("li.active");jQuery(e).length&&(jQuery(e).next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(e).prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0))}};function steppedFormSave(e,t,r){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(e){this.click()});var a=jQuery("#"+e),i=!1;if(jQuery("#form_status").val(t),"save"==t){if(!document.formvalidator.isValid("#item-form"))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return a&&jQuery(a).ajaxSubmit({datatype:"JSON",async:!1,success:function(e){var a=JSON.parse(e);if(null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.data){jQuery("#recordId").val(a.data.id),"save"==t?(jQuery("#tjUcmSectionFinalSave").attr("disabled","disabled"),Joomla.renderMessages({success:[Joomla.JText._("COM_TJUCM_MSG_ON_SAVED_FORM")]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").offset().top-40},"slow")):(i=!0,"1"===r&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var n=window.location.href.split("#")[0],o=-1===n.indexOf("?")?"?":"&",m="id="+a.data.id;jQuery.each(a.data.childContentIds,function(e,t){jQuery("input[name='"+t.elementName+"']").val(t.content_id)}),tjucmRelatedFieldUpdatedOptions=a.data.relatedFieldOptions,jQuery.each(a.data.relatedFieldOptions,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")}),n.indexOf(m)>=0||(n+=o+m),history.pushState(null,null,n)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(e){this.click()})}}),i}function itemformactions(e,t){var r=jQuery("ul#tjucm_myTabTabs").find("li.active a");null==jQuery(r).next("li")?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),null==jQuery(r).prev("li")?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),next?jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"):jQuery("#tjucm_myTabTabs > .active").next("li").prev("a").trigger("click");var a=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),i=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");null==a?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),null==i?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==t&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==t&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} \ No newline at end of file diff --git a/src/components/com_tjucm/site/controllers/type.php b/src/components/com_tjucm/site/controllers/type.php index 6e266dfe..34c27107 100644 --- a/src/components/com_tjucm/site/controllers/type.php +++ b/src/components/com_tjucm/site/controllers/type.php @@ -64,17 +64,18 @@ public function getCompatableUcmType() $typeModel = BaseDatabaseModel::getInstance('Type', 'TjucmModel'); $validUcmType = array(); - $validUcmType[0]['value'] = ""; - $validUcmType[0]['text'] = Text::_('COM_TJUCM_SELECT_UCM_TYPE_DESC'); foreach ($ucmTypes as $key => $type) { - $result = $typeModel->getCompatableUcmType($client, $type->unique_identifier); - - if ($result) + if ($type->unique_identifier != $client) { - $validUcmType[$key]['value'] = $type->unique_identifier; - $validUcmType[$key]['text'] = $type->title; + $result = $typeModel->getCompatableUcmType($client, $type->unique_identifier); + + if ($result) + { + $validUcmType[$key]['value'] = $type->unique_identifier; + $validUcmType[$key]['text'] = $type->title; + } } } diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index fff66bbd..1b8f2b58 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -94,7 +94,8 @@ ?>
- + + id); ?> client . "'); + currentUcmType.append('client', '" . $this->client . "'); var afterCheckCompatibilityOfUcmType = function(error, response){ response = JSON.parse(response); - if (response.data !== null) + if (response.data.length > 0) { jQuery('.copyToOther').removeClass('hide'); jQuery.each(response.data, function(key, value) { @@ -71,15 +71,15 @@ // Code to check ucm type compatibility to copy item com_tjucm.Services.Items.chekCompatibility(currentUcmType, afterCheckCompatibilityOfUcmType); }); - + function copyItem() { var afterCopyItem = function(error, response){ response = JSON.parse(response); - + // Close pop up and display message jQuery( '#copyModal' ).modal('hide'); - + if(response.data !== null) { Joomla.renderMessages({'success':[response.message]}); @@ -89,12 +89,12 @@ function copyItem() Joomla.renderMessages({'error':[response.message]}); } } - + var copyItemData = jQuery('#adminForm').serialize(); - + // Code to copy item to ucm type com_tjucm.Services.Items.copyItem(copyItemData, afterCopyItem); - } + } "); $statusColumnWidth = 0; @@ -148,7 +148,8 @@ function copyItem() {?> - + + if ($this->canImport) { ?> - - - - - - + + -

Select Ucm Type

+

From 2a2e036302db371586b77eb16e857b6f8794847a Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Fri, 5 Jun 2020 12:54:41 +0530 Subject: [PATCH 37/42] Bug #156605 fix: The dropdown of tjlist type field didn't get reset. It shows old value as it is --- src/components/com_tjucm/media/js/ui/itemform.js | 5 ++++- src/components/com_tjucm/media/js/ui/itemform.min.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index ce59afd1..1ca1043c 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -558,11 +558,14 @@ var tjUcmItemForm = { else if(jQuery(fieldObj).hasClass('tjfieldTjList')) { /* This condition used for tjlist option actial values updated - This is used for single & multiple values*/ - if (jQuery(fieldObj).val() !='' && jQuery(fieldObj).val() != undefined) { tjUcmItemFieldFormData.append(jQuery(fieldObj).attr('name'), jQuery(fieldObj).val()); } + else + { + tjUcmItemFieldFormData.append(jQuery(fieldObj).attr('name'), ''); + } /* Check other options multiple values exist and its not empty */ if (jQuery('input#'+jQuery(fieldObj).attr('id')).val() !='' && jQuery('input#'+jQuery(fieldObj).attr('id')).val() != undefined) diff --git a/src/components/com_tjucm/media/js/ui/itemform.min.js b/src/components/com_tjucm/media/js/ui/itemform.min.js index 9aa8231e..25388259 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.min.js +++ b/src/components/com_tjucm/media/js/ui/itemform.min.js @@ -1 +1 @@ -var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=new Array,tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=new Array,tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var e=Number(jQuery("#itemState").val()),t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1===e){var a=jQuery("#item-form #tjucm-autosave").val();t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){if(tjUcmCurrentAutoSaveState=1,jQuery("#item-form").on("change select",":input",function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .field-calendar input:text").blur(function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .js-editor-tinymce").length>0){var i=Joomla.getOptions("plg_editor_tinymce");null!=i&&jQuery.each(i.tinyMCE,function(e,t){if(jQuery("#item-form #jform_"+e).length){var r=jQuery("#jform_"+e+"_ifr").contents().find("body").html();tjUcmTinyMCEFieldIds[e]=r}else if(0==jQuery("#item-form #jform_"+e).length&&"default"!=e){var a=jQuery("textarea[id$='__"+e+"']");a.length&&jQuery.each(a,function(e,t){var r=jQuery(t).attr("id"),a=jQuery("#"+r+"_ifr").contents().find("body").html(),i=r.replace("jform_","");tjUcmTinyMCEFieldIds[i]=a})}})}jQuery("#item-form .wf-editor-container").length>0&&setTimeout(function(){jQuery("#item-form .mceIframeContainer iframe").each(function(){var e=jQuery(this).attr("id"),t=e.replace("jform_","").replace("_ifr",""),r=jQuery("#"+e).contents().find("body").html();tjUcmJCEFieldIds[t]=r})},2e3),1==a&&1==t&&void 0!==r&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){for(var e in(jQuery("#item-form").hasClass("dirty")||0===tjUcmFormSavedByBitRateConfig)&&(tjUcmFormSavedByBitRateConfig=1,jQuery("#tjUcmSectionDraftSave").click()),tjUcmJCEFieldIds)if(tjUcmJCEFieldIds.hasOwnProperty(e)){var t=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmJCEFieldIds[e]!=t){var r=jQuery("#jform_"+e);r.length&&(r.val(t),tjUcmJCEFieldIds[e]=t,tjUcmItemForm.onUcmFormChange(r))}}if(jQuery("#item-form .js-editor-tinymce").length>0)for(var e in tjUcmTinyMCEFieldIds)if(tjUcmTinyMCEFieldIds.hasOwnProperty(e)){var a=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmTinyMCEFieldIds[e]!=a){var i=jQuery("#jform_"+e);i.length&&(i.val(a),tjUcmTinyMCEFieldIds[e]=a,tjUcmItemForm.onUcmFormChange(i))}}},1e3*r)}}else jQuery("#tjucm-auto-save-disabled-msg").show();jQuery("#tjucm_myTabTabs a").on("click",function(){jQuery(this).parent().next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(this).parent().prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0)}),jQuery(document).on("subform-row-add",function(e,t){var r,a=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")&&(r=jQuery(t).find(".js-editor-tinymce textarea").attr("id"))){var i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}if(jQuery(t).find(".wf-editor-container textarea")&&(r=jQuery(t).find(".wf-editor-container textarea").attr("id"))){i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}jQuery.each(tjucmRelatedFieldUpdatedOptions,function(e,r){if(r.templateId){var i=r.templateId.replace("XXX_XXX",a);jQuery(t).find("#"+i).html(""),jQuery.each(r.options,function(e,r){jQuery(t).find("#"+i).append('")}),jQuery(t).find("#"+i).trigger("liszt:updated")}})}),jQuery("#next_button, #previous_button").on("click",function(){if("next_button"==jQuery(this).attr("id")?tjUcmClickedOnNext=1:tjUcmClickedOnPrev=1,jQuery("#item-form").hasClass("dirty"))if(tjUcmCurrentAutoSaveState){var e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(e,t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(t,a){var i=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==i){var n=new FormData;""!=r&&n.append("client",r),n.append(Joomla.getOptions("csrf.token"),1);n.append("draft",e),com_tjucm.Services.Item.create(n,function(e,r){if(r=JSON.parse(r),null==e)if(null!==r.data&&jQuery.isNumeric(r.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(r.data.id);var i=window.location.href.split("#")[0],n=-1===i.indexOf("?")?"?":"&",o="id="+r.data.id;i.indexOf(o)>=0||(i+=n+o),history.pushState(null,null,i),t(r.data.id)}else a(r)})}else jQuery.isNumeric(i)&&0!=i&&t(i)}).then(function(e){t(e)}).catch(function(e){return console.log(e),!1})},onUcmFormChange:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(e,r,t)})},initUcmFormFieldDataSave:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a="",i=new FormData;if(i.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(e).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(e).parent().parent().parent().parent().attr("data-base-name")){var n=jQuery(e).parent().parent().parent().attr("data-base-name");null==n&&(n=jQuery(e).parent().parent().parent().parent().attr("data-base-name"));var o=jQuery(e).attr("id"),m="com_tjucm."+(a=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),u=jQuery("#"+a).val();if(""==u){i.append("parent_id",r),i.append("client",m),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,u){if(u=JSON.parse(u),null==o)return null!==u.data&&jQuery.isNumeric(u.data.id)&&jQuery("#"+a).val(u.data.id),i.append("jform["+n+"]",m),i.append("client",t),i.append("recordid",r),com_tjucm.Services.Item.saveFieldData(i,function(t,r){var a=jQuery(e).attr("name"),i="[]"==a.slice(-2)?"[]":"",n="jform["+jQuery(e).attr("id").split("__").pop()+"]"+i;"radio"==jQuery(e).attr("type")&&(n="jform["+jQuery(e).attr("name").split("][").pop()),jQuery(e).attr("name",n),tjUcmItemForm.saveUcmFormFieldData(m,u.data.id,e),jQuery(e).attr("name",a)}),!0})}else{if(jQuery.isNumeric(u)&&0!=u){var c=jQuery(e).attr("name"),l="[]"==c.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(m,u,e),jQuery(e).attr("name",c),!0}null==u&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(t,r,e),!0},saveUcmFormFieldData:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a=new FormData;return a.append(Joomla.getOptions("csrf.token"),1),a.append("client",e),a.append("recordid",t),"checkbox"==jQuery(r).attr("type")?1==jQuery(r).prop("checked")?a.append(jQuery(r).attr("name"),1):a.append(jQuery(r).attr("name"),0):jQuery(r).hasClass("tjfieldTjList")?(""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val()),""!=jQuery("input#"+jQuery(r).attr("id")).val()&&null!=jQuery("input#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("input#"+jQuery(r).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(r).attr("id")).data("role")?(""!=jQuery("#"+jQuery(r).attr("id")).val()&&null!=jQuery("#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("#"+jQuery(r).attr("id")).val()),""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val())):"file"==jQuery(r).attr("type")?a.append(jQuery(r).attr("name"),jQuery(r)[0].files[0]):null==jQuery(r).val()?a.append(jQuery(r).attr("name"),""):a.append(jQuery(r).attr("name"),jQuery(r).val()),""!=jQuery(r).attr("name")&&null!=jQuery(r).attr("name")&&com_tjucm.Services.Item.saveFieldData(a,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(e,t){if(jQuery("#item-form #tjucm_loader").hide(),t=JSON.parse(t),jQuery("#item-form").removeClass("dirty"),null==t)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=t.data&&t.data.childContentIds&&jQuery.each(t.data.childContentIds,function(e,t){jQuery("#"+e).val(t)}),t.data&&tjUcmFormFinalSave&&(jQuery("#tjucm-auto-save-disabled-msg").show(),jQuery("#itemState").val(0),jQuery("#tjUcmSectionDraftSave").remove(),tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click")),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click")),tjUcmItemForm.setVisibilityOfNavigationButtons(),t.data){var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(r,a)}tjUcmItemForm.renderResponseMessages(t)},renderResponseMessages:function(e){null!=e&&(null!==e.message&&(e.data?Joomla.renderMessages({success:[e.message]}):Joomla.renderMessages({error:[e.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==e.messages&&null!==e.messages.error&&(jQuery.each(e.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(e,t){var r=new FormData;r.append("client",e),r.append("content_id",t),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(r,function(e,t){if(t=JSON.parse(t),""==(tjucmRelatedFieldUpdatedOptions=t.data))return!1;jQuery.each(t.data,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")})})},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),void 0===event?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?event.target.id:"tjUcmSectionDraftSave";var e=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(!document.formvalidator.isValid(document.getElementById("item-form")))return tjUcmItemForm.setVisibilityOfNavigationButtons(),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),!1;jQuery("#system-message-container").html(""),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),e=0}jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(e,function(){var e=document.getElementById("item-form"),t=new FormData(e);t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&t.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery('#item-form input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?t.append(jQuery(this).attr("name"),1):t.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){null==jQuery(this).val()&&t.append(jQuery(this).attr("name"),"")}),void 0!==tjUcmSaveFormInDraftWithNoMsg&&(tjUcmSaveFormInDraftWithNoMsg=void 0,t.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()})},saveSectionData:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var t=new FormData,r=jQuery(e).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(r))return jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),r.length&&r.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&t.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?1==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&t.append(jQuery(this).attr("name"),jQuery(this).val())}),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(){t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),t.append("tjUcmFormSection",jQuery("a[href='"+e+"']").html()),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)})},validateSection:function(e){var t,r,a,i,n,o=!0,m=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),r={error:[]},i=m.length-1;i>=0;i--)(a=jQuery(m[i]).data("label"))&&r.error.push(t+a.text().replace("*",""));Joomla.renderMessages(r)}return o},setVisibilityOfNavigationButtons:function(){var e=jQuery("#tjucm_myTabTabs").find("li.active");jQuery(e).length&&(jQuery(e).next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(e).prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0))}};function steppedFormSave(e,t,r){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(e){this.click()});var a=jQuery("#"+e),i=!1;if(jQuery("#form_status").val(t),"save"==t){if(!document.formvalidator.isValid("#item-form"))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return a&&jQuery(a).ajaxSubmit({datatype:"JSON",async:!1,success:function(e){var a=JSON.parse(e);if(null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.data){jQuery("#recordId").val(a.data.id),"save"==t?(jQuery("#tjUcmSectionFinalSave").attr("disabled","disabled"),Joomla.renderMessages({success:[Joomla.JText._("COM_TJUCM_MSG_ON_SAVED_FORM")]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").offset().top-40},"slow")):(i=!0,"1"===r&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var n=window.location.href.split("#")[0],o=-1===n.indexOf("?")?"?":"&",m="id="+a.data.id;jQuery.each(a.data.childContentIds,function(e,t){jQuery("input[name='"+t.elementName+"']").val(t.content_id)}),tjucmRelatedFieldUpdatedOptions=a.data.relatedFieldOptions,jQuery.each(a.data.relatedFieldOptions,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")}),n.indexOf(m)>=0||(n+=o+m),history.pushState(null,null,n)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(e){this.click()})}}),i}function itemformactions(e,t){var r=jQuery("ul#tjucm_myTabTabs").find("li.active a");null==jQuery(r).next("li")?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),null==jQuery(r).prev("li")?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),next?jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"):jQuery("#tjucm_myTabTabs > .active").next("li").prev("a").trigger("click");var a=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),i=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");null==a?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),null==i?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==t&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==t&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} \ No newline at end of file +var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=new Array,tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=new Array,tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var e=Number(jQuery("#itemState").val()),t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1===e){var a=jQuery("#item-form #tjucm-autosave").val();t=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){if(tjUcmCurrentAutoSaveState=1,jQuery("#item-form").on("change select",":input",function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .field-calendar input:text").blur(function(){tjUcmCurrentAutoSaveState&&tjUcmItemForm.onUcmFormChange(this)}),jQuery("#item-form .js-editor-tinymce").length>0){var i=Joomla.getOptions("plg_editor_tinymce");null!=i&&jQuery.each(i.tinyMCE,function(e,t){if(jQuery("#item-form #jform_"+e).length){var r=jQuery("#jform_"+e+"_ifr").contents().find("body").html();tjUcmTinyMCEFieldIds[e]=r}else if(0==jQuery("#item-form #jform_"+e).length&&"default"!=e){var a=jQuery("textarea[id$='__"+e+"']");a.length&&jQuery.each(a,function(e,t){var r=jQuery(t).attr("id"),a=jQuery("#"+r+"_ifr").contents().find("body").html(),i=r.replace("jform_","");tjUcmTinyMCEFieldIds[i]=a})}})}jQuery("#item-form .wf-editor-container").length>0&&setTimeout(function(){jQuery("#item-form .mceIframeContainer iframe").each(function(){var e=jQuery(this).attr("id"),t=e.replace("jform_","").replace("_ifr",""),r=jQuery("#"+e).contents().find("body").html();tjUcmJCEFieldIds[t]=r})},2e3),1==a&&1==t&&void 0!==r&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){for(var e in(jQuery("#item-form").hasClass("dirty")||0===tjUcmFormSavedByBitRateConfig)&&(tjUcmFormSavedByBitRateConfig=1,jQuery("#tjUcmSectionDraftSave").click()),tjUcmJCEFieldIds)if(tjUcmJCEFieldIds.hasOwnProperty(e)){var t=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmJCEFieldIds[e]!=t){var r=jQuery("#jform_"+e);r.length&&(r.val(t),tjUcmJCEFieldIds[e]=t,tjUcmItemForm.onUcmFormChange(r))}}if(jQuery("#item-form .js-editor-tinymce").length>0)for(var e in tjUcmTinyMCEFieldIds)if(tjUcmTinyMCEFieldIds.hasOwnProperty(e)){var a=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmTinyMCEFieldIds[e]!=a){var i=jQuery("#jform_"+e);i.length&&(i.val(a),tjUcmTinyMCEFieldIds[e]=a,tjUcmItemForm.onUcmFormChange(i))}}},1e3*r)}}else jQuery("#tjucm-auto-save-disabled-msg").show();jQuery("#tjucm_myTabTabs a").on("click",function(){jQuery(this).parent().next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(this).parent().prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0)}),jQuery(document).on("subform-row-add",function(e,t){var r,a=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")&&(r=jQuery(t).find(".js-editor-tinymce textarea").attr("id"))){var i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}if(jQuery(t).find(".wf-editor-container textarea")&&(r=jQuery(t).find(".wf-editor-container textarea").attr("id"))){i=jQuery("#"+r+"_ifr").contents().find("body").html();r=r.replace("jform_",""),tjUcmTinyMCEFieldIds[r]=i}jQuery.each(tjucmRelatedFieldUpdatedOptions,function(e,r){if(r.templateId){var i=r.templateId.replace("XXX_XXX",a);jQuery(t).find("#"+i).html(""),jQuery.each(r.options,function(e,r){jQuery(t).find("#"+i).append('")}),jQuery(t).find("#"+i).trigger("liszt:updated")}})}),jQuery("#next_button, #previous_button").on("click",function(){if("next_button"==jQuery(this).attr("id")?tjUcmClickedOnNext=1:tjUcmClickedOnPrev=1,jQuery("#item-form").hasClass("dirty"))if(tjUcmCurrentAutoSaveState){var e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}else{e=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(e)?(jQuery("#system-message-container").html(""),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons()),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click"),tjUcmItemForm.setVisibilityOfNavigationButtons())):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(e,t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(t,a){var i=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==i){var n=new FormData;""!=r&&n.append("client",r),n.append(Joomla.getOptions("csrf.token"),1);n.append("draft",e),com_tjucm.Services.Item.create(n,function(e,r){if(r=JSON.parse(r),null==e)if(null!==r.data&&jQuery.isNumeric(r.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(r.data.id);var i=window.location.href.split("#")[0],n=-1===i.indexOf("?")?"?":"&",o="id="+r.data.id;i.indexOf(o)>=0||(i+=n+o),history.pushState(null,null,i),t(r.data.id)}else a(r)})}else jQuery.isNumeric(i)&&0!=i&&t(i)}).then(function(e){t(e)}).catch(function(e){return console.log(e),!1})},onUcmFormChange:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(t){var r=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(e,r,t)})},initUcmFormFieldDataSave:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a="",i=new FormData;if(i.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(e).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(e).parent().parent().parent().parent().attr("data-base-name")){var n=jQuery(e).parent().parent().parent().attr("data-base-name");null==n&&(n=jQuery(e).parent().parent().parent().parent().attr("data-base-name"));var o=jQuery(e).attr("id"),m="com_tjucm."+(a=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),u=jQuery("#"+a).val();if(""==u){i.append("parent_id",r),i.append("client",m),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,u){if(u=JSON.parse(u),null==o)return null!==u.data&&jQuery.isNumeric(u.data.id)&&jQuery("#"+a).val(u.data.id),i.append("jform["+n+"]",m),i.append("client",t),i.append("recordid",r),com_tjucm.Services.Item.saveFieldData(i,function(t,r){var a=jQuery(e).attr("name"),i="[]"==a.slice(-2)?"[]":"",n="jform["+jQuery(e).attr("id").split("__").pop()+"]"+i;"radio"==jQuery(e).attr("type")&&(n="jform["+jQuery(e).attr("name").split("][").pop()),jQuery(e).attr("name",n),tjUcmItemForm.saveUcmFormFieldData(m,u.data.id,e),jQuery(e).attr("name",a)}),!0})}else{if(jQuery.isNumeric(u)&&0!=u){var c=jQuery(e).attr("name"),l="[]"==c.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(m,u,e),jQuery(e).attr("name",c),!0}null==u&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(t,r,e),!0},saveUcmFormFieldData:function(e,t,r){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var a=new FormData;return a.append(Joomla.getOptions("csrf.token"),1),a.append("client",e),a.append("recordid",t),"checkbox"==jQuery(r).attr("type")?1==jQuery(r).prop("checked")?a.append(jQuery(r).attr("name"),1):a.append(jQuery(r).attr("name"),0):jQuery(r).hasClass("tjfieldTjList")?(""!=jQuery(r).val()&&null!=jQuery(r).val()?a.append(jQuery(r).attr("name"),jQuery(r).val()):a.append(jQuery(r).attr("name"),""),""!=jQuery("input#"+jQuery(r).attr("id")).val()&&null!=jQuery("input#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("input#"+jQuery(r).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(r).attr("id")).data("role")?(""!=jQuery("#"+jQuery(r).attr("id")).val()&&null!=jQuery("#"+jQuery(r).attr("id")).val()&&a.append(jQuery(r).attr("name"),jQuery("#"+jQuery(r).attr("id")).val()),""!=jQuery(r).val()&&null!=jQuery(r).val()&&a.append(jQuery(r).attr("name"),jQuery(r).val())):"file"==jQuery(r).attr("type")?a.append(jQuery(r).attr("name"),jQuery(r)[0].files[0]):null==jQuery(r).val()?a.append(jQuery(r).attr("name"),""):a.append(jQuery(r).attr("name"),jQuery(r).val()),""!=jQuery(r).attr("name")&&null!=jQuery(r).attr("name")&&com_tjucm.Services.Item.saveFieldData(a,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(e,t){if(jQuery("#item-form #tjucm_loader").hide(),t=JSON.parse(t),jQuery("#item-form").removeClass("dirty"),null==t)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=t.data&&t.data.childContentIds&&jQuery.each(t.data.childContentIds,function(e,t){jQuery("#"+e).val(t)}),t.data&&tjUcmFormFinalSave&&(jQuery("#tjucm-auto-save-disabled-msg").show(),jQuery("#itemState").val(0),jQuery("#tjUcmSectionDraftSave").remove(),tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0),tjUcmClickedOnNext&&(tjUcmClickedOnNext=0,jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click")),tjUcmClickedOnPrev&&(tjUcmClickedOnPrev=0,jQuery("#tjucm_myTabTabs > .active").prev("li").find("a").trigger("click")),tjUcmItemForm.setVisibilityOfNavigationButtons(),t.data){var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(r,a)}tjUcmItemForm.renderResponseMessages(t)},renderResponseMessages:function(e){null!=e&&(null!==e.message&&(e.data?Joomla.renderMessages({success:[e.message]}):Joomla.renderMessages({error:[e.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==e.messages&&null!==e.messages.error&&(jQuery.each(e.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(e,t){var r=new FormData;r.append("client",e),r.append("content_id",t),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(r,function(e,t){if(t=JSON.parse(t),""==(tjucmRelatedFieldUpdatedOptions=t.data))return!1;jQuery.each(t.data,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")})})},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),void 0===event?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?event.target.id:"tjUcmSectionDraftSave";var e=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(!document.formvalidator.isValid(document.getElementById("item-form")))return tjUcmItemForm.setVisibilityOfNavigationButtons(),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),!1;jQuery("#system-message-container").html(""),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),e=0}jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(e,function(){var e=document.getElementById("item-form"),t=new FormData(e);t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&t.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery('#item-form input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?t.append(jQuery(this).attr("name"),1):t.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){null==jQuery(this).val()&&t.append(jQuery(this).attr("name"),"")}),void 0!==tjUcmSaveFormInDraftWithNoMsg&&(tjUcmSaveFormInDraftWithNoMsg=void 0,t.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(e){this.click()})},saveSectionData:function(e){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var t=new FormData,r=jQuery(e).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(r))return jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),r.length&&r.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&t.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?1==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&t.append(jQuery(this).attr("name"),jQuery(this).val())}),jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(){t.delete("task"),t.delete("option"),t.delete("view"),t.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",r),t.append("recordid",a),t.append("tjUcmFormSection",jQuery("a[href='"+e+"']").html()),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)})},validateSection:function(e){var t,r,a,i,n,o=!0,m=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),r={error:[]},i=m.length-1;i>=0;i--)(a=jQuery(m[i]).data("label"))&&r.error.push(t+a.text().replace("*",""));Joomla.renderMessages(r)}return o},setVisibilityOfNavigationButtons:function(){var e=jQuery("#tjucm_myTabTabs").find("li.active");jQuery(e).length&&(jQuery(e).next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(e).prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0))}};function steppedFormSave(e,t,r){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(e){this.click()});var a=jQuery("#"+e),i=!1;if(jQuery("#form_status").val(t),"save"==t){if(!document.formvalidator.isValid("#item-form"))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))return jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return a&&jQuery(a).ajaxSubmit({datatype:"JSON",async:!1,success:function(e){var a=JSON.parse(e);if(null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.data){jQuery("#recordId").val(a.data.id),"save"==t?(jQuery("#tjUcmSectionFinalSave").attr("disabled","disabled"),Joomla.renderMessages({success:[Joomla.JText._("COM_TJUCM_MSG_ON_SAVED_FORM")]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").offset().top-40},"slow")):(i=!0,"1"===r&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var n=window.location.href.split("#")[0],o=-1===n.indexOf("?")?"?":"&",m="id="+a.data.id;jQuery.each(a.data.childContentIds,function(e,t){jQuery("input[name='"+t.elementName+"']").val(t.content_id)}),tjucmRelatedFieldUpdatedOptions=a.data.relatedFieldOptions,jQuery.each(a.data.relatedFieldOptions,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")}),n.indexOf(m)>=0||(n+=o+m),history.pushState(null,null,n)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(e){this.click()})}}),i}function itemformactions(e,t){var r=jQuery("ul#tjucm_myTabTabs").find("li.active a");null==jQuery(r).next("li")?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),null==jQuery(r).prev("li")?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),next?jQuery("#tjucm_myTabTabs > .active").next("li").find("a").trigger("click"):jQuery("#tjucm_myTabTabs > .active").next("li").prev("a").trigger("click");var a=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),i=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");null==a?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),null==i?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==t&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==t&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} From e29ef5fc8f2c4f66396a8c4b0275997c478c7f63 Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Fri, 5 Jun 2020 14:37:43 +0530 Subject: [PATCH 38/42] Bug #156605 fix: The dropdown of tjlist type field didn't get reset. It shows old value as it is --- .../houseKeeping/1.2.4/updateAlias.php | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/com_tjucm/administrator/houseKeeping/1.2.4/updateAlias.php b/src/components/com_tjucm/administrator/houseKeeping/1.2.4/updateAlias.php index 735b74fc..95c61ddc 100644 --- a/src/components/com_tjucm/administrator/houseKeeping/1.2.4/updateAlias.php +++ b/src/components/com_tjucm/administrator/houseKeeping/1.2.4/updateAlias.php @@ -55,23 +55,22 @@ public function migrate() foreach ($ucmTypes as $ucmType) { $ucmTypeTable = JTable::getInstance('Type', 'TjucmTable', array('dbo', $db)); + $ucmTypeTable->load($ucmType->id); // Remove white spaces in alias of UCM types $updatedAlias = JFilterOutput::stringURLSafe($ucmTypeTable->alias); - $oldAlias = $ucmTypeTable->alias; $ucmTypeTable->alias = $updatedAlias; $ucmTypeTable->store(); - - $result['status'] = ''; - $result['message'] = "Migration in progress"; } } // Get all the menus of UCM types + $query = $db->getQuery(true); + $query->select('*'); $query->from($db->quoteName('#__menu')); $query->where( - $db->quoteName(link) . "=" . $db->quote('index.php?option=com_tjucm&view=itemform') . - "||" . $db->quoteName(link) . "=" . $db->quote('index.php?option=com_tjucm&view=items') + $db->quoteName('link') . "=" . $db->quote('index.php?option=com_tjucm&view=itemform') . + "||" . $db->quoteName('link') . "=" . $db->quote('index.php?option=com_tjucm&view=items') ); $db->setQuery($query); $menuItems = $db->loadObjectlist(); @@ -81,14 +80,17 @@ public function migrate() foreach ($menuItems as $menuItem) { $menuItemTable = JTable::getInstance('Menu', 'MenusTable', array('dbo', $db)); + $menuItemTable->load($menuItem->id); $oldparams = json_decode($menuItemTable->params); // Remove white spaces in alias of menus - $oldparams->ucm_type = JFilterOutput::stringURLSafe($oldparams->ucm_type); + if (isset($oldparams->ucm_type)) + { + $oldparams->ucm_type = JFilterOutput::stringURLSafe($oldparams->ucm_type); + } + $menuItemTable->params = json_encode($oldparams); $menuItemTable->store(); - $result['status'] = ''; - $result['message'] = "Migration in progress"; } } @@ -101,6 +103,7 @@ public function migrate() $result['status'] = false; $result['message'] = $e->getMessage(); } + return $result; } } From c92b2a918c60a2332123a57f3e6981f0df1b26e5 Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Fri, 12 Jun 2020 19:55:29 +0530 Subject: [PATCH 39/42] Bug #123 fix: access issue for form view --- .../com_tjucm/site/views/itemform/view.html.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/com_tjucm/site/views/itemform/view.html.php b/src/components/com_tjucm/site/views/itemform/view.html.php index d53848a1..4f8f10c9 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -221,12 +221,15 @@ public function display($tpl = null) $typeTable->load(array('unique_identifier' => $this->client)); $typeParams = json_decode($typeTable->params); - if (!TjucmAccess::canEdit($typeTable->id, $this->item->id)) + if ($this->item->id) { - $app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error'); - $app->setHeader('status', 403, true); + if (!TjucmAccess::canEdit($typeTable->id, $this->item->id)) + { + $app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error'); + $app->setHeader('status', 403, true); - return; + return; + } } // Check if the UCM type is unpublished From f82d2fb78a962169d99e6548f67dd5f359cd89bb Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Mon, 15 Jun 2020 10:34:58 +0530 Subject: [PATCH 40/42] Bug #123 fix: access issue for form view --- src/components/com_tjucm/site/views/itemform/view.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/views/itemform/view.html.php b/src/components/com_tjucm/site/views/itemform/view.html.php index 4f8f10c9..b7eb4b54 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -223,7 +223,7 @@ public function display($tpl = null) if ($this->item->id) { - if (!TjucmAccess::canEdit($typeTable->id, $this->item->id)) + if (!TjucmAccess::canEdit($typeTable->id, $this->item->id) && !TjucmAccess::canEditOwn($typeTable->id, $this->item->id)) { $app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error'); $app->setHeader('status', 403, true); From fe8f8b49c6cacc63035485f59b6046bfec92becd Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Mon, 13 Jul 2020 14:22:37 +0530 Subject: [PATCH 41/42] Task #163118 fix: Other options support for the tj-list field in CSV import --- .../com_tjucm/site/controllers/items.php | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/items.php b/src/components/com_tjucm/site/controllers/items.php index a974a459..3e905acb 100644 --- a/src/components/com_tjucm/site/controllers/items.php +++ b/src/components/com_tjucm/site/controllers/items.php @@ -170,32 +170,49 @@ public function importCsv() if (isset($fieldsArray[$fieldName]->options) && !empty($fieldsArray[$fieldName]->options)) { $fieldParams = new Registry($fieldsArray[$fieldName]->params); + $fieldOptions = array_column($fieldsArray[$fieldName]->options, 'options'); // If there are multiple values for a field then we need to send those as array if (strpos($value, '||') !== false && $fieldParams->get('multiple')) { $optionValue = array_map('trim', explode("||", $value)); $multiSelectValues = array(); + $otherOptionsValues = array(); - foreach ($fieldsArray[$fieldName]->options as $option) + foreach ($optionValue as $option) { - if (in_array($option->options, $optionValue)) + if (in_array($option, $fieldOptions)) { - $multiSelectValues[] = $option->value; + $multiSelectValues[] = $option; } + else + { + if ($fieldParams->get('other')) + { + $otherOptionsValues[] = $option; + } + } + } + + if (!empty($otherOptionsValues)) + { + $multiSelectValues[] = 'tjlistothervalue'; + $multiSelectValues[] = implode(',', $otherOptionsValues); } $itemData[$fieldName] = $multiSelectValues; } else { - foreach ($fieldsArray[$fieldName]->options as $option) + if (in_array($value, $fieldOptions)) + { + $itemData[$fieldName] = $value; + } + else { - if ($option->options == $value) + if ($fieldParams->get('other')) { - $itemData[$fieldName] = $option->value; - - break; + $itemData[$fieldName] = array('tjlistothervalue', $value); } } } From df017048dece752b9ca5e5072048c670549a6657 Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Wed, 22 Jul 2020 17:40:04 +0530 Subject: [PATCH 42/42] Task #123 feat: Support subform fields on list view --- .../com_tjucm/site/layouts/list/list.php | 94 +++++++++++++++++-- .../com_tjucm/site/models/itemform.php | 11 +++ 2 files changed, 97 insertions(+), 8 deletions(-) diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 1b8f2b58..56fd4708 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -43,6 +43,10 @@ JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); $TjfieldsHelper = new TjfieldsHelper; +// Load itemForm model +JLoader::import('components.com_tjucm.models.itemform', JPATH_SITE); +$tjucmItemFormModel = JModelLegacy::getInstance('ItemForm', 'TjucmModel'); + // Get JLayout data $item = $displayData['itemsData']; $created_by = $displayData['created_by']; @@ -158,14 +162,88 @@ { $field = $formObject->getField($tjFieldsFieldTable->name); $field->setValue($fieldValue); - $layoutToUse = ( - array_key_exists( - ucfirst($tjFieldsFieldTable->type), $fieldLayout - ) - ) ? $fieldLayout[ucfirst($tjFieldsFieldTable->type)] : 'field'; - $layout = new JLayoutFile($layoutToUse, JPATH_ROOT . '/components/com_tjfields/layouts/fields'); - $output = $layout->render(array('fieldXml' => $fieldXml, 'field' => $field)); - echo $output; + + if ($field->type == 'Ucmsubform' && $fieldValue) + { + $ucmSubFormData = json_decode($tjucmItemFormModel->getUcmSubFormFieldDataJson($item->id, $field)); + $field->setValue($ucmSubFormData); + ?> +
+
label; ?>:
+
+ getFieldData($field->getAttribute('name')); + + $ucmSubFormFieldParams = json_decode($fieldData->params); + $ucmSubFormFormSource = explode('/', $ucmSubFormFieldParams->formsource); + $ucmSubFormClient = $ucmSubFormFormSource[1] . '.' . str_replace('form_extra.xml', '', $ucmSubFormFormSource[4]); + $view = explode('.', $ucmSubFormClient); + $ucmSubFormData = (array) $ucmSubFormData; + + if (!empty($ucmSubFormData)) + { + $count = 0; + + foreach ($ucmSubFormData as $subFormData) + { + $count++; + $contentIdFieldname = str_replace('.', '_', $ucmSubFormClient) . '_contentid'; + + $ucmSubformFormObject = $tjucmItemModel->getFormExtra( + array( + "clientComponent" => 'com_tjucm', + "client" => $ucmSubFormClient, + "view" => $view[1], + "layout" => 'default', + "content_id" => $subFormData->$contentIdFieldname) + ); + + $ucmSubFormFormXml = simplexml_load_file($field->formsource); + + $ucmSubFormCount = 0; + + foreach ($ucmSubFormFormXml as $ucmSubFormXmlFieldSet) + { + $ucmSubFormXmlFieldSets[$ucmSubFormCount] = $ucmSubFormXmlFieldSet; + $ucmSubFormCount++; + } + + $ucmSubFormRecordData = $tjucmItemModel->getData($subFormData->$contentIdFieldname); + + // Call the JLayout recursively to render fields of ucmsubform + $layout = new JLayoutFile('fields', JPATH_ROOT . '/components/com_tjucm/layouts/detail'); + echo $layout->render(array('xmlFormObject' => $ucmSubFormXmlFieldSets, 'formObject' => $ucmSubformFormObject, 'itemData' => $ucmSubFormRecordData, 'isSubForm' => 1)); + + if (count($ucmSubFormData) > $count) + { + echo "
"; + } + } + } + ?> +
+
+ type), $fieldLayout + ) + ) ? $fieldLayout[ucfirst($tjFieldsFieldTable->type)] : 'field'; + $layout = new JLayoutFile($layoutToUse, JPATH_ROOT . '/components/com_tjfields/layouts/fields'); + $output = $layout->render(array('fieldXml' => $fieldXml, 'field' => $field)); + echo $output; + } } ?> params); + // Check if UCM type is subform $isSubform = $ucmTypeParams->get('is_subform'); @@ -908,6 +909,16 @@ public function getUcmSubFormFieldDataJson($parentRecordId, $efd) $subFormData->$ucmSubformContentIdFieldName = $contentId; $concat = $efd->name . $key; + + // Check if any field has value for the subform entry and if there is no value in subform then dont show it + $subFormDataArray = (array) $subFormData; + unset($subFormDataArray[$ucmSubformContentIdFieldName]); + + if (empty($subFormDataArray)) + { + continue; + } + $ucmSubFormFieldData->$concat = $subFormData; }