From c943ecf0c93033e0bbe04218d2c010352d086907 Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Wed, 4 Sep 2019 15:45:56 +0530 Subject: [PATCH 001/273] Task #188 feat: Added ACL check for cluster on form view page --- .../site/views/itemform/view.html.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) 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 98292ec6..b42646a7 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -18,6 +18,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Component\ComponentHelper; /** * View to edit @@ -115,6 +116,25 @@ public function display($tpl = null) if ($this->id && !$clusterId) { $input->set('cluster_id', $this->item->cluster_id); + $clusterId = $this->item->cluster_id; + } + + // 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 From 1b6cb52fed60b978e50414a4c56458f297832e75 Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Wed, 4 Sep 2019 15:54:34 +0530 Subject: [PATCH 002/273] Task #169 fix: Resolve PHP CS and fatal error of getListQuery --- .../com_tjucm/site/models/items.php | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 62a62ecf..33ee338a 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -93,7 +93,7 @@ protected function populateState($ordering = "a.id", $direction = "DESC") foreach ($fields as $field) { $filterValue = $app->getUserStateFromRequest($this->context . '.' . $field->name, $field->name, '', 'STRING'); - $this->setState('filter.field.' . $field->name, $filterValue); + $this->setState('filter.field.' . $field->name, $filterValue); } if (empty($ucmType)) @@ -230,7 +230,7 @@ protected function getListQuery() } } - $query->where($db->quoteName('a.cluster_id') . ' IN (' . implode(",", $usersClusters) . ')'); + $query->where($db->quoteName('a.cluster_id') . " IN ('" . implode("','", $usersClusters) . "')"); } } @@ -272,7 +272,7 @@ protected function getListQuery() else { // If no search results found then do not return any record - $query->where($db->quoteName('a.id') . '=0'); + $query->where($db->quoteName('a.id') . '=0'); } } @@ -337,12 +337,13 @@ private function filterContent() if ($filterFieldsCount > 1) { - $query->join('LEFT', $db->qn('#__tjfields_fields_value', 'fv' . $filterFieldsCount) . ' ON (' . $db->qn('fv' . ($filterFieldsCount-1).'.content_id') . ' = ' . $db->qn('fv'.$filterFieldsCount.'.content_id') . ')'); + $query->join('LEFT', $db->qn('#__tjfields_fields_value', 'fv' . $filterFieldsCount) . ' ON (' . + $db->qn('fv' . ($filterFieldsCount - 1) . '.content_id') . ' = ' . $db->qn('fv' . $filterFieldsCount . '.content_id') . ')'); } $search = trim(str_replace($field . ':', '', $search)); - $query->where($db->qn('fv'.$filterFieldsCount.'.field_id') . ' = ' . $fieldId); - $query->where($db->qn('fv'.$filterFieldsCount.'.value') . ' LIKE ' . $db->q('%' . $search . '%')); + $query->where($db->qn('fv' . $filterFieldsCount . '.field_id') . ' = ' . $fieldId); + $query->where($db->qn('fv' . $filterFieldsCount . '.value') . ' LIKE ' . $db->q('%' . $search . '%')); $filterFieldFound = 1; $filterApplied = 1; @@ -358,12 +359,13 @@ private function filterContent() if ($filterFieldsCount > 1) { - $query->join('LEFT', $db->qn('#__tjfields_fields_value', 'fv' . $filterFieldsCount) . ' ON (' . $db->qn('fv' . ($filterFieldsCount-1).'.content_id') . ' = ' . $db->qn('fv'.$filterFieldsCount.'.content_id') . ')'); + $query->join('LEFT', $db->qn('#__tjfields_fields_value', 'fv' . $filterFieldsCount) . ' ON (' . + $db->qn('fv' . ($filterFieldsCount - 1) . '.content_id') . ' = ' . $db->qn('fv' . $filterFieldsCount . '.content_id') . ')'); } - $query->where($db->quoteName('fv'.$filterFieldsCount.'.value') . ' LIKE ' . $db->q('%' . $search . '%')); + $query->where($db->quoteName('fv' . $filterFieldsCount . '.value') . ' LIKE ' . $db->q('%' . $search . '%')); $filterApplied = 1; - } + } // For filterable fields JLoader::import('components.com_tjfields.models.fields', JPATH_ADMINISTRATOR); @@ -382,11 +384,12 @@ private function filterContent() if ($filterFieldsCount > 1) { - $query->join('LEFT', $db->qn('#__tjfields_fields_value', 'fv' . $filterFieldsCount) . ' ON (' . $db->qn('fv' . ($filterFieldsCount-1).'.content_id') . ' = ' . $db->qn('fv'.$filterFieldsCount.'.content_id') . ')'); + $query->join('LEFT', $db->qn('#__tjfields_fields_value', 'fv' . $filterFieldsCount) . ' ON (' . + $db->qn('fv' . ($filterFieldsCount - 1) . '.content_id') . ' = ' . $db->qn('fv' . $filterFieldsCount . '.content_id') . ')'); } - $query->where($db->qn('fv'.$filterFieldsCount.'.field_id') . ' = ' . $field->id); - $query->where($db->qn('fv'.$filterFieldsCount.'.value') . ' = ' . $db->q($filterValue)); + $query->where($db->qn('fv' . $filterFieldsCount . '.field_id') . ' = ' . $field->id); + $query->where($db->qn('fv' . $filterFieldsCount . '.value') . ' = ' . $db->q($filterValue)); $filterApplied = 1; } } From 68715d925ce303e29643be5d8c30aee3a8877731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Thu, 24 Oct 2019 12:22:12 +0530 Subject: [PATCH 003/273] Task #152038 chore: On page load check Ucm type compatibility --- .../com_tjucm/administrator/models/type.php | 57 ++++++++++++++++++- .../languages/site/en-GB/en-GB.com_tjucm.ini | 4 ++ src/components/com_tjucm/media/js/load_js.php | 1 + .../site/controllers/itemform.json.php | 49 ++++++++++++++++ .../com_tjucm/site/layouts/list/list.php | 3 + .../site/views/items/tmpl/default.php | 55 ++++++++++++++++++ 6 files changed, 168 insertions(+), 1 deletion(-) diff --git a/src/components/com_tjucm/administrator/models/type.php b/src/components/com_tjucm/administrator/models/type.php index 782c53a2..6dacdfa0 100644 --- a/src/components/com_tjucm/administrator/models/type.php +++ b/src/components/com_tjucm/administrator/models/type.php @@ -13,6 +13,8 @@ jimport('joomla.application.component.modeladmin'); +use Joomla\CMS\MVC\Model\BaseDatabaseModel; + /** * Tjucm model. * @@ -543,11 +545,64 @@ public function delete(&$pks) // Delete UCM type if (!parent::delete($pk)) - { + { return false; } } return true; } + + /** + * Method to validation before copy items + * + * @param object $sourceClient Source client. + * @param object $targetClient Tareget client. + * + * @return Boolean + * + * @since __DEPLOY_VERSION__ + */ + public function checkCompatibility($sourceClient, $targetClient) + { + $validUcmType = array(); + + if ($sourceClient && $targetClient) + { + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models'); + $sourceFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); + $sourceFieldsModel->setState('filter.client', $sourceClient); + $targetFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); + $targetFieldsModel->setState('filter.client', $targetClient); + $sourceFields = $sourceFieldsModel->getItems(); + $targetFields = $targetFieldsModel->getItems(); + + $count = 0; + + foreach ($sourceFields as $sourceField) + { + $prefix = str_replace(".", "_", $sourceClient); + $sourceFieldName = explode($prefix . "_", $sourceField->name); + + foreach ($targetFields as $targetField) + { + $prefix = str_replace(".", "_", $targetClient); + $targetFieldName = explode($prefix . "_", $targetField->name); + + if ($sourceFieldName == $targetFieldName && $sourceField->type == $targetField->type) + { + $count ++; + continue; + } + } + } + + if (count($sourceFields) == $count) + { + return true; + } + + return false; + } + } } 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 f2c102ea..7a9f1075 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 @@ -178,3 +178,7 @@ COM_TJUCM_FORM_SAVE_FAILED_CLIENT_REQUIRED="Unable to process the request as cli COM_TJUCM_FORM_SAVE_FAILED_RECORD_ID_REQUIRED="Unable to process the request as record id is not provided" COM_TJUCM_FORM_SAVE_FAILED_FIELD_DATA_REQUIRED="Unable to process the request as field data is not provided" COM_TJUCM_FORM_SAVE_FAILED_AUTHORIZATION_ERROR="You are not authorized to perform this operation." + +; Since 1.2.3 +COM_TJUCM_COPY_ITEM="Copy" +COM_TJUCM_COPY_ITEM_TO_OTHER="Copy to Other" diff --git a/src/components/com_tjucm/media/js/load_js.php b/src/components/com_tjucm/media/js/load_js.php index b7007e06..c06ed2a8 100755 --- a/src/components/com_tjucm/media/js/load_js.php +++ b/src/components/com_tjucm/media/js/load_js.php @@ -21,3 +21,4 @@ JHtml::script(JUri::root() . 'media/com_tjucm/js/com_tjucm.js'); JHtml::script(JUri::root() . 'media/com_tjucm/js/core/base.js'); JHtml::script(Juri::root() . 'media/com_tjucm/js/services/item.js'); +JHtml::script(Juri::root() . 'media/com_tjucm/js/services/items.js'); diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index f5f3a285..9c5c4bc4 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -16,6 +16,7 @@ use Joomla\CMS\Session\Session; use Joomla\CMS\Router\Route; use Joomla\Registry\Registry; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; jimport('joomla.filesystem.file'); @@ -495,4 +496,52 @@ public function getRelatedFieldOptions() echo new JResponseJson($updatedOptionsForRelatedField); $app->close(); } + + /** + * Method to check the compatibility between ucm types + * + * @return mixed + * + * @since __DEPLOY_VERSION__ + */ + public function checkCompatibility() + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + $app = Factory::getApplication(); + $post = $app->input->post; + $client = $post->get('client', '', 'STRING'); + + if (empty($client)) + { + echo new JResponseJson(null); + $app->close(); + } + + JLoader::import('components.com_tjucm.models.types', JPATH_ADMINISTRATOR); + $typesModel = BaseDatabaseModel::getInstance('Types', 'TjucmModel'); + $typesModel->setState('filter.state', 1); + $ucmTypes = $typesModel->getItems(); + + JLoader::import('components.com_tjucm.models.type', JPATH_ADMINISTRATOR); + $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->checkCompatibility($client, $type->unique_identifier); + + if ($result) + { + $validUcmType[$key]['value'] = $type->unique_identifier; + $validUcmType[$key]['text'] = $type->title; + } + } + + echo new JResponseJson($validUcmType); + $app->close(); + } } diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 91ac31b4..836daa53 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -84,6 +84,9 @@ } ?> + + id); ?> + state)) { 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 47084072..f1b87aea 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -14,6 +14,7 @@ JHtml::_('bootstrap.tooltip'); JHtml::_('behavior.multiselect'); JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('jquery.token'); $user = JFactory::getUser(); $userId = $user->get('id'); @@ -41,6 +42,27 @@ $itemId = $tjUcmFrontendHelper->getItemId($link); $fieldsData = array(); ?> +
loadTemplate('filters'); ?>
@@ -52,6 +74,9 @@ {?> + + + items[0]->state)) { @@ -171,6 +196,12 @@ + + + + + + @@ -179,6 +210,30 @@ + + + canDelete) From 0360d04b979cee621de87edc5df4481286fdd397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 4 Nov 2019 12:52:36 +0530 Subject: [PATCH 004/273] Bug #218 fix: Editor field do not shows formated text in the list and details view --- src/components/com_tjucm/site/layouts/detail/fields.php | 1 + src/components/com_tjucm/site/layouts/list/list.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/components/com_tjucm/site/layouts/detail/fields.php b/src/components/com_tjucm/site/layouts/detail/fields.php index 38b6dfda..634b9502 100644 --- a/src/components/com_tjucm/site/layouts/detail/fields.php +++ b/src/components/com_tjucm/site/layouts/detail/fields.php @@ -30,6 +30,7 @@ $fieldLayout['Related'] = $fieldLayout['SQL'] = "sql"; $fieldLayout['Subform'] = "subform"; $fieldLayout['Ownership'] = "ownership"; +$fieldLayout['Editor'] = "editor"; // Load the tj-fields helper JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 22506057..3589eaa5 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -31,6 +31,7 @@ $fieldLayout['Cluster'] = "cluster"; $fieldLayout['Related'] = $fieldLayout['Sql'] = "sql"; $fieldLayout['Ownership'] = "ownership"; +$fieldLayout['Editor'] = "editor"; // Load the tj-fields helper JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); From 8832cb3429a23de7dcea16b433518b4d3b22c808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 4 Nov 2019 16:36:51 +0530 Subject: [PATCH 005/273] Bug #218 fix: Editor field do not shows formated text in the list and details view --- .../languages/site/en-GB/en-GB.com_tjucm.ini | 3 +++ src/components/com_tjucm/site/router.php | 13 ++++++++----- .../com_tjucm/site/views/itemform/view.html.php | 5 +---- 3 files changed, 12 insertions(+), 9 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 811f4bea..eb9f7ded 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 @@ -179,3 +179,6 @@ COM_TJUCM_FORM_SAVE_FAILED_CLIENT_REQUIRED="Unable to process the request as cli COM_TJUCM_FORM_SAVE_FAILED_RECORD_ID_REQUIRED="Unable to process the request as record id is not provided" COM_TJUCM_FORM_SAVE_FAILED_FIELD_DATA_REQUIRED="Unable to process the request as field data is not provided" COM_TJUCM_FORM_SAVE_FAILED_AUTHORIZATION_ERROR="You are not authorized to perform this operation." + +; Since 1.2.2 +COM_TJUCM_SOMETHING_WENT_WRONG="Something went wrong" diff --git a/src/components/com_tjucm/site/router.php b/src/components/com_tjucm/site/router.php index 0eb0898f..f1fc2a97 100644 --- a/src/components/com_tjucm/site/router.php +++ b/src/components/com_tjucm/site/router.php @@ -148,12 +148,15 @@ public function parse(&$segments) if ($count >= 1) { - $ucmTypeTable = Table::getInstance('Type', 'TjucmTable', array('dbo', $db)); - $ucmTypeTable->load(array('alias' => $segments[1])); - - if ($ucmTypeTable->id) + if (isset($segments[1])) { - $vars['client'] = $ucmTypeTable->unique_identifier; + $ucmTypeTable = Table::getInstance('Type', 'TjucmTable', array('dbo', $db)); + $ucmTypeTable->load(array('alias' => $segments[1])); + + if ($ucmTypeTable->id) + { + $vars['client'] = $ucmTypeTable->unique_identifier; + } } } 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 693e3754..c782dc44 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -239,10 +239,7 @@ public function display($tpl = null) // Check for errors. if (count($errors = $this->get('Errors'))) { - foreach ($errors as $error) - { - $app->enqueueMessage($error, 'error'); - } + $app->enqueueMessage(Text::_("COM_TJUCM_SOMETHING_WENT_WRONG"), 'error'); return false; } From 55a5c6a2ee3f8a460d2f3ee64e1cde53fae4a90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 4 Nov 2019 16:45:52 +0530 Subject: [PATCH 006/273] Bug #218 fix: Editor field do not shows formated text in the list and details view --- src/components/com_tjucm/tjucm.xml | 2 +- src/pkg_tjucm.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/tjucm.xml b/src/components/com_tjucm/tjucm.xml index 6adf1a51..876a72f3 100644 --- a/src/components/com_tjucm/tjucm.xml +++ b/src/components/com_tjucm/tjucm.xml @@ -6,7 +6,7 @@ Techjoomla extensions@techjoomla.com https://techjoomla.com - 25th Oct 2019 + 4th Nov 2019 1.2.2 TJ-UCM - Universal Content Manager]]> script.php diff --git a/src/pkg_tjucm.xml b/src/pkg_tjucm.xml index b326c6a7..fbaaf95c 100644 --- a/src/pkg_tjucm.xml +++ b/src/pkg_tjucm.xml @@ -6,7 +6,7 @@ TJUCM - Universal Content Manager Package Copyright (c) 2009-2019 Techjoomla. All rights reserved. http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - 25th Oct 2019 + 4th Nov 2019 ucm 1.2.2 Techjoomla Team From 048fab5fa6af4251b788b141d6f416385aaf945e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 6 Nov 2019 12:32:28 +0530 Subject: [PATCH 007/273] Bug #223 fix: Pagination not working as expected when we filter the content in the list view --- src/components/com_tjucm/site/models/items.php | 18 ++++++++---------- .../site/views/items/tmpl/default.php | 4 ---- .../site/views/items/tmpl/default_filters.php | 6 +++++- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index bcda4f90..87f85bdc 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -93,7 +93,7 @@ protected function populateState($ordering = "a.id", $direction = "DESC") foreach ($fields as $field) { $filterValue = $app->getUserStateFromRequest($this->context . '.' . $field->name, $field->name, '', 'STRING'); - $this->setState('filter.field.' . $field->name, $filterValue); + $this->setState('filter.field.' . $field->name, $filterValue); } if (empty($ucmType)) @@ -272,7 +272,7 @@ protected function getListQuery() else { // If no search results found then do not return any record - $query->where($db->quoteName('a.id') . '=0'); + $query->where($db->quoteName('a.id') . '=0'); } } @@ -341,8 +341,8 @@ private function filterContent() } $search = trim(str_replace($field . ':', '', $search)); - $query->where($db->qn('fv'.$filterFieldsCount.'.field_id') . ' = ' . $fieldId); - $query->where($db->qn('fv'.$filterFieldsCount.'.value') . ' LIKE ' . $db->q('%' . $search . '%')); + $query->where($db->qn('fv' . $filterFieldsCount . '.field_id') . ' = ' . $fieldId); + $query->where($db->qn('fv' . $filterFieldsCount . '.value') . ' LIKE ' . $db->q('%' . $search . '%')); $filterFieldFound = 1; $filterApplied = 1; @@ -361,9 +361,9 @@ private function filterContent() $query->join('LEFT', $db->qn('#__tjfields_fields_value', 'fv' . $filterFieldsCount) . ' ON (' . $db->qn('fv' . ($filterFieldsCount-1).'.content_id') . ' = ' . $db->qn('fv'.$filterFieldsCount.'.content_id') . ')'); } - $query->where($db->quoteName('fv'.$filterFieldsCount.'.value') . ' LIKE ' . $db->q('%' . $search . '%')); + $query->where($db->quoteName('fv' . $filterFieldsCount . '.value') . ' LIKE ' . $db->q('%' . $search . '%')); $filterApplied = 1; - } + } // For filterable fields JLoader::import('components.com_tjfields.models.fields', JPATH_ADMINISTRATOR); @@ -385,14 +385,12 @@ private function filterContent() $query->join('LEFT', $db->qn('#__tjfields_fields_value', 'fv' . $filterFieldsCount) . ' ON (' . $db->qn('fv' . ($filterFieldsCount-1).'.content_id') . ' = ' . $db->qn('fv'.$filterFieldsCount.'.content_id') . ')'); } - $query->where($db->qn('fv'.$filterFieldsCount.'.field_id') . ' = ' . $field->id); - $query->where($db->qn('fv'.$filterFieldsCount.'.value') . ' = ' . $db->q($filterValue)); + $query->where($db->qn('fv' . $filterFieldsCount . '.field_id') . ' = ' . $field->id); + $query->where($db->qn('fv' . $filterFieldsCount . '.value') . ' = ' . $db->q($filterValue)); $filterApplied = 1; } } - $query->setLimit($this->getState('list.limit')); - // If there is any filter applied then only execute the query if ($filterApplied) { 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 2db9ffdb..61e0c4b5 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -33,10 +33,6 @@ $appendUrl .= "&client=" . $this->client; } -$tmpListColumn = $this->listcolumn; -reset($tmpListColumn); -$firstListColumn = key($tmpListColumn); - $link = 'index.php?option=com_tjucm&view=items' . $appendUrl; $itemId = $tjUcmFrontendHelper->getItemId($link); $fieldsData = array(); 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 769b7066..945418ea 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 @@ -11,6 +11,10 @@ defined('_JEXEC') or die; use Joomla\CMS\Component\ComponentHelper; + +$tmpListColumn = $this->listcolumn; +reset($tmpListColumn); +$firstListColumn = key($tmpListColumn); ?>
@@ -81,4 +85,4 @@ } ?>
-

\ No newline at end of file +

From 21858986c7008d30e43ba2c6bf67cbeef9b8368b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 6 Nov 2019 12:58:48 +0530 Subject: [PATCH 008/273] Bug #223 fix: Pagination not working as expected when we filter the content in the list view --- src/components/com_tjucm/site/models/items.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 87f85bdc..ba3d53d4 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -391,6 +391,9 @@ private function filterContent() } } + $query->order('fv1.content_id DESC'); + $query->group('fv1.content_id'); + // If there is any filter applied then only execute the query if ($filterApplied) { From 74f05ef23657665fbe0caf8e3d7491064e50359a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 6 Nov 2019 17:22:04 +0530 Subject: [PATCH 009/273] Bug #225 fix: Navigation buttons are not visible if there are multiple tabs and auto save and save as draft is disabled --- .../languages/site/en-GB/en-GB.com_tjucm.ini | 8 +++--- .../site/views/itemform/tmpl/default.php | 28 ++++++++++--------- 2 files changed, 19 insertions(+), 17 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 eb9f7ded..3f359642 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 @@ -150,14 +150,14 @@ COM_TJUCM_TYPES_ADD_NEW_DATA_URL="Create Item" COM_TJUCM_NEXT_BUTTON="Next" COM_TJUCM_PREVIOUS_BUTTON="Previous" COM_TJUCM_CANCEL_BUTTON="Cancel" -COM_TJUCM_SAVE_ITEM="Submit Section" -COM_TJUCM_SAVE_AS_DRAFT_ITEM="Save Section Progress" +COM_TJUCM_SAVE_ITEM="Submit" +COM_TJUCM_SAVE_AS_DRAFT_ITEM="Save Progress" COM_TJUCM_NOTE_ON_FORM="Please make sure you have filled all the fields before you submit the form" COM_TJUCM_MSG_ON_SAVED_FORM="Data saved successfully." -COM_TJUCM_MSG_ON_DRAFT_FORM="Section saved as draft successfully" +COM_TJUCM_MSG_ON_DRAFT_FORM="Saved as draft successfully" COM_TJUCM_ALLOWED_COUNT_LIMIT="You are allowed to fill this form upto %d time(s) only" COM_TJUCM_NO_FIELDS_TO_SHOW_ON_LIST_VIEW="Please set 'Show on list view' to 'yes' for at least one field of this UCM type" -COM_TJUCM_ITEMFORM_SUBMIT_ALERT="Are you sure you want to submit this section?"; +COM_TJUCM_ITEMFORM_SUBMIT_ALERT="Are you sure you want to submit this form?"; COM_TJUCM_NO_ACTIVITIES="There are no activities here yet" COM_TJUCM_SAVE_FAILED="Save failed: %s" COM_TJUCM_DELETE_FAILED="Delete failed: %s" 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 89f2358d..561d185e 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/default.php +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default.php @@ -162,23 +162,23 @@ if (isset($setnavigation) && $setnavigation == true) { - if (!empty($this->allow_draft_save)) - { - ?> - - - + + + + + allow_auto_save || $this->allow_draft_save) && $itemState) { ?> @@ -190,6 +190,8 @@ ?> " id="tjUcmSectionFinalSave" onclick="tjUcmItemForm.saveUcmFormData();" /> + " onclick="Joomla.submitbutton('itemform.cancel');" /> + From 9770b7cac1ea702ab614658c7c31d5884433fdcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Thu, 7 Nov 2019 16:01:46 +0530 Subject: [PATCH 010/273] Task #152039 --- .../languages/site/en-GB/en-GB.com_tjucm.ini | 1 + .../site/controllers/itemform.json.php | 178 ++++++++++++++++++ .../site/views/items/tmpl/default.php | 50 +++-- 3 files changed, 218 insertions(+), 11 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 7a9f1075..0a2a77db 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 @@ -182,3 +182,4 @@ COM_TJUCM_FORM_SAVE_FAILED_AUTHORIZATION_ERROR="You are not authorized to perfor ; Since 1.2.3 COM_TJUCM_COPY_ITEM="Copy" COM_TJUCM_COPY_ITEM_TO_OTHER="Copy to Other" +COM_TJUCM_ITEM_COPY_SUCCESSFULLY="Item successfully copied as draft" diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 9c5c4bc4..338ecf18 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -544,4 +544,182 @@ public function checkCompatibility() echo new JResponseJson($validUcmType); $app->close(); } + + /** + * Method to copy item + * + * @return boolean + * + * @since __DEPLOY_VERSION__ + */ + public function copyItem() + { + // Check for request forgeries. + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + $app = Factory::getApplication(); + $post = $app->input->post; + + $sourceClient = $app->input->get('sourceClient', '', 'string'); + $filter = $app->input->get('filter', '', 'ARRAY'); + $targetClient = $filter['ucm_list']; + + JLoader::import('components.com_tjucm.models.type', JPATH_ADMINISTRATOR); + $typeModel = BaseDatabaseModel::getInstance('Type', 'TjucmModel'); + $result = $typeModel->checkCompatibility($sourceClient, $targetClient); + + if ($result) + { + $copyIds = $app->input->get('cid'); + JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); + $tjFieldsHelper = new TjfieldsHelper; + + if (count($copyIds)) + { + $model = $this->getModel('itemform'); + $model->setClient($targetClient); + + foreach ($copyIds as $cid) + { + $ucmOldData = array(); + $ucmOldData['clientComponent'] = 'com_tjucm'; + $ucmOldData['content_id'] = $cid; + $ucmOldData['layout'] = 'edit'; + $ucmOldData['client'] = $sourceClient; + $extraFieldsData = $model->loadFormDataExtra($ucmOldData); + + foreach ($extraFieldsData as $fieldKey => $fieldValue) + { + $prefixSourceClient = str_replace(".", "_", $sourceClient); + $fieldName = explode($prefixSourceClient . "_", $fieldKey); + $prefixTargetClient = str_replace(".", "_", $targetClient); + $targetFieldName = $prefixTargetClient . '_' . $fieldName[1]; + $tjFieldsTable = $tjFieldsHelper->getFieldData($targetFieldName); + + if ($tjFieldsTable->type == 'ucmsubform') + { + $params = json_decode($tjFieldsTable->params)->formsource; + $subFormClient = explode('components/com_tjucm/models/forms/', $params); + $subFormClient = explode('form_extra.xml', $subFormClient[1]); + $subFormClient = 'com_tjucm.' . $subFormClient[0]; + + $tjFieldsTable = $tjFieldsHelper->getFieldData($fieldKey); + $params = json_decode($tjFieldsTable->params)->formsource; + $subFormSourceClient = explode('components/com_tjucm/models/forms/', $params); + $subFormSourceClient = explode('form_extra.xml', $subFormSourceClient[1]); + $subFormSourceClient = 'com_tjucm.' . $subFormSourceClient[0]; + } + + $subFormData = (array) json_decode($fieldValue); + + if ($subFormData) + { + foreach ($subFormData as $keyData => $data) + { + $prefixSourceClient = str_replace(".", "_", $sourceClient); + $fieldName = explode($prefixSourceClient . "_", $keyData); + $prefixTargetClient = str_replace(".", "_", $targetClient); + $subTargetFieldName = $prefixTargetClient . '_' . $fieldName[1]; + $data = (array) $data; + + foreach ((array) $data as $key => $d) + { + $prefixSourceClient = str_replace(".", "_", $subFormSourceClient); + $fieldName = explode($prefixSourceClient . "_", $key); + $prefixTargetClient = str_replace(".", "_", $subFormClient); + $subFieldName = $prefixTargetClient . '_' . $fieldName[1]; + + JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/tables'); + $fieldTable = JTable::getInstance('field', 'TjfieldsTable'); + + $fieldTable->load(array('name' => $key)); + + if ($fieldName[1] == 'contentid') + { + $d = ''; + } + + $temp = array(); + + if (is_array($d)) + { + switch ($fieldTable->type) + { + case 'tjlist': + case 'related': + case 'multi_select': + foreach ($d as $option) + { + $temp[] = $option->value; + } + + if (!empty($temp)) + { + $data[$subFieldName] = $temp; + } + + break; + + default: + foreach ($d as $option) + { + $data[$subFieldName] = $option->value; + } + break; + } + } + else + { + $data[$subFieldName] = $d; + } + + unset($data[$key]); + } + + $subFormData[$subTargetFieldName] = $data; + unset($subFormData[$keyData]); + } + + $extraFieldsData[$targetFieldName] = $subFormData; + } + else + { + $extraFieldsData[$targetFieldName] = $fieldValue; + } + + unset($extraFieldsData[$fieldKey]); + } + + $ucmData = array(); + $ucmData['id'] = 0; + $ucmData['client'] = $targetClient; + $ucmData['parent_id'] = 0; + $ucmData['state'] = 0; + $ucmData['draft'] = 1; + + $result = $model->save($ucmData); + $recordId = $model->getState($model->getName() . '.id'); + + if ($recordId) + { + $formData = array(); + $formData['content_id'] = $recordId; + $formData['fieldsvalue'] = $extraFieldsData; + $formData['client'] = $targetClient; + + // If data is valid then save the data into DB + $response = $model->saveExtraFields($formData); + + $msg = ($response) ? Text::_("COM_TJUCM_ITEM_COPY_SUCCESSFULLY") : Text::_("COM_TJUCM_FORM_SAVE_FAILED"); + + echo new JResponseJson($response, $msg); + $app->close(); + } + + echo new JResponseJson(null); + $app->close(); + } + } + } + } } 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 f1b87aea..64da47f6 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -12,6 +12,8 @@ JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); JHtml::_('bootstrap.tooltip'); +JHtml::_('behavior.keepalive'); +JHtml::_('behavior.formvalidation'); JHtml::_('behavior.multiselect'); JHtml::_('formbehavior.chosen', 'select'); JHtml::_('jquery.token'); @@ -41,19 +43,19 @@ $link = 'index.php?option=com_tjucm&view=items' . $appendUrl; $itemId = $tjUcmFrontendHelper->getItemId($link); $fieldsData = array(); -?> - -
+ + 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]}); + } + else + { + Joomla.renderMessages({'error':[response.message]}); + } + } + + var copyItemData = jQuery('#adminForm').serialize(); + + // Code to copy item to ucm type + com_tjucm.Services.Items.copyItem(copyItemData, afterCopyItem); + } +"); +?> + loadTemplate('filters'); ?>
@@ -199,17 +226,16 @@ - + - + - + canDelete) From faa5d0586130a46acefdad3f933297afd0b62b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Thu, 7 Nov 2019 16:37:38 +0530 Subject: [PATCH 011/273] Task #152039 chore: On click of 'Copy' button call itemform controller task to Copy Item --- .../com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini | 1 - 1 file changed, 1 deletion(-) 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 21ee3d36..3e80eae2 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 @@ -187,4 +187,3 @@ COM_TJUCM_ITEM_COPY_SUCCESSFULLY="Item successfully copied as draft" ; Since 1.2.2 COM_TJUCM_SOMETHING_WENT_WRONG="Something went wrong" - From 90b3423793678574e700fd67f90c8bb07722e319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Thu, 7 Nov 2019 16:54:32 +0530 Subject: [PATCH 012/273] Task #227 fix: Unused code in repo --- .../site/controllers/itemform.json.php | 53 +- .../com_tjucm/site/controllers/itemform.php | 445 +------------- src/components/com_tjucm/site/models/item.php | 123 ---- .../com_tjucm/site/models/itemform.php | 566 +----------------- .../com_tjucm/site/models/items.php | 80 --- 5 files changed, 32 insertions(+), 1235 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index f5f3a285..95683603 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -63,52 +63,6 @@ public function __construct() parent::__construct(); } - /** - * Method to check if you can add a new record. - * - * Extended classes can override this if necessary. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 12.2 - */ - protected function allowAdd($data = array()) - { - $user = Factory::getUser(); - - return $user->authorise('core.type.createitem', 'com_tjucm.type.' . $this->ucmTypeId); - } - - /** - * Method to check if you can edit an existing record. - * - * Extended classes can override this if necessary. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key; default is id. - * - * @return boolean - * - * @since 12.2 - */ - protected function allowEdit($data = array(), $key = 'id') - { - $user = Factory::getUser(); - $edit = $user->authorise('core.type.edititem', 'com_tjucm.type.' . $this->ucmTypeId); - $editOwn = $user->authorise('core.type.editownitem', 'com_tjucm.type.' . $this->ucmTypeId); - - if ($edit || $editOwn) - { - return true; - } - else - { - return false; - } - } - /** * Function to save ucm data item * @@ -472,6 +426,13 @@ private function processErrors($errors) } } + /** + * Method to get updated list of options for related field + * + * @return void + * + * @since 1.2.1 + */ public function getRelatedFieldOptions() { JSession::checkToken() or jexit(Text::_('JINVALID_TOKEN')); diff --git a/src/components/com_tjucm/site/controllers/itemform.php b/src/components/com_tjucm/site/controllers/itemform.php index 0517aa72..8f64a208 100644 --- a/src/components/com_tjucm/site/controllers/itemform.php +++ b/src/components/com_tjucm/site/controllers/itemform.php @@ -18,8 +18,6 @@ jimport('joomla.filesystem.file'); -require_once JPATH_SITE . "/components/com_tjfields/filterFields.php"; - /** * Item controller class. * @@ -27,9 +25,6 @@ */ class TjucmControllerItemForm extends JControllerForm { - // Use imported Trait in model - use TjfieldsFilterField; - /** * Constructor * @@ -90,66 +85,6 @@ public function __construct() parent::__construct(); } - /** - * Method to add a new record. - * - * @return boolean True if the record can be added, false if not. - * - * @since 12.2 - */ - public function add() - { - $app = Factory::getApplication(); - $context = "$this->option.edit.$this->context"; - - $tjUcmFrontendHelper = new TjucmHelpersTjucm; - - // Access check. - if (!$this->allowAdd()) - { - // Set the internal error and also the redirect error. - $this->setError(Text::_('JLIB_APPLICATION_ERROR_CREATE_RECORD_NOT_PERMITTED')); - $this->setMessage($this->getError(), 'error'); - - $link = 'index.php?option=com_tjucm&view=items' . $this->appendUrl; - $itemId = $tjUcmFrontendHelper->getItemId($link); - - $this->setRedirect(Route::_($link . '&Itemid=' . $itemId . $this->getRedirectToListAppend(), false)); - - return false; - } - - // Clear the record edit information from the session. - $app->setUserState($context . '.data', null); - - $clusterId = $app->input->getInt('cluster_id', 0); - $cluster = ''; - - // Check cluster exist - if ($clusterId) - { - $cluster = '&cluster_id=' . $clusterId; - } - - // Redirect to the edit screen. - $link = 'index.php?option=com_tjucm&view=itemform&client=' . $this->client; - $itemId = $tjUcmFrontendHelper->getItemId($link); - - $this->setRedirect(Route::_($link . '&Itemid=' . $itemId . $cluster . $this->getRedirectToItemAppend(), false)); - - return true; - } - - /** - * Function to apply field data changes - * - * @return void - */ - public function apply() - { - $this->save(); - } - /** * Method to check out an item for editing and redirect to the edit form. * @@ -197,338 +132,6 @@ public function edit($key = null, $urlVar = null) $this->setRedirect(Route::_('index.php?option=com_tjucm&view=itemform' . $recordId . '&Itemid=' . $itemId, false)); } - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 12.2 - */ - public function save($key = null, $urlVar = null) - { - // Check for request forgeries. - Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); - $app = Factory::getApplication(); - $lang = Factory::getLanguage(); - $model = $this->getModel(); - $task = $this->getTask(); - $formStatus = $app->input->get('form_status', '', 'STRING'); - - // Set client value - $model->setClient($this->client); - - $table = $model->getTable(); - - // Get the user data. - $data = $app->input->get('jform', array(), 'array'); - $data['id'] = empty($data['id']) ? 0 : (int) $data['id']; - $all_jform_data = $data; - - // Get file information - $files = $app->input->files->get('jform'); - - // Jform tweak - Get all posted data. - $post = $app->input->post; - - // Populate the row id from the session. - - // $data[$key] = $recordId; - - // The save2copy task needs to be handled slightly differently. - if ($task == 'save2copy') - { - // Check-in the original row. - if ($checkin && $model->checkin($data[$key]) === false) - { - // Check-in failed. Go back to the item and display a notice. - $this->setError(Text::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError())); - $this->setMessage($this->getError(), 'error'); - - echo new JResponseJson(null); - jexit(); - } - - // Reset the ID, the multilingual associations and then treat the request as for Apply. - $data[$key] = 0; - $data['associations'] = array(); - $task = 'apply'; - } - - // Access check. - if (!$this->allowSave($data, $key)) - { - $this->setError(Text::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED')); - $this->setMessage($this->getError(), 'error'); - - echo new JResponseJson(null); - jexit(); - } - - // Validate the posted data. - // Sometimes the form needs some posted data, such as for plugins and modules. - $form = $model->getForm($data, false); - - if (!$form) - { - $app->enqueueMessage($model->getError(), 'error'); - - echo new JResponseJson(null); - jexit(); - } - - // Test whether the data is valid. - $validData = $model->validate($form, $data); - - // Check for validation errors. - if ($validData === false) - { - // Get the validation messages. - $errors = $model->getErrors(); - - // Push up to three validation messages out to the user. - for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) - { - if ($errors[$i] instanceof Exception) - { - $app->enqueueMessage($errors[$i]->getMessage(), 'error'); - } - else - { - $app->enqueueMessage($errors[$i], 'error'); - } - } - - echo new JResponseJson(null); - jexit(); - } - - // Jform tweaking - get data for extra fields jform. - $extra_jform_data = array_diff_key($all_jform_data, $validData); - - // Check if form file is present. - jimport('joomla.filesystem.file'); - /* Explode client 1. Componet name 2.type */ - $client = explode(".", $this->client); - /* End */ - - $filePath = JPATH_ADMINISTRATOR . '/components/com_tjucm/models/forms/' . $client[1] . '_extra.xml'; - - if (JFile::exists($filePath)) - { - // Validate the posted data. - $formExtra = $model->getFormExtra( - array( - "category" => isset($data['category_id']) ? $data['category_id'] : '', - "clientComponent" => 'com_tjucm', - "client" => $this->client, - "view" => $client[1], - "layout" => 'edit', ) - ); - - if (!$formExtra) - { - JError::raiseWarning(500, $model->getError()); - - return false; - } - - if (!empty($formExtra)) - { - // Remove required attribute from fields if data is stored in draft mode - if ($formStatus == 'draft') - { - $validData['draft'] = 1; - $fieldSets = $formExtra->getFieldsets(); - - foreach ($fieldSets as $fieldset) - { - foreach ($formExtra->getFieldset($fieldset->name) as $field) - { - $formExtra->setFieldAttribute($field->fieldname, 'required', false); - $formExtra->setFieldAttribute($field->fieldname, 'validate', ''); - } - } - } - else - { - $validData['draft'] = 0; - } - - // Remove the fields having empty value from both the array before merge - if (is_array($data)) - { - $data = array_filter($data); - } - - if (is_array($files)) - { - $files = array_filter($files); - } - - /* If file field is required then in the validation method return false - * * so that we will mearge $data and $ files array using array_merge function - * * and pass to the validation funcation.*/ - - if (!empty($files)) - { - $extra_jform_data = array_merge_recursive($data, $files); - } - - // Validate the posted extra data. - $extra_jform_data = $model->validateExtra($formExtra, $extra_jform_data); - } - - // Check for errors. - if ($extra_jform_data === false) - { - // Get the validation messages. - $errors = $model->getErrors(); - - // Push up to three validation messages out to the user. - for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) - { - if ($errors[$i] instanceof Exception) - { - $app->enqueueMessage($errors[$i]->getMessage(), 'error'); - } - else - { - $app->enqueueMessage($errors[$i], 'error'); - } - } - - echo new JResponseJson(null); - jexit(); - } - } - - if (!isset($validData['tags'])) - { - $validData['tags'] = null; - } - - $response = ''; - - try - { - $status_title = $app->input->get('form_status'); - $validData['status'] = $status_title; - - if (!empty($files)) - { - $extra_jform_data['tjFieldFileField'] = $files; - } - - // If no data send then dont add any entry in item form table - start - $allow = 0; - - foreach ($extra_jform_data as $extra_data) - { - if ($extra_data != '') - { - $allow = 1; - - break; - } - } - - if (empty($allow)) - { - $app->enqueueMessage(Text::_("COM_TJUCM_NO_FORM_DATA"), 'error'); - - echo new JResponseJson(null); - jexit(); - } - - // Set cluster values to store in core UCM table values - $model->setClusterData($validData, $data); - - // Get sorted dataset of submitted ucmsubform records as per their client - $ucmSubFormDataSet = $model->getFormattedUcmSubFormRecords($validData, $extra_jform_data); - - $isNew = empty($validData['id']) ? 1 : 0; - - // Save parent form record - $recordId = $model->save($validData, $extra_jform_data); - $validData['parent_id'] = $recordId; - - // Save ucmSubForm records - if (!empty($ucmSubFormDataSet)) - { - $subFormContentIds = $model->saveUcmSubFormRecords($validData, $ucmSubFormDataSet); - } - - // Get updated options for related fields - $app->input->set('id', $recordId); - $updatedRelatedFieldsOptions = $model->getUdatedRelatedFieldOptions($recordId); - - if ($recordId === false) - { - echo new JResponseJson(null); - jexit(); - } - - if ($recordId) - { - $validData['id'] = $recordId; - - $dispatcher = JEventDispatcher::getInstance(); - JPluginHelper::importPlugin("system", "jlike_tjucm"); - $dispatcher->trigger('jlike_tjucmOnAfterSave', array($recordId, $validData)); - - // TJ-ucm plugin trigger after save - $dispatcher = JEventDispatcher::getInstance(); - JPluginHelper::importPlugin("content"); - $dispatcher->trigger('onUcmItemAfterSave', array($validData, $extra_jform_data, $isNew)); - - $response = $recordId; - $redirect_url = ''; - $redirect_msg = ''; - } - } - catch (Exception $e) - { - $response = $e; - $redirect_url = ''; - $redirect_msg = $e->getMessage(); - } - - if ($this->isajax) - { - if (!empty($response)) - { - $response = array('id' => $response); - - // Add subform record ids in the response - if (isset($subFormContentIds) && !empty($subFormContentIds)) - { - $response['childContentIds'] = $subFormContentIds; - } - - // Add updated options of related fields in the response - if (!empty($updatedRelatedFieldsOptions)) - { - $response['relatedFieldOptions'] = $updatedRelatedFieldsOptions; - } - } - - echo new JResponseJson($response); - jexit(); - } - else - { - $app->redirect($redirect_url, $redirect_msg); - } - - // Invoke the postSave method to allow for the child class to access the model. - $this->postSaveHook($model, $validData); - - return true; - } - /** * Method to cancel an edit. * @@ -665,58 +268,12 @@ public function redirectToListView($typeId, $allowedCount) Factory::getApplication()->redirect($link, sprintf(Text::_('COM_TJUCM_ALLOWED_COUNT_LIMIT'), $allowedCount), "Warning"); } - /** - * Method to check if you can add a new record. - * - * Extended classes can override this if necessary. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 12.2 - */ - protected function allowAdd($data = array()) - { - $user = Factory::getUser(); - - return $user->authorise('core.type.createitem', 'com_tjucm.type.' . $this->ucmTypeId); - } - - /** - * Method to check if you can edit an existing record. - * - * Extended classes can override this if necessary. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key; default is id. - * - * @return boolean - * - * @since 12.2 - */ - protected function allowEdit($data = array(), $key = 'id') - { - $user = Factory::getUser(); - $edit = $user->authorise('core.type.edititem', 'com_tjucm.type.' . $this->ucmTypeId); - $editOwn = $user->authorise('core.type.editownitem', 'com_tjucm.type.' . $this->ucmTypeId); - - if ($edit || $editOwn) - { - return true; - } - else - { - return false; - } - } - /** * Method to check out an item for copying and redirect to the edit form. * * @return void * - * @since __DEPLOY_VERSION__ + * @since 1.2.1 */ public function prepareForCopy() { diff --git a/src/components/com_tjucm/site/models/item.php b/src/components/com_tjucm/site/models/item.php index 02e31596..973a20be 100644 --- a/src/components/com_tjucm/site/models/item.php +++ b/src/components/com_tjucm/site/models/item.php @@ -241,109 +241,6 @@ public function getTable($type = 'Item', $prefix = 'TjucmTable', $config = array return JTable::getInstance($type, $prefix, $config); } - /** - * Get the id of an item by alias - * - * @param string $alias Item alias - * - * @return mixed - */ - public function getItemIdByAlias($alias) - { - $table = $this->getTable(); - - $table->load(array('alias' => $alias)); - - return $table->id; - } - - /** - * Method to check in an item. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkin($id = null) - { - // Get the id. - $id = (!empty($id)) ? $id : (int) $this->getState('item.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Attempt to check the row in. - if (method_exists($table, 'checkin')) - { - if (!$table->checkin($id)) - { - return false; - } - } - } - - return true; - } - - /** - * Method to check out an item for editing. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkout($id = null) - { - // Get the user id. - $id = (!empty($id)) ? $id : (int) $this->getState('item.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Get the current user object. - $user = JFactory::getUser(); - - // Attempt to check the row out. - if (method_exists($table, 'checkout')) - { - if (!$table->checkout($user->get('id'), $id)) - { - return false; - } - } - } - - return true; - } - - /** - * Get the name of a category by id - * - * @param int $id Category id - * - * @return Object|null Object if success, null in case of failure - */ - public function getCategoryName($id) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query - ->select('title') - ->from('#__categories') - ->where('id = ' . $id); - $db->setQuery($query); - - return $db->loadObject(); - } - /** * Publish the element * @@ -391,26 +288,6 @@ public function delete(&$id) } } - /** - * Method to getAliasFieldNameByView - * - * @param array $view An array of record primary keys. - * - * @return boolean True if successful, false if an error occurs. - * - * @since 1.0 - */ - public function getAliasFieldNameByView($view) - { - switch ($view) - { - case 'type': - case 'typeform': - return 'alias'; - break; - } - } - /** * Method to check if a user has permissions to view ucm items of given type * diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index 32175e0a..d42cd838 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -241,89 +241,6 @@ public function getTable($type = 'Item', $prefix = 'TjucmTable', $config = array return JTable::getInstance($type, $prefix, $config); } - /** - * Get an item by alias - * - * @param string $alias Alias string - * - * @return int Element id - */ - public function getItemIdByAlias($alias) - { - $table = $this->getTable(); - - $table->load(array('alias' => $alias)); - - return $table->id; - } - - /** - * Method to check in an item. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkin($id = null) - { - // Get the id. - $id = (!empty($id)) ? $id : (int) $this->getState('item.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Attempt to check the row in. - if (method_exists($table, 'checkin')) - { - if (!$table->checkin($id)) - { - return false; - } - } - } - - return true; - } - - /** - * Method to check out an item for editing. - * - * @param integer $id The id of the row to check out. - * - * @return boolean True on success, false on failure. - * - * @since 1.6 - */ - public function checkout($id = null) - { - // Get the user id. - $id = (!empty($id)) ? $id : (int) $this->getState('item.id'); - - if ($id) - { - // Initialise the table - $table = $this->getTable(); - - // Get the current user object. - $user = JFactory::getUser(); - - // Attempt to check the row out. - if (method_exists($table, 'checkout')) - { - if (!$table->checkout($user->get('id'), $id)) - { - return false; - } - } - } - - return true; - } - /** * Get an array of data items * @@ -336,16 +253,6 @@ public function setClient($client) $this->client = $client; } - /** - * Get an client value - * - * @return mixed Array of data items on success, false on failure. - */ - public function getClient() - { - return $this->client; - } - /** * Method to get the record form. * @@ -382,7 +289,7 @@ public function getForm($data = array(), $loadData = true) * * @return JForm A JForm object on success, false on failure * - * @since 1.6 + * @since 1.2.2 */ public function getFieldForm($data = array(), $loadData = true) { @@ -430,6 +337,16 @@ public function getFieldForm($data = array(), $loadData = true) return $form; } + /** + * Method to get the type form object. + * + * @param array $data An optional array of data for the form to interogate. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * + * @return JForm A JForm object on success, false on failure + * + * @since 1.2.2 + */ public function getTypeForm($data = array(), $loadData = true) { $draft = isset($data['draft']) ? $data['draft'] : 0; @@ -468,6 +385,16 @@ public function getTypeForm($data = array(), $loadData = true) return $form; } + /** + * Method to get the type section form object. + * + * @param array $data An optional array of data for the form to interogate. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * + * @return JForm A JForm object on success, false on failure + * + * @since 1.2.2 + */ public function getSectionForm($data = array(), $loadData = true) { if (empty($data['client']) || empty($data['section'])) @@ -710,266 +637,6 @@ public function saveExtraFields($fieldData) return TjfieldsFilterField::saveExtraFields($fieldData); } - /** - * Method to save the form data. - * - * @param array $data The form data. - * @param array $extra_jform_data Exra field data. - * - * @return boolean - * - * @since 1.6 - */ - public function saveTOBEDELETED($data, $extra_jform_data = '') - { - $app = JFactory::getApplication(); - $user = JFactory::getUser(); - $status_title = $app->input->get('form_status'); - $ucmTypeId = $this->getState('ucmType.id'); - $typeItemId = (!empty($data['id'])) ? $data['id'] : (int) $this->getState('item.id'); - $authorised = false; - - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/models'); - $tjUcmModelType = JModelLegacy::getInstance('Type', 'TjucmModel'); - - if (empty($ucmTypeId)) - { - // Get UCM type id from uniquue identifier - $ucmTypeId = $tjUcmModelType->getTypeId($data['client']); - } - - if ($ucmTypeId) - { - // Check if user is allowed to save the content - $typeData = $tjUcmModelType->getItem($ucmTypeId); - $allowedCount = $typeData->allowed_count; - - // 0 : add unlimited records against this UCM type - $allowedCount = empty($allowedCount) ? 0 : $allowedCount; - $userId = $user->id; - $allowedToAdd = $this->allowedToAddTypeData($userId, $data['client'], $allowedCount); - - if (!$allowedToAdd && $typeItemId == 0) - { - $message = JText::sprintf('COM_TJUCM_ALLOWED_COUNT_LIMIT', $allowedCount); - $app->enqueueMessage($message, 'warning'); - - return false; - } - - if ($typeItemId) - { - // Check the user can edit this item - $canEdit = $user->authorise('core.type.edititem', 'com_tjucm.type.' . $ucmTypeId); - $canEditOwn = $user->authorise('core.type.editownitem', 'com_tjucm.type.' . $ucmTypeId); - - // Get the UCM item details - Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/tables'); - $itemDetails = Table::getInstance('Item', 'TjucmTable'); - $itemDetails->load(array('id' => $typeItemId)); - - // If there is ownership field in form and the field is assigned some value then update created_by for the record - $client = explode(".", $itemDetails->client); - $ownershipField = $client[0] . '_' . $client[1] . '_ownershipcreatedby'; - - if (isset($extra_jform_data[$ownershipField]) && !empty($extra_jform_data[$ownershipField])) - { - JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR); - $ownershipFieldData = Table::getInstance('Field', 'TjfieldsTable'); - $ownershipFieldData->load(array('name' => $ownershipField)); - $ownershipFieldParams = json_decode($ownershipFieldData->params); - - if ($ownershipFieldParams->ucmItemOwner == 1) - { - $data['created_by'] = $extra_jform_data[$ownershipField]; - } - } - else - { - $data['created_by'] = $itemDetails->created_by; - } - - if ($canEdit) - { - $authorised = true; - } - elseif (($canEditOwn) && ($itemDetails->created_by == $user->id)) - { - if (!empty($data['created_by']) && $itemDetails->created_by == $data['created_by']) - { - $authorised = true; - } - } - } - else - { - // Check the user can create new items in this section - $authorised = $user->authorise('core.type.createitem', 'com_tjucm.type.' . $ucmTypeId); - } - } - - if ($authorised !== true) - { - throw new Exception(JText::_('COM_TJUCM_ERROR_MESSAGE_NOT_AUTHORISED'), 403); - - return false; - } - - $ucmTypeData = $this->common->getDataValues('#__tj_ucm_types', 'id AS type_id, params', 'unique_identifier = "' - . $data['client'] . '"', 'loadAssoc'); - - $data['type_id'] = empty($data['type_id']) ? $ucmTypeData['type_id'] : $data['type_id']; - - $ucmTypeParams = json_decode($ucmTypeData['params']); - - $table = $this->getTable(); - - if (isset($ucmTypeParams->publish_items) && $ucmTypeParams->publish_items == 0) - { - $data['state'] = 0; - } - else - { - $data['state'] = 1; - } - - // To store fields value in TJ-Fields - $data_extra = array(); - - if (!empty($extra_jform_data)) - { - $data_extra['client'] = $data['client']; - $data_extra['fieldsvalue'] = $extra_jform_data; - } - - $isNew = empty($typeItemId) ? 1 : 0; - - // OnBefore UCM record save trigger. - JPluginHelper::importPlugin('tjucm'); - $dispatcher = JDispatcher::getInstance(); - $dispatcher->trigger('tjucmOnBeforeSaveItem', array(&$data, &$data_extra, $isNew)); - - // Load TJ-Fields tables - Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/tables'); - - // If item category field is added in the type then save item category agains the item record - foreach ($extra_jform_data as $fieldName => $fieldData) - { - $fieldTable = Table::getInstance('Field', 'TjfieldsTable'); - $fieldTable->load(array('name' => $fieldName)); - - if ($fieldTable->type == 'itemcategory') - { - $data['category_id'] = $fieldData; - - break; - } - } - - if ($table->save($data) === true) - { - if (!empty($extra_jform_data)) - { - $data_extra['content_id'] = $table->id; - - // Save extra fields data. - $this->saveExtraFields($data_extra); - } - - $data['id'] = $table->id; - - // OnAfter UCM record save trigger. - $dispatcher->trigger('tjucmOnAfterSaveItem', array($data, $data_extra)); - - return $table->id; - } - else - { - throw new Exception($table->getError()); - } - } - - /** - * Method to duplicate an Item - * - * @param array &$pks An array of primary key IDs. - * - * @return boolean True if successful. - * - * @throws Exception - */ - public function duplicate(&$pks) - { - $user = JFactory::getUser(); - $ucmTypeId = $this->getState('ucmType.id'); - - // Access checks. - if (!$user->authorise('core.type.createitem', 'com_tjucm.type.' . $ucmTypeId)) - { - throw new Exception(JText::_('JERROR_CORE_CREATE_NOT_PERMITTED')); - - return false; - } - - $dispatcher = JEventDispatcher::getInstance(); - $context = $this->option . '.' . $this->name; - - // Include the plugins for the save events. - JPluginHelper::importPlugin($this->events_map['save']); - - $table = $this->getTable(); - - foreach ($pks as $pk) - { - if ($table->load($pk, true)) - { - // Reset the id to create a new record. - $table->id = 0; - - if (!$table->check()) - { - throw new Exception($table->getError()); - - return false; - } - - if (!empty($table->type_id)) - { - if (is_array($table->type_id)) - { - $table->type_id = implode(',', $table->type_id); - } - } - else - { - $table->type_id = ''; - } - - // Trigger the before save event. - $result = $dispatcher->trigger($this->event_before_save, array($context, &$table, true)); - - if (in_array(false, $result, true) || !$table->store()) - { - throw new Exception($table->getError()); - } - - // Trigger the after save event. - $dispatcher->trigger($this->event_after_save, array($context, &$table, true)); - } - else - { - throw new Exception($table->getError()); - - return false; - } - } - - // Clean cache - $this->cleanCache(); - - return true; - } - /** * Method to delete data * @@ -1050,38 +717,6 @@ public function delete(&$contentId) } } - /** - * Check if data can be saved - * - * @return bool - */ - public function getCanSave() - { - $table = $this->getTable(); - - return $table !== false; - } - - /** - * Method to getAliasFieldNameByView - * - * @param array $view An array of record primary keys. - * - * @return boolean True if successful, false if an error occurs. - * - * @since 1.0 - */ - public function getAliasFieldNameByView($view) - { - switch ($view) - { - case 'type': - case 'typeform': - return 'alias'; - break; - } - } - /** * Check if user is submit new type data or not * @@ -1125,161 +760,6 @@ public function allowedToAddTypeData($userId, $client, $allowedCount) } } - /** - * Method to set cluster data in posted data. - * - * @param array &$validData The validated data. - * - * @param array $data UCM form data. - * - * @return null - * - * @since 1.6 - */ - public function setClusterData(&$validData, $data) - { - $clusterField = $ownershipField = ''; - - // To get type of UCM - if (!empty($this->client)) - { - $client = explode(".", $this->client); - $clusterField = $client[0] . '_' . $client[1] . '_clusterclusterid'; - $ownershipField = $client[0] . '_' . $client[1] . '_ownershipcreatedby'; - } - - JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR); - $ownershipFieldData = Table::getInstance('Field', 'TjfieldsTable'); - $ownershipFieldData->load(array('name' => $ownershipField)); - $ownershipFieldParams = json_decode($ownershipFieldData->params); - - // Save created_by field by ownership user field (To save form on behalf of someone) - if (!empty($data[$ownershipField]) && empty($data[$clusterField]) && ($ownershipFieldParams->ucmItemOwner == 1)) - { - $validData['created_by'] = $data[$ownershipField]; - } - - // Cluster Id store in UCM data - $clusterExist = ComponentHelper::getComponent('com_cluster', true)->enabled; - - if (!empty($data[$clusterField]) && $clusterExist) - { - $user = Factory::getUser(); - $isSuperUser = $user->authorise('core.admin'); - - JLoader::import("/components/com_cluster/includes/cluster", JPATH_ADMINISTRATOR); - $ClusterModel = ClusterFactory::model('ClusterUsers', array('ignore_request' => true)); - $ClusterModel->setState('list.group_by_user_id', 1); - $ClusterModel->setState('filter.published', 1); - $ClusterModel->setState('filter.cluster_id', (int) $data[$clusterField]); - - if (!$isSuperUser && !$user->authorise('core.manageall', 'com_cluster')) - { - $ClusterModel->setState('filter.user_id', $user->id); - } - - // Get all assigned cluster entries - $clusters = $ClusterModel->getItems(); - - if (!empty($clusters)) - { - $validData['cluster_id'] = $data[$clusterField]; - - if (!empty($data[$ownershipField])) - { - $clusterUsers = array(); - - foreach ($clusters as $cluster) - { - $clusterUsers[] = $cluster->user_id; - } - - if (in_array($data[$ownershipField], $clusterUsers) && ($ownershipFieldParams->ucmItemOwner == 1)) - { - $validData['created_by'] = $data[$ownershipField]; - } - } - } - } - } - - /** - * Function to get formatted data to be added of ucmsubform records - * - * @param ARRAY $validData Parent record data - * @param ARRAY &$extra_jform_data form data - * - * @return ARRAY - */ - public function getFormattedUcmSubFormRecords($validData, &$extra_jform_data) - { - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/models'); - $tjUcmModelType = JModelLegacy::getInstance('Type', 'TjucmModel'); - - JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models'); - $tjFieldsFieldsModel = JModelLegacy::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); - $tjFieldsFieldsModel->setState('filter.client', $validData['client']); - $tjFieldsFieldsModel->setState('filter.type', 'ucmsubform'); - - // Get list of ucmsubform fields in the parent form - $ucmSubFormFields = $tjFieldsFieldsModel->getItems(); - - // Variable to store ucmsubform records posted in the form - $ucmSubFormDataSet = array(); - - // Sort all the ucmsubform records as per client - foreach ($ucmSubFormFields as $ucmSubFormField) - { - if (!isset($extra_jform_data[$ucmSubFormField->name])) - { - continue; - } - - $subformRecords = $extra_jform_data[$ucmSubFormField->name]; - - if (!empty($subformRecords)) - { - $ucmSubFormData = array(); - - foreach ($subformRecords as $key => $subformRecord) - { - // Append file data to the ucmSubForm data - if (array_key_exists('tjFieldFileField', $extra_jform_data)) - { - if (isset($extra_jform_data['tjFieldFileField'][$ucmSubFormField->name][$key])) - { - $subformRecord['tjFieldFileField'] = $extra_jform_data['tjFieldFileField'][$ucmSubFormField->name][$key]; - } - } - - $subformRecord = array_filter($subformRecord); - - if (!empty($subformRecord)) - { - // Add ucmSubFormFieldName in the data to pass data to JS - $subformRecord['ucmSubformFieldName'] = $ucmSubFormField->name; - - $ucmSubFormData[] = $subformRecord; - } - } - - if (!empty($ucmSubFormData)) - { - $ucmSubFormFieldParams = json_decode($ucmSubFormField->params); - $ucmSubFormFormSource = explode('/', $ucmSubFormFieldParams->formsource); - $ucmSubFormClient = $ucmSubFormFormSource[1] . '.' . str_replace('form_extra.xml', '', $ucmSubFormFormSource[4]); - $ucmSubFormDataSet[$ucmSubFormClient] = $ucmSubFormData; - $extra_jform_data[$ucmSubFormField->name] = $ucmSubFormClient; - } - } - } - - // Remove empty records - $ucmSubFormDataSet = array_filter($ucmSubFormDataSet); - - return $ucmSubFormDataSet; - } - /** * Function to save ucmSubForm records * @@ -1435,7 +915,9 @@ public function getUcmSubFormFieldDataJson($parentRecordId, $efd) /** * Function to updated related field options * - * @param INT $contentId parent content id + * @param INT $client client + * + * @param INT $contentId Content id * * @return ARRAY */ diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index ba3d53d4..8c6ad78b 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -553,86 +553,6 @@ private function getFieldsData($contentIds) return $db->loadObjectList(); } - /** - * Overrides the default function to check Date fields format, identified by - * "_dateformat" suffix, and erases the field if it's not correct. - * - * @return void - */ - protected function loadFormData() - { - $app = JFactory::getApplication(); - $filters = $app->getUserState($this->context . '.filter', array()); - $error_dateformat = false; - - foreach ($filters as $key => $value) - { - if (strpos($key, '_dateformat') && !empty($value) && $this->isValidDate($value) == null) - { - $filters[$key] = ''; - $error_dateformat = true; - } - } - - if ($error_dateformat) - { - $app->enqueueMessage(JText::_("COM_TJUCM_SEARCH_FILTER_DATE_FORMAT"), "warning"); - $app->setUserState($this->context . '.filter', $filters); - } - - return parent::loadFormData(); - } - - /** - * Checks if a given date is valid and in a specified format (YYYY-MM-DD) - * - * @param string $date Date to be checked - * - * @return bool - */ - private function isValidDate($date) - { - $date = str_replace('/', '-', $date); - - return (date_create($date)) ? JFactory::getDate($date)->format("Y-m-d") : null; - } - - /** - * Method to getAliasFieldNameByView - * - * @param array $view An array of record primary keys. - * - * @return boolean True if successful, false if an error occurs. - * - * @since 12.2 - */ - public function getAliasFieldNameByView($view) - { - switch ($view) - { - case 'items': - return 'alias'; - break; - } - } - - /** - * Get an item by alias - * - * @param string $alias Alias string - * - * @return int Element id - */ - public function getItemIdByAlias($alias) - { - $db = JFactory::getDbo(); - $table = JTable::getInstance('type', 'TjucmTable', array('dbo', $db)); - - $table->load(array('alias' => $alias)); - - return $table->id; - } - /** * Check if there are fields to show in list view * From 985a06d72195b6452f17933d9667cfcd7741a466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Fri, 8 Nov 2019 10:57:24 +0530 Subject: [PATCH 013/273] Update code to check ucm compatibility --- .../com_tjucm/administrator/models/type.php | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/components/com_tjucm/administrator/models/type.php b/src/components/com_tjucm/administrator/models/type.php index 6dacdfa0..db6b7123 100644 --- a/src/components/com_tjucm/administrator/models/type.php +++ b/src/components/com_tjucm/administrator/models/type.php @@ -567,42 +567,46 @@ public function checkCompatibility($sourceClient, $targetClient) { $validUcmType = array(); - if ($sourceClient && $targetClient) + if (!$sourceClient && !$targetClient) { - BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models'); - $sourceFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); - $sourceFieldsModel->setState('filter.client', $sourceClient); - $targetFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); - $targetFieldsModel->setState('filter.client', $targetClient); - $sourceFields = $sourceFieldsModel->getItems(); - $targetFields = $targetFieldsModel->getItems(); + return false; + } + + // Get the source ucm type and target ucm type fields list + BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models'); + $sourceFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); + $sourceFieldsModel->setState('filter.client', $sourceClient); + $targetFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); + $targetFieldsModel->setState('filter.client', $targetClient); + $sourceFields = $sourceFieldsModel->getItems(); + $targetFields = $targetFieldsModel->getItems(); - $count = 0; + $count = 0; + + foreach ($sourceFields as $sourceField) + { + $prefix = str_replace(".", "_", $sourceClient); + $sourceFieldName = explode($prefix . "_", $sourceField->name); - foreach ($sourceFields as $sourceField) + foreach ($targetFields as $targetField) { - $prefix = str_replace(".", "_", $sourceClient); - $sourceFieldName = explode($prefix . "_", $sourceField->name); + $prefix = str_replace(".", "_", $targetClient); + $targetFieldName = explode($prefix . "_", $targetField->name); - foreach ($targetFields as $targetField) + // Check source and destination field name and field types are equal + if ($sourceFieldName == $targetFieldName && $sourceField->type == $targetField->type) { - $prefix = str_replace(".", "_", $targetClient); - $targetFieldName = explode($prefix . "_", $targetField->name); - - if ($sourceFieldName == $targetFieldName && $sourceField->type == $targetField->type) - { - $count ++; - continue; - } + $count ++; + continue; } } + } - if (count($sourceFields) == $count) - { - return true; - } - - return false; + if (count($sourceFields) == $count) + { + return true; } + + return false; } } From 700cd95fd94092a287f52ebf59f92df244c5ecac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Fri, 8 Nov 2019 12:15:02 +0530 Subject: [PATCH 014/273] Move checkCompatibility function to type controller --- .../site/controllers/itemform.json.php | 54 ++---------- .../com_tjucm/site/controllers/type.php | 84 +++++++++++++++++++ 2 files changed, 90 insertions(+), 48 deletions(-) create mode 100644 src/components/com_tjucm/site/controllers/type.php diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index c2b47cea..b4f21673 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -458,54 +458,6 @@ public function getRelatedFieldOptions() $app->close(); } - /** - * Method to check the compatibility between ucm types - * - * @return mixed - * - * @since __DEPLOY_VERSION__ - */ - public function checkCompatibility() - { - Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); - - $app = Factory::getApplication(); - $post = $app->input->post; - $client = $post->get('client', '', 'STRING'); - - if (empty($client)) - { - echo new JResponseJson(null); - $app->close(); - } - - JLoader::import('components.com_tjucm.models.types', JPATH_ADMINISTRATOR); - $typesModel = BaseDatabaseModel::getInstance('Types', 'TjucmModel'); - $typesModel->setState('filter.state', 1); - $ucmTypes = $typesModel->getItems(); - - JLoader::import('components.com_tjucm.models.type', JPATH_ADMINISTRATOR); - $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->checkCompatibility($client, $type->unique_identifier); - - if ($result) - { - $validUcmType[$key]['value'] = $type->unique_identifier; - $validUcmType[$key]['text'] = $type->title; - } - } - - echo new JResponseJson($validUcmType); - $app->close(); - } - /** * Method to copy item * @@ -527,6 +479,8 @@ public function copyItem() JLoader::import('components.com_tjucm.models.type', JPATH_ADMINISTRATOR); $typeModel = BaseDatabaseModel::getInstance('Type', 'TjucmModel'); + + // Server side Validation for source and UCM Type $result = $typeModel->checkCompatibility($sourceClient, $targetClient); if ($result) @@ -547,8 +501,11 @@ public function copyItem() $ucmOldData['content_id'] = $cid; $ucmOldData['layout'] = 'edit'; $ucmOldData['client'] = $sourceClient; + + // Get the field values $extraFieldsData = $model->loadFormDataExtra($ucmOldData); + // Code to replace source field name with destination field name foreach ($extraFieldsData as $fieldKey => $fieldValue) { $prefixSourceClient = str_replace(".", "_", $sourceClient); @@ -658,6 +615,7 @@ public function copyItem() $ucmData['state'] = 0; $ucmData['draft'] = 1; + // Save data into UCM data table $result = $model->save($ucmData); $recordId = $model->getState($model->getName() . '.id'); diff --git a/src/components/com_tjucm/site/controllers/type.php b/src/components/com_tjucm/site/controllers/type.php new file mode 100644 index 00000000..3134fedd --- /dev/null +++ b/src/components/com_tjucm/site/controllers/type.php @@ -0,0 +1,84 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access +defined('_JEXEC') or die; + +use Joomla\CMS\Session\Session; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; + +/** + * Type controller class. + * + * @since __DEPLOY_VERSION__ + */ +class TjucmControllerType extends JControllerForm +{ + /** + * Constructor + * + * @throws Exception + */ + public function __construct() + { + $this->view_list = 'types'; + parent::__construct(); + } + + /** + * Method to check the compatibility between ucm types + * + * @return mixed + * + * @since __DEPLOY_VERSION__ + */ + public function checkCompatibility() + { + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + $app = Factory::getApplication(); + $post = $app->input->post; + $client = $post->get('client', '', 'STRING'); + + if (empty($client)) + { + echo new JResponseJson(null); + $app->close(); + } + + JLoader::import('components.com_tjucm.models.types', JPATH_ADMINISTRATOR); + $typesModel = BaseDatabaseModel::getInstance('Types', 'TjucmModel'); + $typesModel->setState('filter.state', 1); + $ucmTypes = $typesModel->getItems(); + + JLoader::import('components.com_tjucm.models.type', JPATH_ADMINISTRATOR); + $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->checkCompatibility($client, $type->unique_identifier); + + if ($result) + { + $validUcmType[$key]['value'] = $type->unique_identifier; + $validUcmType[$key]['text'] = $type->title; + } + } + + echo new JResponseJson($validUcmType); + $app->close(); + } +} From 0ca17983a8531cb3185001ab5269ca4dcadfff95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Fri, 8 Nov 2019 12:32:57 +0530 Subject: [PATCH 015/273] Changes varible names --- .../com_tjucm/administrator/models/type.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/com_tjucm/administrator/models/type.php b/src/components/com_tjucm/administrator/models/type.php index db6b7123..6fdc4121 100644 --- a/src/components/com_tjucm/administrator/models/type.php +++ b/src/components/com_tjucm/administrator/models/type.php @@ -574,12 +574,16 @@ public function checkCompatibility($sourceClient, $targetClient) // Get the source ucm type and target ucm type fields list BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models'); - $sourceFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); - $sourceFieldsModel->setState('filter.client', $sourceClient); - $targetFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); - $targetFieldsModel->setState('filter.client', $targetClient); - $sourceFields = $sourceFieldsModel->getItems(); - $targetFields = $targetFieldsModel->getItems(); + $tjFieldsFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); + + // Get source UCM Type fields + $tjFieldsFieldsModel->setState('filter.client', $sourceClient); + $sourceFields = $tjFieldsFieldsModel->getItems(); + + // Get destination UCM Type fields + $tjFieldsFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); + $tjFieldsFieldsModel->setState('filter.client', $targetClient); + $targetFields = $tjFieldsFieldsModel->getItems(); $count = 0; From 53efda74efc31be4074d7bbdad07a3fe6e6625c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Fri, 8 Nov 2019 12:37:01 +0530 Subject: [PATCH 016/273] Change checkCompatibility method name to getCompatableUcmType --- .../com_tjucm/administrator/models/type.php | 2 +- .../com_tjucm/media/js/services/items.js | 29 +++++++++++++++++++ .../site/controllers/itemform.json.php | 2 +- .../com_tjucm/site/controllers/type.php | 4 +-- 4 files changed, 33 insertions(+), 4 deletions(-) create mode 100755 src/components/com_tjucm/media/js/services/items.js diff --git a/src/components/com_tjucm/administrator/models/type.php b/src/components/com_tjucm/administrator/models/type.php index 6fdc4121..213042fc 100644 --- a/src/components/com_tjucm/administrator/models/type.php +++ b/src/components/com_tjucm/administrator/models/type.php @@ -563,7 +563,7 @@ public function delete(&$pks) * * @since __DEPLOY_VERSION__ */ - public function checkCompatibility($sourceClient, $targetClient) + public function getCompatableUcmType($sourceClient, $targetClient) { $validUcmType = array(); diff --git a/src/components/com_tjucm/media/js/services/items.js b/src/components/com_tjucm/media/js/services/items.js new file mode 100755 index 00000000..8b8baf42 --- /dev/null +++ b/src/components/com_tjucm/media/js/services/items.js @@ -0,0 +1,29 @@ +/* + * @package TJ-UCM + * @author Techjoomla + * @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved + * @license GNU General Public License version 2, or later + */ +'use strict'; +/** global: com_tjucm */ +com_tjucm.Services.Items = new (com_tjucm.Services.Base.extend({ + checkCompatibilityUrl: window.tjSiteRoot + "index.php?option=com_tjucm&task=type.getCompatableUcmType", + copyItemUrl: window.tjSiteRoot + "index.php?option=com_tjucm&format=json&task=itemform.copyItem", + config: { + headers: {} + }, + response: { + "success": "", + "message": "" + }, + chekCompatibility: function (currentUcmType, callback){ + this.config.processData = false; + this.config.contentType = false; + this.post(this.checkCompatibilityUrl, currentUcmType, this.config, callback); + }, + copyItem: function (copyItemData, callback){ + this.config.processData = false; + this.config.contentType = 'application/x-www-form-urlencoded; charset=UTF-8'; + this.post(this.copyItemUrl, copyItemData, this.config, callback); + } +})); diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index b4f21673..372806cb 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -481,7 +481,7 @@ public function copyItem() $typeModel = BaseDatabaseModel::getInstance('Type', 'TjucmModel'); // Server side Validation for source and UCM Type - $result = $typeModel->checkCompatibility($sourceClient, $targetClient); + $result = $typeModel->getCompatableUcmType($sourceClient, $targetClient); if ($result) { diff --git a/src/components/com_tjucm/site/controllers/type.php b/src/components/com_tjucm/site/controllers/type.php index 3134fedd..6e266dfe 100644 --- a/src/components/com_tjucm/site/controllers/type.php +++ b/src/components/com_tjucm/site/controllers/type.php @@ -41,7 +41,7 @@ public function __construct() * * @since __DEPLOY_VERSION__ */ - public function checkCompatibility() + public function getCompatableUcmType() { Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); @@ -69,7 +69,7 @@ public function checkCompatibility() foreach ($ucmTypes as $key => $type) { - $result = $typeModel->checkCompatibility($client, $type->unique_identifier); + $result = $typeModel->getCompatableUcmType($client, $type->unique_identifier); if ($result) { From 497628711efe7ece329b8bd041f5837b76fdefd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Fri, 8 Nov 2019 12:43:29 +0530 Subject: [PATCH 017/273] Update code change --- src/components/com_tjucm/site/views/items/tmpl/default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e28707c8..20597ac1 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -228,7 +228,7 @@ function copyItem() - + From 9af0f373e37b9b7da6a0d6fcaed4538932602965 Mon Sep 17 00:00:00 2001 From: Amol Thite Date: Fri, 8 Nov 2019 15:18:59 +0530 Subject: [PATCH 018/273] Task #229 feat: Basic class sructure created --- .../com_tjucm/site/includes/defines.php | 23 ++ .../com_tjucm/site/includes/item.php | 316 ++++++++++++++++++ .../com_tjucm/site/includes/tjucm.php | 176 ++++++++++ 3 files changed, 515 insertions(+) create mode 100644 src/components/com_tjucm/site/includes/defines.php create mode 100644 src/components/com_tjucm/site/includes/item.php create mode 100644 src/components/com_tjucm/site/includes/tjucm.php diff --git a/src/components/com_tjucm/site/includes/defines.php b/src/components/com_tjucm/site/includes/defines.php new file mode 100644 index 00000000..e6485254 --- /dev/null +++ b/src/components/com_tjucm/site/includes/defines.php @@ -0,0 +1,23 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +if (defined('COM_TJUCM_SITE_DEFINE_FILE')) +{ + return; +} + +define('COM_TJUCM_ITEM_STATE_PUBLISHED', 1); +define('COM_TJUCM_ITEM_STATE_UNPUBLISHED', 0); +define('COM_TJUCM_ITEM_STATE_ARCHIVED', 2); +define('COM_TJUCM_ITEM_STATE_TRASHED', -2); +define('COM_TJUCM_ITEM_STATE_DRAFT', -1); + +// Need this constant for performance purpose Always define this at the end of file +define('COM_TJUCM_SITE_DEFINE_FILE', true); diff --git a/src/components/com_tjucm/site/includes/item.php b/src/components/com_tjucm/site/includes/item.php new file mode 100644 index 00000000..806d9fcf --- /dev/null +++ b/src/components/com_tjucm/site/includes/item.php @@ -0,0 +1,316 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +defined('_JEXEC') or die(); + +use Joomla\CMS\Object\CMSObject; + +/** + * Tjucm item class. + * + * @since __DEPLOY_VERSION__ + */ +class TjucmItem extends CMSObject +{ + /** + * The auto incremental primary key of the item + * + * @var integer + * @since __DEPLOY_VERSION__ + */ + public $id = 0; + + /** + * In case of UCM-Subform parent_id is used to point to the parent record of the UCM-Subform records + * + * @var integer + * @since __DEPLOY_VERSION__ + */ + public $parent_id = 0; + + /** + * Id of assets table for the item + * + * @var integer + * @since __DEPLOY_VERSION__ + */ + public $asset_id = 0; + + /** + * Defines ordering of the item - Not Used As Of Now + * + * @var integer + * @since __DEPLOY_VERSION__ + */ + public $ordering = 0; + + /** + * State of item + * + * @var integer + * @since __DEPLOY_VERSION__ + */ + public $state = COM_TJUCM_ITEM_STATE_UNPUBLISHED; + + /** + * Category of the item - Category from the categories created for UCM type + * + * @var integer + * @since __DEPLOY_VERSION__ + */ + public $category_id = ''; + + /** + * Id of UCM type to which the item belongs + * + * @var integer + * @since __DEPLOY_VERSION__ + */ + public $type_id = 0; + + /** + * Unique identifier of the UCM type + * + * @var string + * @since __DEPLOY_VERSION__ + */ + public $client = ''; + + /** + * Cluster id to which the item belongs + * + * @var integer + * @since __DEPLOY_VERSION__ + */ + public $cluster_id = ''; + + /** + * Joomla user id by whom the record is being checked out + * + * @var integer + * @since __DEPLOY_VERSION__ + */ + public $checked_out = ''; + + /** + * Joomla user id by whom the record is created + * + * @var integer + * @since __DEPLOY_VERSION__ + */ + public $created_by = ''; + + /** + * Joomla user id by whom the record is modified + * + * @var integer + * @since __DEPLOY_VERSION__ + */ + public $modified_by = ''; + + /** + * Flag to mark if the item is a draft + * + * @var integer + * @since __DEPLOY_VERSION__ + */ + public $draft = ''; + + /** + * Date time when the item was last checked out + * + * @var datetime + * @since __DEPLOY_VERSION__ + */ + public $checked_out_time = ''; + + /** + * Date time when the item was created + * + * @var datetime + * @since __DEPLOY_VERSION__ + */ + public $created_date = ''; + + /** + * Date time when the item was last modified + * + * @var datetime + * @since __DEPLOY_VERSION__ + */ + public $modified_date = ''; + + /** + * holds the already loaded instances of the Item + * + * @var array + * @since __DEPLOY_VERSION__ + */ + protected static $itemObj = array(); + + /** + * Holds the fields values in the item + * + * @var array + * @since __DEPLOY_VERSION__ + */ + private $fieldsValues = array(); + + /** + * Constructor activating the default information of the item + * + * @param int $id The unique item key to load. + * + * @since __DEPLOY_VERSION__ + */ + public function __construct($id = 0) + { + if (!empty($id)) + { + $this->load($id); + } + } + + /** + * Returns the item object + * + * @param integer $id The primary key of the item to load (optional). + * + * @return TjucmItem The item object. + * + * @since __DEPLOY_VERSION__ + */ + public static function getInstance($id = 0) + { + if (!$id) + { + return new TjucmItem; + } + + if (empty(self::$itemObj[$id])) + { + self::$itemObj[$id] = new TjucmItem($id); + } + + return self::$itemObj[$id]; + } + + /** + * Method to load a item properties + * + * @param int $id The item id + * + * @return boolean True on success + * + * @since __DEPLOY_VERSION__ + */ + public function load($id) + { + $table = Tjucm::table("item"); + + if ($table->load($id)) + { + $this->setProperties($table->getProperties()); + + // Load field values for the item + // $this->setFieldsValues($table->id); + + return true; + } + + return false; + } + + /** + * Method to save the Item object to the database + * + * @return boolean True on success + * + * @since __DEPLOY_VERSION__ + */ + public function save() + { + $isNew = $this->isNew(); + + // Create the item table object + $table = Tjucm::table('item'); + + // Allow an exception to be thrown. + try + { + $table->bind(get_object_vars($this)); + + // Check and store the object. + if (!$table->check()) + { + $this->setError($table->getError()); + + return false; + } + + // Store the item data in the database + $result = $table->store(); + + // Set the id for the item object in case we created a new item. + if ($result && $isNew) + { + $this->load($table->get('id')); + $item = Tjucm::model('item'); + $this->item_id = $item->generateItemID($this->id); + + return $this->save(); + } + elseif ($result && !$isNew) + { + return $this->load($this->id); + } + } + catch (\Exception $e) + { + $this->setError($e->getMessage()); + + return false; + } + + return $result; + } + + /** + * Method to check is item new or not + * + * @return boolean True on success + * + * @since __DEPLOY_VERSION__ + */ + private function isNew() + { + return $this->id < 1; + } + + /** + * Returns a property of the object or the default value if the property is not set. + * + * @param string $property The name of the property. + * @param mixed $default The default value. + * + * @return mixed The value of the property. + * + * @since __DEPLOY_VERSION__ + */ + public function get($property, $default = null) + { + if (isset($this->$property)) + { + return $this->$property; + } + + return $default; + } +} diff --git a/src/components/com_tjucm/site/includes/tjucm.php b/src/components/com_tjucm/site/includes/tjucm.php new file mode 100644 index 00000000..8311e061 --- /dev/null +++ b/src/components/com_tjucm/site/includes/tjucm.php @@ -0,0 +1,176 @@ + + * @copyright Copyright (C) 2009 - 2019 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 Tjucm +{ + /** + * Holds the record of the loaded Tjucm classes + * + * @var array + * @since __DEPLOY_VERSION__ + */ + private static $loadedClass = array(); + + /** + * Holds the record of the component config + * + * @var Joomla\Registry\Registry + * @since __DEPLOY_VERSION__ + */ + private static $config = null; + + /** + * Retrieves a table from the table folder + * + * @param string $name The table file name + * @param array $config Configuration array for model. Optional. + * + * @return Table|boolean object or false on failure + * + * @since __DEPLOY_VERSION__ + **/ + public static function table($name, $config = array()) + { + Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/tables'); + $table = Table::getInstance($name, 'TjucmTable', $config); + + return $table; + } + + /** + * Retrieves a model from the model folder + * + * @param string $name The model name + * @param array $config Configuration array for model. Optional. + * + * @return BaseDatabaseModel|boolean object or false on failure + * + * @since __DEPLOY_VERSION__ + **/ + public static function model($name, $config = array()) + { + JLoader::import('components.com_tjucm.models.type', JPATH_ADMINISTRATOR); + JLoader::import('components.com_tjucm.models.types', JPATH_ADMINISTRATOR); + BaseDatabaseModel::addIncludePath(JPATH_SITE . '/components/com_tjucm/models', 'TjucmModel'); + $model = BaseDatabaseModel::getInstance($name, 'TjucmModel', $config); + + return $model; + } + + /** + * Magic method to create instance of Tjucm library + * + * @param string $name The name of the class + * @param mixed $arguments Arguments of class + * + * @return mixed return the Object of the respective class if exist OW return false + * + * @since __DEPLOY_VERSION__ + **/ + public static function __callStatic($name, $arguments) + { + self::loadClass($name); + + $className = 'Tjucm' . StringHelper::ucfirst($name); + + if (class_exists($className)) + { + if (method_exists($className, 'getInstance')) + { + return call_user_func_array(array($className, 'getInstance'), $arguments); + } + + return new $className; + } + + return false; + } + + /** + * Load the class library if not loaded + * + * @param string $className The name of the class which required to load + * + * @return boolean True on success + * + * @since __DEPLOY_VERSION__ + **/ + public static function loadClass($className) + { + if (! isset(self::$loadedClass[$className])) + { + $className = (string) StringHelper::strtolower($className); + + $path = JPATH_SITE . '/components/com_tjucm/includes/' . $className . '.php'; + + include_once $path; + + self::$loadedClass[$className] = true; + } + + return self::$loadedClass[$className]; + } + + /** + * Load the component configuration + * + * @return Joomla\Registry\Registry A Registry object. + */ + public static function config() + { + if (empty(self::$config)) + { + self::$config = ComponentHelper::getParams('com_tjucm'); + } + + return self::$config; + } + + /** + * Initializes the css, js and necessary dependencies + * + * @param string $location The location where the assets needs to load + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public static function init($location = 'site') + { + static $loaded = null; + $docType = Factory::getDocument()->getType(); + + if (! $loaded[$location] && ($docType == 'html')) + { + // HTMLHelper::script('administrator/components/com_tjucm/assets/js/tjucm_ajaxForm_save.js'); + HTMLHelper::StyleSheet('media/jui/css/icomoon.css'); + + $loaded[$location] = true; + } + } +} From 795f537aa2831c90c6bc4638e4c21c0a3daab917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 8 Nov 2019 16:45:28 +0530 Subject: [PATCH 019/273] Task #229 fix: Improve the codebase --- .../com_tjucm/site/models/itemform.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index d42cd838..7add93fc 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -26,7 +26,7 @@ /** * Tjucm model. * - * @since 1.6 + * @since 1.0 */ class TjucmModelItemForm extends JModelAdmin { @@ -34,7 +34,7 @@ class TjucmModelItemForm extends JModelAdmin /** * @var string The prefix to use with controller messages. - * @since 1.6 + * @since 1.0 */ protected $text_prefix = 'COM_TJUCM'; @@ -55,7 +55,7 @@ class TjucmModelItemForm extends JModelAdmin * @param array $config An optional associative array of configuration settings. * * @see JController - * @since 1.6 + * @since 1.0 */ public function __construct($config = array()) { @@ -72,7 +72,7 @@ public function __construct($config = array()) * * @return void * - * @since 1.6 + * @since 1.0 */ protected function populateState() { @@ -232,7 +232,7 @@ public function &getData($id = null) * * @return JTable A database object * - * @since 1.6 + * @since 1.0 */ public function getTable($type = 'Item', $prefix = 'TjucmTable', $config = array()) { @@ -261,7 +261,7 @@ public function setClient($client) * * @return JForm A JForm object on success, false on failure * - * @since 1.6 + * @since 1.0 */ public function getForm($data = array(), $loadData = true) { @@ -466,7 +466,7 @@ public function getSectionForm($data = array(), $loadData = true) * * @return mixed The data for the form. * - * @since 1.6 + * @since 1.0 */ protected function loadFormData() { @@ -493,7 +493,7 @@ protected function loadFormData() * * @return boolean True on success. * - * @since 1.6 + * @since 1.0 */ public function save($data) { From 643b13e64fb50ef99e7fe76682b017be6a9952d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cshraddha?= <“shraddha_s@techjoomla.com”> Date: Fri, 8 Nov 2019 16:55:46 +0530 Subject: [PATCH 020/273] Code changes as per comments --- .../com_tjucm/site/controllers/itemform.json.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 372806cb..f0299bdf 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -561,6 +561,7 @@ public function copyItem() if (is_array($d)) { + // TODO Temprary used switch case need to modify code switch ($fieldTable->type) { case 'tjlist': @@ -630,14 +631,11 @@ public function copyItem() $response = $model->saveExtraFields($formData); $msg = ($response) ? Text::_("COM_TJUCM_ITEM_COPY_SUCCESSFULLY") : Text::_("COM_TJUCM_FORM_SAVE_FAILED"); - - echo new JResponseJson($response, $msg); - $app->close(); } - - echo new JResponseJson(null); - $app->close(); } + + echo new JResponseJson($response, $msg); + $app->close(); } } } From 436bdd06c3728407b66a271b659761b93434fc20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 8 Nov 2019 17:08:26 +0530 Subject: [PATCH 021/273] Task #229 fix: Improve the codebase --- src/components/com_tjucm/site/models/itemform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index 7add93fc..a9c4a300 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -244,7 +244,7 @@ public function getTable($type = 'Item', $prefix = 'TjucmTable', $config = array /** * Get an array of data items * - * @param string $client client value + * @param string $client client * * @return mixed Array of data items on success, false on failure. */ From 94e4d6125a83974f4d8b12a88c19ca88e5059642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 8 Nov 2019 17:11:34 +0530 Subject: [PATCH 022/273] Task #229 fix: Improve the codebase --- src/components/com_tjucm/site/models/itemform.php | 6 ++++-- 1 file 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 a9c4a300..5c3e98de 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -24,7 +24,7 @@ use Joomla\Registry\Registry; /** - * Tjucm model. + * Tjucm model * * @since 1.0 */ @@ -609,7 +609,9 @@ public function saveExtraFields($fieldData) $ownerShipFieldName = str_replace('.', '_', $fieldData['client']) . '_ownershipcreatedby'; $itemCategoryFieldName = str_replace('.', '_', $fieldData['client']) . '_itemcategory'; - if (array_key_exists($clusterFieldName, $fieldData['fieldsvalue']) || array_key_exists($ownerShipFieldName, $fieldData['fieldsvalue']) || array_key_exists($itemCategoryFieldName, $fieldData['fieldsvalue'])) + if (array_key_exists($clusterFieldName, $fieldData['fieldsvalue']) + || array_key_exists($ownerShipFieldName, $fieldData['fieldsvalue']) + || array_key_exists($itemCategoryFieldName, $fieldData['fieldsvalue'])) { JLoader::import('components.com_tjucm.tables.item', JPATH_ADMINISTRATOR); $ucmItemTable = JTable::getInstance('Item', 'TjucmTable', array('dbo', JFactory::getDbo())); From 6d875272ea417b8a86964a948214d78a6cd20a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 11 Nov 2019 10:55:04 +0530 Subject: [PATCH 023/273] Task #229 fix: Improve the codebase --- src/components/com_tjucm/site/models/itemform.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index 5c3e98de..9c60c53a 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -24,7 +24,7 @@ use Joomla\Registry\Registry; /** - * Tjucm model + * Tjucm model. * * @since 1.0 */ From 9aa4b788e0773ae1bc025a6a8bd2d309a4dbf072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 11 Nov 2019 11:10:08 +0530 Subject: [PATCH 024/273] Task #229 fix: Improve the codebase --- 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 876a72f3..37c4391d 100644 --- a/src/components/com_tjucm/tjucm.xml +++ b/src/components/com_tjucm/tjucm.xml @@ -36,6 +36,7 @@ layouts controllers helpers + includes js From 56c3b5a709d1d9dc5fd292be1755c7ac2cd8e52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 13 Nov 2019 12:54:59 +0530 Subject: [PATCH 025/273] Task #229 fix: Improve the codebase --- .../administrator/assets/css/tjucm.css | 30 ----- .../administrator/assets/js/tjucm_type.js | 3 - .../administrator/classes/funlist.php | 62 ---------- .../com_tjucm/administrator/models/item.php | 8 +- .../com_tjucm/administrator/models/type.php | 15 +-- .../com_tjucm/administrator/tjucm.php | 9 -- .../administrator/views/type/tmpl/edit.php | 7 -- src/components/com_tjucm/media/.htaccess | 4 + src/components/com_tjucm/media/css/.htaccess | 3 + src/components/com_tjucm/media/css/index.html | 1 + src/components/com_tjucm/media/css/tjucm.css | 8 ++ .../com_tjucm/media/js/com_tjucm.min.js | 1 + .../com_tjucm/media/js/core/base.min.js | 1 + .../com_tjucm/media/js/core/class.min.js | 1 + src/components/com_tjucm/media/js/form.js | 19 --- src/components/com_tjucm/media/js/index.html | 1 + src/components/com_tjucm/media/js/load_js.php | 23 ---- .../com_tjucm/media/js/services/item.min.js | 1 + .../assets/js => media/js/ui}/itemform.js | 0 .../com_tjucm/media/js/ui/itemform.min.js | 1 + .../js/vendor/jquery}/jquery.are-you-sure.js | 0 .../js/vendor/jquery}/jquery.form.js | 0 .../js/vendor/shim}/ays-beforeunload-shim.js | 0 .../site/controllers/itemform.json.php | 4 +- .../com_tjucm/site/includes/tjucm.php | 37 +++++- .../com_tjucm/site/includes/version.php | 103 ++++++++++++++++ .../com_tjucm/site/models/itemform.php | 110 +----------------- src/components/com_tjucm/site/tjucm.php | 27 +---- .../site/views/itemform/tmpl/default.php | 41 +++---- .../site/views/items/tmpl/default.php | 2 +- 30 files changed, 195 insertions(+), 327 deletions(-) delete mode 100644 src/components/com_tjucm/administrator/assets/js/tjucm_type.js delete mode 100644 src/components/com_tjucm/administrator/classes/funlist.php create mode 100755 src/components/com_tjucm/media/.htaccess create mode 100755 src/components/com_tjucm/media/css/.htaccess create mode 100644 src/components/com_tjucm/media/css/index.html create mode 100644 src/components/com_tjucm/media/css/tjucm.css create mode 100755 src/components/com_tjucm/media/js/com_tjucm.min.js create mode 100755 src/components/com_tjucm/media/js/core/base.min.js create mode 100755 src/components/com_tjucm/media/js/core/class.min.js delete mode 100644 src/components/com_tjucm/media/js/form.js create mode 100644 src/components/com_tjucm/media/js/index.html delete mode 100755 src/components/com_tjucm/media/js/load_js.php create mode 100755 src/components/com_tjucm/media/js/services/item.min.js rename src/components/com_tjucm/{administrator/assets/js => media/js/ui}/itemform.js (100%) create mode 100644 src/components/com_tjucm/media/js/ui/itemform.min.js rename src/components/com_tjucm/{administrator/assets/js => media/js/vendor/jquery}/jquery.are-you-sure.js (100%) rename src/components/com_tjucm/{administrator/assets/js => media/js/vendor/jquery}/jquery.form.js (100%) rename src/components/com_tjucm/{administrator/assets/js => media/js/vendor/shim}/ays-beforeunload-shim.js (100%) create mode 100644 src/components/com_tjucm/site/includes/version.php diff --git a/src/components/com_tjucm/administrator/assets/css/tjucm.css b/src/components/com_tjucm/administrator/assets/css/tjucm.css index 7ae82a71..c323376d 100644 --- a/src/components/com_tjucm/administrator/assets/css/tjucm.css +++ b/src/components/com_tjucm/administrator/assets/css/tjucm.css @@ -1,33 +1,3 @@ -.icon-48-types { -background-image: url(../images/l_types.png); -padding-left:60px!important; -} - -.icon-48-type { -background-image: url(../images/l_types.png); -padding-left:60px!important; -} - -.color-box-types { -float: left;width: 15px;height: 15px;margin-right: 5px;border: 1px solid rgba(0, 0, 0, .2);} - -.icon-48-items { -background-image: url(../images/l_items.png); -padding-left:60px!important; -} - -.icon-48-item { -background-image: url(../images/l_items.png); -padding-left:60px!important; -} - -.color-box-items { -float: left;width: 15px;height: 15px;margin-right: 5px;border: 1px solid rgba(0, 0, 0, .2);} - -.other-filters{ - padding: 0 14px; -} - /* CSS for frontend*/ #item-form .radio input{ margin-left:5px !important; diff --git a/src/components/com_tjucm/administrator/assets/js/tjucm_type.js b/src/components/com_tjucm/administrator/assets/js/tjucm_type.js deleted file mode 100644 index 442914a5..00000000 --- a/src/components/com_tjucm/administrator/assets/js/tjucm_type.js +++ /dev/null @@ -1,3 +0,0 @@ -js = jQuery.noConflict(); -js(document).ready(function () { -}); diff --git a/src/components/com_tjucm/administrator/classes/funlist.php b/src/components/com_tjucm/administrator/classes/funlist.php deleted file mode 100644 index 33c7ffe4..00000000 --- a/src/components/com_tjucm/administrator/classes/funlist.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. - * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL - */ - -defined('_JEXEC') or die('Restricted access'); -jimport('joomla.form.form'); - -/** - * Extra function list. - * - * @package Joomla.site - * @subpackage com_tjucm - * - * @since 1.0 - */ -class TjucmFunList -{ - /** - * Function to get data - * - * @param STRING $table Name of database table - * @param STRING $selectList Selected value colume name - * @param STRING $where Query where condition - * @param STRING $returnObject Selecting data using JDatabase - link https://docs.joomla.org/Selecting_data_using_JDatabase - * @param STRING $joinType LEFT, RIGHT etc - * @param STRING $joinTable Name of database table - * - * @return true - * - * @since 1.0.0 - */ - public function getDataValues($table, $selectList = "*", $where = "", $returnObject = "", $joinType = "", $joinTable = "") - { - // Ref - link https://docs.joomla.org/Selecting_data_using_JDatabase - - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - - $query->select($selectList); - $query->from($table); - - if ($joinTable) - { - $query->join($joinType, $joinTable); - } - - if ($where) - { - $query->where($where); - } - - $db->setQuery($query); - - return $db->$returnObject(); - } -} diff --git a/src/components/com_tjucm/administrator/models/item.php b/src/components/com_tjucm/administrator/models/item.php index 1a6bf330..0c3b54d0 100644 --- a/src/components/com_tjucm/administrator/models/item.php +++ b/src/components/com_tjucm/administrator/models/item.php @@ -55,9 +55,6 @@ class TjucmModelItem extends JModelAdmin */ public function __construct($config = array()) { - JLoader::import('components.com_tjucm.classes.funlist', JPATH_ADMINISTRATOR); - $this->common = new TjucmFunList; - parent::__construct($config); } @@ -290,7 +287,10 @@ public function save($data, $extra_jform_data = '', $post = '') $input = JFactory::getApplication()->input; $filter = JFilterInput::getInstance(); - $data['type_id'] = $this->common->getDataValues('#__tj_ucm_types', 'id AS type_id', 'unique_identifier = "' . $this->client . '"', 'loadResult'); + JLoader::import('components.com_tjucm.tables.type', JPATH_ADMINISTRATOR); + $tjUcmTypeTable = JTable::getInstance('TjucmTableType', 'JTable', array('dbo', JFactory::getDbo())); + $tjUcmTypeTable->load(array('unique_identifier' => $this->client)); + $data['type_id'] = $tjUcmTypeTable->id; if (parent::save($data)) { diff --git a/src/components/com_tjucm/administrator/models/type.php b/src/components/com_tjucm/administrator/models/type.php index 782c53a2..f9cf2ad5 100644 --- a/src/components/com_tjucm/administrator/models/type.php +++ b/src/components/com_tjucm/administrator/models/type.php @@ -48,9 +48,6 @@ class TjucmModelType extends JModelAdmin */ public function __construct($config = array()) { - JLoader::import('components.com_tjucm.classes.funlist', JPATH_ADMINISTRATOR); - $this->common = new TjucmFunList; - parent::__construct($config); } @@ -313,11 +310,7 @@ public function save($data) if (!empty($data['id'])) { $field_group = $this->getGroupCount($data['unique_identifier']); - - // Not able to get count using getTotal method of category model - $field_category = $this->common->getDataValues('#__categories', 'count(*)', 'extension = "' . $data['unique_identifier'] . '"', 'loadResult'); - - // $field_category = $this->getCategoryCount($data['unique_identifier']); + $field_category = $this->getCategoryCount($data['unique_identifier']); if ($field_group == 0 && $field_category == 0) { @@ -417,10 +410,10 @@ public function getGroupCount($client) public function getCategoryCount($client) { JLoader::import('components.com_categories.models.categories', JPATH_ADMINISTRATOR); - $categories_model = JModelLegacy::getInstance('Categories', 'CategoriesModel'); - $categories_model->setState('filter.extension', $client); + $categoryModel = JModelLegacy::getInstance('Categories', 'CategoriesModel', array('ignore_request' => true)); + $categoryModel->setState('filter.extension', $client); - return $categories_model->getTotal(); + return $categoryModel->getTotal(); } /** diff --git a/src/components/com_tjucm/administrator/tjucm.php b/src/components/com_tjucm/administrator/tjucm.php index 0bfd57c3..fd288f3f 100644 --- a/src/components/com_tjucm/administrator/tjucm.php +++ b/src/components/com_tjucm/administrator/tjucm.php @@ -20,15 +20,6 @@ // Include dependancies jimport('joomla.application.component.controller'); -$path = JPATH_COMPONENT_ADMINISTRATOR . '/classes/' . 'funlist.php'; - -if (!class_exists('TjucmFunList')) -{ - // Require_once $path; - JLoader::register('TjucmFunList', $path); - JLoader::load('TjucmFunList'); -} - // Load backend helper $path = JPATH_ADMINISTRATOR . '/components/com_tjucm/helpers/tjucm.php'; diff --git a/src/components/com_tjucm/administrator/views/type/tmpl/edit.php b/src/components/com_tjucm/administrator/views/type/tmpl/edit.php index 21ec84bd..7482dbaf 100644 --- a/src/components/com_tjucm/administrator/views/type/tmpl/edit.php +++ b/src/components/com_tjucm/administrator/views/type/tmpl/edit.php @@ -14,15 +14,8 @@ JHtml::_('behavior.formvalidation'); JHtml::_('formbehavior.chosen', 'select'); JHtml::_('behavior.keepalive'); - -JHtml::script(JUri::root() . 'administrator/components/com_tjucm/assets/js/tjucm_type.js'); ?> -extra_sidebar)) -{ - $this->sidebar .= $this->extra_sidebar; -} -?> +
sidebar)): ?>
sidebar; ?>
@@ -120,21 +118,9 @@
-
-
- +
- - + $this)); ?>
- +
- - + +
diff --git a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini index 53000a39..3308c040 100644 --- a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini @@ -178,4 +178,4 @@ COM_TJUCM_PERMISSION_TYPE_ITEM_DELETEOWN="Delete Own Item" COM_TJUCM_PERMISSION_TYPE_ITEM_DELETEOWN_DESC="Allows users in the group to delete own items in this UCM type." ; Added in version 1.2.4 -COM_QUICK2CART_SEARCH_FILTER_SUBMIT="Search" \ No newline at end of file +COM_TJUCM_SEARCH_FILTER_SUBMIT="Search" \ No newline at end of file From c87e7cc6c49c7259db4de44bae37844b1e1ec74e Mon Sep 17 00:00:00 2001 From: Pravin_s Date: Thu, 12 Dec 2019 18:40:09 +0530 Subject: [PATCH 085/273] Task #285 chore: Resolve feedback comments --- .../site/controllers/itemform.json.php | 3 +-- .../site/views/itemform/view.html.php | 26 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 7f2e0337..aab5f4fd 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -280,7 +280,6 @@ public function saveFormData() $formData['fieldsvalue'] = $data; $formData['client'] = $client; $formData['created_by'] = $table->created_by; - $isNew = $table->draft; // If data is valid then save the data into DB $response = $model->saveFieldsData($formData); @@ -310,7 +309,7 @@ public function saveFormData() // TJ-ucm plugin trigger after save $dispatcher = JEventDispatcher::getInstance(); PluginHelper::importPlugin("content"); - $dispatcher->trigger('onUcmItemAfterSave', array($table->getProperties(), $data, $isNew)); + $dispatcher->trigger('onUcmItemAfterSave', array($table->getProperties(), $data)); } } 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 7f847501..98657315 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -119,21 +119,25 @@ public function display($tpl = null) $clusterId = $this->item->cluster_id; } - // 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')) + // Get com_cluster component status + if (ComponentHelper::getComponent('com_cluster', true)->enabled) { - JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); + // Get com_subusers component status + $subUserExist = ComponentHelper::getComponent('com_subusers', true)->enabled; - // Check user has permission for mentioned cluster - if (!RBACL::authorise($user->id, 'com_cluster', 'core.manage', $clusterId)) + // Check user have permission to edit record of assigned cluster + if ($subUserExist && !empty($clusterId) && !$user->authorise('core.manageall', 'com_cluster')) { - $app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'error'); - $app->setHeader('status', 403, true); + JLoader::import("/components/com_subusers/includes/rbacl", JPATH_ADMINISTRATOR); - return; + // 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; + } } } From 8f4cd0e8622bc700f8e687f9750e52765818f0ce Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Thu, 12 Dec 2019 19:46:29 +0530 Subject: [PATCH 086/273] Bug#277 fix: Backend>>The title of form view of Types is not appropriate. --- .../com_tjucm/administrator/views/item/view.html.php | 2 +- .../com_tjucm/administrator/views/items/view.html.php | 2 +- .../com_tjucm/administrator/views/type/view.html.php | 9 ++++++--- .../com_tjucm/administrator/views/types/view.html.php | 6 +++--- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/components/com_tjucm/administrator/views/item/view.html.php b/src/components/com_tjucm/administrator/views/item/view.html.php index e5ccfae0..b6b01f4c 100644 --- a/src/components/com_tjucm/administrator/views/item/view.html.php +++ b/src/components/com_tjucm/administrator/views/item/view.html.php @@ -96,7 +96,7 @@ protected function addToolbar() $canDo = TjucmHelper::getActions(); - JToolBarHelper::title(JText::_('COM_TJUCM_TITLE_ITEM'), 'item.png'); + JToolBarHelper::title(JText::_('COM_TJUCM_TITLE_ITEM'), 'icon-pencil'); // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create')))) diff --git a/src/components/com_tjucm/administrator/views/items/view.html.php b/src/components/com_tjucm/administrator/views/items/view.html.php index 7df465d5..89810a12 100644 --- a/src/components/com_tjucm/administrator/views/items/view.html.php +++ b/src/components/com_tjucm/administrator/views/items/view.html.php @@ -78,7 +78,7 @@ protected function addToolbar() $state = $this->get('State'); $canDo = TjucmHelper::getActions(); - JToolBarHelper::title(JText::_('COM_TJUCM_TITLE_ITEMS'), 'items.png'); + JToolBarHelper::title(JText::_('COM_TJUCM_TITLE_ITEMS'), 'list'); // Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/item'; diff --git a/src/components/com_tjucm/administrator/views/type/view.html.php b/src/components/com_tjucm/administrator/views/type/view.html.php index 0a0ab0e6..546162ec 100644 --- a/src/components/com_tjucm/administrator/views/type/view.html.php +++ b/src/components/com_tjucm/administrator/views/type/view.html.php @@ -63,8 +63,7 @@ protected function addToolbar() JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); - $isNew = ($this->item->id == 0); - + $isNew = ($this->item->id == 0); if (isset($this->item->checked_out)) { $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); @@ -76,7 +75,11 @@ protected function addToolbar() $canDo = TjucmHelper::getActions(); - JToolBarHelper::title(JText::_('COM_TJUCM_TITLE_TYPE'), 'type.png'); + $component_title = JText::_('COM_TJUCM_COMPONENT'); + JToolbarHelper::title($component_title.": ". + JText::_('COM_TJUCM_PAGE_' . ($checkedOut ? 'VIEW_TYPE' : ($isNew ? 'ADD_TYPE' : 'EDIT_TYPE'))), + 'pencil-2 article-add' + ); // If not checked out, can save the item. if (!$checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create')))) diff --git a/src/components/com_tjucm/administrator/views/types/view.html.php b/src/components/com_tjucm/administrator/views/types/view.html.php index 4888da5e..6da08511 100644 --- a/src/components/com_tjucm/administrator/views/types/view.html.php +++ b/src/components/com_tjucm/administrator/views/types/view.html.php @@ -67,9 +67,9 @@ protected function addToolbar() { $state = $this->get('State'); $canDo = TjucmHelper::getActions(); - - JToolBarHelper::title(JText::_('COM_TJUCM_TITLE_TYPES'), 'list'); - + $component_title = JText::_('COM_TJUCM_COMPONENT'); + JToolBarHelper::title($component_title .": ". JText::_('COM_TJUCM_TITLE_TYPES'), 'list'); + // Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/type'; From d5bfd64768f9b37c2ee40db46deb89e26e464534 Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Fri, 13 Dec 2019 09:58:39 +0530 Subject: [PATCH 087/273] Bug#277 fix: Backend>>The title of form view of Types is not appropriate. --- .../com_tjucm/administrator/views/type/view.html.php | 9 +++++---- .../com_tjucm/administrator/views/types/view.html.php | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/components/com_tjucm/administrator/views/type/view.html.php b/src/components/com_tjucm/administrator/views/type/view.html.php index 546162ec..1fe5b9d6 100644 --- a/src/components/com_tjucm/administrator/views/type/view.html.php +++ b/src/components/com_tjucm/administrator/views/type/view.html.php @@ -63,7 +63,8 @@ protected function addToolbar() JFactory::getApplication()->input->set('hidemainmenu', true); $user = JFactory::getUser(); - $isNew = ($this->item->id == 0); + $isNew = ($this->item->id == 0); + if (isset($this->item->checked_out)) { $checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id')); @@ -75,9 +76,9 @@ protected function addToolbar() $canDo = TjucmHelper::getActions(); - $component_title = JText::_('COM_TJUCM_COMPONENT'); - JToolbarHelper::title($component_title.": ". - JText::_('COM_TJUCM_PAGE_' . ($checkedOut ? 'VIEW_TYPE' : ($isNew ? 'ADD_TYPE' : 'EDIT_TYPE'))), + $component_title = JText::_('COM_TJUCM_COMPONENT'); + JToolbarHelper::title( + $component_title . ": " . JText::_('COM_TJUCM_PAGE_' . ($checkedOut ? 'VIEW_TYPE' : ($isNew ? 'ADD_TYPE' : 'EDIT_TYPE'))), 'pencil-2 article-add' ); diff --git a/src/components/com_tjucm/administrator/views/types/view.html.php b/src/components/com_tjucm/administrator/views/types/view.html.php index 6da08511..46428a8c 100644 --- a/src/components/com_tjucm/administrator/views/types/view.html.php +++ b/src/components/com_tjucm/administrator/views/types/view.html.php @@ -67,9 +67,9 @@ protected function addToolbar() { $state = $this->get('State'); $canDo = TjucmHelper::getActions(); - $component_title = JText::_('COM_TJUCM_COMPONENT'); - JToolBarHelper::title($component_title .": ". JText::_('COM_TJUCM_TITLE_TYPES'), 'list'); - + $component_title = JText::_('COM_TJUCM_COMPONENT'); + JToolBarHelper::title($component_title . " : " . JText::_('COM_TJUCM_TITLE_TYPES'), 'list'); + // Check if the form exists before showing the add/edit buttons $formPath = JPATH_COMPONENT_ADMINISTRATOR . '/views/type'; From 63fe65d368775c0f38ffbea6c56a568730f8adab Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Fri, 13 Dec 2019 13:10:37 +0530 Subject: [PATCH 088/273] Bug#280 fix: Backend: The alias of form view of type should be validated --- .../houseKeeping/1.2.4/updateAlias.php | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 src/components/com_tjucm/administrator/houseKeeping/1.2.4/updateAlias.php 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 new file mode 100644 index 00000000..dfadf235 --- /dev/null +++ b/src/components/com_tjucm/administrator/houseKeeping/1.2.4/updateAlias.php @@ -0,0 +1,122 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ +// No direct access +defined('_JEXEC') or die('Restricted access'); +use Joomla\Registry\Registry; +use Joomla\CMS\Factory; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Filesystem\File; + +/** + * Migration file for TJ-UCM + * + * @since 1.0 + */ +class TjHouseKeepingUpdateAlias extends TjModelHouseKeeping +{ + public $title = "Update Types Alias"; + + public $description = 'Update UCM Types alias'; + + /** + * Subform migration script + * + * @return void + * + * @since 1.0 + */ + public function migrate() + { + JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjucm/tables'); + JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjfields/tables'); + JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_menus/tables'); + + JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_ADMINISTRATOR); + + // TJ-Fields helper object + $tjfieldsHelper = new TjfieldsHelper; + + $result = array(); + $ucmSubFormFieldsConfig = array(); + + try + { + // Get all the UCM types + $db = JFactory::getDbo(); + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->qn('#__tj_ucm_types')); + $db->setQuery($query); + $ucmTypes = $db->loadObjectlist(); + + $session = JFactory::getSession(); + $updatedTypes = (empty($session->get('updatedTypes'))) ? array() : $session->get('updatedTypes'); + + if (!empty($ucmTypes)) + { + foreach ($ucmTypes as $ucmType) + { + if (in_array($ucmType->id, $updatedTypes)) + { + continue; + } + + $ucmTypeTable = JTable::getInstance('Type', 'TjucmTable', array('dbo', $db)); + $ucmTypeTable->load($ucmType->id); + + $updatedAlias = JFilterOutput::stringURLSafe($ucmTypeTable->alias); + $oldAlias = $ucmTypeTable->alias; + $ucmTypeTable->alias = $updatedAlias; + $ucmTypeTable->store(); + + $updatedTypes[] = $ucmType->id; + $session->set('updatedTypes', $updatedTypes); + + $result['status'] = ''; + $result['message'] = "Migration in progress"; + } + } + + // Menus + $query->from($db->quoteName('#__menu')); + $query->where("link" . "=" . "'index.php?option=com_tjucm&view=itemform'" . "||" . "link" . "=" . "'index.php?option=com_tjucm&view=items'"); + $db->setQuery($query); + $menuItems = $db->loadObjectlist(); + + if (!empty($menuItems)) + { + foreach ($menuItems as $menuItem) + { + $menuItemTable = JTable::getInstance('Menu', 'MenusTable', array('dbo', $db)); + $menuItemTable->load($menuItem->id); + $oldparams = json_decode($menuItemTable->params); + $oldparams->ucm_type = JFilterOutput::stringURLSafe($oldparams->ucm_type); + $menuItemTable->params = json_encode($oldparams); + $menuItemTable->store(); + $updatedTypes[] = $ucmType->id; + $session->set('updatedTypes', $updatedTypes); + $result['status'] = ''; + $result['message'] = "Migration in progress"; + } + } + + $session->set('updatedTypes', ''); + $result['status'] = true; + $result['message'] = "Migration successful"; + } + catch (Exception $e) + { + $result['err_code'] = ''; + $result['status'] = false; + $result['message'] = $e->getMessage(); + } + return $result; + } +} From cbf822d7122780e900561694ac5a8c6562cef016 Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Fri, 13 Dec 2019 10:08:38 -0500 Subject: [PATCH 089/273] Bug #154594 fix : Adding custom layout(12X12) --- .../en-GB/en-GB.com_tjucm.sys.ini | 3 +- .../site/views/itemform/tmpl/grid.php | 138 ++++++++++++++++++ .../site/views/itemform/tmpl/grid.xml | 18 +++ 3 files changed, 158 insertions(+), 1 deletion(-) create mode 100644 src/components/com_tjucm/site/views/itemform/tmpl/grid.php create mode 100644 src/components/com_tjucm/site/views/itemform/tmpl/grid.xml diff --git a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.sys.ini b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.sys.ini index 743d4656..031b1c8c 100644 --- a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.sys.ini +++ b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.sys.ini @@ -5,4 +5,5 @@ COM_TJUCM_TITLE_ITEMS="Items" COM_TJUCM_TITLE_FORM_VIEW_ITEM="ItemForm" COM_TJUCM_TITLE_FORM_VIEW_ITEM_DESC="Show a form to add or edit a Item" COM_TJUCM_TITLE_LIST_VIEW_ITEMS="Items" -COM_TJUCM_TITLE_LIST_VIEW_ITEMS_DESC="Show a list of Items" \ No newline at end of file +COM_TJUCM_TITLE_LIST_VIEW_ITEMS_DESC="Show a list of Items" +COM_TJUCM_TITLE_FORM_VIEW_ITEMFORM="Grid(12X12)" \ No newline at end of file diff --git a/src/components/com_tjucm/site/views/itemform/tmpl/grid.php b/src/components/com_tjucm/site/views/itemform/tmpl/grid.php new file mode 100644 index 00000000..137aabb3 --- /dev/null +++ b/src/components/com_tjucm/site/views/itemform/tmpl/grid.php @@ -0,0 +1,138 @@ + + * @package Com_Tjucm + * @author Techjoomla + * @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved. + * @license GNU General Public License version 2 or later. + */ + +// No direct access +defined('_JEXEC') or die; + +$fieldsets_counter = 0; +$layout = JFactory::getApplication()->input->get('layout'); + + +if ($this->form_extra) +{ + // Iterate through the normal form fieldsets and display each one + $fieldSets = $this->form_extra->getFieldsets(); + + foreach ($fieldSets as $fieldset) + { + if (count($fieldSets) > 1) + { + if ($fieldsets_counter == 0) + { + echo JHtml::_('bootstrap.startTabSet', 'tjucm_myTab'); + } + + $fieldsets_counter++; + + if (count($this->form_extra->getFieldset($fieldset->name))) + { + foreach ($this->form_extra->getFieldset($fieldset->name) as $field) + { + if (!$field->hidden) + { + $tabName = JFilterOutput::stringURLUnicodeSlug(trim($fieldset->name)); + echo JHtml::_("bootstrap.addTab", "tjucm_myTab", $tabName, $fieldset->name); + break; + } + } + } + } + ?> +
+ form_extra->getFieldset($fieldset->name) as $field) + { + if (!$field->hidden) + { if($field->type!="radio") + { + ?> +
+
+
+ label; ?> +
+
+ input; ?> +
+
+
+
+ label."
"; ?> +
+
+ input; ?> +
+ type == 'File') + { + ?> + + +
+
+ +
+ 1) + { + if (count($this->form_extra->getFieldset($fieldset->name))) + { + foreach ($this->form_extra->getFieldset($fieldset->name) as $field) + { + if (!$field->hidden) + { + echo JHtml::_("bootstrap.endTab"); + break; + } + } + } + } + } + + if (count($fieldSets) > 1) + { + echo JHtml::_('bootstrap.endTabSet'); + } +} +else +{ + ?> +
+ +
+ + + + + + +
+ + +
+
+
From 6e2120097a821bcb19bfb39ef974dfaf12c63dbc Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Mon, 16 Dec 2019 10:46:55 +0530 Subject: [PATCH 090/273] Bug#280 fix: Backend: The alias of form view of type should be validated --- .../houseKeeping/1.2.4/updateAlias.php | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 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 dfadf235..d1a38241 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 @@ -17,7 +17,7 @@ /** * Migration file for TJ-UCM * - * @since 1.0 + * @since 1.2.4 */ class TjHouseKeepingUpdateAlias extends TjModelHouseKeeping { @@ -30,12 +30,11 @@ class TjHouseKeepingUpdateAlias extends TjModelHouseKeeping * * @return void * - * @since 1.0 + * @since 1.2.4 */ public function migrate() { JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjucm/tables'); - JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjfields/tables'); JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_menus/tables'); JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_ADMINISTRATOR); @@ -56,35 +55,25 @@ public function migrate() $db->setQuery($query); $ucmTypes = $db->loadObjectlist(); - $session = JFactory::getSession(); - $updatedTypes = (empty($session->get('updatedTypes'))) ? array() : $session->get('updatedTypes'); - if (!empty($ucmTypes)) { foreach ($ucmTypes as $ucmType) { - if (in_array($ucmType->id, $updatedTypes)) - { - continue; - } - $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(); - $updatedTypes[] = $ucmType->id; - $session->set('updatedTypes', $updatedTypes); - $result['status'] = ''; $result['message'] = "Migration in progress"; } } - // Menus + // Get all the menus of UCM types $query->from($db->quoteName('#__menu')); $query->where("link" . "=" . "'index.php?option=com_tjucm&view=itemform'" . "||" . "link" . "=" . "'index.php?option=com_tjucm&view=items'"); $db->setQuery($query); @@ -97,17 +86,16 @@ public function migrate() $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); $menuItemTable->params = json_encode($oldparams); $menuItemTable->store(); - $updatedTypes[] = $ucmType->id; - $session->set('updatedTypes', $updatedTypes); $result['status'] = ''; $result['message'] = "Migration in progress"; } } - $session->set('updatedTypes', ''); $result['status'] = true; $result['message'] = "Migration successful"; } From f66be60e5ae5337342ed0923c9bb9587a7999238 Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Mon, 16 Dec 2019 01:58:45 -0500 Subject: [PATCH 091/273] Bug#154050 fix:The filter of list view of types is not in searchtools --- .../com_tjucm/administrator/models/forms/filter_types.xml | 8 ++++---- .../com_tjucm/administrator/views/types/tmpl/default.php | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/com_tjucm/administrator/models/forms/filter_types.xml b/src/components/com_tjucm/administrator/models/forms/filter_types.xml index 72878b68..6dce3c49 100644 --- a/src/components/com_tjucm/administrator/models/forms/filter_types.xml +++ b/src/components/com_tjucm/administrator/models/forms/filter_types.xml @@ -2,10 +2,10 @@ + type="text" + hint="COM_TJUCM_SEARCH_FILTER_SUBMIT" + label="COM_USERS_FILTER_SEARCH_DESC" + class="js-stools-search-string" /> state->get('list.ordering'); $listDirn = $this->state->get('list.direction'); From c8869efb1797a3841b3e201a28e2c72d1660adc4 Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Mon, 16 Dec 2019 12:57:07 +0530 Subject: [PATCH 092/273] Bug#280 fix: Backend: The alias of form view of type should be validated --- .../houseKeeping/1.2.4/updateAlias.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 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 d1a38241..410f3787 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 @@ -7,12 +7,9 @@ * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL */ + // No direct access defined('_JEXEC') or die('Restricted access'); -use Joomla\Registry\Registry; -use Joomla\CMS\Factory; -use Joomla\CMS\MVC\Model\BaseDatabaseModel; -use Joomla\CMS\Filesystem\File; /** * Migration file for TJ-UCM @@ -37,13 +34,10 @@ public function migrate() JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjucm/tables'); JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_menus/tables'); - JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_ADMINISTRATOR); - // TJ-Fields helper object $tjfieldsHelper = new TjfieldsHelper; $result = array(); - $ucmSubFormFieldsConfig = array(); try { @@ -60,9 +54,8 @@ 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 + // Remove white spaces in alias of UCM types $updatedAlias = JFilterOutput::stringURLSafe($ucmTypeTable->alias); $oldAlias = $ucmTypeTable->alias; $ucmTypeTable->alias = $updatedAlias; @@ -75,7 +68,10 @@ public function migrate() // Get all the menus of UCM types $query->from($db->quoteName('#__menu')); - $query->where("link" . "=" . "'index.php?option=com_tjucm&view=itemform'" . "||" . "link" . "=" . "'index.php?option=com_tjucm&view=items'"); + $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->setQuery($query); $menuItems = $db->loadObjectlist(); @@ -84,7 +80,6 @@ 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 From 9740c4294739d3a185ae9f9838eb053a1c83ae8a Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Mon, 16 Dec 2019 03:53:44 -0500 Subject: [PATCH 093/273] Bug#154050 fix:The filter of list view of types is not in searchtools --- .../administrator/views/types/tmpl/default.php | 10 +++++----- .../com_tjucm/administrator/views/types/view.html.php | 6 ++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/components/com_tjucm/administrator/views/types/tmpl/default.php b/src/components/com_tjucm/administrator/views/types/tmpl/default.php index b722960e..94b7824d 100644 --- a/src/components/com_tjucm/administrator/views/types/tmpl/default.php +++ b/src/components/com_tjucm/administrator/views/types/tmpl/default.php @@ -110,9 +110,9 @@ - sidebar)): ?> + sidebar)): ?>
sidebar; ?>
-
+
@@ -142,10 +142,10 @@
- + - +
diff --git a/src/components/com_tjucm/administrator/views/types/view.html.php b/src/components/com_tjucm/administrator/views/types/view.html.php index ccaf8505..8fcb032e 100644 --- a/src/components/com_tjucm/administrator/views/types/view.html.php +++ b/src/components/com_tjucm/administrator/views/types/view.html.php @@ -42,9 +42,9 @@ public function display($tpl = null) $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->filterForm = $this->get('FilterForm'); - $this->activeFilters = $this->get('ActiveFilters'); + $this->activeFilters = $this->get('ActiveFilters'); - //Check for errors. + // Check for errors. if (count($errors = $this->get('Errors'))) { throw new Exception(implode("\n", $errors)); @@ -140,8 +140,6 @@ protected function addToolbar() { JToolBarHelper::preferences('com_tjucm'); } - - } /** From 822c7039cb555fa74ea9622d679c5cc15039f7ac Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Mon, 16 Dec 2019 06:41:36 -0500 Subject: [PATCH 094/273] Bug#152978 fix:Menu should get switched once user in the edit mode of the form. --- src/components/com_tjucm/site/controllers/item.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/item.php b/src/components/com_tjucm/site/controllers/item.php index bfca6a61..32f0f00f 100644 --- a/src/components/com_tjucm/site/controllers/item.php +++ b/src/components/com_tjucm/site/controllers/item.php @@ -70,7 +70,8 @@ public function edit() // Get the model. $model = $this->getModel('Item', 'TjucmModel'); - + $items_model = $this->getModel('Items','TjucmModel'); + $this->client = $items_model->getState('ucm.client'); // Check out the item if ($editId) { @@ -112,6 +113,8 @@ public function publish() $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); + $items_model = $this->getModel('Items','TjucmModel'); + $this->client = $items_model->getState('ucm.client'); if ($canEdit || $canChange) { @@ -140,7 +143,7 @@ public function publish() $this->setMessage(JText::_('COM_TJUCM_ITEM_SAVED_SUCCESSFULLY')); // If there isn't any menu item active, redirect to list view - $itemId = $tjUcmFrontendHelper->getItemId('index.php?option=com_tjucm&view=items' . $this->appendUrl); + $itemId = $tjUcmFrontendHelper->getItemId('index.php?option=com_tjucm&view=items' . $this->client); $this->setRedirect(JRoute::_('index.php?option=com_tjucm&view=items' . $this->appendUrl . '&Itemid=' . $itemId, false)); } else From 38a6bb155abc90dcc8b1ae97e944891635bb66eb Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Mon, 16 Dec 2019 06:54:41 -0500 Subject: [PATCH 095/273] Bug#152978 fix:Menu should get switched once user in the edit mode of the form. --- src/components/com_tjucm/site/controllers/item.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/item.php b/src/components/com_tjucm/site/controllers/item.php index 32f0f00f..0e7cbf07 100644 --- a/src/components/com_tjucm/site/controllers/item.php +++ b/src/components/com_tjucm/site/controllers/item.php @@ -72,6 +72,7 @@ public function edit() $model = $this->getModel('Item', 'TjucmModel'); $items_model = $this->getModel('Items','TjucmModel'); $this->client = $items_model->getState('ucm.client'); + // Check out the item if ($editId) { @@ -113,8 +114,7 @@ public function publish() $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); - $items_model = $this->getModel('Items','TjucmModel'); - $this->client = $items_model->getState('ucm.client'); + if ($canEdit || $canChange) { @@ -143,7 +143,7 @@ public function publish() $this->setMessage(JText::_('COM_TJUCM_ITEM_SAVED_SUCCESSFULLY')); // If there isn't any menu item active, redirect to list view - $itemId = $tjUcmFrontendHelper->getItemId('index.php?option=com_tjucm&view=items' . $this->client); + $itemId = $tjUcmFrontendHelper->getItemId('index.php?option=com_tjucm&view=items' . $this->appendUrl); $this->setRedirect(JRoute::_('index.php?option=com_tjucm&view=items' . $this->appendUrl . '&Itemid=' . $itemId, false)); } else From d77ae8e18a8d98a5ab2a8368da4c64deafd04556 Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Tue, 17 Dec 2019 02:04:20 -0500 Subject: [PATCH 096/273] Bug#154594:Adding custom layout 12X12 --- .../site/views/itemform/tmpl/default_grid.php | 138 ++++++++++++++++++ .../site/views/itemform/tmpl/grid.php | 130 +---------------- .../site/views/itemform/tmpl/grid.xml | 2 +- 3 files changed, 141 insertions(+), 129 deletions(-) create mode 100644 src/components/com_tjucm/site/views/itemform/tmpl/default_grid.php diff --git a/src/components/com_tjucm/site/views/itemform/tmpl/default_grid.php b/src/components/com_tjucm/site/views/itemform/tmpl/default_grid.php new file mode 100644 index 00000000..0ee9d6b6 --- /dev/null +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default_grid.php @@ -0,0 +1,138 @@ + + * @package Com_Tjucm + * @author Techjoomla + * @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved. + * @license GNU General Public License version 2 or later. + */ + +// No direct access +defined('_JEXEC') or die; + +$fieldsets_counter = 0; +$layout = JFactory::getApplication()->input->get('layout'); + + +if ($this->form_extra) +{ + // Iterate through the normal form fieldsets and display each one + $fieldSets = $this->form_extra->getFieldsets(); + + foreach ($fieldSets as $fieldset) + { + if (count($fieldSets) > 1) + { + if ($fieldsets_counter == 0) + { + echo JHtml::_('bootstrap.startTabSet', 'tjucm_myTab'); + } + + $fieldsets_counter++; + + if (count($this->form_extra->getFieldset($fieldset->name))) + { + foreach ($this->form_extra->getFieldset($fieldset->name) as $field) + { + if (!$field->hidden) + { + $tabName = JFilterOutput::stringURLUnicodeSlug(trim($fieldset->name)); + echo JHtml::_("bootstrap.addTab", "tjucm_myTab", $tabName, $fieldset->name); + break; + } + } + } + } + ?> +
+ form_extra->getFieldset($fieldset->name) as $field) + { + if (!$field->hidden) + { + if($field->type=="Checkbox") + { + ?> +
+
+
+ label; ?> +
+
+ input; ?> +
+
+
+
+ label; ?> +
+
+ input; ?> +
+ type == 'File') + { + ?> + + +
+
+ +
+ 1) + { + if (count($this->form_extra->getFieldset($fieldset->name))) + { + foreach ($this->form_extra->getFieldset($fieldset->name) as $field) + { + if (!$field->hidden) + { + echo JHtml::_("bootstrap.endTab"); + break; + } + } + } + } + } + + if (count($fieldSets) > 1) + { + echo JHtml::_('bootstrap.endTabSet'); + } +} +else +{ + ?> +
+ +
+ * @package Com_Tjucm * @author Techjoomla - * @copyright Copyright (c) 2009-2017 TechJoomla. All rights reserved. + * @copyright Copyright (c) 2009-2018 TechJoomla. All rights reserved. * @license GNU General Public License version 2 or later. */ // No direct access defined('_JEXEC') or die; - -$fieldsets_counter = 0; -$layout = JFactory::getApplication()->input->get('layout'); - - -if ($this->form_extra) -{ - // Iterate through the normal form fieldsets and display each one - $fieldSets = $this->form_extra->getFieldsets(); - - foreach ($fieldSets as $fieldset) - { - if (count($fieldSets) > 1) - { - if ($fieldsets_counter == 0) - { - echo JHtml::_('bootstrap.startTabSet', 'tjucm_myTab'); - } - - $fieldsets_counter++; - - if (count($this->form_extra->getFieldset($fieldset->name))) - { - foreach ($this->form_extra->getFieldset($fieldset->name) as $field) - { - if (!$field->hidden) - { - $tabName = JFilterOutput::stringURLUnicodeSlug(trim($fieldset->name)); - echo JHtml::_("bootstrap.addTab", "tjucm_myTab", $tabName, $fieldset->name); - break; - } - } - } - } - ?> -
- form_extra->getFieldset($fieldset->name) as $field) - { - if (!$field->hidden) - { if($field->type!="radio") - { - ?> -
-
-
- label; ?> -
-
- input; ?> -
-
-
-
- label."
"; ?> -
-
- input; ?> -
- type == 'File') - { - ?> - - -
-
- -
- 1) - { - if (count($this->form_extra->getFieldset($fieldset->name))) - { - foreach ($this->form_extra->getFieldset($fieldset->name) as $field) - { - if (!$field->hidden) - { - echo JHtml::_("bootstrap.endTab"); - break; - } - } - } - } - } - - if (count($fieldSets) > 1) - { - echo JHtml::_('bootstrap.endTabSet'); - } -} -else -{ - ?> -
- -
- - + From 27bb121fc5841236f9d9649dfcceae4b7f53c90e Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Tue, 17 Dec 2019 02:10:24 -0500 Subject: [PATCH 097/273] Bug#154594:Adding custom layout 12X12 --- .../com_tjucm/site/views/itemform/tmpl/default.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) 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 511eb3d7..cdd7957c 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/default.php +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default.php @@ -41,6 +41,7 @@ $baseUrl = $jinput->input->server->get('REQUEST_URI', '', 'STRING'); $calledFrom = (strpos($baseUrl, 'administrator')) ? 'backend' : 'frontend'; $layout = ($calledFrom == 'frontend') ? 'default' : 'edit'; +$dyanamic_layout=$this->setLayout($typeParams->layout); $fieldsets_counter_deafult = 0; $setnavigation = false; @@ -116,7 +117,7 @@
form_extra) - { + { if($this->id!='0') { ?> @@ -124,7 +125,7 @@

title); ?>

-

title); ?>

-

loadTemplate('extrafields'); + } + else + { + echo $this->loadTemplate('grid'); + } ?>
Date: Wed, 18 Dec 2019 12:12:25 +0530 Subject: [PATCH 098/273] Task #154510 feat: Import Records from the frontend --- .../com_tjucm/administrator/access.xml | 1 + .../administrator/en-GB/en-GB.com_tjucm.ini | 2 + .../languages/site/en-GB/en-GB.com_tjucm.ini | 12 + .../com_tjucm/site/controllers/items.php | 270 ++++++++++++++++++ .../com_tjucm/site/helpers/tjucm.php | 1 + .../site/views/items/tmpl/default.php | 28 +- .../site/views/items/tmpl/importitems.php | 90 ++++++ .../com_tjucm/site/views/items/view.html.php | 13 +- 8 files changed, 407 insertions(+), 10 deletions(-) create mode 100644 src/components/com_tjucm/site/views/items/tmpl/importitems.php diff --git a/src/components/com_tjucm/administrator/access.xml b/src/components/com_tjucm/administrator/access.xml index 8f34851d..689379fa 100644 --- a/src/components/com_tjucm/administrator/access.xml +++ b/src/components/com_tjucm/administrator/access.xml @@ -14,6 +14,7 @@ + diff --git a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini index ed8ac522..8e1dac38 100644 --- a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini @@ -159,6 +159,8 @@ COM_TJUCM_PERMISSION_TYPE_ITEM_EDITOWN="Edit Own Item" COM_TJUCM_PERMISSION_TYPE_ITEM_EDITOWN_DESC="Allows users in the group to edit own items in this UCM type." COM_TJUCM_PERMISSION_TYPE_ITEM_DELETE="Delete All Items" COM_TJUCM_PERMISSION_TYPE_ITEM_DELETE_DESC="Allows users in the group to delete items created by any user in this UCM type." +COM_TJUCM_PERMISSION_TYPE_ITEM_IMPORT="Import Items" +COM_TJUCM_PERMISSION_TYPE_ITEM_IMPORT_DESC="Allows users in the group to import the items from CSV file.
NOTE:- This will only work if a user has the permission to add item in the UCM type." COM_TJUCM_FORM_LBL_TYPE_IS_SUBFORM="Is Subform" COM_TJUCM_FORM_DESC_TYPE_IS_SUBFORM="Set whether this UCM type is a subform. If you select YES then you can create a field of this UCM type as a subform field in any other UCM type." COM_TJUCM_FORM_LBL_TYPE_LAYOUT="Form Layout" 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 c8556410..880eeb6d 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 @@ -7,6 +7,7 @@ COM_TJUCM_ITEM_NOT_LOADED="Could not load the item" COM_TJUCM_VIEW_FILE="[View File]" COM_TJUCM_VIEW_RECORD="View" COM_TJUCM_ADD_ITEM="Add" +COM_TJUCM_IMPORT_ITEM="Import Records" COM_TJUCM_EDIT_ITEM="Edit" COM_TJUCM_DELETE_ITEM="Delete" COM_TJUCM_DELETE_MESSAGE="Are you sure that you want delete this item?" @@ -190,3 +191,14 @@ COM_TJUCM_SOMETHING_WENT_WRONG="Something went wrong" COM_TJUCM_DATA_STATUS_DRAFT="Draft" COM_TJUCM_DATA_STATUS_SAVE="Saved" COM_TJUCM_DATA_STATUS="Status" + +; Since 1.2.4 +COM_TJUCM_ITEMS_UPLOAD_CSV_FILE_HELP="Note: To import records using CSV file for this form you should have CSV file in the following format. %s to download sample CSV file" +COM_TJUCM_ITEMS_CSV_FILE_UPLOAD_ERROR="Error in uploading the CSV file" +COM_TJUCM_ITEMS_INVALID_CSV_FILE="Selected file is invalid" +COM_TJUCM_ITEMS_INVALID_CSV_FILE_REQUIRED_COLUMN_MISSING="Some required column(s) are missing in the uploaded CSV file" +COM_TJUCM_ITEMS_UPLOAD_CSV_FILE="Choose CSV File" +COM_TJUCM_CLICK_HERE="Click Here" +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" diff --git a/src/components/com_tjucm/site/controllers/items.php b/src/components/com_tjucm/site/controllers/items.php index 697c3dbe..771bedbe 100644 --- a/src/components/com_tjucm/site/controllers/items.php +++ b/src/components/com_tjucm/site/controllers/items.php @@ -11,6 +11,15 @@ // No direct access. defined('_JEXEC') or die; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Filesystem\File; +use Joomla\Registry\Registry; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Table\Table; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Factory; + /** * Items list controller class. * @@ -35,4 +44,265 @@ public function &getModel($name = 'Items', $prefix = 'TjucmModel', $config = arr return $model; } + + /** + * Function to import records in specifed UCM type from CSV. + * + * @return null + * + * @since 1.2.4 + */ + public function importCsv() + { + Session::checkToken() or die('Invalid Token'); + + $app = Factory::getApplication(); + $importFile = $app->input->files->get('csv-file-upload'); + + $client = $app->input->get("client", '', 'STRING'); + + if (empty($client)) + { + $app->enqueueMessage(Text::_('COM_TJUCM_SOMETHING_WENT_WRONG'), 'error'); + $app->redirect(Uri::root() . 'index.php?option=com_tjucm&view=items&layout=importitems&tmpl=component'); + } + + // Check if the file is a CSV file + if ($importFile['type'] != "text/csv") + { + $app->enqueueMessage(Text::_('COM_TJUCM_ITEMS_INVALID_CSV_FILE'), 'error'); + $app->redirect(Uri::root() . 'index.php?option=com_tjucm&view=items&layout=importitems&tmpl=component&client=' . $client); + } + + // Load required files + JLoader::import('components.com_tjucm.models.itemform', JPATH_SITE); + JLoader::import('components.com_tjfields.models.fields', JPATH_ADMINISTRATOR); + JLoader::import('components.com_tjfields.models.options', JPATH_ADMINISTRATOR); + + $uploadPath = Factory::getConfig()->get('tmp_path') . '/' . File::makeSafe($importFile['name']); + + // Upload the JSON file + if (!File::upload($importFile['tmp_name'], $uploadPath)) + { + $app->enqueueMessage(Text::_('COM_TJUCM_ITEMS_CSV_FILE_UPLOAD_ERROR'), 'error'); + $app->redirect(Uri::root() . 'index.php?option=com_tjucm&view=items&layout=importitems&tmpl=component&client=' . $client); + } + + $tjFieldsFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); + $tjFieldsFieldsModel->setState("filter.client", $client); + $tjFieldsFieldsModel->setState("filter.state", 1); + $tjFieldsFieldsModel->setState('list.ordering', 'a.ordering'); + $tjFieldsFieldsModel->setState('list.direction', 'asc'); + $fields = $tjFieldsFieldsModel->getItems(); + + $fieldsArray = array(); + $requiredFieldsName = array(); + $requiredFieldsLabel = array(); + $fieldsName = array_column($fields, 'name'); + $fieldsLabel = array_column($fields, 'label'); + $fieldHeaders = array_combine($fieldsName, $fieldsLabel); + + foreach ($fields as $field) + { + // Get the required fields for the UCM type + if ($field->required == 1) + { + $requiredFieldsName[$field->name] = $field->name; + $requiredFieldsLabel[] = $field->label; + } + + if (in_array($field->type, array('radio', 'single_select', 'multi_select', 'tjlist'))) + { + $tjFieldsOptionsModel = BaseDatabaseModel::getInstance('Options', 'TjfieldsModel', array('ignore_request' => true)); + $tjFieldsOptionsModel->setState("filter.field_id", $field->id); + $field->options = $tjFieldsOptionsModel->getItems(); + } + + $fieldsArray[$field->name] = $field; + } + + $file = fopen($uploadPath, 'r'); + $headerRow = true; + $invalidRows = 0; + $validRows = 0; + + while (($data = fgetcsv($file)) !== false) + { + if ($headerRow) + { + $headers = $data; + $headerRow = false; + + // Check if all the required fields headers are present in the CSV file to be imported + $isValid = (count(array_intersect($requiredFieldsLabel, $headers)) == count($requiredFieldsLabel)); + + if (!$isValid) + { + $app->enqueueMessage(Text::_('COM_TJUCM_ITEMS_INVALID_CSV_FILE_REQUIRED_COLUMN_MISSING'), 'error'); + $app->redirect(Uri::root() . 'index.php?option=com_tjucm&view=items&layout=importitems&tmpl=component&client=' . $client); + } + } + elseif (count($headers) == count($data)) + { + $itemData = array(); + + // Prepare item data for item creation + foreach ($data as $key => $value) + { + $fieldName = array_search($headers[$key], $fieldHeaders); + $value = trim($value); + + if ($fieldName !== false && $value != '') + { + if (isset($fieldsArray[$fieldName]->options) && !empty($fieldsArray[$fieldName]->options)) + { + $fieldParams = new Registry($fieldsArray[$fieldName]->params); + + if (strpos($value, '||') !== false && $fieldParams->get('multiple')) + { + $optionValue = array_map('trim', explode("||", $value)); + $multiSelectValues = array(); + + foreach ($fieldsArray[$fieldName]->options as $option) + { + if (in_array($option->options, $optionValue)) + { + $multiSelectValues[] = $option->value; + } + } + + $itemData[$fieldName] = $multiSelectValues; + } + else + { + foreach ($fieldsArray[$fieldName]->options as $option) + { + if ($option->options == $value) + { + $itemData[$fieldName] = $option->value; + + break; + } + } + } + } + else + { + $itemData[$fieldName] = trim($value); + } + } + } + + // Check if all the required values are present in the row + $isValid = (count(array_intersect_key($itemData, $requiredFieldsName)) == count($requiredFieldsName)); + + if (!$isValid || empty($itemData)) + { + $invalidRows++; + } + else + { + $tjucmItemFormModel = BaseDatabaseModel::getInstance('ItemForm', 'TjucmModel'); + + if ($tjucmItemFormModel->save(array('client' => $client))) + { + $contentId = (int) $tjucmItemFormModel->getState($tjucmItemFormModel->getName() . '.id'); + + $fieldsData = array(); + $fieldsData['client'] = $client; + $fieldsData['content_id'] = $contentId; + $fieldsData['fieldsvalue'] = $itemData; + + if ($tjucmItemFormModel->saveFieldsData($fieldsData)) + { + $validRows++; + + continue; + } + } + else + { + if (!empty($tjucmItemFormModel->getErrors())) + { + foreach ($tjucmItemFormModel->getErrors() as $error) + { + $app->enqueueMessage($error, 'error'); + } + } + } + } + } + else + { + $invalidRows++; + } + } + + if ($validRows) + { + $app->enqueueMessage(Text::sprintf('COM_TJUCM_ITEMS_IMPORTED_SCUUESSFULLY', $validRows), 'success'); + } + + if ($invalidRows) + { + $app->enqueueMessage(Text::sprintf('COM_TJUCM_ITEMS_IMPORT_REJECTED_RECORDS', $invalidRows), 'warning'); + } + + if (empty($validRows) && empty($invalidRows)) + { + $app->enqueueMessage(Text::_('COM_TJUCM_ITEMS_NO_RECORDS_TO_IMPORT'), 'error'); + } + + $app->redirect(Uri::root() . 'index.php?option=com_tjucm&view=items&layout=importitems&tmpl=component&client=' . $client); + } + + /** + * Function to generate schema of CSV file for importing the records in specifed UCM type. + * + * @return null + * + * @since 1.2.4 + */ + public function getCsvImportFormat() + { + Session::checkToken('get') or die('Invalid Token'); + + $app = Factory::getApplication(); + $client = $app->input->get("client", '', 'STRING'); + + if (empty($client)) + { + $app->enqueueMessage(Text::_('COM_TJUCM_SOMETHING_WENT_WRONG'), 'error'); + $app->redirect(Uri::root() . 'index.php?option=com_tjucm&view=items&layout=importitems&tmpl=component'); + } + + // Get UCM Type data + JLoader::import('components.com_tjucm.tables.type', JPATH_ADMINISTRATOR); + $ucmTypeTable = Table::getInstance('Type', 'TjucmTable'); + $ucmTypeTable->load(array("unique_identifier" => $client)); + + // Get fields in the given UCM type + JLoader::import('components.com_tjfields.models.fields', JPATH_ADMINISTRATOR); + $tjFieldsFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); + $tjFieldsFieldsModel->setState("filter.client", $client); + $tjFieldsFieldsModel->setState("filter.state", 1); + $tjFieldsFieldsModel->setState('list.ordering', 'a.ordering'); + $tjFieldsFieldsModel->setState('list.direction', 'asc'); + $fields = $tjFieldsFieldsModel->getItems(); + $fieldsLabel = array_column($fields, 'label'); + + // Generate schema CSV file with CSV headers as label of the fields for given UCM type and save it in temp folder + $fileName = preg_replace('/[^A-Za-z0-9\-]/', '', $ucmTypeTable->title) . '.csv'; + $csvFileTmpPath = Factory::getConfig()->get('tmp_path') . '/' . $fileName; + $output = fopen($csvFileTmpPath, 'w'); + fputcsv($output, $fieldsLabel); + fclose($output); + + // Download the CSV file + header("Content-type: text/csv"); + header("Content-disposition: attachment; filename = " . $fileName); + readfile($csvFileTmpPath); + + jexit(); + } } diff --git a/src/components/com_tjucm/site/helpers/tjucm.php b/src/components/com_tjucm/site/helpers/tjucm.php index 830226a4..51be6798 100644 --- a/src/components/com_tjucm/site/helpers/tjucm.php +++ b/src/components/com_tjucm/site/helpers/tjucm.php @@ -76,6 +76,7 @@ public static function getLanguageConstantForJs() Text::script('COM_TJUCM_FIELDS_VALIDATION_ERROR_DATE', true); Text::script('COM_TJUCM_FIELDS_VALIDATION_ERROR_NUMBER', true); Text::script('COM_TJUCM_MSG_ON_SAVED_FORM', true); + Text::script('COM_TJUCM_ITEMS_INVALID_CSV_FILE', true); } /** 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 0b58f67c..ed17e796 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -13,8 +13,18 @@ JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html'); JHtml::_('bootstrap.tooltip'); JHtml::_('behavior.multiselect'); +JHtml::_('behavior.modal'); JHtml::_('formbehavior.chosen', 'select'); +$importItemsPopUpUrl = JUri::root() . '/index.php?option=com_tjucm&view=items&layout=importitems&tmpl=component&client=' . $this->client; +JFactory::getDocument()->addScriptDeclaration(' + jQuery(document).ready(function(){ + jQuery("#adminForm #import-items").click(function() { + SqueezeBox.open("' . $importItemsPopUpUrl . '" ,{handler: "iframe", size: {x: window.innerWidth-250, y: window.innerHeight-150}}); + }); + }); +'); + $user = JFactory::getUser(); $userId = $user->get('id'); $tjUcmFrontendHelper = new TjucmHelpersTjucm; @@ -39,13 +49,13 @@ $statusColumnWidth = 0; ?> -items)) +items)) { ?> @@ -56,12 +66,22 @@ { ?> - + canImport) + { + ?> + + + +
+
 
+
 
diff --git a/src/components/com_tjucm/site/views/items/tmpl/importitems.php b/src/components/com_tjucm/site/views/items/tmpl/importitems.php new file mode 100644 index 00000000..f791976b --- /dev/null +++ b/src/components/com_tjucm/site/views/items/tmpl/importitems.php @@ -0,0 +1,90 @@ + + * @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + */ + +// No direct access +defined('_JEXEC') or die; + +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Session\Session; + +HTMLHelper::_('bootstrap.tooltip'); + +Factory::getDocument()->addScriptDeclaration(' + jQuery(document).ready(function(){ + jQuery("#uploadForm #upload-submit").click(function() { + if (jQuery("#uploadForm #csv-file-upload").val() == "") + { + jQuery("#uploadForm #csv-file-upload").css("border-color", "red"); + + return false; + } + else + { + var tjUcmUploadFileName = jQuery("#uploadForm #csv-file-upload").val(); + var tjUcmUploadFileExtension = tjUcmUploadFileName.substr((tjUcmUploadFileName.lastIndexOf(".") +1)); + + if (tjUcmUploadFileExtension === "csv") + { + jQuery("#uploadForm #upload-submit").attr("disabled", "disabled"); + jQuery("#uploadForm #csv-file-upload").css("border-color", ""); + document.getElementById("uploadForm").submit(); + } + else + { + jQuery("#uploadForm #csv-file-upload").css("border-color", "red"); + jQuery("#system-message-container").html(); + Joomla.renderMessages({"error":[Joomla.JText._("COM_TJUCM_ITEMS_INVALID_CSV_FILE")]}); + + return false; + } + } + + return false; + }); + }); +'); +?> + +

+ +

+
+
+
+ + +
+
+
 
+ +
+
+
+ +
+
+ + + + + diff --git a/src/components/com_tjucm/site/views/items/view.html.php b/src/components/com_tjucm/site/views/items/view.html.php index 18752759..198ff08b 100644 --- a/src/components/com_tjucm/site/views/items/view.html.php +++ b/src/components/com_tjucm/site/views/items/view.html.php @@ -93,6 +93,7 @@ public function display($tpl = null) $this->ucmTypeId = $id = $model->getState('ucmType.id'); $this->client = $model->getState('ucm.client'); $this->canCreate = $user->authorise('core.type.createitem', 'com_tjucm.type.' . $this->ucmTypeId); + $this->canImport = $user->authorise('core.type.importitem', 'com_tjucm.type.' . $this->ucmTypeId); $this->canView = $user->authorise('core.type.viewitem', 'com_tjucm.type.' . $this->ucmTypeId); $this->canEdit = $user->authorise('core.type.edititem', 'com_tjucm.type.' . $this->ucmTypeId); $this->canChange = $user->authorise('core.type.edititemstate', 'com_tjucm.type.' . $this->ucmTypeId); @@ -125,18 +126,18 @@ public function display($tpl = null) // To get title of list as per the ucm type if (empty($this->title)) - { + { // Get the active item $menuItem = $app->getMenu()->getActive(); - + // Get the params $this->menuparams = $menuItem->params; - + if (!empty($this->menuparams)) - { - $this->title = $this->menuparams->get('ucm_type'); - } + { + $this->title = $this->menuparams->get('ucm_type'); } + } // If there are no fields column to show in list view then dont allow to show data $this->showList = $model->showListCheck($this->client); From ab15ff791077710b2e9a9eeacdf6447ff9581520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 18 Dec 2019 12:19:23 +0530 Subject: [PATCH 099/273] Task #154510 feat: Import Records from the frontend --- src/components/com_tjucm/site/controllers/items.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/com_tjucm/site/controllers/items.php b/src/components/com_tjucm/site/controllers/items.php index 771bedbe..2da87d80 100644 --- a/src/components/com_tjucm/site/controllers/items.php +++ b/src/components/com_tjucm/site/controllers/items.php @@ -88,6 +88,7 @@ public function importCsv() $app->redirect(Uri::root() . 'index.php?option=com_tjucm&view=items&layout=importitems&tmpl=component&client=' . $client); } + // Get all fields in the given UCM type $tjFieldsFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); $tjFieldsFieldsModel->setState("filter.client", $client); $tjFieldsFieldsModel->setState("filter.state", 1); @@ -95,6 +96,7 @@ public function importCsv() $tjFieldsFieldsModel->setState('list.direction', 'asc'); $fields = $tjFieldsFieldsModel->getItems(); + // Map the field names as per field labels in the uploaded CSV file $fieldsArray = array(); $requiredFieldsName = array(); $requiredFieldsLabel = array(); @@ -111,6 +113,7 @@ public function importCsv() $requiredFieldsLabel[] = $field->label; } + // Add options data the radio and list type fields if (in_array($field->type, array('radio', 'single_select', 'multi_select', 'tjlist'))) { $tjFieldsOptionsModel = BaseDatabaseModel::getInstance('Options', 'TjfieldsModel', array('ignore_request' => true)); @@ -121,11 +124,13 @@ public function importCsv() $fieldsArray[$field->name] = $field; } + // Read the CSV file $file = fopen($uploadPath, 'r'); $headerRow = true; $invalidRows = 0; $validRows = 0; + // Loop through the uploaded file while (($data = fgetcsv($file)) !== false) { if ($headerRow) @@ -158,6 +163,7 @@ public function importCsv() { $fieldParams = new Registry($fieldsArray[$fieldName]->params); + // 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)); @@ -202,6 +208,7 @@ public function importCsv() } else { + // Save the record in UCM $tjucmItemFormModel = BaseDatabaseModel::getInstance('ItemForm', 'TjucmModel'); if ($tjucmItemFormModel->save(array('client' => $client))) @@ -222,6 +229,7 @@ public function importCsv() } else { + // Return the error messages if any if (!empty($tjucmItemFormModel->getErrors())) { foreach ($tjucmItemFormModel->getErrors() as $error) From 01bec2dd5c572626ce79adb28c79043cda4b195a Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Wed, 18 Dec 2019 13:56:16 +0530 Subject: [PATCH 100/273] Bug#277 fix: Backend>>The title of form view of Types is not appropriate. --- .../languages/administrator/en-GB/en-GB.com_tjucm.ini | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini index ed8ac522..56fb42c2 100644 --- a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini @@ -30,7 +30,8 @@ COM_TJUCM_TO_FILTER="To %s" COM_TJUCM_VIEW_FILE="[View File]" COM_TJUCM_ITEMS_SUCCESS_DUPLICATED="Items successfully duplicated" COM_TJUCM_SOMETHING_WENT_WRONG="Something went wrong" - +COM_TYPE_PAGE_ADD_TYPE="Types: New" +COM_TYPE_PAGE_EDIT_TYPE="Types: Edit" COM_TJUCM_TYPE_EXPORT="Export" COM_TJUCM_TYPE_IMPORT="Import" COM_TJUCM_TYPE_DELETE_CONFIRMATION="All the field groups, fields and the data related to selected UCM type(s) will be deleted. Are you sure that you want to delete the selected UCM type(s)?" @@ -58,6 +59,14 @@ COM_TJUCM_TYPE_IMPORT_INVALID_FILE_CONTENT_ERROR="File content is invalid" COM_TJUCM_TYPE_IMPORT_SUCCESS_MSG="UCM type(s) imported successfully" COM_TJUCM_DUPLICATE_TYPE_ERROR="UCM type already exists" +COM_TJLMS_COMPONENT="LMS" +COM_JTICKETING_COMPONENT="Ticketing" +COM_TJUCM_COMPONENT="UCM" +COM_TJUCM_TITLE_TYPES="Types" + +COM_TJUCM_PAGE_ADD_TYPE="Types - New" +COM_TJUCM_PAGE_EDIT_TYPE="Types - Edit" + COM_TJUCM_TITLE_ITEMS="Items" COM_TJUCM_ITEMS_ID="ID" COM_TJUCM_ITEMS_ORDERING="Order" From decc3effca3628f10335c513a8a6b82e167c178c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 18 Dec 2019 14:11:41 +0530 Subject: [PATCH 101/273] Task #154510 feat: Import Records from the frontend --- src/components/com_tjucm/site/controllers/items.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/com_tjucm/site/controllers/items.php b/src/components/com_tjucm/site/controllers/items.php index 2da87d80..647eeeed 100644 --- a/src/components/com_tjucm/site/controllers/items.php +++ b/src/components/com_tjucm/site/controllers/items.php @@ -192,6 +192,15 @@ public function importCsv() } } } + elseif ($fieldsArray[$fieldName]->type == 'cluster') + { + if (JLoader::import('components.com_cluster.tables.clusters', JPATH_ADMINISTRATOR)) + { + $clusterTable = Table::getInstance('Clusters', 'ClusterTable'); + $clusterTable->load(array("name" => $value)); + $itemData[$fieldName] = $clusterTable->id; + } + } else { $itemData[$fieldName] = trim($value); From 0005f539db2ae399fbcc5b7cff34bc9b2c8dbde6 Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Wed, 18 Dec 2019 06:34:26 -0500 Subject: [PATCH 102/273] Bug#152978 fix:Menu should gt switched when user edit the form from detail view. --- .../com_tjucm/site/controllers/item.php | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/item.php b/src/components/com_tjucm/site/controllers/item.php index 0e7cbf07..02faed5e 100644 --- a/src/components/com_tjucm/site/controllers/item.php +++ b/src/components/com_tjucm/site/controllers/item.php @@ -47,6 +47,28 @@ public function __construct() $tjUcmModelType = JModelLegacy::getInstance('Type', 'TjucmModel'); $this->ucmTypeId = $tjUcmModelType->getTypeId($this->client); + // If client is empty then get client from menu params + if (empty($this->client)) + { + // Get the active item + $menuitem = $app->getMenu()->getActive(); + + // Get the params + $this->menuparams = $menuitem->params; + + if (!empty($this->menuparams)) + { + $this->ucm_type = $this->menuparams->get('ucm_type'); + + if (!empty($this->ucm_type)) + { + JLoader::import('components.com_tjfields.tables.type', JPATH_ADMINISTRATOR); + $ucmTypeTable = JTable::getInstance('Type', 'TjucmTable', array('dbo', JFactory::getDbo())); + $ucmTypeTable->load(array('alias' => $this->ucm_type)); + $this->client = $ucmTypeTable->unique_identifier; + } + } + } parent::__construct(); } @@ -70,8 +92,7 @@ public function edit() // Get the model. $model = $this->getModel('Item', 'TjucmModel'); - $items_model = $this->getModel('Items','TjucmModel'); - $this->client = $items_model->getState('ucm.client'); + // Check out the item if ($editId) @@ -143,7 +164,7 @@ public function publish() $this->setMessage(JText::_('COM_TJUCM_ITEM_SAVED_SUCCESSFULLY')); // If there isn't any menu item active, redirect to list view - $itemId = $tjUcmFrontendHelper->getItemId('index.php?option=com_tjucm&view=items' . $this->appendUrl); + $itemId = $tjUcmFrontendHelper->getItemId('index.php?option=com_tjucm&view=items' . $this->client); $this->setRedirect(JRoute::_('index.php?option=com_tjucm&view=items' . $this->appendUrl . '&Itemid=' . $itemId, false)); } else From 58df698db2f2b5b9bc9c9cabd658c9387b8acc5a Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Wed, 18 Dec 2019 07:10:07 -0500 Subject: [PATCH 103/273] Bug#154594 fix:Adding custom layout 12X12 --- .../administrator/en-GB/en-GB.com_tjucm.sys.ini | 4 +++- .../site/views/itemform/tmpl/default.php | 8 ++++---- .../site/views/itemform/tmpl/default.xml | 2 +- .../com_tjucm/site/views/itemform/tmpl/grid.php | 12 ++++++------ .../com_tjucm/site/views/itemform/tmpl/grid.xml | 16 ++++++++-------- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.sys.ini b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.sys.ini index 031b1c8c..f40930d0 100644 --- a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.sys.ini +++ b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.sys.ini @@ -6,4 +6,6 @@ COM_TJUCM_TITLE_FORM_VIEW_ITEM="ItemForm" COM_TJUCM_TITLE_FORM_VIEW_ITEM_DESC="Show a form to add or edit a Item" COM_TJUCM_TITLE_LIST_VIEW_ITEMS="Items" COM_TJUCM_TITLE_LIST_VIEW_ITEMS_DESC="Show a list of Items" -COM_TJUCM_TITLE_FORM_VIEW_ITEMFORM="Grid(12X12)" \ No newline at end of file +COM_TJUCM_TITLE_FORM_VIEW_ITEMFORM="One line one input" +COM_TJUCM_DEFAULT_TITLE_IN_OPTION="One line one input" +COM_TJUCM_GRID_TITLE_IN_OPTION="Inline layout" \ No newline at end of file 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 cdd7957c..0e827432 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/default.php +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default.php @@ -41,7 +41,7 @@ $baseUrl = $jinput->input->server->get('REQUEST_URI', '', 'STRING'); $calledFrom = (strpos($baseUrl, 'administrator')) ? 'backend' : 'frontend'; $layout = ($calledFrom == 'frontend') ? 'default' : 'edit'; -$dyanamic_layout=$this->setLayout($typeParams->layout); +$dynamicLayout = $this->setLayout($typeParams->layout); $fieldsets_counter_deafult = 0; $setnavigation = false; @@ -118,12 +118,12 @@ form_extra) { - if($this->id!='0') + if ( $this->id! = '0') { ?> loadTemplate('extrafields'); } diff --git a/src/components/com_tjucm/site/views/itemform/tmpl/default.xml b/src/components/com_tjucm/site/views/itemform/tmpl/default.xml index ec0402d1..8ea7f9e2 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/default.xml +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default.xml @@ -1,6 +1,6 @@ - + diff --git a/src/components/com_tjucm/site/views/itemform/tmpl/grid.php b/src/components/com_tjucm/site/views/itemform/tmpl/grid.php index d8443cf2..39cc8e81 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/grid.php +++ b/src/components/com_tjucm/site/views/itemform/tmpl/grid.php @@ -1,11 +1,11 @@ - * @package Com_Tjucm - * @author Techjoomla - * @copyright Copyright (c) 2009-2018 TechJoomla. All rights reserved. - * @license GNU General Public License version 2 or later. - */ +* @Package TJ-UCM +* @subpackage com_tjucm +* @author Techjoomla extensions@techjoomla.com +* @copyright Copyright (C) 2009 - 2019 Techjoomla. All rights reserved. +* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL +*/ // No direct access defined('_JEXEC') or die; diff --git a/src/components/com_tjucm/site/views/itemform/tmpl/grid.xml b/src/components/com_tjucm/site/views/itemform/tmpl/grid.xml index f2a0afce..c3b15fb0 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/grid.xml +++ b/src/components/com_tjucm/site/views/itemform/tmpl/grid.xml @@ -1,17 +1,17 @@ - + -
- -
From 2aff0b2f8cc827467f29831e570cfc3cfa3e0ed1 Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Wed, 18 Dec 2019 07:16:27 -0500 Subject: [PATCH 104/273] Bug#154594 fix:Adding custom layout 12X12 --- src/components/com_tjucm/site/views/itemform/tmpl/default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 0e827432..cd6199c1 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/default.php +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default.php @@ -118,7 +118,7 @@ form_extra) { - if ( $this->id! = '0') + if ($this->id != '0') { ?> diff --git a/src/components/com_tjucm/site/views/itemform/tmpl/default.xml b/src/components/com_tjucm/site/views/itemform/tmpl/default.xml index 8ea7f9e2..9e725678 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/default.xml +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default.xml @@ -1,6 +1,6 @@ - + From ace10d5e99d398e4947859d5bd5b859d7e01fece Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Thu, 19 Dec 2019 17:04:11 +0530 Subject: [PATCH 106/273] Bug #311 fix: Frontend>>Editor field not working correctly. --- .../com_tjucm/site/layouts/detail/fields.php | 26 ++++- .../com_tjucm/site/layouts/list/list.php | 49 ++++++-- .../site/views/items/tmpl/default.php | 105 ++++++++++-------- 3 files changed, 118 insertions(+), 62 deletions(-) diff --git a/src/components/com_tjucm/site/layouts/detail/fields.php b/src/components/com_tjucm/site/layouts/detail/fields.php index 41c6f7a8..fb8d2892 100644 --- a/src/components/com_tjucm/site/layouts/detail/fields.php +++ b/src/components/com_tjucm/site/layouts/detail/fields.php @@ -1,10 +1,10 @@ + * @package TJ-UCM + * + * @author TechJoomla * @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access @@ -63,6 +63,7 @@ $count++; $fieldCount = 0; ?> +
getFieldset($fieldset->name) as $field) @@ -178,7 +179,21 @@ $layout = new JLayoutFile($layoutToUse, JPATH_ROOT . '/components/com_tjfields/layouts/fields'); $output = $layout->render(array('fieldXml' => $xmlField, 'field' => $field)); - echo $output; + + // To align text, textarea, textareacounter and editor fields properly + + if ($field->type == 'Textarea'|| $field->type == 'Textareacounter'|| $field->type == 'Text' || $field->type == 'Editor') + { + ?> +
+ +
+
@@ -188,5 +203,6 @@ } ?>
+
+ * @author TechJoomla * @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access @@ -51,7 +51,7 @@ $xmlFormObject = $displayData['xmlFormObject']; $formObject = $displayData['formObject']; $ucmTypeId = $displayData['ucmTypeId']; -$allowDraftSave= $displayData['ucmTypeParams']->allow_draft_save; +$allowDraftSave = $displayData['ucmTypeParams']->allow_draft_save; $appendUrl = ''; $csrf = "&" . Session::getFormToken() . '=1'; @@ -93,13 +93,16 @@ } ?> +
state)) { $class = ($canChange) ? 'active' : 'disabled'; ?> + { + ?> field_values)) { foreach ($item->field_values as $key => $fieldValue) @@ -147,7 +155,11 @@ { $field = $formObject->getField($tjFieldsFieldTable->name); $field->setValue($fieldValue); - $layoutToUse = (array_key_exists(ucfirst($tjFieldsFieldTable->type), $fieldLayout)) ? $fieldLayout[ucfirst($tjFieldsFieldTable->type)] : 'field'; + $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; @@ -156,22 +168,36 @@ + 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 ed17e796..9e946804 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -48,19 +48,22 @@ $fieldsData = array(); $statusColumnWidth = 0; ?> +
items)) - { - ?> - - loadTemplate('filters'); ?> -
+ if (isset($this->items)) + { + ?> + loadTemplate('filters'); + ?> +
allowedToAdd) { @@ -90,38 +93,34 @@ if (!empty($this->showList)) { if (!empty($this->items)) - {?> -
- - items[0]->state)) - { + { + ?> + + + items[0]->state)) + { ?> - + - - - ucmTypeParams->allow_draft_save) && $this->ucmTypeParams->allow_draft_save == 1) - { - $statusColumnWidth = 2; - ?> + } + ?> listcolumn)) - { - JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjfields/tables'); - $tjFieldsFieldTable = JTable::getInstance('field', 'TjfieldsTable'); + if (!empty($this->ucmTypeParams->allow_draft_save) && $this->ucmTypeParams->allow_draft_save == 1) + { + $statusColumnWidth = 2; + ?> + + listcolumn as $fieldId => $col_name) { @@ -137,12 +136,11 @@ } ?> - canEdit || $this->canDelete) { @@ -153,18 +151,18 @@ - - - + + + items)) { ?> - @@ -197,7 +195,18 @@ { // Call the JLayout to render the fields in the details view $layout = new JLayoutFile('list.list', JPATH_ROOT . '/components/com_tjucm/'); - echo $layout->render(array('itemsData' => $item, 'created_by' => $this->created_by, 'client' => $this->client, 'xmlFormObject' => $formXml, 'ucmTypeId' => $this->ucmTypeId, 'ucmTypeParams' => $this->ucmTypeParams, 'fieldsData' => $fieldsData, 'formObject' => $formObject)); + echo $layout->render( + array( + 'itemsData' => $item, + 'created_by' => $this->created_by, + 'client' => $this->client, + 'xmlFormObject' => $formXml, + 'ucmTypeId' => $this->ucmTypeId, + 'ucmTypeParams' => $this->ucmTypeParams, + 'fieldsData' => $fieldsData, + 'formObject' => $formObject + ) + ); } } else @@ -223,8 +232,11 @@ if ($this->allowedToAdd) { ?> - - + + + "/> +canDelete) { From 7d4a1e8e0791c72a82c77df818fe44e20dcf2238 Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Thu, 19 Dec 2019 18:20:01 +0530 Subject: [PATCH 107/273] Bug#154793 fix:Functionality to save items depending upon the bit rate(seconds). --- .../administrator/models/forms/type.xml | 5 +++++ .../administrator/en-GB/en-GB.com_tjucm.ini | 6 ++++++ .../com_tjucm/media/js/ui/itemform.js | 14 ++++++++++++++ .../com_tjucm/site/layouts/list/list.php | 4 ++-- .../site/views/itemform/tmpl/default.php | 2 ++ .../com_tjucm/site/views/itemform/view.html.php | 17 ++++++++++++++++- 6 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/components/com_tjucm/administrator/models/forms/type.xml b/src/components/com_tjucm/administrator/models/forms/type.xml index 7aca87fc..f037a190 100644 --- a/src/components/com_tjucm/administrator/models/forms/type.xml +++ b/src/components/com_tjucm/administrator/models/forms/type.xml @@ -38,6 +38,11 @@ + + + + + diff --git a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini index ed8ac522..9791a7fc 100644 --- a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini @@ -176,3 +176,9 @@ COM_TJUCM_FIX_DATABASE="Fix Database" ; Added in version 1.2.0 COM_TJUCM_PERMISSION_TYPE_ITEM_DELETEOWN="Delete Own Item" COM_TJUCM_PERMISSION_TYPE_ITEM_DELETEOWN_DESC="Allows users in the group to delete own items in this UCM type." + +;Added in version 1.2.4 +COM_TJUCM_FORM_LBL_TYPE_ALLOW_BITRATE_ON="Bitrate On" +COM_TJUCM_FORM_DESC_LBL_TYPE_ALLOW_BITRATE_ON="Set to 'YES' if you want to allow submission of item as per the bits set in seconds." +COM_TJUCM_FORM_LBL_TYPE_BITRATE_SECONDS="Bitrate Time(seconds)" +COM_TJUCM_FORM_DESC_LBL_TYPE_BITRATE_SECONDS="Enter time in seconds to save data repeatedly for this ucm type." \ No newline at end of file diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 36c91ec2..37e1298f 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -17,6 +17,12 @@ jQuery(window).load(function() /*Code to get item state*/ var tjUcmCurrentDraftSaveState = Number(jQuery('#itemState').val()); + /*value of bitrate on button*/ + var tjUcmAllowBitrate = jQuery('#item-form #tjucm-bitrate').val(); + + /*value of bitrate seconds on button*/ + var tjUcmBitrateSeconds = jQuery('#item-form #tjucm-bitrate_seconds').val(); + /* If record is submitted and no longet in the draft state then dont allow autosave to work*/ if (tjUcmCurrentDraftSaveState === 1) { @@ -242,6 +248,14 @@ jQuery(window).load(function() jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow"); } }); + + /* Handel saving if data as per the seconds of bitrate*/ + var tjUcmFormSubmitCallingButtonId = event.target.id; + if(tjUcmAllowAutoSave == 1 && tjUcmAllowBitrate == 1 && tjUcmFormSubmitCallingButtonId != 'tjUcmSectionFinalSave') + { + var milliseconds = tjUcmBitrateSeconds*1000; + setTimeout(function(){ tjUcmItemForm.saveUcmFormData(); }, milliseconds ); + } }); var tjUcmItemForm = { diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index ba61b877..893a45de 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -160,12 +160,12 @@ { ?> + { + ?> field_values)) { foreach ($item->field_values as $key => $fieldValue) @@ -141,13 +148,17 @@ $fieldXml = $formObject->getFieldXml($tjFieldsFieldTable->name); ?> - + { + ?> field_values)) { foreach ($item->field_values as $key => $fieldValue) @@ -141,13 +148,17 @@ $fieldXml = $formObject->getFieldXml($tjFieldsFieldTable->name); ?> - Date: Fri, 21 Feb 2020 15:32:36 +0530 Subject: [PATCH 149/273] Update default.php --- .../site/views/items/tmpl/default.php | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) 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 db0ae775..c3a8c250 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -164,8 +164,7 @@ function copyItem() - ucmTypeParams->allow_draft_save) && $this->ucmTypeParams->allow_draft_save == 1) { $statusColumnWidth = 2; @@ -211,20 +210,6 @@ function copyItem() - items)) - { - ?> - - - - - - showList)) @@ -281,6 +266,20 @@ function copyItem() } ?> + items)) + { + ?> + + + + + +
- + state == 1) { @@ -116,16 +119,21 @@ } ?> - + escape($item->id); ?> draft) ? Text::_('COM_TJUCM_DATA_STATUS_DRAFT') : Text::_('COM_TJUCM_DATA_STATUS_SAVE'); ?> - + + + - | + | + + - | + | + + @@ -180,3 +206,4 @@ } ?>
+ - - - + + +
+ pagination->getListFooter(); ?>
- + - | + | + + 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 98657315..c3c45c87 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -194,6 +194,19 @@ public function display($tpl = null) return; } + if (empty($this->title)) + { + // Get the active item + $menuItem = $app->getMenu()->getActive(); + + // Get the params + $this->menuparams = $menuItem->params; + + if (!empty($this->menuparams)) + { + $this->title = $this->menuparams->get('ucm_type'); + } + } // Check the view access to the itemform (the model has already computed the values). if ($this->item->params->get('access-view') == false) @@ -262,7 +275,9 @@ public function display($tpl = null) $this->allow_auto_save = (isset($typeParams->allow_auto_save) && empty($typeParams->allow_auto_save)) ? 0 : 1; $this->allow_draft_save = (isset($typeParams->allow_draft_save) && !empty($typeParams->allow_draft_save)) ? 1 : 0; - + $this->allow_bit_rate=(isset($typeParams->bitrate_on) && !empty($typeParams->bitrate_on)) ? 1 : 0; + $this->allow_bit_rate_seconds=$typeParams->bitrate_seconds; + // Check for errors. if (count($errors = $this->get('Errors'))) { From 917ca27b6208c81a49cbfbbe7802d9dea4800639 Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Fri, 20 Dec 2019 09:58:12 +0530 Subject: [PATCH 108/273] Bug#154793 fix:Functionality to save items depending upon the bit rate(seconds). --- src/components/com_tjucm/media/js/ui/itemform.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 37e1298f..8c16cbfb 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -254,7 +254,10 @@ jQuery(window).load(function() if(tjUcmAllowAutoSave == 1 && tjUcmAllowBitrate == 1 && tjUcmFormSubmitCallingButtonId != 'tjUcmSectionFinalSave') { var milliseconds = tjUcmBitrateSeconds*1000; - setTimeout(function(){ tjUcmItemForm.saveUcmFormData(); }, milliseconds ); + for(var i=0;i<=milliseconds;i++) + { + tjUcmItemForm.saveUcmFormData(); + } } }); From 7314c3a1dae2a2e59601f2977c3b3fca84354a70 Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Fri, 20 Dec 2019 11:48:23 +0530 Subject: [PATCH 109/273] Bug#154793 fix:Functionality to save items depending upon the bit rate(seconds). --- src/components/com_tjucm/media/js/ui/itemform.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 8c16cbfb..28dbb1f9 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -254,10 +254,7 @@ jQuery(window).load(function() if(tjUcmAllowAutoSave == 1 && tjUcmAllowBitrate == 1 && tjUcmFormSubmitCallingButtonId != 'tjUcmSectionFinalSave') { var milliseconds = tjUcmBitrateSeconds*1000; - for(var i=0;i<=milliseconds;i++) - { - tjUcmItemForm.saveUcmFormData(); - } + setInterval(function(){ tjUcmItemForm.saveUcmFormData(); }, milliseconds ); } }); From ad9a1b9e2132a7f91026989ab33c571bfb230076 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 23 Dec 2019 15:17:12 +0530 Subject: [PATCH 110/273] Task #154510 feat: Import Records from the frontend --- src/components/com_tjucm/site/controllers/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/controllers/items.php b/src/components/com_tjucm/site/controllers/items.php index 647eeeed..9b264ceb 100644 --- a/src/components/com_tjucm/site/controllers/items.php +++ b/src/components/com_tjucm/site/controllers/items.php @@ -68,7 +68,7 @@ public function importCsv() } // Check if the file is a CSV file - if ($importFile['type'] != "text/csv") + if (!in_array($importFile['type'], array('application/vnd.ms-excel', 'text/plain', 'text/csv', 'text/tsv'))) { $app->enqueueMessage(Text::_('COM_TJUCM_ITEMS_INVALID_CSV_FILE'), 'error'); $app->redirect(Uri::root() . 'index.php?option=com_tjucm&view=items&layout=importitems&tmpl=component&client=' . $client); From 45db73b22919b262af4a522f15c806e81d12ed5f Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Thu, 26 Dec 2019 11:24:58 +0530 Subject: [PATCH 111/273] Bug #317 fix: Edge>> Action button alignment is not properly placed as per chrome browser --- .../com_tjucm/site/layouts/list/list.php | 49 ++++++++++++++----- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index ba61b877..a33b600e 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -1,10 +1,10 @@ + * @author TechJoomla * @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access @@ -51,7 +51,7 @@ $xmlFormObject = $displayData['xmlFormObject']; $formObject = $displayData['formObject']; $ucmTypeId = $displayData['ucmTypeId']; -$allowDraftSave= $displayData['ucmTypeParams']->allow_draft_save; +$allowDraftSave = $displayData['ucmTypeParams']->allow_draft_save; $appendUrl = ''; $csrf = "&" . Session::getFormToken() . '=1'; @@ -99,7 +99,9 @@ { $class = ($canChange) ? 'active' : 'disabled'; ?> - + state == 1) { @@ -116,16 +118,21 @@ } ?> - + escape($item->id); ?> draft) ? Text::_('COM_TJUCM_DATA_STATUS_DRAFT') : Text::_('COM_TJUCM_DATA_STATUS_SAVE'); ?> + created_by == $user->id)) { $field = $formObject->getField($tjFieldsFieldTable->name); $field->setValue($fieldValue); - $layoutToUse = (array_key_exists(ucfirst($tjFieldsFieldTable->type), $fieldLayout)) ? $fieldLayout[ucfirst($tjFieldsFieldTable->type)] : 'field'; + $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; @@ -156,22 +167,36 @@ - + + + - | + | + + - | + | + + From ee8452664e5de3c761ef88fe06a282221a9c619e Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Thu, 26 Dec 2019 11:40:43 +0530 Subject: [PATCH 112/273] Bug#319 fix: Edge>> Pagination should be visible outside the scrollbar not inside it. --- .../com_tjucm/site/layouts/list/list.php | 49 ++++++++++++++----- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index ba61b877..a33b600e 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -1,10 +1,10 @@ + * @author TechJoomla * @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access @@ -51,7 +51,7 @@ $xmlFormObject = $displayData['xmlFormObject']; $formObject = $displayData['formObject']; $ucmTypeId = $displayData['ucmTypeId']; -$allowDraftSave= $displayData['ucmTypeParams']->allow_draft_save; +$allowDraftSave = $displayData['ucmTypeParams']->allow_draft_save; $appendUrl = ''; $csrf = "&" . Session::getFormToken() . '=1'; @@ -99,7 +99,9 @@ { $class = ($canChange) ? 'active' : 'disabled'; ?> - + state == 1) { @@ -116,16 +118,21 @@ } ?> - + escape($item->id); ?> draft) ? Text::_('COM_TJUCM_DATA_STATUS_DRAFT') : Text::_('COM_TJUCM_DATA_STATUS_SAVE'); ?> + created_by == $user->id)) { $field = $formObject->getField($tjFieldsFieldTable->name); $field->setValue($fieldValue); - $layoutToUse = (array_key_exists(ucfirst($tjFieldsFieldTable->type), $fieldLayout)) ? $fieldLayout[ucfirst($tjFieldsFieldTable->type)] : 'field'; + $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; @@ -156,22 +167,36 @@ - + + + - | + | + + - | + | + + From 2d468d619291c3ec8bbc63f92acc691289d1618d Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Thu, 26 Dec 2019 15:31:14 +0530 Subject: [PATCH 113/273] Bug #321 fix: Local Site>> Getting some technical message once user installed the latest package on local site. --- .../site/views/itemform/view.html.php | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 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 98657315..12aa6760 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -80,6 +80,15 @@ class TjucmViewItemform extends JViewLegacy */ protected $copyRecId; + /** + * The Title of view + * + * @var String + * + * @since 1.2.4 + */ + protected $title; + /** * Display the view * @@ -292,7 +301,7 @@ protected function _prepareDocument() { $app = Factory::getApplication(); $menus = $app->getMenu(); - $title = null; + $this->title = null; // Because the application sets a default page title, // we need to get it from the menu item itself @@ -307,22 +316,22 @@ protected function _prepareDocument() $this->params->def('page_heading', Text::_('COM_TJUCM_DEFAULT_PAGE_TITLE')); } - $title = $this->params->get('page_title', ''); + $this->title = $this->params->get('page_title', ''); - if (empty($title)) + if (empty($this->title)) { - $title = $app->get('sitename'); + $this->title = $app->get('sitename'); } elseif ($app->get('sitename_pagetitles', 0) == 1) { - $title = Text::sprintf('JPAGETITLE', $app->get('sitename'), $title); + $this->title = Text::sprintf('JPAGETITLE', $app->get('sitename'), $this->title); } elseif ($app->get('sitename_pagetitles', 0) == 2) { - $title = Text::sprintf('JPAGETITLE', $title, $app->get('sitename')); + $this->title = Text::sprintf('JPAGETITLE', $this->title, $app->get('sitename')); } - $this->document->setTitle($title); + $this->document->setTitle($this->title); if ($this->params->get('menu-meta_description')) { From 5f3e45bb81b91102c5edd8049ef78c58c944f18b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 27 Dec 2019 10:14:47 +0530 Subject: [PATCH 114/273] Bug #154962 fix: data is not being validated before save --- .../com_tjucm/site/controllers/items.php | 82 ++++++++++++++----- 1 file changed, 62 insertions(+), 20 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/items.php b/src/components/com_tjucm/site/controllers/items.php index 9b264ceb..f752b089 100644 --- a/src/components/com_tjucm/site/controllers/items.php +++ b/src/components/com_tjucm/site/controllers/items.php @@ -129,6 +129,7 @@ public function importCsv() $headerRow = true; $invalidRows = 0; $validRows = 0; + $errors = array(); // Loop through the uploaded file while (($data = fgetcsv($file)) !== false) @@ -217,36 +218,36 @@ public function importCsv() } else { - // Save the record in UCM $tjucmItemFormModel = BaseDatabaseModel::getInstance('ItemForm', 'TjucmModel'); - if ($tjucmItemFormModel->save(array('client' => $client))) - { - $contentId = (int) $tjucmItemFormModel->getState($tjucmItemFormModel->getName() . '.id'); - - $fieldsData = array(); - $fieldsData['client'] = $client; - $fieldsData['content_id'] = $contentId; - $fieldsData['fieldsvalue'] = $itemData; + $fieldsData = array(); + $fieldsData['client'] = $client; - if ($tjucmItemFormModel->saveFieldsData($fieldsData)) - { - $validRows++; + $form = $tjucmItemFormModel->getTypeForm($fieldsData); + $data = $tjucmItemFormModel->validate($form, $itemData); - continue; - } - } - else + if ($data !== false) { - // Return the error messages if any - if (!empty($tjucmItemFormModel->getErrors())) + // Save the record in UCM + if ($tjucmItemFormModel->save(array('client' => $client))) { - foreach ($tjucmItemFormModel->getErrors() as $error) + $contentId = (int) $tjucmItemFormModel->getState($tjucmItemFormModel->getName() . '.id'); + + $fieldsData['content_id'] = $contentId; + $fieldsData['fieldsvalue'] = $data; + + if ($tjucmItemFormModel->saveFieldsData($fieldsData)) { - $app->enqueueMessage($error, 'error'); + $validRows++; + + continue; } } } + + $invalidRows++; + + $errors = array_merge($errors, $tjucmItemFormModel->getErrors()); } } else @@ -255,6 +256,11 @@ public function importCsv() } } + if (!empty($errors)) + { + $this->processErrors($errors); + } + if ($validRows) { $app->enqueueMessage(Text::sprintf('COM_TJUCM_ITEMS_IMPORTED_SCUUESSFULLY', $validRows), 'success'); @@ -322,4 +328,40 @@ public function getCsvImportFormat() jexit(); } + + /** + * Method to procees errors + * + * @param ARRAY $errors ERRORS + * + * @return void + * + * @since 1.0 + */ + private function processErrors($errors) + { + $app = Factory::getApplication(); + + if (!empty($errors)) + { + $code = 500; + $msg = array(); + + // Push up to three validation messages out to the user. + for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) + { + if ($errors[$i] instanceof Exception) + { + $code = $errors[$i]->getCode(); + $msg[] = $errors[$i]->getMessage(); + } + else + { + $msg[] = $errors[$i]; + } + } + + $app->enqueueMessage(implode("
", $msg), 'error'); + } + } } From c5f07aba6b971fab9e0d34f4dd06cf185927b68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 27 Dec 2019 10:29:29 +0530 Subject: [PATCH 115/273] Bug #154943 fix: show msg to the user for records being imported --- .../com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini | 1 + .../com_tjucm/site/views/items/tmpl/importitems.php | 5 +++++ 2 files changed, 6 insertions(+) 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 880eeb6d..c5177092 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 @@ -202,3 +202,4 @@ COM_TJUCM_CLICK_HERE="Click Here" 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..." diff --git a/src/components/com_tjucm/site/views/items/tmpl/importitems.php b/src/components/com_tjucm/site/views/items/tmpl/importitems.php index f791976b..19e1ecfa 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/importitems.php +++ b/src/components/com_tjucm/site/views/items/tmpl/importitems.php @@ -35,6 +35,7 @@ if (tjUcmUploadFileExtension === "csv") { + jQuery("#uploadForm #records-import-msg").removeClass("hidden"); jQuery("#uploadForm #upload-submit").attr("disabled", "disabled"); jQuery("#uploadForm #csv-file-upload").css("border-color", ""); document.getElementById("uploadForm").submit(); @@ -71,6 +72,10 @@ +
 
+
+ +

 
- +

From b0ffcd087608cd0871dfe319a8884729fc2a466f Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Fri, 27 Dec 2019 14:24:28 +0530 Subject: [PATCH 117/273] Bug152608 fix:Front end>> Editor field not showing data at front end once user select editor JCE. --- .../com_tjucm/media/js/ui/itemform.js | 92 +++++++++++-------- 1 file changed, 54 insertions(+), 38 deletions(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 36c91ec2..59f29cf6 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -42,57 +42,73 @@ jQuery(window).load(function() tjUcmItemForm.onUcmFormChange(this); } }); - - var tjUcmTinyMCE = Joomla.getOptions("plg_editor_tinymce"); - - /* Get the value of editor fields*/ - if (tjUcmTinyMCE != undefined) + /*to save data of editor field if editor=tinymce*/ + if(jQuery(".js-editor-tinymce").length > 0) { - jQuery.each(tjUcmTinyMCE.tinyMCE, function(index, value){ - if (jQuery("#item-form #jform_"+index).length) - { - var tjUcmEditorFieldContent = jQuery("#jform_"+index+"_ifr").contents().find('body').html(); - tjUcmTinyMCEFieldIds[index] = tjUcmEditorFieldContent; - } - else if ((jQuery("#item-form #jform_"+index).length == 0) && (index != 'default')) - { - var tjUcmSubFormEditorFields = jQuery("textarea[id$='__"+index+"']"); + var tjUcmTinyMCE = Joomla.getOptions("plg_editor_tinymce"); - if (tjUcmSubFormEditorFields.length) + /* Get the value of editor fields*/ + if (tjUcmTinyMCE != undefined) + { + jQuery.each(tjUcmTinyMCE.tinyMCE, function(index, value){ + if (jQuery("#item-form #jform_"+index).length) { - jQuery.each(tjUcmSubFormEditorFields, function(findex, fvalue){ - var tjUcmEditorFieldContentId = jQuery(fvalue).attr('id'); - var tjUcmEditorFieldContent = jQuery("#"+tjUcmEditorFieldContentId+"_ifr").contents().find('body').html(); - var tjucmTempIndex = tjUcmEditorFieldContentId.replace("jform_", ""); - tjUcmTinyMCEFieldIds[tjucmTempIndex] = tjUcmEditorFieldContent; - }); + var tjUcmEditorFieldContent = jQuery("#jform_"+index+"_ifr").contents().find('body').html(); + tjUcmTinyMCEFieldIds[index] = tjUcmEditorFieldContent; } - } - }); - - /* Check after some time if the content of editor is changed and if so then save it in DB*/ - setInterval(function () { - for (var key in tjUcmTinyMCEFieldIds) { - if (tjUcmTinyMCEFieldIds.hasOwnProperty(key)) { - var tjUcmEditorFieldContent = jQuery("#jform_"+key+"_ifr").contents().find('body').html(); + else if ((jQuery("#item-form #jform_"+index).length == 0) && (index != 'default')) + { + var tjUcmSubFormEditorFields = jQuery("textarea[id$='__"+index+"']"); - if (tjUcmTinyMCEFieldIds[key] != tjUcmEditorFieldContent) + if (tjUcmSubFormEditorFields.length) { - var tjUcmTempFieldObj = jQuery("#jform_"+key); + jQuery.each(tjUcmSubFormEditorFields, function(findex, fvalue){ + var tjUcmEditorFieldContentId = jQuery(fvalue).attr('id'); + var tjUcmEditorFieldContent = jQuery("#"+tjUcmEditorFieldContentId+"_ifr").contents().find('body').html(); + var tjucmTempIndex = tjUcmEditorFieldContentId.replace("jform_", ""); + tjUcmTinyMCEFieldIds[tjucmTempIndex] = tjUcmEditorFieldContent; + }); + } + } + }); - if (tjUcmTempFieldObj.length) + /* Check after some time if the content of editor is changed and if so then save it in DB*/ + setInterval(function () { + for (var key in tjUcmTinyMCEFieldIds) { + if (tjUcmTinyMCEFieldIds.hasOwnProperty(key)) { + var tjUcmEditorFieldContent = jQuery("#jform_"+key+"_ifr").contents().find('body').html(); + + if (tjUcmTinyMCEFieldIds[key] != tjUcmEditorFieldContent) { - tjUcmTempFieldObj.val(tjUcmEditorFieldContent); - tjUcmTinyMCEFieldIds[key] = tjUcmEditorFieldContent; - tjUcmItemForm.onUcmFormChange(tjUcmTempFieldObj); + var tjUcmTempFieldObj = jQuery("#jform_"+key); + + if (tjUcmTempFieldObj.length) + { + tjUcmTempFieldObj.val(tjUcmEditorFieldContent); + tjUcmTinyMCEFieldIds[key] = tjUcmEditorFieldContent; + tjUcmItemForm.onUcmFormChange(tjUcmTempFieldObj); + } } } } - } - },7000); + },7000); + } + } + /*to save data of editor field if editor=jce*/ + if(jQuery(".wf-editor-container").length > 0) + { + var milliseconds = tjUcmBitrateSeconds*1000; + setInterval(function(){ + var jceContent = document.getElementById('jform_com_tjucm_text_fef_ifr'); + var innerDoc = jceContent.contentDocument || jceContent.contentWindow.document; + var currentJceText = innerDoc.body.innerHTML; + var tjUcmTempFieldJceObj = jQuery("#jform_com_tjucm_text_fef"); + tjUcmTempFieldJceObj.val(currentJceText); + tjUcmItemForm.onUcmFormChange(tjUcmTempFieldJceObj); + }, milliseconds ); } } - } + } else { jQuery("#tjucm-auto-save-disabled-msg").show(); From ce3622e2f9df9661efb46c9834d6e0884366f843 Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Fri, 27 Dec 2019 18:48:33 +0530 Subject: [PATCH 118/273] Bug#328 fix: Edge>> Form Field Alignments should be consistent in all browser. --- src/components/com_tjucm/media/css/tjucm.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/com_tjucm/media/css/tjucm.css b/src/components/com_tjucm/media/css/tjucm.css index c323376d..b0c2906b 100644 --- a/src/components/com_tjucm/media/css/tjucm.css +++ b/src/components/com_tjucm/media/css/tjucm.css @@ -6,3 +6,10 @@ margin-left:5px !important; #item-form .chzn-container{ width:200px !important; } + +#item-form .field-calendar input{ + display: inline !important; +} + #item-form textarea{ + height: inherit !important; +} From a8b3c92a9505df159183c9b666b0845915a2e22e Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Fri, 27 Dec 2019 18:56:33 +0530 Subject: [PATCH 119/273] Bug152608 fix:Front end>> Editor field not showing data at front end once user select editor JCE. --- .../administrator/models/forms/type.xml | 5 ++++ .../administrator/en-GB/en-GB.com_tjucm.ini | 6 ++++ .../com_tjucm/media/js/ui/itemform.js | 28 ++++++++++++++++--- .../com_tjucm/site/layouts/list/list.php | 4 +-- .../site/views/itemform/tmpl/default.php | 2 ++ .../site/views/itemform/view.html.php | 17 ++++++++++- 6 files changed, 55 insertions(+), 7 deletions(-) diff --git a/src/components/com_tjucm/administrator/models/forms/type.xml b/src/components/com_tjucm/administrator/models/forms/type.xml index 7aca87fc..b159c9d4 100644 --- a/src/components/com_tjucm/administrator/models/forms/type.xml +++ b/src/components/com_tjucm/administrator/models/forms/type.xml @@ -38,6 +38,11 @@ + + + + + diff --git a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini index ed8ac522..154abf88 100644 --- a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini @@ -176,3 +176,9 @@ COM_TJUCM_FIX_DATABASE="Fix Database" ; Added in version 1.2.0 COM_TJUCM_PERMISSION_TYPE_ITEM_DELETEOWN="Delete Own Item" COM_TJUCM_PERMISSION_TYPE_ITEM_DELETEOWN_DESC="Allows users in the group to delete own items in this UCM type." + +;Added in version 1.2.4 +COM_TJUCM_FORM_LBL_TYPE_ALLOW_BITRATE_ON="Bitrate On" +COM_TJUCM_FORM_DESC_LBL_TYPE_ALLOW_BITRATE_ON="Set to 'YES' if you want to allow submission of item as per the bits set in seconds. Note:If you want editor field in your type please Make Bitrate on." +COM_TJUCM_FORM_LBL_TYPE_BITRATE_SECONDS="Bitrate Time(seconds)" +COM_TJUCM_FORM_DESC_LBL_TYPE_BITRATE_SECONDS="Enter time in seconds to save data repeatedly for this ucm type." \ No newline at end of file diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 59f29cf6..32a75de4 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -21,7 +21,10 @@ jQuery(window).load(function() if (tjUcmCurrentDraftSaveState === 1) { var tjUcmAllowAutoSave = jQuery('#item-form #tjucm-autosave').val(); + var tjUcmAllowBitrate = jQuery('#item-form #tjucm-bitrate').val(); + /*value of bitrate seconds on button*/ + var tjUcmBitrateSeconds = jQuery('#item-form #tjucm-bitrate_seconds').val(); /*Check if auto save is enabled for UCM type*/ if (tjUcmAllowAutoSave == 1) { @@ -43,7 +46,7 @@ jQuery(window).load(function() } }); /*to save data of editor field if editor=tinymce*/ - if(jQuery(".js-editor-tinymce").length > 0) + if(jQuery("#item-form .js-editor-tinymce").length > 0) { var tjUcmTinyMCE = Joomla.getOptions("plg_editor_tinymce"); @@ -95,7 +98,7 @@ jQuery(window).load(function() } } /*to save data of editor field if editor=jce*/ - if(jQuery(".wf-editor-container").length > 0) + if(jQuery("#item-form .wf-editor-container").length > 0) { var milliseconds = tjUcmBitrateSeconds*1000; setInterval(function(){ @@ -258,6 +261,13 @@ jQuery(window).load(function() jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow"); } }); + /* Handel saving if data as per the seconds of bitrate*/ + var tjUcmFormSubmitCallingButtonId = event.target.id; + if(tjUcmAllowAutoSave == 1 && tjUcmAllowBitrate == 1 && tjUcmFormSubmitCallingButtonId != 'tjUcmSectionFinalSave') + { + var milliseconds = tjUcmBitrateSeconds*1000; + setInterval(function(){ tjUcmItemForm.saveUcmFormData(); }, milliseconds ); + } }); var tjUcmItemForm = { @@ -673,11 +683,16 @@ var tjUcmItemForm = { tjUcmSaveRecordAsDraft = 0; } - /* For AJAX save need to assign values to the editor field containers*/ + /* For AJAX save need to assign values to the editor field containers of editor="TinyMce"*/ jQuery("#item-form .toggle-editor a").each(function(index) { this.click(); }); + /* For AJAX save need to assign values to the editor field containers of editor="jce editor"*/ + jQuery("#item-form .wf-editor-toggle").each(function(index) { + this.click(); + }); + tjUcmItemForm.getUcmParentRecordId(tjUcmSaveRecordAsDraft, function (){ var tjUcmForm = document.getElementById('item-form'); var tjUcmItemFormData = new FormData(tjUcmForm); @@ -717,10 +732,15 @@ var tjUcmItemForm = { com_tjucm.Services.Item.saveFormData(tjUcmItemFormData, tjUcmItemForm.afterDataSave); }); - /* Once data is assigned to the textarea toggle the editors*/ + /* Once data is assigned to the textarea toggle the TinyMce editors*/ jQuery("#item-form .toggle-editor a").each(function(index) { this.click(); }); + + /* Once data is assigned to the textarea toggle the Jce editors*/ + jQuery("#item-form .wf-editor-toggle").each(function(index) { + this.click(); + }); }, saveSectionData: function (tabId){ /* Disable the action buttons before performing the action*/ diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index ba61b877..893a45de 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -160,12 +160,12 @@ { ?>
- + - | + | + + 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 98657315..705f2dab 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -194,6 +194,19 @@ public function display($tpl = null) return; } + if (empty($this->title)) + { + // Get the active item + $menuItem = $app->getMenu()->getActive(); + + // Get the params + $this->menuparams = $menuItem->params; + + if (!empty($this->menuparams)) + { + $this->title = $this->menuparams->get('ucm_type'); + } + } // Check the view access to the itemform (the model has already computed the values). if ($this->item->params->get('access-view') == false) @@ -262,7 +275,9 @@ public function display($tpl = null) $this->allow_auto_save = (isset($typeParams->allow_auto_save) && empty($typeParams->allow_auto_save)) ? 0 : 1; $this->allow_draft_save = (isset($typeParams->allow_draft_save) && !empty($typeParams->allow_draft_save)) ? 1 : 0; - + $this->allow_bit_rate=(isset($typeParams->bitrate_on) && !empty($typeParams->bitrate_on)) ? 1 : 0; + $this->allow_bit_rate_seconds=$typeParams->bitrate_seconds; + // Check for errors. if (count($errors = $this->get('Errors'))) { From 2b994dee658447894ef97d0b190720b406b89df8 Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Fri, 27 Dec 2019 19:05:55 +0530 Subject: [PATCH 120/273] Bug152608 fix:Front end>> Editor field not showing data at front end once user select editor JCE. --- .../languages/administrator/en-GB/en-GB.com_tjucm.ini | 2 +- src/components/com_tjucm/media/js/ui/itemform.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini index 154abf88..c2f9beef 100644 --- a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini @@ -179,6 +179,6 @@ COM_TJUCM_PERMISSION_TYPE_ITEM_DELETEOWN_DESC="Allows users in the group to dele ;Added in version 1.2.4 COM_TJUCM_FORM_LBL_TYPE_ALLOW_BITRATE_ON="Bitrate On" -COM_TJUCM_FORM_DESC_LBL_TYPE_ALLOW_BITRATE_ON="Set to 'YES' if you want to allow submission of item as per the bits set in seconds. Note:If you want editor field in your type please Make Bitrate on." +COM_TJUCM_FORM_DESC_LBL_TYPE_ALLOW_BITRATE_ON="Set to 'YES' if you want to allow submission of item as per the bits set in seconds. Note:If you want editor field in your UCM type make Bitrate button on." COM_TJUCM_FORM_LBL_TYPE_BITRATE_SECONDS="Bitrate Time(seconds)" COM_TJUCM_FORM_DESC_LBL_TYPE_BITRATE_SECONDS="Enter time in seconds to save data repeatedly for this ucm type." \ No newline at end of file diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 32a75de4..1ddf32ec 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -21,10 +21,13 @@ jQuery(window).load(function() if (tjUcmCurrentDraftSaveState === 1) { var tjUcmAllowAutoSave = jQuery('#item-form #tjucm-autosave').val(); + + /*value of bitrate button*/ var tjUcmAllowBitrate = jQuery('#item-form #tjucm-bitrate').val(); /*value of bitrate seconds on button*/ var tjUcmBitrateSeconds = jQuery('#item-form #tjucm-bitrate_seconds').val(); + /*Check if auto save is enabled for UCM type*/ if (tjUcmAllowAutoSave == 1) { @@ -76,6 +79,7 @@ jQuery(window).load(function() }); /* Check after some time if the content of editor is changed and if so then save it in DB*/ + var milliseconds = tjUcmBitrateSeconds*1000; setInterval(function () { for (var key in tjUcmTinyMCEFieldIds) { if (tjUcmTinyMCEFieldIds.hasOwnProperty(key)) { @@ -94,7 +98,7 @@ jQuery(window).load(function() } } } - },7000); + },milliseconds); } } /*to save data of editor field if editor=jce*/ From d4dc22cf5e15ca567270aa5551991f0a746fd856 Mon Sep 17 00:00:00 2001 From: ankush-maherwal Date: Mon, 30 Dec 2019 11:41:24 +0530 Subject: [PATCH 121/273] Update type.xml --- src/components/com_tjucm/administrator/models/forms/type.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/administrator/models/forms/type.xml b/src/components/com_tjucm/administrator/models/forms/type.xml index b159c9d4..fcdc00e9 100644 --- a/src/components/com_tjucm/administrator/models/forms/type.xml +++ b/src/components/com_tjucm/administrator/models/forms/type.xml @@ -38,7 +38,7 @@ - + From bf888c8fdc3914444ba435c34b5429746e02ceba Mon Sep 17 00:00:00 2001 From: ankush-maherwal Date: Mon, 30 Dec 2019 11:49:05 +0530 Subject: [PATCH 122/273] Update en-GB.com_tjucm.ini --- .../languages/administrator/en-GB/en-GB.com_tjucm.ini | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini index c2f9beef..51e2a8ae 100644 --- a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini @@ -178,7 +178,7 @@ COM_TJUCM_PERMISSION_TYPE_ITEM_DELETEOWN="Delete Own Item" COM_TJUCM_PERMISSION_TYPE_ITEM_DELETEOWN_DESC="Allows users in the group to delete own items in this UCM type." ;Added in version 1.2.4 -COM_TJUCM_FORM_LBL_TYPE_ALLOW_BITRATE_ON="Bitrate On" -COM_TJUCM_FORM_DESC_LBL_TYPE_ALLOW_BITRATE_ON="Set to 'YES' if you want to allow submission of item as per the bits set in seconds. Note:If you want editor field in your UCM type make Bitrate button on." -COM_TJUCM_FORM_LBL_TYPE_BITRATE_SECONDS="Bitrate Time(seconds)" -COM_TJUCM_FORM_DESC_LBL_TYPE_BITRATE_SECONDS="Enter time in seconds to save data repeatedly for this ucm type." \ No newline at end of file +COM_TJUCM_FORM_LBL_TYPE_ALLOW_BITRATE_ON="Enable timely autosave?" +COM_TJUCM_FORM_DESC_LBL_TYPE_ALLOW_BITRATE_ON="Set to 'YES' if you want to allow submission of item after specified interval of time. Note:If you have used editor field in your UCM type then you should enable this configuration" +COM_TJUCM_FORM_LBL_TYPE_BITRATE_SECONDS="Autosave Interval (seconds)" +COM_TJUCM_FORM_DESC_LBL_TYPE_BITRATE_SECONDS="Enter time in seconds to save data repeatedly for this ucm type" From 0cf90571288890d026c8190a78b9dc429693dd35 Mon Sep 17 00:00:00 2001 From: ankush-maherwal Date: Mon, 30 Dec 2019 14:17:54 +0530 Subject: [PATCH 123/273] Update itemform.js --- .../com_tjucm/media/js/ui/itemform.js | 153 +++++++++--------- 1 file changed, 78 insertions(+), 75 deletions(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 1ddf32ec..2c2799b7 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -48,74 +48,68 @@ jQuery(window).load(function() tjUcmItemForm.onUcmFormChange(this); } }); - /*to save data of editor field if editor=tinymce*/ - if(jQuery("#item-form .js-editor-tinymce").length > 0) - { - var tjUcmTinyMCE = Joomla.getOptions("plg_editor_tinymce"); - /* Get the value of editor fields*/ - if (tjUcmTinyMCE != undefined) + /* Auto save form as per configured bit rate*/ + if (tjUcmAllowAutoSave == 1 && tjUcmAllowBitrate == 1 && tjUcmBitrateSeconds !== undefined) + { + if (jQuery("#item-form #tjUcmSectionDraftSave").length >= 1) { - jQuery.each(tjUcmTinyMCE.tinyMCE, function(index, value){ - if (jQuery("#item-form #jform_"+index).length) + setInterval(function(){ + jQuery("#tjUcmSectionDraftSave").click(); + }, tjUcmBitrateSeconds*1000); + } + } + + var tjUcmTinyMCE = Joomla.getOptions("plg_editor_tinymce"); + + /* Get the value of editor fields*/ + if (tjUcmTinyMCE != undefined) + { + jQuery.each(tjUcmTinyMCE.tinyMCE, function(index, value){ + if (jQuery("#item-form #jform_"+index).length) + { + var tjUcmEditorFieldContent = jQuery("#jform_"+index+"_ifr").contents().find('body').html(); + tjUcmTinyMCEFieldIds[index] = tjUcmEditorFieldContent; + } + else if ((jQuery("#item-form #jform_"+index).length == 0) && (index != 'default')) + { + var tjUcmSubFormEditorFields = jQuery("textarea[id$='__"+index+"']"); + + if (tjUcmSubFormEditorFields.length) { - var tjUcmEditorFieldContent = jQuery("#jform_"+index+"_ifr").contents().find('body').html(); - tjUcmTinyMCEFieldIds[index] = tjUcmEditorFieldContent; + jQuery.each(tjUcmSubFormEditorFields, function(findex, fvalue){ + var tjUcmEditorFieldContentId = jQuery(fvalue).attr('id'); + var tjUcmEditorFieldContent = jQuery("#"+tjUcmEditorFieldContentId+"_ifr").contents().find('body').html(); + var tjucmTempIndex = tjUcmEditorFieldContentId.replace("jform_", ""); + tjUcmTinyMCEFieldIds[tjucmTempIndex] = tjUcmEditorFieldContent; + }); } - else if ((jQuery("#item-form #jform_"+index).length == 0) && (index != 'default')) - { - var tjUcmSubFormEditorFields = jQuery("textarea[id$='__"+index+"']"); + } + }); - if (tjUcmSubFormEditorFields.length) - { - jQuery.each(tjUcmSubFormEditorFields, function(findex, fvalue){ - var tjUcmEditorFieldContentId = jQuery(fvalue).attr('id'); - var tjUcmEditorFieldContent = jQuery("#"+tjUcmEditorFieldContentId+"_ifr").contents().find('body').html(); - var tjucmTempIndex = tjUcmEditorFieldContentId.replace("jform_", ""); - tjUcmTinyMCEFieldIds[tjucmTempIndex] = tjUcmEditorFieldContent; - }); - } - } - }); + /* Check after some time if the content of editor is changed and if so then save it in DB*/ + setInterval(function () { + for (var key in tjUcmTinyMCEFieldIds) { + if (tjUcmTinyMCEFieldIds.hasOwnProperty(key)) { + var tjUcmEditorFieldContent = jQuery("#jform_"+key+"_ifr").contents().find('body').html(); - /* Check after some time if the content of editor is changed and if so then save it in DB*/ - var milliseconds = tjUcmBitrateSeconds*1000; - setInterval(function () { - for (var key in tjUcmTinyMCEFieldIds) { - if (tjUcmTinyMCEFieldIds.hasOwnProperty(key)) { - var tjUcmEditorFieldContent = jQuery("#jform_"+key+"_ifr").contents().find('body').html(); + if (tjUcmTinyMCEFieldIds[key] != tjUcmEditorFieldContent) + { + var tjUcmTempFieldObj = jQuery("#jform_"+key); - if (tjUcmTinyMCEFieldIds[key] != tjUcmEditorFieldContent) + if (tjUcmTempFieldObj.length) { - var tjUcmTempFieldObj = jQuery("#jform_"+key); - - if (tjUcmTempFieldObj.length) - { - tjUcmTempFieldObj.val(tjUcmEditorFieldContent); - tjUcmTinyMCEFieldIds[key] = tjUcmEditorFieldContent; - tjUcmItemForm.onUcmFormChange(tjUcmTempFieldObj); - } + tjUcmTempFieldObj.val(tjUcmEditorFieldContent); + tjUcmTinyMCEFieldIds[key] = tjUcmEditorFieldContent; + tjUcmItemForm.onUcmFormChange(tjUcmTempFieldObj); } } } - },milliseconds); - } - } - /*to save data of editor field if editor=jce*/ - if(jQuery("#item-form .wf-editor-container").length > 0) - { - var milliseconds = tjUcmBitrateSeconds*1000; - setInterval(function(){ - var jceContent = document.getElementById('jform_com_tjucm_text_fef_ifr'); - var innerDoc = jceContent.contentDocument || jceContent.contentWindow.document; - var currentJceText = innerDoc.body.innerHTML; - var tjUcmTempFieldJceObj = jQuery("#jform_com_tjucm_text_fef"); - tjUcmTempFieldJceObj.val(currentJceText); - tjUcmItemForm.onUcmFormChange(tjUcmTempFieldJceObj); - }, milliseconds ); + } + }, tjUcmBitrateSeconds*1000); } } - } + } else { jQuery("#tjucm-auto-save-disabled-msg").show(); @@ -265,13 +259,6 @@ jQuery(window).load(function() jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow"); } }); - /* Handel saving if data as per the seconds of bitrate*/ - var tjUcmFormSubmitCallingButtonId = event.target.id; - if(tjUcmAllowAutoSave == 1 && tjUcmAllowBitrate == 1 && tjUcmFormSubmitCallingButtonId != 'tjUcmSectionFinalSave') - { - var milliseconds = tjUcmBitrateSeconds*1000; - setInterval(function(){ tjUcmItemForm.saveUcmFormData(); }, milliseconds ); - } }); var tjUcmItemForm = { @@ -655,7 +642,17 @@ var tjUcmItemForm = { saveUcmFormData: function(){ /* Disable the action buttons before performing the action*/ jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', true); - var tjUcmFormSubmitCallingButtonId = event.target.id; + + if (event === undefined) + { + var tjUcmFormSubmitCallingButtonId = 'tjUcmSectionDraftSave'; + var tjUcmBitrateAutoSaveCall = 1; + } + else + { + var tjUcmFormSubmitCallingButtonId = event.target.id; + } + var tjUcmSaveRecordAsDraft = 1; if (tjUcmFormSubmitCallingButtonId == 'tjUcmSectionFinalSave') @@ -687,12 +684,12 @@ var tjUcmItemForm = { tjUcmSaveRecordAsDraft = 0; } - /* For AJAX save need to assign values to the editor field containers of editor="TinyMce"*/ + /* For AJAX save need to assign values to the editor field containers of tinyMCE editor*/ jQuery("#item-form .toggle-editor a").each(function(index) { this.click(); }); - /* For AJAX save need to assign values to the editor field containers of editor="jce editor"*/ + /* For AJAX save need to assign values to the editor field containers of JCE editor*/ jQuery("#item-form .wf-editor-toggle").each(function(index) { this.click(); }); @@ -723,20 +720,26 @@ var tjUcmItemForm = { } jQuery('input[type="checkbox"]').each(function (){ - if (jQuery(this).prop('checked') == true) - { - tjUcmItemFormData.append(jQuery(this).attr('name'), 1); - } - else - { - tjUcmItemFormData.append(jQuery(this).attr('name'), 0); - } + if (jQuery(this).prop('checked') == true) + { + tjUcmItemFormData.append(jQuery(this).attr('name'), 1); + } + else + { + tjUcmItemFormData.append(jQuery(this).attr('name'), 0); + } }); + /* Do not show draft save msg if the save is triggered as per bitrate config*/ + if (tjUcmBitrateAutoSaveCall !== undefined) + { + tjUcmItemFormData.append('showDraftMessage', 0); + } + com_tjucm.Services.Item.saveFormData(tjUcmItemFormData, tjUcmItemForm.afterDataSave); }); - /* Once data is assigned to the textarea toggle the TinyMce editors*/ + /* Once data is assigned to the textarea toggle the tinyMCE editors*/ jQuery("#item-form .toggle-editor a").each(function(index) { this.click(); }); @@ -744,7 +747,7 @@ var tjUcmItemForm = { /* Once data is assigned to the textarea toggle the Jce editors*/ jQuery("#item-form .wf-editor-toggle").each(function(index) { this.click(); - }); + }); }, saveSectionData: function (tabId){ /* Disable the action buttons before performing the action*/ From 5f2db6274420bbd2e3e32bf4572b6eb08eea5925 Mon Sep 17 00:00:00 2001 From: ankush-maherwal Date: Mon, 30 Dec 2019 14:20:05 +0530 Subject: [PATCH 124/273] Update itemform.js --- .../com_tjucm/media/js/ui/itemform.js | 49 ------------------- 1 file changed, 49 deletions(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 2c2799b7..d384ef78 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -59,55 +59,6 @@ jQuery(window).load(function() }, tjUcmBitrateSeconds*1000); } } - - var tjUcmTinyMCE = Joomla.getOptions("plg_editor_tinymce"); - - /* Get the value of editor fields*/ - if (tjUcmTinyMCE != undefined) - { - jQuery.each(tjUcmTinyMCE.tinyMCE, function(index, value){ - if (jQuery("#item-form #jform_"+index).length) - { - var tjUcmEditorFieldContent = jQuery("#jform_"+index+"_ifr").contents().find('body').html(); - tjUcmTinyMCEFieldIds[index] = tjUcmEditorFieldContent; - } - else if ((jQuery("#item-form #jform_"+index).length == 0) && (index != 'default')) - { - var tjUcmSubFormEditorFields = jQuery("textarea[id$='__"+index+"']"); - - if (tjUcmSubFormEditorFields.length) - { - jQuery.each(tjUcmSubFormEditorFields, function(findex, fvalue){ - var tjUcmEditorFieldContentId = jQuery(fvalue).attr('id'); - var tjUcmEditorFieldContent = jQuery("#"+tjUcmEditorFieldContentId+"_ifr").contents().find('body').html(); - var tjucmTempIndex = tjUcmEditorFieldContentId.replace("jform_", ""); - tjUcmTinyMCEFieldIds[tjucmTempIndex] = tjUcmEditorFieldContent; - }); - } - } - }); - - /* Check after some time if the content of editor is changed and if so then save it in DB*/ - setInterval(function () { - for (var key in tjUcmTinyMCEFieldIds) { - if (tjUcmTinyMCEFieldIds.hasOwnProperty(key)) { - var tjUcmEditorFieldContent = jQuery("#jform_"+key+"_ifr").contents().find('body').html(); - - if (tjUcmTinyMCEFieldIds[key] != tjUcmEditorFieldContent) - { - var tjUcmTempFieldObj = jQuery("#jform_"+key); - - if (tjUcmTempFieldObj.length) - { - tjUcmTempFieldObj.val(tjUcmEditorFieldContent); - tjUcmTinyMCEFieldIds[key] = tjUcmEditorFieldContent; - tjUcmItemForm.onUcmFormChange(tjUcmTempFieldObj); - } - } - } - } - }, tjUcmBitrateSeconds*1000); - } } } else From 8f838343d5d73d5a6422ad97a7ed4c728eb10c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 30 Dec 2019 14:27:39 +0530 Subject: [PATCH 125/273] Bug152608 fix: Front end>> Editor field not showing data at front end --- .../com_tjucm/media/js/ui/itemform.min.js | 2 +- .../site/controllers/itemform.json.php | 24 +++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) 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 d90045e1..7613b649 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;jQuery(window).load(function(){if(1===Number(jQuery("#itemState").val())){if(1==jQuery("#item-form #tjucm-autosave").val()){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)});var e=Joomla.getOptions("plg_editor_tinymce");null!=e&&(jQuery.each(e.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})}}),setInterval(function(){for(var e in tjUcmTinyMCEFieldIds)if(tjUcmTinyMCEFieldIds.hasOwnProperty(e)){var t=jQuery("#jform_"+e+"_ifr").contents().find("body").html();if(tjUcmTinyMCEFieldIds[e]!=t){var r=jQuery("#jform_"+e);r.length&&(r.val(t),tjUcmTinyMCEFieldIds[e]=t,tjUcmItemForm.onUcmFormChange(r))}}},7e3))}}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=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")){var a=jQuery(t).find(".js-editor-tinymce textarea").attr("id");if(a){var i=jQuery("#"+a+"_ifr").contents().find("body").html();a=a.replace("jform_",""),tjUcmTinyMCEFieldIds[a]=i}}jQuery.each(tjucmRelatedFieldUpdatedOptions,function(e,a){if(a.templateId){var i=a.templateId.replace("XXX_XXX",r);jQuery(t).find("#"+i).html(""),jQuery.each(a.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("#item-form").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("#item-form").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"),u="com_tjucm."+(a=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),m=jQuery("#"+a).val();if(""==m){i.append("parent_id",r),i.append("client",u),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,m){if(m=JSON.parse(m),null==o)return null!==m.data&&jQuery.isNumeric(m.data.id)&&jQuery("#"+a).val(m.data.id),i.append("jform["+n+"]",u),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(u,m.data.id,e),jQuery(e).attr("name",a)}),!0})}else if(jQuery.isNumeric(m)&&0!=m){var l=jQuery(e).attr("name"),c="[]"==l.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+c;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(u,m,e),jQuery(e).attr("name",l),!0}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(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("#item-form").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("#item-form").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);var e=event.target.id,t=1;if("tjUcmSectionFinalSave"==e){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("#item-form").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),t=0}jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),tjUcmItemForm.getUcmParentRecordId(t,function(){var t=document.getElementById("item-form"),r=new FormData(t);r.delete("task"),r.delete("option"),r.delete("view"),r.delete("layout");var a=jQuery("#item-form").find("input[name='jform[client]']").val(),i=jQuery("#item-form").find("input[name='jform[id]']").val();r.append(Joomla.getOptions("csrf.token"),1),r.append("client",a),r.append("recordid",i),"tjUcmSectionDraftSave"==e&&r.append("draft",1),"tjUcmSectionFinalSave"==e&&(tjUcmFormFinalSave=1),jQuery('input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?r.append(jQuery(this).attr("name"),1):r.append(jQuery(this).attr("name"),0)}),com_tjucm.Services.Item.saveFormData(r,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").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("#item-form").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,u=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),r={error:[]},i=u.length-1;i>=0;i--)(a=jQuery(u[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("#item-form").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("#item-form").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("#item-form").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#item-form").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("?")?"?":"&",u="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(u)>=0||(n+=o+u),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;jQuery(window).load(function(){if(1===Number(jQuery("#itemState").val())){var e=jQuery("#item-form #tjucm-autosave").val(),t=jQuery("#item-form #tjucm-bitrate").val(),a=jQuery("#item-form #tjucm-bitrate_seconds").val();1==e&&(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)}),1==e&&1==t&&void 0!==a&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){jQuery("#tjUcmSectionDraftSave").click()},1e3*a))}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 a=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")){var r=jQuery(t).find(".js-editor-tinymce textarea").attr("id");if(r){var 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,a){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("#item-form").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("#item-form").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(e,t){var a=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(t,r){var i=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==i){var n=new FormData;""!=a&&n.append("client",a),n.append(Joomla.getOptions("csrf.token"),1);n.append("draft",e),com_tjucm.Services.Item.create(n,function(e,a){if(a=JSON.parse(a),null==e)if(null!==a.data&&jQuery.isNumeric(a.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(a.data.id);var i=window.location.href.split("#")[0],n=-1===i.indexOf("?")?"?":"&",o="id="+a.data.id;i.indexOf(o)>=0||(i+=n+o),history.pushState(null,null,i),t(a.data.id)}else r(a)})}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 a=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(e,a,t)})},initUcmFormFieldDataSave:function(e,t,a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var r="",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"),u="com_tjucm."+(r=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),m=jQuery("#"+r).val();if(""==m){i.append("parent_id",a),i.append("client",u),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,m){if(m=JSON.parse(m),null==o)return null!==m.data&&jQuery.isNumeric(m.data.id)&&jQuery("#"+r).val(m.data.id),i.append("jform["+n+"]",u),i.append("client",t),i.append("recordid",a),com_tjucm.Services.Item.saveFieldData(i,function(t,a){var r=jQuery(e).attr("name"),i="[]"==r.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(u,m.data.id,e),jQuery(e).attr("name",r)}),!0})}else if(jQuery.isNumeric(m)&&0!=m){var l=jQuery(e).attr("name"),c="[]"==l.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+c;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(u,m,e),jQuery(e).attr("name",l),!0}return!1}return tjUcmItemForm.saveUcmFormFieldData(t,a,e),!0},saveUcmFormFieldData:function(e,t,a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var r=new FormData;return r.append(Joomla.getOptions("csrf.token"),1),r.append("client",e),r.append("recordid",t),"checkbox"==jQuery(a).attr("type")?1==jQuery(a).prop("checked")?r.append(jQuery(a).attr("name"),1):r.append(jQuery(a).attr("name"),0):jQuery(a).hasClass("tjfieldTjList")?(""!=jQuery(a).val()&&null!=jQuery(a).val()&&r.append(jQuery(a).attr("name"),jQuery(a).val()),""!=jQuery("input#"+jQuery(a).attr("id")).val()&&null!=jQuery("input#"+jQuery(a).attr("id")).val()&&r.append(jQuery(a).attr("name"),jQuery("input#"+jQuery(a).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(a).attr("id")).data("role")?(""!=jQuery("#"+jQuery(a).attr("id")).val()&&null!=jQuery("#"+jQuery(a).attr("id")).val()&&r.append(jQuery(a).attr("name"),jQuery("#"+jQuery(a).attr("id")).val()),""!=jQuery(a).val()&&null!=jQuery(a).val()&&r.append(jQuery(a).attr("name"),jQuery(a).val())):"file"!=jQuery(a).attr("type")?r.append(jQuery(a).attr("name"),jQuery(a).val()):r.append(jQuery(a).attr("name"),jQuery(a)[0].files[0]),""!=jQuery(a).attr("name")&&null!=jQuery(a).attr("name")&&com_tjucm.Services.Item.saveFieldData(r,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(e,t){if(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 a=jQuery("#item-form").find("input[name='jform[client]']").val(),r=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(a,r)}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("#item-form").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("#item-form").position().top},"slow")))},updateRelatedFieldsOptions:function(e,t){var a=new FormData;a.append("client",e),a.append("content_id",t),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(a,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,a){var r="";"1"==a.selected&&(r=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")})})},saveUcmFormData:function(){if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),void 0===event)var e="tjUcmSectionDraftSave",t=1;else e=event.target.id;var a=1;if("tjUcmSectionFinalSave"==e){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("#item-form").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),a=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(a,function(){var a=document.getElementById("item-form"),r=new FormData(a);r.delete("task"),r.delete("option"),r.delete("view"),r.delete("layout");var i=jQuery("#item-form").find("input[name='jform[client]']").val(),n=jQuery("#item-form").find("input[name='jform[id]']").val();r.append(Joomla.getOptions("csrf.token"),1),r.append("client",i),r.append("recordid",n),"tjUcmSectionDraftSave"==e&&r.append("draft",1),"tjUcmSectionFinalSave"==e&&(tjUcmFormFinalSave=1),jQuery('input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?r.append(jQuery(this).attr("name"),1):r.append(jQuery(this).attr("name"),0)}),void 0!==t&&r.append("showDraftMessage",0),com_tjucm.Services.Item.saveFormData(r,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,a=jQuery(e).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(a))return jQuery("html, body").animate({scrollTop:jQuery("#item-form").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),a.length&&a.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 a=jQuery("#item-form").find("input[name='jform[client]']").val(),r=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",a),t.append("recordid",r),t.append("tjUcmFormSection",jQuery("a[href='"+e+"']").html()),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)})},validateSection:function(e){var t,a,r,i,n,o=!0,u=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),a={error:[]},i=u.length-1;i>=0;i--)(r=jQuery(u[i]).data("label"))&&a.error.push(t+r.text().replace("*",""));Joomla.renderMessages(a)}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,a){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(e){this.click()});var r=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("#item-form").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("#item-form").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return r&&jQuery(r).ajaxSubmit({datatype:"JSON",async:!1,success:function(e){var r=JSON.parse(e);if(null!==r.messages&&null!==r.messages.error&&(jQuery.each(r.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#item-form").position().top},"slow")),null!==r.message&&""!=r.message&&(Joomla.renderMessages({info:[r.message]}),jQuery("html, body").animate({scrollTop:jQuery("#item-form").position().top},"slow")),null!==r.data){jQuery("#recordId").val(r.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"===a&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var n=window.location.href.split("#")[0],o=-1===n.indexOf("?")?"?":"&",u="id="+r.data.id;jQuery.each(r.data.childContentIds,function(e,t){jQuery("input[name='"+t.elementName+"']").val(t.content_id)}),tjucmRelatedFieldUpdatedOptions=r.data.relatedFieldOptions,jQuery.each(r.data.relatedFieldOptions,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,a){var r="";"1"==a.selected&&(r=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")}),n.indexOf(u)>=0||(n+=o+u),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 a=jQuery("ul#tjucm_myTabTabs").find("li.active a");null==jQuery(a).next("li")?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),null==jQuery(a).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 r=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==r?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/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index aab5f4fd..54946b3d 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -225,15 +225,16 @@ public function saveFormData() { JSession::checkToken() or jexit(Text::_('JINVALID_TOKEN')); - $app = Factory::getApplication(); - $post = $app->input->post; - $recordId = $post->get('recordid', 0, 'INT'); - $client = $post->get('client', '', 'STRING'); - $formData = $post->get('jform', array(), 'ARRAY'); - $filesData = $app->input->files->get('jform', array(), 'ARRAY'); - $formData = array_merge_recursive($formData, $filesData); - $section = $post->get('tjUcmFormSection', '', 'STRING'); - $draft = $post->get('draft', 0, 'INT'); + $app = Factory::getApplication(); + $post = $app->input->post; + $recordId = $post->get('recordid', 0, 'INT'); + $client = $post->get('client', '', 'STRING'); + $formData = $post->get('jform', array(), 'ARRAY'); + $filesData = $app->input->files->get('jform', array(), 'ARRAY'); + $formData = array_merge_recursive($formData, $filesData); + $section = $post->get('tjUcmFormSection', '', 'STRING'); + $showDraftMsg = $post->get('showDraftMessage', 1, 'INT'); + $draft = $post->get('draft', 0, 'INT'); if (empty($formData) || empty($client)) { @@ -290,7 +291,10 @@ public function saveFormData() { if ($draft) { - $msg = ($response) ? Text::_("COM_TJUCM_ITEM_DRAFT_SAVED_SUCCESSFULLY") : Text::_("COM_TJUCM_FORM_SAVE_FAILED"); + if ($showDraftMsg) + { + $msg = ($response) ? Text::_("COM_TJUCM_ITEM_DRAFT_SAVED_SUCCESSFULLY") : Text::_("COM_TJUCM_FORM_SAVE_FAILED"); + } } else { From f1c59db062f653ee4f3b09bc658820fe5ce2f998 Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Fri, 3 Jan 2020 12:04:31 +0530 Subject: [PATCH 126/273] Bug#130261 fix: Live > Applicant account > application form > work experience > delete a section :: Needs confirmation message before deleting. --- .../site/views/item/tmpl/default.php | 21 ++++++++++++++++++- 1 file changed, 20 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 00fc4663..a49b6ff1 100644 --- a/src/components/com_tjucm/site/views/item/tmpl/default.php +++ b/src/components/com_tjucm/site/views/item/tmpl/default.php @@ -59,9 +59,28 @@ { $redirectURL = JRoute::_('index.php?option=com_tjucm&task=itemform.remove&id=' . $this->item->id . '&client=' . $this->client . "&" . JSession::getFormToken() . '=1', false); ?> - + + + + Date: Fri, 3 Jan 2020 18:23:44 +0530 Subject: [PATCH 127/273] Bug#154085 fix: Created multiple record entries in DB while creating type items if Auto Save enabled in UCM Type --- src/components/com_tjucm/media/js/core/base.js | 2 ++ src/components/com_tjucm/media/js/services/item.js | 1 + 2 files changed, 3 insertions(+) diff --git a/src/components/com_tjucm/media/js/core/base.js b/src/components/com_tjucm/media/js/core/base.js index dae0116e..35ad0f20 100755 --- a/src/components/com_tjucm/media/js/core/base.js +++ b/src/components/com_tjucm/media/js/core/base.js @@ -44,6 +44,7 @@ com_tjucm.Services.Base = Class.extend({ config.contentType = typeof config.contentType != "undefined" ? config.contentType : 'application/x-www-form-urlencoded; charset=UTF-8'; config.processData = typeof config.processData != "undefined" ? config.processData : true; + config.async = typeof config.async != "undefined" ? config.async : false; return jQuery.ajax({ type: "POST", @@ -51,6 +52,7 @@ com_tjucm.Services.Base = Class.extend({ data: data, contentType: config.contentType, processData: config.processData, + async: config.async, headers: config.headers, beforeSend: function () { }, diff --git a/src/components/com_tjucm/media/js/services/item.js b/src/components/com_tjucm/media/js/services/item.js index d287e809..533f5ad8 100755 --- a/src/components/com_tjucm/media/js/services/item.js +++ b/src/components/com_tjucm/media/js/services/item.js @@ -21,6 +21,7 @@ com_tjucm.Services.Item = new (com_tjucm.Services.Base.extend({ create: function (ucmTypeData, callback){ this.config.processData = false; this.config.contentType = false; + this.config.async = false; this.post(this.createNewRecordUrl, ucmTypeData, this.config, callback); }, saveFieldData: function (ucmFormData, callback) { From 023997c181cbeb5e184d0e019e52573f2a9a925b Mon Sep 17 00:00:00 2001 From: Prav Date: Mon, 6 Jan 2020 15:25:15 +0530 Subject: [PATCH 128/273] Task#336 chore: Unbale to listed out record created with Other option --- .../com_tjucm/site/models/items.php | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 65ea3349..743ad0e2 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -292,9 +292,9 @@ protected function getListQuery() // Search on fields data $filteredItemIds = $this->filterContent($client); - if (is_array($filteredItemIds)) + if ($filteredItemIds) { - if (!empty($filteredItemIds)) + if (!empty($filteredItemIds) && is_array($filteredItemIds)) { $filteredItemIds = implode(',', $filteredItemIds); $query->where($db->quoteName('a.id') . ' IN (' . $filteredItemIds . ')'); @@ -329,6 +329,8 @@ protected function getListQuery() /** * Function to filter content as per field values * + * @param string $client Client + * * @return Array Content Ids * * @since 1.2.1 @@ -407,8 +409,9 @@ private function filterContent($client) foreach ($fields as $field) { $filterValue = $this->getState('filter.field.' . $field->name); + $filteroptionId = $this->getState('filter.field.' . $field->name . '.optionId'); - if ($filterValue != '') + if ($filterValue != '' || $filteroptionId) { $filterFieldsCount++; @@ -419,7 +422,25 @@ private function filterContent($client) } $query->where($db->qn('fv' . $filterFieldsCount . '.field_id') . ' = ' . $field->id); - $query->where($db->qn('fv' . $filterFieldsCount . '.value') . ' = ' . $db->q($filterValue)); + + if ($filteroptionId) + { + // Check option id blank or null + if ($filteroptionId == 'other') + { + $query->where('(' . $db->qn('fv' . $filterFieldsCount . '.option_id') . + ' is null OR ' . $db->qn('fv' . $filterFieldsCount . '.option_id') . ' = 0 )'); + } + else + { + $query->where($db->qn('fv' . $filterFieldsCount . '.option_id') . ' = ' . $db->q($filteroptionId)); + } + } + else + { + $query->where($db->qn('fv' . $filterFieldsCount . '.value') . ' = ' . $db->q($filterValue)); + } + $filterApplied = 1; } } @@ -432,7 +453,9 @@ private function filterContent($client) { $db->setQuery($query); - return $db->loadColumn(); + $filteredRecord = $db->loadColumn(); + + return empty($filteredRecord)? true : $filteredRecord; } else { From bdb06fe3699c31bd9caa57ace7899884997ebbaf Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Wed, 8 Jan 2020 14:23:27 +0530 Subject: [PATCH 129/273] Bug130261 fix : Live > Applicant account > application form > work experience > delete a section :: Needs confirmation message before deleting. --- src/components/com_tjucm/media/js/ui/item.js | 12 ++++++++++++ src/components/com_tjucm/media/js/ui/item.min.js | 1 + src/components/com_tjucm/site/includes/tjucm.php | 5 +++++ .../com_tjucm/site/views/item/tmpl/default.php | 7 +++---- .../com_tjucm/site/views/itemform/tmpl/default.php | 13 ++++++++----- 5 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 src/components/com_tjucm/media/js/ui/item.js create mode 100644 src/components/com_tjucm/media/js/ui/item.min.js diff --git a/src/components/com_tjucm/media/js/ui/item.js b/src/components/com_tjucm/media/js/ui/item.js new file mode 100644 index 00000000..d085dbed --- /dev/null +++ b/src/components/com_tjucm/media/js/ui/item.js @@ -0,0 +1,12 @@ +/* confirmation message before item deletion */ + jQuery(window).ready(function () { + jQuery('.delete-button').click(deleteItem); + }); + + function deleteItem() + { + if (!confirm(Joomla.JText._('COM_TJUCM_DELETE_MESSAGE'))) + { + return false; + } + } diff --git a/src/components/com_tjucm/media/js/ui/item.min.js b/src/components/com_tjucm/media/js/ui/item.min.js new file mode 100644 index 00000000..5db4df2c --- /dev/null +++ b/src/components/com_tjucm/media/js/ui/item.min.js @@ -0,0 +1 @@ +function deleteItem(){if(!confirm(Joomla.JText._("COM_TJUCM_DELETE_MESSAGE")))return!1}jQuery(window).ready(function(){jQuery(".delete-button").click(deleteItem)}); \ No newline at end of file diff --git a/src/components/com_tjucm/site/includes/tjucm.php b/src/components/com_tjucm/site/includes/tjucm.php index 1f05b010..79bdf3b9 100644 --- a/src/components/com_tjucm/site/includes/tjucm.php +++ b/src/components/com_tjucm/site/includes/tjucm.php @@ -201,6 +201,11 @@ public static function init($location = 'site') HTMLHelper::StyleSheet('media/com_tjucm/css/tjucm.css', $options); } + if ($view == 'item') + { + HTMLHelper::script('media/com_tjucm/js/ui/item.js'); + } + $loaded[$location] = true; } } 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 a49b6ff1..835a8416 100644 --- a/src/components/com_tjucm/site/views/item/tmpl/default.php +++ b/src/components/com_tjucm/site/views/item/tmpl/default.php @@ -1,10 +1,9 @@ + * @package TJ-UCM + * @author TechJoomla * @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved. - * @license GNU General Public License version 2 or later; see LICENSE.txt + * @license GNU General Public License version 2 or later; see LICENSE.txt */ // No direct access 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 511eb3d7..e9de75a6 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/default.php +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default.php @@ -18,6 +18,9 @@ HTMLHelper::_('formbehavior.chosen', 'select'); HTMLHelper::_('jquery.token'); +/*To load language constant of js file*/ +JText::script('COM_TJUCM_DELETE_MESSAGE'); + /* * Script to show alert box if form changes are made and user is closing/refreshing/navigating the tab * without saving the content @@ -116,15 +119,15 @@ form_extra) - { - if($this->id!='0') + { + if ($this->id != '0') { ?> title); ?>

-
Date: Wed, 8 Jan 2020 14:30:15 +0530 Subject: [PATCH 130/273] Bug130261 fix : Live > Applicant account > application form > work experience > delete a section :: Needs confirmation message before deleting. --- .../site/views/item/tmpl/default.php | 22 +++---------------- .../site/views/itemform/tmpl/default.php | 3 --- 2 files changed, 3 insertions(+), 22 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 835a8416..5d848ca9 100644 --- a/src/components/com_tjucm/site/views/item/tmpl/default.php +++ b/src/components/com_tjucm/site/views/item/tmpl/default.php @@ -9,6 +9,9 @@ // No direct access defined('_JEXEC') or die; +/*To load language constant of js file*/ +JText::script('COM_TJUCM_DELETE_MESSAGE'); + $user = JFactory::getUser(); if ($this->form_extra) @@ -64,22 +67,3 @@ ?>
- - - Date: Wed, 8 Jan 2020 15:00:03 +0530 Subject: [PATCH 131/273] Bug154793 fix :Functionality to save items depending upon the bit rate(seconds). --- src/components/com_tjucm/media/js/ui/item.js | 12 ++++ .../com_tjucm/media/js/ui/itemform.js | 65 +++++++++++++++---- 2 files changed, 66 insertions(+), 11 deletions(-) create mode 100644 src/components/com_tjucm/media/js/ui/item.js diff --git a/src/components/com_tjucm/media/js/ui/item.js b/src/components/com_tjucm/media/js/ui/item.js new file mode 100644 index 00000000..d085dbed --- /dev/null +++ b/src/components/com_tjucm/media/js/ui/item.js @@ -0,0 +1,12 @@ +/* confirmation message before item deletion */ + jQuery(window).ready(function () { + jQuery('.delete-button').click(deleteItem); + }); + + function deleteItem() + { + if (!confirm(Joomla.JText._('COM_TJUCM_DELETE_MESSAGE'))) + { + return false; + } + } diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 28dbb1f9..37a98e32 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -10,6 +10,8 @@ var tjUcmClickedOnPrev = 0; var tjUcmCurrentAutoSaveState = 0; /*Variable to store if form is submited for final save*/ var tjUcmFormFinalSave = 0; +/*Variable to store the data of JCE editor field*/ +var tjUcmJCEFieldIds = new Array(); /* This function executes for autosave form */ jQuery(window).load(function() @@ -21,7 +23,7 @@ jQuery(window).load(function() var tjUcmAllowBitrate = jQuery('#item-form #tjucm-bitrate').val(); /*value of bitrate seconds on button*/ - var tjUcmBitrateSeconds = jQuery('#item-form #tjucm-bitrate_seconds').val(); + var tjUcmBitrateSeconds = jQuery('#item-form #tjucm-bitrate_seconds').val(); /* If record is submitted and no longet in the draft state then dont allow autosave to work*/ if (tjUcmCurrentDraftSaveState === 1) @@ -97,8 +99,58 @@ jQuery(window).load(function() } },7000); } + /*to save data of editor field if editor=jce*/ + if(jQuery("#item-form .wf-editor-container").length > 0) + { + /*function to get iframe id of JCE editor*/ + setTimeout(function(){ + jQuery("#item-form .mceIframeContainer iframe").each(function (){ + + var iframeId=jQuery(this).attr('id'); + var tjucmIframeIndex = iframeId.replace("jform_", ""); + var tjucmJceIframeIndex = tjucmIframeIndex.replace("_ifr", ""); + var iframeContent=jQuery("#"+iframeId).contents().find('body').html(); + + tjUcmJCEFieldIds[tjucmJceIframeIndex]=iframeContent;console.log(tjUcmJCEFieldIds)});},2000); + + /*Function to save data as per bitrate*/ + setInterval(function(){ + for (var key in tjUcmJCEFieldIds) + { + if (tjUcmJCEFieldIds.hasOwnProperty(key)) + { + var iframeContent = jQuery("#jform_"+key+"_ifr").contents().find('body').html(); + + if (tjUcmJCEFieldIds[key] != iframeContent) + { + var tjUcmTempJceFieldObj = jQuery("#jform_"+key); + + if (tjUcmTempJceFieldObj.length) + { + tjUcmTempJceFieldObj.val(iframeContent); + tjUcmJCEFieldIds[key] = iframeContent; + tjUcmItemForm.onUcmFormChange(tjUcmTempJceFieldObj); + } + } + } + } + }, tjUcmBitrateSeconds*1000 ); + } + + // /* Auto save form as per configured bit rate*/ + if (tjUcmAllowAutoSave == 1 && tjUcmAllowBitrate == 1 && tjUcmBitrateSeconds !== undefined) + { + if (jQuery("#item-form #tjUcmSectionDraftSave").length >= 1) + { + setInterval(function(){ + if(jQuery('#item-form').hasClass('dirty')) + { + jQuery("#tjUcmSectionDraftSave").click(); + }, tjUcmBitrateSeconds*1000); + } + } + } } - } else { jQuery("#tjucm-auto-save-disabled-msg").show(); @@ -249,15 +301,6 @@ jQuery(window).load(function() } }); - /* Handel saving if data as per the seconds of bitrate*/ - var tjUcmFormSubmitCallingButtonId = event.target.id; - if(tjUcmAllowAutoSave == 1 && tjUcmAllowBitrate == 1 && tjUcmFormSubmitCallingButtonId != 'tjUcmSectionFinalSave') - { - var milliseconds = tjUcmBitrateSeconds*1000; - setInterval(function(){ tjUcmItemForm.saveUcmFormData(); }, milliseconds ); - } -}); - var tjUcmItemForm = { getUcmParentRecordId: function (draft, callback){ var tjUcmParentClient = jQuery('#item-form').find("input[name='jform[client]']").val(); From ddb9da26c02ac0b27cea0b0b5bc012660748a366 Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Wed, 8 Jan 2020 15:52:54 +0530 Subject: [PATCH 132/273] Bug154085 fix : Created multiple record entries in DB while creating type items if Auto Save enabled in UCM Type. --- src/components/com_tjucm/media/js/core/base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/media/js/core/base.js b/src/components/com_tjucm/media/js/core/base.js index 35ad0f20..727df27c 100755 --- a/src/components/com_tjucm/media/js/core/base.js +++ b/src/components/com_tjucm/media/js/core/base.js @@ -44,7 +44,7 @@ com_tjucm.Services.Base = Class.extend({ config.contentType = typeof config.contentType != "undefined" ? config.contentType : 'application/x-www-form-urlencoded; charset=UTF-8'; config.processData = typeof config.processData != "undefined" ? config.processData : true; - config.async = typeof config.async != "undefined" ? config.async : false; + config.async = typeof config.async != "undefined" ? config.async : true; return jQuery.ajax({ type: "POST", From dad4c115fbded457e1fd129a0ab1877ab88f6f2d Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Tue, 21 Jan 2020 10:59:17 +0530 Subject: [PATCH 133/273] Bug #154793 fix : Functionality to save items depending upon the bit rate(seconds). --- .../com_tjucm/media/js/ui/itemform.js | 136 +++++++++--------- 1 file changed, 71 insertions(+), 65 deletions(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 37a98e32..b732ee18 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -51,90 +51,50 @@ jQuery(window).load(function() } }); - var tjUcmTinyMCE = Joomla.getOptions("plg_editor_tinymce"); - - /* Get the value of editor fields*/ - if (tjUcmTinyMCE != undefined) + /*function to get iframe id of JCE editor*/ + if(jQuery("#item-form .js-editor-tinymce").length > 0) { - jQuery.each(tjUcmTinyMCE.tinyMCE, function(index, value){ - if (jQuery("#item-form #jform_"+index).length) - { - var tjUcmEditorFieldContent = jQuery("#jform_"+index+"_ifr").contents().find('body').html(); - tjUcmTinyMCEFieldIds[index] = tjUcmEditorFieldContent; - } - else if ((jQuery("#item-form #jform_"+index).length == 0) && (index != 'default')) + var tjUcmTinyMCE = Joomla.getOptions("plg_editor_tinymce"); + if (tjUcmTinyMCE != undefined) + { + jQuery.each(tjUcmTinyMCE.tinyMCE, function(index, value) { - var tjUcmSubFormEditorFields = jQuery("textarea[id$='__"+index+"']"); - - if (tjUcmSubFormEditorFields.length) + if (jQuery("#item-form #jform_"+index).length) { - jQuery.each(tjUcmSubFormEditorFields, function(findex, fvalue){ - var tjUcmEditorFieldContentId = jQuery(fvalue).attr('id'); - var tjUcmEditorFieldContent = jQuery("#"+tjUcmEditorFieldContentId+"_ifr").contents().find('body').html(); - var tjucmTempIndex = tjUcmEditorFieldContentId.replace("jform_", ""); - tjUcmTinyMCEFieldIds[tjucmTempIndex] = tjUcmEditorFieldContent; - }); + var tjUcmEditorFieldContent = jQuery("#jform_"+index+"_ifr").contents().find('body').html(); + tjUcmTinyMCEFieldIds[index] = tjUcmEditorFieldContent; } - } - }); - - /* Check after some time if the content of editor is changed and if so then save it in DB*/ - setInterval(function () { - for (var key in tjUcmTinyMCEFieldIds) { - if (tjUcmTinyMCEFieldIds.hasOwnProperty(key)) { - var tjUcmEditorFieldContent = jQuery("#jform_"+key+"_ifr").contents().find('body').html(); + else if ((jQuery("#item-form #jform_"+index).length == 0) && (index != 'default')) + { + var tjUcmSubFormEditorFields = jQuery("textarea[id$='__"+index+"']"); - if (tjUcmTinyMCEFieldIds[key] != tjUcmEditorFieldContent) + if (tjUcmSubFormEditorFields.length) { - var tjUcmTempFieldObj = jQuery("#jform_"+key); - - if (tjUcmTempFieldObj.length) + jQuery.each(tjUcmSubFormEditorFields, function(findex, fvalue) { - tjUcmTempFieldObj.val(tjUcmEditorFieldContent); - tjUcmTinyMCEFieldIds[key] = tjUcmEditorFieldContent; - tjUcmItemForm.onUcmFormChange(tjUcmTempFieldObj); - } + var tjUcmEditorFieldContentId = jQuery(fvalue).attr('id'); + var tjUcmEditorFieldContent = jQuery("#"+tjUcmEditorFieldContentId+"_ifr").contents().find('body').html(); + var tjucmTempIndex = tjUcmEditorFieldContentId.replace("jform_", ""); + tjUcmTinyMCEFieldIds[tjucmTempIndex] = tjUcmEditorFieldContent; + }); } } - } - },7000); + }); + } } /*to save data of editor field if editor=jce*/ if(jQuery("#item-form .wf-editor-container").length > 0) { /*function to get iframe id of JCE editor*/ setTimeout(function(){ - jQuery("#item-form .mceIframeContainer iframe").each(function (){ + jQuery("#item-form .mceIframeContainer iframe").each(function (){ var iframeId=jQuery(this).attr('id'); var tjucmIframeIndex = iframeId.replace("jform_", ""); var tjucmJceIframeIndex = tjucmIframeIndex.replace("_ifr", ""); var iframeContent=jQuery("#"+iframeId).contents().find('body').html(); - tjUcmJCEFieldIds[tjucmJceIframeIndex]=iframeContent;console.log(tjUcmJCEFieldIds)});},2000); - - /*Function to save data as per bitrate*/ - setInterval(function(){ - for (var key in tjUcmJCEFieldIds) - { - if (tjUcmJCEFieldIds.hasOwnProperty(key)) - { - var iframeContent = jQuery("#jform_"+key+"_ifr").contents().find('body').html(); - - if (tjUcmJCEFieldIds[key] != iframeContent) - { - var tjUcmTempJceFieldObj = jQuery("#jform_"+key); - - if (tjUcmTempJceFieldObj.length) - { - tjUcmTempJceFieldObj.val(iframeContent); - tjUcmJCEFieldIds[key] = iframeContent; - tjUcmItemForm.onUcmFormChange(tjUcmTempJceFieldObj); - } - } - } - } - }, tjUcmBitrateSeconds*1000 ); + tjUcmJCEFieldIds[tjucmJceIframeIndex]=iframeContent;});},2000); } // /* Auto save form as per configured bit rate*/ @@ -146,11 +106,57 @@ jQuery(window).load(function() if(jQuery('#item-form').hasClass('dirty')) { jQuery("#tjUcmSectionDraftSave").click(); - }, tjUcmBitrateSeconds*1000); - } + } + //For saving data of Jce editor. + if("#item-form .wf-editor-container") + { + for (var key in tjUcmJCEFieldIds) + { + if (tjUcmJCEFieldIds.hasOwnProperty(key)) + { + var iframeContent = jQuery("#jform_"+key+"_ifr").contents().find('body').html(); + if (tjUcmJCEFieldIds[key] != iframeContent) + { + var tjUcmTempFieldObj1 = jQuery("#jform_"+key); + + if (tjUcmTempFieldObj1.length) + { + tjUcmTempFieldObj1.val(iframeContent); + tjUcmJCEFieldIds[key] = iframeContent; + tjUcmItemForm.onUcmFormChange(tjUcmTempFieldObj1); + } + } + } + } + } + //For saving data of tinyMce editor + if(jQuery(".js-editor-tinymce").length > 0) + { + for (var key in tjUcmTinyMCEFieldIds) + { + if (tjUcmTinyMCEFieldIds.hasOwnProperty(key)) + { + var tjUcmEditorFieldContent = jQuery("#jform_"+key+"_ifr").contents().find('body').html(); + + if (tjUcmTinyMCEFieldIds[key] != tjUcmEditorFieldContent) + { + var tjUcmTempFieldObj = jQuery("#jform_"+key); + + if (tjUcmTempFieldObj.length) + { + tjUcmTempFieldObj.val(tjUcmEditorFieldContent); + tjUcmTinyMCEFieldIds[key] = tjUcmEditorFieldContent; + tjUcmItemForm.onUcmFormChange(tjUcmTempFieldObj); + } + } + } + } + + } }, tjUcmBitrateSeconds*1000); } } } + } else { jQuery("#tjucm-auto-save-disabled-msg").show(); From d840081464329c28611f4a6f5080d76f420fd613 Mon Sep 17 00:00:00 2001 From: ChavanAnkitaMahesh <“ankita_c@techjoomla.com”> Date: Tue, 21 Jan 2020 11:09:25 +0530 Subject: [PATCH 134/273] Bug #154793 fix : Functionality to save items depending upon the bit rate(seconds). --- src/components/com_tjucm/media/js/ui/itemform.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index b732ee18..2bd0186a 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -130,7 +130,7 @@ jQuery(window).load(function() } } //For saving data of tinyMce editor - if(jQuery(".js-editor-tinymce").length > 0) + if(jQuery("#item-form .js-editor-tinymce").length > 0) { for (var key in tjUcmTinyMCEFieldIds) { From 11c628a7a6c062a1761eafc583715b1ce8175464 Mon Sep 17 00:00:00 2001 From: ankush-maherwal Date: Tue, 21 Jan 2020 17:09:29 +0530 Subject: [PATCH 135/273] Update itemform.json.php --- .../com_tjucm/site/controllers/itemform.json.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 3e952254..4abfdd86 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -555,11 +555,12 @@ public function copyItem() if ($fieldType == 'file') { - $fielData['field_id'] = $fieldId; - $fielData['value'] = $fieldValue; - $fielData['params'] = $fielParams; - $fielData['sourceparams'] = $sourceFieldParams; - $fielFieldArray[] = $fielData; + $fileData = array(); + $fileData['field_id'] = $fieldId; + $fileData['value'] = $fieldValue; + $fileData['params'] = $fielParams; + $fileData['sourceparams'] = $sourceFieldParams; + $fielFieldArray[] = $fileData; } if ($subFormData) From 22f9221a472b2ec4482e2f80960e0d3d12a8ea3a Mon Sep 17 00:00:00 2001 From: ankush-maherwal Date: Tue, 21 Jan 2020 17:14:12 +0530 Subject: [PATCH 136/273] Update itemform.json.php --- .../com_tjucm/site/controllers/itemform.json.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 4abfdd86..e735d771 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -518,7 +518,7 @@ public function copyItem() $ucmOldData['content_id'] = $cid; $ucmOldData['layout'] = 'edit'; $ucmOldData['client'] = $sourceClient; - $fielFieldArray = array(); + $fileFieldArray = array(); // Get the field values $extraFieldsData = $model->loadFormDataExtra($ucmOldData); @@ -560,7 +560,7 @@ public function copyItem() $fileData['value'] = $fieldValue; $fileData['params'] = $fielParams; $fileData['sourceparams'] = $sourceFieldParams; - $fielFieldArray[] = $fileData; + $fileFieldArray[] = $fileData; } if ($subFormData) @@ -654,15 +654,15 @@ public function copyItem() if ($recordId) { - foreach ($fielFieldArray as $fielField) + foreach ($fileFieldArray as $fileField) { - $fileFieldValue = round(microtime(true)) . "_" . JUserHelper::genRandomPassword(5) . "_" . $fielField['value']; + $fileFieldValue = round(microtime(true)) . "_" . JUserHelper::genRandomPassword(5) . "_" . $fileField['value']; - if (copy($fielField['sourceparams']->uploadpath . $fielField['value'], $fielField['params']->uploadpath . $fileFieldValue)) + if (copy($fileField['sourceparams']->uploadpath . $fileField['value'], $fileField['params']->uploadpath . $fileFieldValue)) { JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/tables'); $fielValuedTable = JTable::getInstance('fieldsvalue', 'TjfieldsTable'); - $fielValuedTable->field_id = $fielField['field_id']; + $fielValuedTable->field_id = $fileField['field_id']; $fielValuedTable->content_id = $recordId; $fielValuedTable->value = $fileFieldValue; $fielValuedTable->user_id = Factory::getUser()->id; From dcce9f131f50f6cd847ce638d8fda7a0317e4f3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Tue, 21 Jan 2020 17:33:33 +0530 Subject: [PATCH 137/273] Task #152038 chore: On page load check Ucm type compatibility --- src/components/com_tjucm/media/js/services/items.min.js | 1 + src/components/com_tjucm/site/includes/tjucm.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 src/components/com_tjucm/media/js/services/items.min.js diff --git a/src/components/com_tjucm/media/js/services/items.min.js b/src/components/com_tjucm/media/js/services/items.min.js new file mode 100644 index 00000000..e6ea44df --- /dev/null +++ b/src/components/com_tjucm/media/js/services/items.min.js @@ -0,0 +1 @@ +"use strict";com_tjucm.Services.Items=new(com_tjucm.Services.Base.extend({checkCompatibilityUrl:window.tjSiteRoot+"index.php?option=com_tjucm&task=type.getCompatableUcmType",copyItemUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.copyItem",config:{headers:{}},response:{success:"",message:""},chekCompatibility:function(t,o){this.config.processData=!1,this.config.contentType=!1,this.post(this.checkCompatibilityUrl,t,this.config,o)},copyItem:function(t,o){this.config.processData=!1,this.config.contentType="application/x-www-form-urlencoded; charset=UTF-8",this.post(this.copyItemUrl,t,this.config,o)}})); \ No newline at end of file diff --git a/src/components/com_tjucm/site/includes/tjucm.php b/src/components/com_tjucm/site/includes/tjucm.php index 50536c52..238f38d3 100644 --- a/src/components/com_tjucm/site/includes/tjucm.php +++ b/src/components/com_tjucm/site/includes/tjucm.php @@ -197,7 +197,7 @@ public static function init($location = 'site') HTMLHelper::script('media/com_tjucm/js/services/item.min.js', $options); HTMLHelper::script('media/com_tjucm/js/vendor/jquery/jquery.form.js', $options); HTMLHelper::script('media/com_tjucm/js/ui/itemform.min.js', $options); - HTMLHelper::script('media/com_tjucm/js/services/items.js', $options); + HTMLHelper::script('media/com_tjucm/js/services/items.min.js', $options); HTMLHelper::StyleSheet('media/com_tjucm/css/tjucm.css', $options); } From 29621d7cff9431ac6f08b2ac0138f9953be404e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Thu, 23 Jan 2020 12:56:23 +0530 Subject: [PATCH 138/273] Bug #154793 fix: Functionality to save items depending upon the bit rate(seconds) --- .../com_tjucm/media/js/ui/itemform.js | 33 +++++++++++++++---- .../com_tjucm/media/js/ui/itemform.min.js | 2 +- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index b897fae0..7dd72e6f 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -1,6 +1,6 @@ /*Variable to store the updated options of related field*/ var tjucmRelatedFieldUpdatedOptions = ''; -/*Variable to store the data of editor field*/ +/*Variable to store the data of tinyMCE editor field*/ var tjUcmTinyMCEFieldIds = new Array(); /*Variable to store if the next button is clicked*/ var tjUcmClickedOnNext = 0; @@ -12,6 +12,8 @@ var tjUcmCurrentAutoSaveState = 0; var tjUcmFormFinalSave = 0; /*Variable to store the data of JCE editor field*/ var tjUcmJCEFieldIds = new Array(); +/*Variable to store if form is saved once using bit rate config*/ +var tjUcmFormSavedByBitRateConfig = 0; /* This function executes for autosave form */ jQuery(window).load(function() @@ -57,7 +59,7 @@ jQuery(window).load(function() } }); - /*function to get iframe id of JCE editor*/ + /*function to get iframe id of tinyMCE editor*/ if(jQuery("#item-form .js-editor-tinymce").length > 0) { var tjUcmTinyMCE = Joomla.getOptions("plg_editor_tinymce"); @@ -88,7 +90,8 @@ jQuery(window).load(function() }); } } - /*to save data of editor field if editor=jce*/ + + /*function to get iframe id of JCE editor*/ if(jQuery("#item-form .wf-editor-container").length > 0) { /*function to get iframe id of JCE editor*/ @@ -103,16 +106,20 @@ jQuery(window).load(function() tjUcmJCEFieldIds[tjucmJceIframeIndex]=iframeContent;});},2000); } - // /* Auto save form as per configured bit rate*/ + /* Auto save form as per configured bit rate*/ if (tjUcmAllowAutoSave == 1 && tjUcmAllowBitrate == 1 && tjUcmBitrateSeconds !== undefined) { if (jQuery("#item-form #tjUcmSectionDraftSave").length >= 1) { setInterval(function(){ - if(jQuery('#item-form').hasClass('dirty')) + if(jQuery('#item-form').hasClass('dirty') || tjUcmFormSavedByBitRateConfig === 0) { + /* Once the form is saved using the bit rate config mark the flag*/ + tjUcmFormSavedByBitRateConfig = 1; + jQuery("#tjUcmSectionDraftSave").click(); } + //For saving data of Jce editor. if("#item-form .wf-editor-container") { @@ -135,6 +142,7 @@ jQuery(window).load(function() } } } + //For saving data of tinyMce editor if(jQuery("#item-form .js-editor-tinymce").length > 0) { @@ -206,6 +214,19 @@ jQuery(window).load(function() } } + /* If there is any editor field in sub-form then add its reference in variable tjUcmJCEFieldIds*/ + if (jQuery(row).find('.wf-editor-container textarea')) + { + var tjUcmIdOfEditorFieldInSubForm = jQuery(row).find('.wf-editor-container textarea').attr('id'); + + if (tjUcmIdOfEditorFieldInSubForm) + { + var tjUcmSubFormEditorFieldContent = jQuery("#"+tjUcmIdOfEditorFieldInSubForm+"_ifr").contents().find('body').html(); + tjUcmIdOfEditorFieldInSubForm = tjUcmIdOfEditorFieldInSubForm.replace('jform_', ''); + tjUcmTinyMCEFieldIds[tjUcmIdOfEditorFieldInSubForm] = tjUcmSubFormEditorFieldContent; + } + } + /* Update options of related fields*/ jQuery.each(tjucmRelatedFieldUpdatedOptions, function(index, value) { if (value.templateId) @@ -312,6 +333,7 @@ jQuery(window).load(function() jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow"); } }); +}); var tjUcmItemForm = { getUcmParentRecordId: function (draft, callback){ @@ -1111,7 +1133,6 @@ function itemformactions(tab_id, navDirection) jQuery('#tjucm_myTabTabs > .active').next('li').prev('a').trigger('click'); } - var nextTabName = jQuery('ul#' + getTabId).find('li.active').next('li').children('a').attr('href'); var prevTabName = jQuery('ul#' + getTabId).find('li.active').prev('li').children('a').attr('href'); 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 7613b649..0a20037c 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;jQuery(window).load(function(){if(1===Number(jQuery("#itemState").val())){var e=jQuery("#item-form #tjucm-autosave").val(),t=jQuery("#item-form #tjucm-bitrate").val(),a=jQuery("#item-form #tjucm-bitrate_seconds").val();1==e&&(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)}),1==e&&1==t&&void 0!==a&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){jQuery("#tjUcmSectionDraftSave").click()},1e3*a))}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 a=jQuery(t).attr("data-group").replace(jQuery(t).attr("data-base-name"),"");if(jQuery(t).find(".js-editor-tinymce textarea")){var r=jQuery(t).find(".js-editor-tinymce textarea").attr("id");if(r){var 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,a){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("#item-form").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("#item-form").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(e,t){var a=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(t,r){var i=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==i){var n=new FormData;""!=a&&n.append("client",a),n.append(Joomla.getOptions("csrf.token"),1);n.append("draft",e),com_tjucm.Services.Item.create(n,function(e,a){if(a=JSON.parse(a),null==e)if(null!==a.data&&jQuery.isNumeric(a.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(a.data.id);var i=window.location.href.split("#")[0],n=-1===i.indexOf("?")?"?":"&",o="id="+a.data.id;i.indexOf(o)>=0||(i+=n+o),history.pushState(null,null,i),t(a.data.id)}else r(a)})}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 a=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(e,a,t)})},initUcmFormFieldDataSave:function(e,t,a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var r="",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"),u="com_tjucm."+(r=o.replace(o.split("_").pop(),"contentid")).split("__").pop().replace("_contentid","").replace("com_tjucm_",""),m=jQuery("#"+r).val();if(""==m){i.append("parent_id",a),i.append("client",u),i.append("draft",1),com_tjucm.Services.Item.create(i,function(o,m){if(m=JSON.parse(m),null==o)return null!==m.data&&jQuery.isNumeric(m.data.id)&&jQuery("#"+r).val(m.data.id),i.append("jform["+n+"]",u),i.append("client",t),i.append("recordid",a),com_tjucm.Services.Item.saveFieldData(i,function(t,a){var r=jQuery(e).attr("name"),i="[]"==r.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(u,m.data.id,e),jQuery(e).attr("name",r)}),!0})}else if(jQuery.isNumeric(m)&&0!=m){var l=jQuery(e).attr("name"),c="[]"==l.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+c;if("radio"==jQuery(e).attr("type"))d="jform["+jQuery(e).attr("name").split("][").pop();return jQuery(e).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(u,m,e),jQuery(e).attr("name",l),!0}return!1}return tjUcmItemForm.saveUcmFormFieldData(t,a,e),!0},saveUcmFormFieldData:function(e,t,a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var r=new FormData;return r.append(Joomla.getOptions("csrf.token"),1),r.append("client",e),r.append("recordid",t),"checkbox"==jQuery(a).attr("type")?1==jQuery(a).prop("checked")?r.append(jQuery(a).attr("name"),1):r.append(jQuery(a).attr("name"),0):jQuery(a).hasClass("tjfieldTjList")?(""!=jQuery(a).val()&&null!=jQuery(a).val()&&r.append(jQuery(a).attr("name"),jQuery(a).val()),""!=jQuery("input#"+jQuery(a).attr("id")).val()&&null!=jQuery("input#"+jQuery(a).attr("id")).val()&&r.append(jQuery(a).attr("name"),jQuery("input#"+jQuery(a).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(a).attr("id")).data("role")?(""!=jQuery("#"+jQuery(a).attr("id")).val()&&null!=jQuery("#"+jQuery(a).attr("id")).val()&&r.append(jQuery(a).attr("name"),jQuery("#"+jQuery(a).attr("id")).val()),""!=jQuery(a).val()&&null!=jQuery(a).val()&&r.append(jQuery(a).attr("name"),jQuery(a).val())):"file"!=jQuery(a).attr("type")?r.append(jQuery(a).attr("name"),jQuery(a).val()):r.append(jQuery(a).attr("name"),jQuery(a)[0].files[0]),""!=jQuery(a).attr("name")&&null!=jQuery(a).attr("name")&&com_tjucm.Services.Item.saveFieldData(r,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(e,t){if(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 a=jQuery("#item-form").find("input[name='jform[client]']").val(),r=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(a,r)}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("#item-form").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("#item-form").position().top},"slow")))},updateRelatedFieldsOptions:function(e,t){var a=new FormData;a.append("client",e),a.append("content_id",t),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(a,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,a){var r="";"1"==a.selected&&(r=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")})})},saveUcmFormData:function(){if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),void 0===event)var e="tjUcmSectionDraftSave",t=1;else e=event.target.id;var a=1;if("tjUcmSectionFinalSave"==e){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("#item-form").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),a=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(a,function(){var a=document.getElementById("item-form"),r=new FormData(a);r.delete("task"),r.delete("option"),r.delete("view"),r.delete("layout");var i=jQuery("#item-form").find("input[name='jform[client]']").val(),n=jQuery("#item-form").find("input[name='jform[id]']").val();r.append(Joomla.getOptions("csrf.token"),1),r.append("client",i),r.append("recordid",n),"tjUcmSectionDraftSave"==e&&r.append("draft",1),"tjUcmSectionFinalSave"==e&&(tjUcmFormFinalSave=1),jQuery('input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?r.append(jQuery(this).attr("name"),1):r.append(jQuery(this).attr("name"),0)}),void 0!==t&&r.append("showDraftMessage",0),com_tjucm.Services.Item.saveFormData(r,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,a=jQuery(e).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(a))return jQuery("html, body").animate({scrollTop:jQuery("#item-form").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(e){this.click()}),a.length&&a.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 a=jQuery("#item-form").find("input[name='jform[client]']").val(),r=jQuery("#item-form").find("input[name='jform[id]']").val();t.append(Joomla.getOptions("csrf.token"),1),t.append("client",a),t.append("recordid",r),t.append("tjUcmFormSection",jQuery("a[href='"+e+"']").html()),com_tjucm.Services.Item.saveFormData(t,tjUcmItemForm.afterDataSave)})},validateSection:function(e){var t,a,r,i,n,o=!0,u=[];for(i=0,n=e.length;i0){for(t=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),a={error:[]},i=u.length-1;i>=0;i--)(r=jQuery(u[i]).data("label"))&&a.error.push(t+r.text().replace("*",""));Joomla.renderMessages(a)}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,a){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(e){this.click()});var r=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("#item-form").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("#item-form").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return r&&jQuery(r).ajaxSubmit({datatype:"JSON",async:!1,success:function(e){var r=JSON.parse(e);if(null!==r.messages&&null!==r.messages.error&&(jQuery.each(r.messages.error,function(e,t){Joomla.renderMessages({error:[t]})}),jQuery("html, body").animate({scrollTop:jQuery("#item-form").position().top},"slow")),null!==r.message&&""!=r.message&&(Joomla.renderMessages({info:[r.message]}),jQuery("html, body").animate({scrollTop:jQuery("#item-form").position().top},"slow")),null!==r.data){jQuery("#recordId").val(r.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"===a&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var n=window.location.href.split("#")[0],o=-1===n.indexOf("?")?"?":"&",u="id="+r.data.id;jQuery.each(r.data.childContentIds,function(e,t){jQuery("input[name='"+t.elementName+"']").val(t.content_id)}),tjucmRelatedFieldUpdatedOptions=r.data.relatedFieldOptions,jQuery.each(r.data.relatedFieldOptions,function(e,t){jQuery("#"+t.elementId).html(""),jQuery.each(t.options,function(e,a){var r="";"1"==a.selected&&(r=' selected="selected" '),jQuery("#"+t.elementId).append('")}),jQuery("#"+t.elementId).trigger("liszt:updated")}),n.indexOf(u)>=0||(n+=o+u),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 a=jQuery("ul#tjucm_myTabTabs").find("li.active a");null==jQuery(a).next("li")?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),null==jQuery(a).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 r=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==r?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;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("#item-form").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("#item-form").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 l=jQuery(e).attr("name"),c="[]"==l.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+c;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",l),!0}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(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("#item-form").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("#item-form").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(){if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),void 0===event)var e="tjUcmSectionDraftSave",t=1;else e=event.target.id;var r=1;if("tjUcmSectionFinalSave"==e){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("#item-form").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),r=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(r,function(){var r=document.getElementById("item-form"),a=new FormData(r);a.delete("task"),a.delete("option"),a.delete("view"),a.delete("layout");var i=jQuery("#item-form").find("input[name='jform[client]']").val(),n=jQuery("#item-form").find("input[name='jform[id]']").val();a.append(Joomla.getOptions("csrf.token"),1),a.append("client",i),a.append("recordid",n),"tjUcmSectionDraftSave"==e&&a.append("draft",1),"tjUcmSectionFinalSave"==e&&(tjUcmFormFinalSave=1),jQuery('input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?a.append(jQuery(this).attr("name"),1):a.append(jQuery(this).attr("name"),0)}),void 0!==t&&a.append("showDraftMessage",0),com_tjucm.Services.Item.saveFormData(a,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("#item-form").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("#item-form").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("#item-form").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("#item-form").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#item-form").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 ae41c5b3a01363de9905faf5de21e475a352a2f7 Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Fri, 24 Jan 2020 10:51:45 +0530 Subject: [PATCH 139/273] Bug #156457 fix: Front End>> Updated data is not visible in the view table once user edited it. --- src/components/com_tjucm/site/controllers/itemform.json.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index e735d771..5dd831d9 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -317,6 +317,10 @@ public function saveFormData() $dispatcher->trigger('onUcmItemAfterSave', array($table->getProperties(), $data)); } } + else + { + $msg = ($response) ? Text::_("COM_TJUCM_ITEM_SAVED_SUCCESSFULLY") : Text::_("COM_TJUCM_FORM_SAVE_FAILED_AUTHORIZATION_ERROR"); + } echo new JResponseJson($response, $msg); $app->close(); From 83e36c6343340c7bde4597756644357942e2f7c3 Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Fri, 24 Jan 2020 10:54:20 +0530 Subject: [PATCH 140/273] Bug #156457 fix: Front End>> Updated data is not visible in the view table once user edited it. --- src/components/com_tjucm/site/controllers/itemform.json.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 5dd831d9..9df61970 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -319,7 +319,7 @@ public function saveFormData() } else { - $msg = ($response) ? Text::_("COM_TJUCM_ITEM_SAVED_SUCCESSFULLY") : Text::_("COM_TJUCM_FORM_SAVE_FAILED_AUTHORIZATION_ERROR"); + $msg = Text::_("COM_TJUCM_FORM_SAVE_FAILED_AUTHORIZATION_ERROR"); } echo new JResponseJson($response, $msg); From b9e155ed45370eba3583fdc5ce7158a1aaf57b11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 24 Jan 2020 15:08:00 +0530 Subject: [PATCH 141/273] Bug #156336 fix: Front End>> Name of the color is not visible clearly as box is too much small in size --- src/components/com_tjucm/media/css/tjucm.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/components/com_tjucm/media/css/tjucm.css b/src/components/com_tjucm/media/css/tjucm.css index b0c2906b..75f344e0 100644 --- a/src/components/com_tjucm/media/css/tjucm.css +++ b/src/components/com_tjucm/media/css/tjucm.css @@ -13,3 +13,8 @@ width:200px !important; #item-form textarea{ height: inherit !important; } + +#item-form .minicolors-theme-bootstrap .hex { + width: 100px !important; + height: auto; +} \ No newline at end of file From a8aa33312a72797adb7778c995bc7ebb75c710ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 24 Jan 2020 15:23:03 +0530 Subject: [PATCH 142/273] Bug #154919 fix: Local Site>> Getting some technical message once user installed the latest package on local site --- .../com_tjucm/site/views/itemform/tmpl/default.php | 2 +- .../com_tjucm/site/views/itemform/view.html.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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 79aad352..9b02b752 100644 --- a/src/components/com_tjucm/site/views/itemform/tmpl/default.php +++ b/src/components/com_tjucm/site/views/itemform/tmpl/default.php @@ -41,7 +41,7 @@ $baseUrl = $jinput->input->server->get('REQUEST_URI', '', 'STRING'); $calledFrom = (strpos($baseUrl, 'administrator')) ? 'backend' : 'frontend'; $layout = ($calledFrom == 'frontend') ? 'default' : 'edit'; -$dynamicLayout = $this->setLayout($typeParams->layout); +$dynamicLayout = $this->setLayout($this->layout); $fieldsets_counter_deafult = 0; $setnavigation = 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 3c942b00..6f8e5301 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -242,7 +242,7 @@ public function display($tpl = null) } // Set Layout to type view - $layout = isset($typeParams->layout) ? $typeParams->layout : ''; + $this->layout = isset($typeParams->layout) ? $typeParams->layout : ''; if (isset($typeParams->layout) && !empty($typeParams->layout)) { @@ -284,9 +284,9 @@ public function display($tpl = null) $this->allow_auto_save = (isset($typeParams->allow_auto_save) && empty($typeParams->allow_auto_save)) ? 0 : 1; $this->allow_draft_save = (isset($typeParams->allow_draft_save) && !empty($typeParams->allow_draft_save)) ? 1 : 0; - $this->allow_bit_rate=(isset($typeParams->bitrate_on) && !empty($typeParams->bitrate_on)) ? 1 : 0; - $this->allow_bit_rate_seconds=$typeParams->bitrate_seconds; - + $this->allow_bit_rate = (isset($typeParams->bitrate_on) && !empty($typeParams->bitrate_on)) ? 1 : 0; + $this->allow_bit_rate_seconds = $typeParams->bitrate_seconds; + // Check for errors. if (count($errors = $this->get('Errors'))) { From e325a46513a3ece34a315efd21ac0ac803c0e0d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Fri, 24 Jan 2020 16:03:50 +0530 Subject: [PATCH 143/273] Bug #156460 fix: Front End>> User redirect to other menu and getting an error while trying to unpublish the record without permission --- .../com_tjucm/site/controllers/item.php | 25 ++++++++++--------- .../com_tjucm/site/layouts/list/list.php | 3 +-- .../site/views/items/tmpl/default.php | 4 ++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/item.php b/src/components/com_tjucm/site/controllers/item.php index 02faed5e..ab40ac17 100644 --- a/src/components/com_tjucm/site/controllers/item.php +++ b/src/components/com_tjucm/site/controllers/item.php @@ -30,18 +30,6 @@ public function __construct() $this->client = JFactory::getApplication()->input->get('client'); $this->created_by = JFactory::getApplication()->input->get('created_by'); - $this->appendUrl = ""; - - if (!empty($this->created_by)) - { - $this->appendUrl .= "&created_by=" . $this->created_by; - } - - if (!empty($this->client)) - { - $this->appendUrl .= "&client=" . $this->client; - } - // Get UCM type id from uniquue identifier JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjucm/models'); $tjUcmModelType = JModelLegacy::getInstance('Type', 'TjucmModel'); @@ -69,6 +57,19 @@ public function __construct() } } } + + $this->appendUrl = ""; + + if (!empty($this->created_by)) + { + $this->appendUrl .= "&created_by=" . $this->created_by; + } + + if (!empty($this->client)) + { + $this->appendUrl .= "&client=" . $this->client; + } + parent::__construct(); } diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 81aa1802..6ff9d6a7 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -22,7 +22,6 @@ } $fieldsData = $displayData['fieldsData']; - $app = Factory::getApplication(); $user = Factory::getUser(); @@ -152,7 +151,7 @@ $fieldXml = $formObject->getFieldXml($tjFieldsFieldTable->name); ?> -

+ created_by == $user->id)) { 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 6d7b8a7a..6ce3b12c 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -258,7 +258,9 @@ function copyItem() 'ucmTypeId' => $this->ucmTypeId, 'ucmTypeParams' => $this->ucmTypeParams, 'fieldsData' => $fieldsData, - 'formObject' => $formObject + 'formObject' => $formObject, + 'statusColumnWidth' => $statusColumnWidth, + 'listcolumn' => $this->listcolumn ) ); } From f68f136a09d5faf7c9279dcffdeb9d2686966caa Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Tue, 28 Jan 2020 16:34:28 +0530 Subject: [PATCH 144/273] Bug #344 fix: Front end>>Text in other field is not wrapped properly of Other field textbox in the List type. --- src/components/com_tjucm/media/css/tjucm.css | 6 +++++- src/components/com_tjucm/site/includes/tjucm.php | 1 + src/components/com_tjucm/site/layouts/detail/fields.php | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/com_tjucm/media/css/tjucm.css b/src/components/com_tjucm/media/css/tjucm.css index 75f344e0..5641015a 100644 --- a/src/components/com_tjucm/media/css/tjucm.css +++ b/src/components/com_tjucm/media/css/tjucm.css @@ -17,4 +17,8 @@ width:200px !important; #item-form .minicolors-theme-bootstrap .hex { width: 100px !important; height: auto; -} \ No newline at end of file +} + +.tjucm-wrapper .tj-wordwrap{ +word-break: break-word; +} diff --git a/src/components/com_tjucm/site/includes/tjucm.php b/src/components/com_tjucm/site/includes/tjucm.php index 238f38d3..18f58beb 100644 --- a/src/components/com_tjucm/site/includes/tjucm.php +++ b/src/components/com_tjucm/site/includes/tjucm.php @@ -205,6 +205,7 @@ public static function init($location = 'site') if ($view == 'item') { HTMLHelper::script('media/com_tjucm/js/ui/item.js'); + HTMLHelper::StyleSheet('media/com_tjucm/css/tjucm.css', $options); } $loaded[$location] = true; diff --git a/src/components/com_tjucm/site/layouts/detail/fields.php b/src/components/com_tjucm/site/layouts/detail/fields.php index fb8d2892..acec8160 100644 --- a/src/components/com_tjucm/site/layouts/detail/fields.php +++ b/src/components/com_tjucm/site/layouts/detail/fields.php @@ -180,9 +180,9 @@ $layout = new JLayoutFile($layoutToUse, JPATH_ROOT . '/components/com_tjfields/layouts/fields'); $output = $layout->render(array('fieldXml' => $xmlField, 'field' => $field)); - // To align text, textarea, textareacounter and editor fields properly + // To align text, textarea, textareacounter, editor and tjlist fields properly - if ($field->type == 'Textarea'|| $field->type == 'Textareacounter'|| $field->type == 'Text' || $field->type == 'Editor') + if ($field->type == 'Textarea'|| $field->type == 'Textareacounter'|| $field->type == 'Text' || $field->type == 'Editor' || $field->type == 'tjlist') { ?>
From 59eb0594ebed332d3ba5510be5857d2f73caffad Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Tue, 4 Feb 2020 15:41:29 +0530 Subject: [PATCH 145/273] Bug #157037 fix: Frontend: User receives error on list view when new package is installed --- src/components/com_tjucm/site/views/items/tmpl/default.php | 1 + 1 file changed, 1 insertion(+) 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 6ce3b12c..34349779 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -184,6 +184,7 @@ function copyItem() } else { + JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjfields/tables'); $tjFieldsFieldTable = JTable::getInstance('field', 'TjfieldsTable'); $tjFieldsFieldTable->load($fieldId); $fieldsData[$fieldId] = $tjFieldsFieldTable; From ec53678ac9251be559f2b3ad62c2f5f5a29566b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Mon, 10 Feb 2020 13:01:37 +0530 Subject: [PATCH 146/273] Bug #154304 fix: After click on save as draft error message shown if the subform field is required --- .../site/controllers/itemform.json.php | 35 ++++++++++++++++--- .../com_tjucm/site/models/itemform.php | 15 ++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 9df61970..7da39ebd 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -249,7 +249,6 @@ public function saveFormData() // Create JForm object for the field $model = $this->getModel('itemform'); $formData['client'] = $client; - $form = $model->getTypeForm($formData); if (!empty($section)) { @@ -265,7 +264,35 @@ public function saveFormData() // Validate field data $data = $model->validate($form, $formData); - if ($data == false) + // Validate UCM subform data - start + $fieldSets = $form->getFieldsets(); + + foreach ($fieldSets as $fieldset) + { + foreach ($form->getFieldset($fieldset->name) as $field) + { + if ($field->type == 'Ucmsubform') + { + $subForm = $field->loadSubForm(); + $subFormFieldName = str_replace('jform[', '', $field->name); + $subFormFieldName = str_replace(']', '', $subFormFieldName); + + foreach ($formData[$subFormFieldName] as $ucmSubFormData) + { + $ucmSubFormData = $model->validate($subForm, $ucmSubFormData); + + if ($ucmSubFormData === false) + { + $data = false; + } + } + } + } + } + + // Validate UCM subform data - end + + if ($data === false) { $errors = $model->getErrors(); $this->processErrors($errors); @@ -431,7 +458,7 @@ private function processErrors($errors) $msg = array(); // Push up to three validation messages out to the user. - for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) + for ($i = 0; $i < count($errors); $i++) { if ($errors[$i] instanceof Exception) { @@ -444,7 +471,7 @@ private function processErrors($errors) } } - $app->enqueueMessage(implode("\n", $msg), 'error'); + $app->enqueueMessage(implode("
", $msg), 'error'); } } diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index c6bceca5..5ccbb910 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -358,6 +358,21 @@ public function getTypeForm($data = array(), $loadData = true) { foreach ($form->getFieldset($fieldset->name) as $field) { + // Remove required attribute from the subform fields in case of draft save + if ($field->type == 'Subform' || $field->type == 'Ucmsubform') + { + $subForm = $field->loadSubForm(); + $subFormFieldSets = $subForm->getFieldsets(); + + foreach ($subFormFieldSets as $subFormFieldSet) + { + foreach ($subForm->getFieldset($subFormFieldSet->name) as $subFormField) + { + $subForm->setFieldAttribute($subFormField->fieldname, 'required', false); + } + } + } + $form->setFieldAttribute($field->fieldname, 'required', false); } } From cec01ee4156b1240d4cb33bdbe78880f35ced44a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 19 Feb 2020 16:56:39 +0530 Subject: [PATCH 147/273] Bug #154304 fix: After click on 'save as draft' error message shown if the subform field is required --- .../com_tjucm/media/js/ui/itemform.js | 31 ++++++++++++++++--- .../com_tjucm/media/js/ui/itemform.min.js | 2 +- 2 files changed, 28 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 7dd72e6f..c73b926e 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -14,6 +14,10 @@ var tjUcmFormFinalSave = 0; var tjUcmJCEFieldIds = new Array(); /*Variable to store if form is saved once using bit rate config*/ var tjUcmFormSavedByBitRateConfig = 0; +/*Variable to store if save call is from bitrate*/ +var tjUcmSaveFormInDraftWithNoMsg = undefined; +/*Variable to store id of button from which the save is initiated*/ +var tjUcmFormSubmitCallingButtonId = ''; /* This function executes for autosave form */ jQuery(window).load(function() @@ -512,6 +516,13 @@ var tjUcmItemForm = { return true; } + else if (tjucmRecordId == undefined) + { + /* In case of subform onchange save the entire form*/ + tjUcmSaveFormInDraftWithNoMsg = 1; + tjUcmFormSubmitCallingButtonId = 'tjUcmSectionDraftSave'; + jQuery("#tjUcmSectionDraftSave").click(); + } return false; } @@ -717,14 +728,22 @@ var tjUcmItemForm = { /* Disable the action buttons before performing the action*/ jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', true); + /* In case of save through bitrate setting event will be undefined*/ if (event === undefined) { - var tjUcmFormSubmitCallingButtonId = 'tjUcmSectionDraftSave'; - var tjUcmBitrateAutoSaveCall = 1; + tjUcmFormSubmitCallingButtonId = 'tjUcmSectionDraftSave'; + tjUcmSaveFormInDraftWithNoMsg = 1; } else { - var tjUcmFormSubmitCallingButtonId = event.target.id; + if (event.target.id == 'tjUcmSectionDraftSave' || event.target.id == 'tjUcmSectionFinalSave') + { + tjUcmFormSubmitCallingButtonId = event.target.id; + } + else + { + tjUcmFormSubmitCallingButtonId = 'tjUcmSectionDraftSave'; + } } var tjUcmSaveRecordAsDraft = 1; @@ -793,6 +812,9 @@ var tjUcmItemForm = { tjUcmFormFinalSave = 1; } + /* Reset the variable*/ + tjUcmFormSubmitCallingButtonId = ''; + jQuery('input[type="checkbox"]').each(function (){ if (jQuery(this).prop('checked') == true) { @@ -805,8 +827,9 @@ var tjUcmItemForm = { }); /* Do not show draft save msg if the save is triggered as per bitrate config*/ - if (tjUcmBitrateAutoSaveCall !== undefined) + if (tjUcmSaveFormInDraftWithNoMsg !== undefined) { + tjUcmSaveFormInDraftWithNoMsg = undefined; tjUcmItemFormData.append('showDraftMessage', 0); } 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 0a20037c..f042679a 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;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("#item-form").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("#item-form").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 l=jQuery(e).attr("name"),c="[]"==l.slice(-2)?"[]":"",d="jform["+jQuery(e).attr("id").split("__").pop()+"]"+c;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",l),!0}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(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("#item-form").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("#item-form").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(){if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),void 0===event)var e="tjUcmSectionDraftSave",t=1;else e=event.target.id;var r=1;if("tjUcmSectionFinalSave"==e){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("#item-form").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),r=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(r,function(){var r=document.getElementById("item-form"),a=new FormData(r);a.delete("task"),a.delete("option"),a.delete("view"),a.delete("layout");var i=jQuery("#item-form").find("input[name='jform[client]']").val(),n=jQuery("#item-form").find("input[name='jform[id]']").val();a.append(Joomla.getOptions("csrf.token"),1),a.append("client",i),a.append("recordid",n),"tjUcmSectionDraftSave"==e&&a.append("draft",1),"tjUcmSectionFinalSave"==e&&(tjUcmFormFinalSave=1),jQuery('input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?a.append(jQuery(this).attr("name"),1):a.append(jQuery(this).attr("name"),0)}),void 0!==t&&a.append("showDraftMessage",0),com_tjucm.Services.Item.saveFormData(a,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("#item-form").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("#item-form").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("#item-form").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("#item-form").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#item-form").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 t=Number(jQuery("#itemState").val()),e=jQuery("#item-form #tjucm-bitrate").val(),r=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1===t){var a=jQuery("#item-form #tjucm-autosave").val();e=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(t,e){if(jQuery("#item-form #jform_"+t).length){var r=jQuery("#jform_"+t+"_ifr").contents().find("body").html();tjUcmTinyMCEFieldIds[t]=r}else if(0==jQuery("#item-form #jform_"+t).length&&"default"!=t){var a=jQuery("textarea[id$='__"+t+"']");a.length&&jQuery.each(a,function(t,e){var r=jQuery(e).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 t=jQuery(this).attr("id"),e=t.replace("jform_","").replace("_ifr",""),r=jQuery("#"+t).contents().find("body").html();tjUcmJCEFieldIds[e]=r})},2e3),1==a&&1==e&&void 0!==r&&jQuery("#item-form #tjUcmSectionDraftSave").length>=1&&setInterval(function(){for(var t in(jQuery("#item-form").hasClass("dirty")||0===tjUcmFormSavedByBitRateConfig)&&(tjUcmFormSavedByBitRateConfig=1,jQuery("#tjUcmSectionDraftSave").click()),tjUcmJCEFieldIds)if(tjUcmJCEFieldIds.hasOwnProperty(t)){var e=jQuery("#jform_"+t+"_ifr").contents().find("body").html();if(tjUcmJCEFieldIds[t]!=e){var r=jQuery("#jform_"+t);r.length&&(r.val(e),tjUcmJCEFieldIds[t]=e,tjUcmItemForm.onUcmFormChange(r))}}if(jQuery("#item-form .js-editor-tinymce").length>0)for(var t in tjUcmTinyMCEFieldIds)if(tjUcmTinyMCEFieldIds.hasOwnProperty(t)){var a=jQuery("#jform_"+t+"_ifr").contents().find("body").html();if(tjUcmTinyMCEFieldIds[t]!=a){var i=jQuery("#jform_"+t);i.length&&(i.val(a),tjUcmTinyMCEFieldIds[t]=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(t,e){var r,a=jQuery(e).attr("data-group").replace(jQuery(e).attr("data-base-name"),"");if(jQuery(e).find(".js-editor-tinymce textarea")&&(r=jQuery(e).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(e).find(".wf-editor-container textarea")&&(r=jQuery(e).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(t,r){if(r.templateId){var i=r.templateId.replace("XXX_XXX",a);jQuery(e).find("#"+i).html(""),jQuery.each(r.options,function(t,r){jQuery(e).find("#"+i).append('")}),jQuery(e).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 t=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(t)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{t=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(t)?(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("#item-form").position().top},"slow")}else{t=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(t)?(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("#item-form").position().top},"slow")}})});var tjUcmItemForm={getUcmParentRecordId:function(t,e){var r=jQuery("#item-form").find("input[name='jform[client]']").val();new Promise(function(e,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",t),com_tjucm.Services.Item.create(n,function(t,r){if(r=JSON.parse(r),null==t)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),e(r.data.id)}else a(r)})}else jQuery.isNumeric(i)&&0!=i&&e(i)}).then(function(t){e(t)}).catch(function(t){return console.log(t),!1})},onUcmFormChange:function(t){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(e){var r=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(t,r,e)})},initUcmFormFieldDataSave:function(t,e,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(t).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(t).parent().parent().parent().parent().attr("data-base-name")){var n=jQuery(t).parent().parent().parent().attr("data-base-name");null==n&&(n=jQuery(t).parent().parent().parent().parent().attr("data-base-name"));var o=jQuery(t).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",e),i.append("recordid",r),com_tjucm.Services.Item.saveFieldData(i,function(e,r){var a=jQuery(t).attr("name"),i="[]"==a.slice(-2)?"[]":"",n="jform["+jQuery(t).attr("id").split("__").pop()+"]"+i;"radio"==jQuery(t).attr("type")&&(n="jform["+jQuery(t).attr("name").split("][").pop()),jQuery(t).attr("name",n),tjUcmItemForm.saveUcmFormFieldData(m,u.data.id,t),jQuery(t).attr("name",a)}),!0})}else{if(jQuery.isNumeric(u)&&0!=u){var c=jQuery(t).attr("name"),l="[]"==c.slice(-2)?"[]":"",d="jform["+jQuery(t).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(t).attr("type"))d="jform["+jQuery(t).attr("name").split("][").pop();return jQuery(t).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(m,u,t),jQuery(t).attr("name",c),!0}null==u&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(e,r,t),!0},saveUcmFormFieldData:function(t,e,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",t),a.append("recordid",e),"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(t,e){if(e=JSON.parse(e),jQuery("#item-form").removeClass("dirty"),null==e)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=e.data&&e.data.childContentIds&&jQuery.each(e.data.childContentIds,function(t,e){jQuery("#"+t).val(e)}),e.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(),e.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(e)},renderResponseMessages:function(t){null!=t&&(null!==t.message&&(t.data?Joomla.renderMessages({success:[t.message]}):Joomla.renderMessages({error:[t.message]}),jQuery("html, body").animate({scrollTop:jQuery("#item-form").position().top},"slow")),null!==t.messages&&null!==t.messages.error&&(jQuery.each(t.messages.error,function(t,e){Joomla.renderMessages({error:[e]})}),jQuery("html, body").animate({scrollTop:jQuery("#item-form").position().top},"slow")))},updateRelatedFieldsOptions:function(t,e){var r=new FormData;r.append("client",t),r.append("content_id",e),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(r,function(t,e){if(e=JSON.parse(e),""==(tjucmRelatedFieldUpdatedOptions=e.data))return!1;jQuery.each(e.data,function(t,e){jQuery("#"+e.elementId).html(""),jQuery.each(e.options,function(t,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+e.elementId).append('")}),jQuery("#"+e.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 t=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("#item-form").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),t=0}jQuery("#item-form .toggle-editor a").each(function(t){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(t){this.click()}),tjUcmItemForm.getUcmParentRecordId(t,function(){var t=document.getElementById("item-form"),e=new FormData(t);e.delete("task"),e.delete("option"),e.delete("view"),e.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();e.append(Joomla.getOptions("csrf.token"),1),e.append("client",r),e.append("recordid",a),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&e.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery('input[type="checkbox"]').each(function(){1==jQuery(this).prop("checked")?e.append(jQuery(this).attr("name"),1):e.append(jQuery(this).attr("name"),0)}),void 0!==tjUcmSaveFormInDraftWithNoMsg&&(tjUcmSaveFormInDraftWithNoMsg=void 0,e.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(e,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(t){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(t){this.click()})},saveSectionData:function(t){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var e=new FormData,r=jQuery(t).find("input, textarea, select, fieldset");if(!tjUcmItemForm.validateSection(r))return jQuery("html, body").animate({scrollTop:jQuery("#item-form").position().top},"slow"),!1;jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(t){this.click()}),r.length&&r.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&e.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()&&e.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(){e.delete("task"),e.delete("option"),e.delete("view"),e.delete("layout");var r=jQuery("#item-form").find("input[name='jform[client]']").val(),a=jQuery("#item-form").find("input[name='jform[id]']").val();e.append(Joomla.getOptions("csrf.token"),1),e.append("client",r),e.append("recordid",a),e.append("tjUcmFormSection",jQuery("a[href='"+t+"']").html()),com_tjucm.Services.Item.saveFormData(e,tjUcmItemForm.afterDataSave)})},validateSection:function(t){var e,r,a,i,n,o=!0,m=[];for(i=0,n=t.length;i0){for(e=Joomla.JText._("JLIB_FORM_FIELD_INVALID"),r={error:[]},i=m.length-1;i>=0;i--)(a=jQuery(m[i]).data("label"))&&r.error.push(e+a.text().replace("*",""));Joomla.renderMessages(r)}return o},setVisibilityOfNavigationButtons:function(){var t=jQuery("#tjucm_myTabTabs").find("li.active");jQuery(t).length&&(jQuery(t).next("li").length?jQuery("#next_button").attr("disabled",!1):jQuery("#next_button").attr("disabled",!0),jQuery(t).prev("li").length?jQuery("#previous_button").attr("disabled",!1):jQuery("#previous_button").attr("disabled",!0))}};function steppedFormSave(t,e,r){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(t){this.click()});var a=jQuery("#"+t),i=!1;if(jQuery("#form_status").val(e),"save"==e){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("#item-form").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("#item-form").position().top},"slow"),!1;jQuery("#item-form").removeClass("dirty")}return a&&jQuery(a).ajaxSubmit({datatype:"JSON",async:!1,success:function(t){var a=JSON.parse(t);if(null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(t,e){Joomla.renderMessages({error:[e]})}),jQuery("html, body").animate({scrollTop:jQuery("#item-form").position().top},"slow")),null!==a.message&&""!=a.message&&(Joomla.renderMessages({info:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#item-form").position().top},"slow")),null!==a.data){jQuery("#recordId").val(a.data.id),"save"==e?(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(t,e){jQuery("input[name='"+e.elementName+"']").val(e.content_id)}),tjucmRelatedFieldUpdatedOptions=a.data.relatedFieldOptions,jQuery.each(a.data.relatedFieldOptions,function(t,e){jQuery("#"+e.elementId).html(""),jQuery.each(e.options,function(t,r){var a="";"1"==r.selected&&(a=' selected="selected" '),jQuery("#"+e.elementId).append('")}),jQuery("#"+e.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(t){this.click()})}}),i}function itemformactions(t,e){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"==e&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==e&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} \ No newline at end of file From 93ee6ba06e550e0b7180936423c2db37be47ecc2 Mon Sep 17 00:00:00 2001 From: ankush-maherwal Date: Fri, 21 Feb 2020 14:39:52 +0530 Subject: [PATCH 148/273] Update default.php --- src/components/com_tjucm/site/views/items/tmpl/default.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 34349779..db0ae775 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -162,7 +162,7 @@ function copyItem() } ?>
- +
- pagination->getListFooter(); ?> -
+ pagination->getListFooter(); ?> +
From 430bac6e88b459cd183cc61ea08ee291da03e8f2 Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Mon, 24 Feb 2020 19:26:34 +0530 Subject: [PATCH 150/273] Task #156455 feat: Front end>> User getting zero result when the Text Draft entered in search box. --- .../com_tjucm/site/models/items.php | 7 +++++ .../site/views/items/tmpl/default_filters.php | 30 ++++++++++++++++--- .../com_tjucm/site/views/items/view.html.php | 3 ++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 65ea3349..988ede84 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -138,6 +138,13 @@ protected function populateState($ordering = "a.id", $direction = "DESC") $this->setState($ucmType . '.filter.cluster_id', $clusterId); } + $draft = $app->getUserStateFromRequest($this->context . '.draft', 'draft'); + + if ($draft) + { + $this->setState('filter.draft', $draft); + } + $this->setState('ucm.client', $ucmType); $this->setState("ucmType.id", $typeId); 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 27e04593..c2391ce9 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 @@ -19,20 +19,34 @@
- + +
+ enabled) { JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR); @@ -47,7 +61,11 @@ ?> canEditOwn = $user->authorise('core.type.editownitem', 'com_tjucm.type.' . $this->ucmTypeId); $this->canDelete = $user->authorise('core.type.deleteitem', 'com_tjucm.type.' . $this->ucmTypeId); $this->canDeleteOwn = $user->authorise('core.type.deleteownitem', 'com_tjucm.type.' . $this->ucmTypeId); + $this->draft = array( "0" => "Submitted", "1" => "Draft"); // If did not get the client from url then get if from menu param if (empty($this->client)) From 838c21f405cabd8a72b266a6baac00db262cd736 Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Tue, 25 Feb 2020 19:22:19 +0530 Subject: [PATCH 151/273] Task #156455 feat: Front end>> User getting zero result when the Text Draft entered in search box. --- .../languages/site/en-GB/en-GB.com_tjucm.ini | 1 + src/components/com_tjucm/site/models/items.php | 13 +++++++++++-- .../com_tjucm/site/views/items/view.html.php | 3 ++- 3 files changed, 14 insertions(+), 3 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 696ffec5..0c368d5a 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 @@ -196,6 +196,7 @@ COM_TJUCM_SOMETHING_WENT_WRONG="Something went wrong" COM_TJUCM_DATA_STATUS_DRAFT="Draft" COM_TJUCM_DATA_STATUS_SAVE="Saved" COM_TJUCM_DATA_STATUS="Status" +COM_TJUCM_DATA_STATUS_SELECT_OPTION="Select item status" ; Since 1.2.4 COM_TJUCM_ITEMS_UPLOAD_CSV_FILE_HELP="Note: To import records using CSV file for this form you should have CSV file in the following format. %s to download sample CSV file" diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 988ede84..226610ae 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -140,9 +140,9 @@ protected function populateState($ordering = "a.id", $direction = "DESC") $draft = $app->getUserStateFromRequest($this->context . '.draft', 'draft'); - if ($draft) + if ($draft != '-' ) { - $this->setState('filter.draft', $draft); + $this->setState('filter.draft', (int) $draft); } $this->setState('ucm.client', $ucmType); @@ -283,6 +283,13 @@ protected function getListQuery() $query->where(($db->quoteName('(a.state) ') . ' IN (0, 1)')); } + // Filter by draft status + $draft = $this->getState('filter.draft'); + + if ($draft !== null) + { + $query->where($db->quoteName('a.draft') . ' = ' . (int) $draft); + } // Search by content id $search = $this->getState($client . '.filter.search'); @@ -336,6 +343,8 @@ protected function getListQuery() /** * Function to filter content as per field values * + * @param string $client Client + * * @return Array Content Ids * * @since 1.2.1 diff --git a/src/components/com_tjucm/site/views/items/view.html.php b/src/components/com_tjucm/site/views/items/view.html.php index 098870ae..a3ed61e3 100644 --- a/src/components/com_tjucm/site/views/items/view.html.php +++ b/src/components/com_tjucm/site/views/items/view.html.php @@ -102,7 +102,8 @@ public function display($tpl = null) $this->canEditOwn = $user->authorise('core.type.editownitem', 'com_tjucm.type.' . $this->ucmTypeId); $this->canDelete = $user->authorise('core.type.deleteitem', 'com_tjucm.type.' . $this->ucmTypeId); $this->canDeleteOwn = $user->authorise('core.type.deleteownitem', 'com_tjucm.type.' . $this->ucmTypeId); - $this->draft = array( "0" => "Submitted", "1" => "Draft"); + $this->draft = array("-" => JText::_('COM_TJUCM_DATA_STATUS_SELECT_OPTION'), + "0" => JText::_("COM_TJUCM_DATA_STATUS_SAVE"), "1" => JText::_('COM_TJUCM_DATA_STATUS_DRAFT')); // If did not get the client from url then get if from menu param if (empty($this->client)) From 943b4981d895d3120c0c562355b53b5570aae5d6 Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Wed, 26 Feb 2020 11:43:35 +0530 Subject: [PATCH 152/273] Task #156455 feat: Front end>> User getting zero result when the Text Draft entered in search box. --- src/components/com_tjucm/site/models/items.php | 10 +++------- .../com_tjucm/site/views/items/view.html.php | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 226610ae..babd152a 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -139,11 +139,7 @@ protected function populateState($ordering = "a.id", $direction = "DESC") } $draft = $app->getUserStateFromRequest($this->context . '.draft', 'draft'); - - if ($draft != '-' ) - { - $this->setState('filter.draft', (int) $draft); - } + $this->setState('filter.draft', $draft); $this->setState('ucm.client', $ucmType); $this->setState("ucmType.id", $typeId); @@ -286,9 +282,9 @@ protected function getListQuery() // Filter by draft status $draft = $this->getState('filter.draft'); - if ($draft !== null) + if ($draft != '') { - $query->where($db->quoteName('a.draft') . ' = ' . (int) $draft); + $query->where($db->quoteName('a.draft') . ' = ' . $draft); } // Search by content id $search = $this->getState($client . '.filter.search'); diff --git a/src/components/com_tjucm/site/views/items/view.html.php b/src/components/com_tjucm/site/views/items/view.html.php index a3ed61e3..9d79de02 100644 --- a/src/components/com_tjucm/site/views/items/view.html.php +++ b/src/components/com_tjucm/site/views/items/view.html.php @@ -102,7 +102,7 @@ public function display($tpl = null) $this->canEditOwn = $user->authorise('core.type.editownitem', 'com_tjucm.type.' . $this->ucmTypeId); $this->canDelete = $user->authorise('core.type.deleteitem', 'com_tjucm.type.' . $this->ucmTypeId); $this->canDeleteOwn = $user->authorise('core.type.deleteownitem', 'com_tjucm.type.' . $this->ucmTypeId); - $this->draft = array("-" => JText::_('COM_TJUCM_DATA_STATUS_SELECT_OPTION'), + $this->draft = array("" => JText::_('COM_TJUCM_DATA_STATUS_SELECT_OPTION'), "0" => JText::_("COM_TJUCM_DATA_STATUS_SAVE"), "1" => JText::_('COM_TJUCM_DATA_STATUS_DRAFT')); // If did not get the client from url then get if from menu param From 8e1a754ccf5635b714b6da34a974bde8dd7b6bb7 Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Wed, 26 Feb 2020 15:02:11 +0530 Subject: [PATCH 153/273] Bug #157397 fix: FrontEnd>> User getting blank pop up once tap on button of the 'Copy to another'. --- src/components/com_tjucm/site/helpers/tjucm.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/com_tjucm/site/helpers/tjucm.php b/src/components/com_tjucm/site/helpers/tjucm.php index 51be6798..bd958cc6 100644 --- a/src/components/com_tjucm/site/helpers/tjucm.php +++ b/src/components/com_tjucm/site/helpers/tjucm.php @@ -77,6 +77,7 @@ public static function getLanguageConstantForJs() Text::script('COM_TJUCM_FIELDS_VALIDATION_ERROR_NUMBER', true); Text::script('COM_TJUCM_MSG_ON_SAVED_FORM', true); Text::script('COM_TJUCM_ITEMS_INVALID_CSV_FILE', true); + Text::script('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST', true); } /** From f71dd1419b1cf5ef416ce4d6f31e95d97504811f Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Wed, 26 Feb 2020 18:18:41 +0530 Subject: [PATCH 154/273] Task #156455 feat: Front end>> User getting zero result when the Text Draft entered in search box. --- src/components/com_tjucm/site/models/items.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index babd152a..e59f2f2f 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -282,7 +282,7 @@ protected function getListQuery() // Filter by draft status $draft = $this->getState('filter.draft'); - if ($draft != '') + if (in_array($draft, array('0', '1'))) { $query->where($db->quoteName('a.draft') . ' = ' . $draft); } From e8299969b1919dc61045109dbff2f7f42928dfc0 Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Fri, 28 Feb 2020 11:21:03 +0530 Subject: [PATCH 155/273] Bug #158265 fix: Front-end>>Form view: Submit buttons get disabled after click on when sub-form is not filled --- .../com_tjucm/site/controllers/itemform.json.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 7da39ebd..74462925 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -277,13 +277,16 @@ public function saveFormData() $subFormFieldName = str_replace('jform[', '', $field->name); $subFormFieldName = str_replace(']', '', $subFormFieldName); - foreach ($formData[$subFormFieldName] as $ucmSubFormData) + if (!empty($formData[$subFormFieldName])) { - $ucmSubFormData = $model->validate($subForm, $ucmSubFormData); - - if ($ucmSubFormData === false) + foreach ($formData[$subFormFieldName] as $ucmSubFormData) { - $data = false; + $ucmSubFormData = $model->validate($subForm, $ucmSubFormData); + + if ($ucmSubFormData === false) + { + $data = false; + } } } } From 8fd21bf240aa2b958124f6f833fa46db933e8228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cankush=5Fm=E2=80=9D?= Date: Wed, 4 Mar 2020 11:59:02 +0530 Subject: [PATCH 156/273] Bug #123 fix: the migration issue --- .../com_tjucm/administrator/houseKeeping/1.2.4/updateAlias.php | 1 + 1 file changed, 1 insertion(+) 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 410f3787..735b74fc 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 @@ -33,6 +33,7 @@ public function migrate() { JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_tjucm/tables'); JTable::addIncludePath(JPATH_ROOT . '/administrator/components/com_menus/tables'); + JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_ADMINISTRATOR); // TJ-Fields helper object $tjfieldsHelper = new TjfieldsHelper; From 1380f46d5d564553381d379e615cb02a023ddc65 Mon Sep 17 00:00:00 2001 From: Aishwarya Date: Fri, 6 Mar 2020 14:32:00 +0530 Subject: [PATCH 157/273] Bug #154977 fix: Edge>> Pagination should be visible outside the scrollbar not inside it. --- .../site/views/items/tmpl/default.php | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) 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 c3a8c250..be991251 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -266,22 +266,14 @@ function copyItem() } ?> - +
+items)) { - ?> - - - - pagination->getListFooter(); ?> - - - - pagination->getListFooter(); } - ?> - -
+?> Date: Wed, 11 Mar 2020 17:22:56 +0530 Subject: [PATCH 158/273] 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 177/273] 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 178/273] 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 179/273] 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 180/273] 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 181/273] 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 182/273] 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 183/273] 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 184/273] 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 185/273] 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 186/273] 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 187/273] 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 188/273] 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 189/273] 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 190/273] 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 191/273] 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 192/273] 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 193/273] 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 194/273] 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 195/273] 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 196/273] 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 197/273] 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 bb4c4355a0cc2b38e76690b790ee2c6f19dfbfdf Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Mon, 15 Jun 2020 21:34:30 +0530 Subject: [PATCH 198/273] Task #162316 feat: Support Parent ID in UCM Import --- .../com_tjucm/site/controllers/items.php | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/controllers/items.php b/src/components/com_tjucm/site/controllers/items.php index f752b089..e6e97d90 100644 --- a/src/components/com_tjucm/site/controllers/items.php +++ b/src/components/com_tjucm/site/controllers/items.php @@ -151,10 +151,17 @@ public function importCsv() elseif (count($headers) == count($data)) { $itemData = array(); + $parentid = 0; // Prepare item data for item creation foreach ($data as $key => $value) { + if ($headers[$key] === 'parentid') + { + $parentid = $value; + continue; + } + $fieldName = array_search($headers[$key], $fieldHeaders); $value = trim($value); @@ -226,10 +233,22 @@ public function importCsv() $form = $tjucmItemFormModel->getTypeForm($fieldsData); $data = $tjucmItemFormModel->validate($form, $itemData); + // Check if parent is Valid + if ($parentid) + { + $tableParentData = $tjucmItemFormModel->getTable(); + $tableParentData->load(array('id' => $parentid)); + + if (!property_exists($tableParentData->id) && (!$tableParentData->id)) + { + $data = false; + } + } + if ($data !== false) { // Save the record in UCM - if ($tjucmItemFormModel->save(array('client' => $client))) + if ($tjucmItemFormModel->save(array('client' => $client, 'parent_id' => $parentid))) { $contentId = (int) $tjucmItemFormModel->getState($tjucmItemFormModel->getName() . '.id'); From 3f368222bda76e7872f34963fcf73a84c010e4eb Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Tue, 16 Jun 2020 21:31:37 +0530 Subject: [PATCH 199/273] Task #162316 feat: Support Parent ID in UCM Import --- .../languages/site/en-GB/en-GB.com_tjucm.ini | 2 ++ .../com_tjucm/site/controllers/items.php | 22 +++++++--------- .../com_tjucm/site/models/itemform.php | 26 +++++++++++++++++++ 3 files changed, 38 insertions(+), 12 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..63f4f0a9 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 @@ -157,6 +157,8 @@ COM_TJUCM_NOTE_ON_FORM="Please make sure you have filled all the fields before y COM_TJUCM_MSG_ON_SAVED_FORM="Data saved successfully." COM_TJUCM_MSG_ON_DRAFT_FORM="Saved as draft successfully" COM_TJUCM_ALLOWED_COUNT_LIMIT="You are allowed to fill this form upto %d time(s) only" +COM_TJUCM_SUBFORM_NOT_ALLOWED_WITH_OUT_PARENT_ID="You can not save subform without parent ID" +COM_TJUCM_INVALID_PARENT_ID="Parent ID is invalid." COM_TJUCM_NO_FIELDS_TO_SHOW_ON_LIST_VIEW="Please set 'Show on list view' to 'yes' for at least one field of this UCM type" COM_TJUCM_ITEMFORM_SUBMIT_ALERT="Are you sure you want to submit this form?"; COM_TJUCM_NO_ACTIVITIES="There are no activities here yet" diff --git a/src/components/com_tjucm/site/controllers/items.php b/src/components/com_tjucm/site/controllers/items.php index e6e97d90..756a4ed8 100644 --- a/src/components/com_tjucm/site/controllers/items.php +++ b/src/components/com_tjucm/site/controllers/items.php @@ -233,18 +233,6 @@ public function importCsv() $form = $tjucmItemFormModel->getTypeForm($fieldsData); $data = $tjucmItemFormModel->validate($form, $itemData); - // Check if parent is Valid - if ($parentid) - { - $tableParentData = $tjucmItemFormModel->getTable(); - $tableParentData->load(array('id' => $parentid)); - - if (!property_exists($tableParentData->id) && (!$tableParentData->id)) - { - $data = false; - } - } - if ($data !== false) { // Save the record in UCM @@ -323,6 +311,10 @@ public function getCsvImportFormat() $ucmTypeTable = Table::getInstance('Type', 'TjucmTable'); $ucmTypeTable->load(array("unique_identifier" => $client)); + // Check if UCM type is subform + $ucmTypeParams = new Registry($ucmTypeTable->params); + $isSubform = $ucmTypeParams->get('is_subform'); + // Get fields in the given UCM type JLoader::import('components.com_tjfields.models.fields', JPATH_ADMINISTRATOR); $tjFieldsFieldsModel = BaseDatabaseModel::getInstance('Fields', 'TjfieldsModel', array('ignore_request' => true)); @@ -333,6 +325,12 @@ public function getCsvImportFormat() $fields = $tjFieldsFieldsModel->getItems(); $fieldsLabel = array_column($fields, 'label'); + if ($isSubform) + { + // Add parentid in colunm + array_push($fieldsLabel, 'parentid'); + } + // Generate schema CSV file with CSV headers as label of the fields for given UCM type and save it in temp folder $fileName = preg_replace('/[^A-Za-z0-9\-]/', '', $ucmTypeTable->title) . '.csv'; $csvFileTmpPath = Factory::getConfig()->get('tmp_path') . '/' . $fileName; diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index 5ccbb910..559c968f 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -21,6 +21,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Component\ComponentHelper; use Joomla\Registry\Registry; +use Joomla\CMS\Language\Text; /** * Tjucm model. @@ -534,6 +535,31 @@ public function save($data) } $ucmTypeParams = new Registry($tjUcmTypeTable->params); + // Check if UCM type is subform + $isSubform = $ucmTypeParams->get('is_subform'); + + if ($isSubform) + { + if ($data['parent_id']) + { + $tableParentData = $this->getTable(); + $tableParentData->load(array('id' => $data['parent_id'])); + + if (!property_exists($tableParentData->id) && (!$tableParentData->id)) + { + $this->setError(Text::_('COM_TJUCM_INVALID_PARENT_ID')); + + return false; + } + } + + if (!$data['parent_id']) + { + $this->setError(Text::_('COM_TJUCM_SUBFORM_NOT_ALLOWED_WITH_OUT_PARENT_ID')); + + return false; + } + } // Check if user is allowed to add/edit the record if (empty($data['id'])) From 0cc57c96dea32704ed8583f75c62400a717d8aa2 Mon Sep 17 00:00:00 2001 From: ankush-maherwal Date: Wed, 17 Jun 2020 11:17:25 +0530 Subject: [PATCH 200/273] Update en-GB.com_tjucm.ini --- .../com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 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 63f4f0a9..e74a7b5f 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 @@ -157,8 +157,8 @@ COM_TJUCM_NOTE_ON_FORM="Please make sure you have filled all the fields before y COM_TJUCM_MSG_ON_SAVED_FORM="Data saved successfully." COM_TJUCM_MSG_ON_DRAFT_FORM="Saved as draft successfully" COM_TJUCM_ALLOWED_COUNT_LIMIT="You are allowed to fill this form upto %d time(s) only" -COM_TJUCM_SUBFORM_NOT_ALLOWED_WITH_OUT_PARENT_ID="You can not save subform without parent ID" -COM_TJUCM_INVALID_PARENT_ID="Parent ID is invalid." +COM_TJUCM_SUBFORM_NOT_ALLOWED_WITH_OUT_PARENT_ID="You can not save child form's record without parent form's record ID" +COM_TJUCM_INVALID_PARENT_ID="Parent form's record ID (parent id) is invalid." COM_TJUCM_NO_FIELDS_TO_SHOW_ON_LIST_VIEW="Please set 'Show on list view' to 'yes' for at least one field of this UCM type" COM_TJUCM_ITEMFORM_SUBMIT_ALERT="Are you sure you want to submit this form?"; COM_TJUCM_NO_ACTIVITIES="There are no activities here yet" From d8f0e40fe9ab49638883117e9473847bd15fd7f5 Mon Sep 17 00:00:00 2001 From: ankush-maherwal Date: Wed, 17 Jun 2020 11:18:48 +0530 Subject: [PATCH 201/273] Update en-GB.com_tjucm.ini --- .../com_tjucm/languages/site/en-GB/en-GB.com_tjucm.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 e74a7b5f..af1b82f5 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 @@ -158,7 +158,7 @@ COM_TJUCM_MSG_ON_SAVED_FORM="Data saved successfully." COM_TJUCM_MSG_ON_DRAFT_FORM="Saved as draft successfully" COM_TJUCM_ALLOWED_COUNT_LIMIT="You are allowed to fill this form upto %d time(s) only" COM_TJUCM_SUBFORM_NOT_ALLOWED_WITH_OUT_PARENT_ID="You can not save child form's record without parent form's record ID" -COM_TJUCM_INVALID_PARENT_ID="Parent form's record ID (parent id) is invalid." +COM_TJUCM_INVALID_PARENT_ID="Parent form's record ID (parent_id) is invalid." COM_TJUCM_NO_FIELDS_TO_SHOW_ON_LIST_VIEW="Please set 'Show on list view' to 'yes' for at least one field of this UCM type" COM_TJUCM_ITEMFORM_SUBMIT_ALERT="Are you sure you want to submit this form?"; COM_TJUCM_NO_ACTIVITIES="There are no activities here yet" From 53fee27726be1400632b2506109bf6bf5294ff20 Mon Sep 17 00:00:00 2001 From: ankush-maherwal Date: Wed, 17 Jun 2020 11:20:18 +0530 Subject: [PATCH 202/273] Update items.php --- src/components/com_tjucm/site/controllers/items.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/items.php b/src/components/com_tjucm/site/controllers/items.php index 756a4ed8..10a9f094 100644 --- a/src/components/com_tjucm/site/controllers/items.php +++ b/src/components/com_tjucm/site/controllers/items.php @@ -151,14 +151,14 @@ public function importCsv() elseif (count($headers) == count($data)) { $itemData = array(); - $parentid = 0; + $parentId = 0; // Prepare item data for item creation foreach ($data as $key => $value) { if ($headers[$key] === 'parentid') { - $parentid = $value; + $parentId = $value; continue; } @@ -236,7 +236,7 @@ public function importCsv() if ($data !== false) { // Save the record in UCM - if ($tjucmItemFormModel->save(array('client' => $client, 'parent_id' => $parentid))) + if ($tjucmItemFormModel->save(array('client' => $client, 'parent_id' => $parentId))) { $contentId = (int) $tjucmItemFormModel->getState($tjucmItemFormModel->getName() . '.id'); From 7af067df93b5a82fa461dc496b915859b741ad95 Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Wed, 17 Jun 2020 11:27:16 +0530 Subject: [PATCH 203/273] Task #162316 feat: changes --- src/components/com_tjucm/site/controllers/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/items.php b/src/components/com_tjucm/site/controllers/items.php index 10a9f094..a974a459 100644 --- a/src/components/com_tjucm/site/controllers/items.php +++ b/src/components/com_tjucm/site/controllers/items.php @@ -156,7 +156,7 @@ public function importCsv() // Prepare item data for item creation foreach ($data as $key => $value) { - if ($headers[$key] === 'parentid') + if ($headers[$key] === 'parent_id') { $parentId = $value; continue; @@ -328,7 +328,7 @@ public function getCsvImportFormat() if ($isSubform) { // Add parentid in colunm - array_push($fieldsLabel, 'parentid'); + array_push($fieldsLabel, 'parent_id'); } // Generate schema CSV file with CSV headers as label of the fields for given UCM type and save it in temp folder From 1ab06f5577dbac2bec04ba3c0b440e466193f543 Mon Sep 17 00:00:00 2001 From: Kishori Date: Tue, 30 Jun 2020 18:51:23 +0530 Subject: [PATCH 204/273] Bug #162716: UCM subform should inherit the status of publish/Unpublish as per parent form --- src/components/com_tjucm/site/models/item.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/site/models/item.php b/src/components/com_tjucm/site/models/item.php index 8d7c199f..b374d3a5 100644 --- a/src/components/com_tjucm/site/models/item.php +++ b/src/components/com_tjucm/site/models/item.php @@ -256,10 +256,23 @@ public function publish(&$id, $state = 1) { $table = $this->getTable(); $table->load($id); - $table->draft = $state == 1 ? 0 : 1; $table->state = $state; - return $table->store(); + if($table->store()) + { + JLoader::import('components.com_tjucm.models.items', JPATH_SITE); + $itemsModel = BaseDatabaseModel::getInstance('Items', 'TjucmModel', array('ignore_request' => true)); + $itemsModel->setState("parent_id", $id); + $children = $itemsModel->getItems(); + + foreach ($children as $child) + { + $childTable = $this->getTable(); + $childTable->load($child->id); + $childTable->state = $state; + $childTable->store(); + } + } } /** From 1f983d4b0651eb2655843cdd19e0953d768e3d24 Mon Sep 17 00:00:00 2001 From: Kishori Date: Mon, 6 Jul 2020 17:59:59 +0530 Subject: [PATCH 205/273] Bug #162716 fix: UCM subform should inherit the status of publish --- src/components/com_tjucm/site/models/item.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/site/models/item.php b/src/components/com_tjucm/site/models/item.php index b374d3a5..ba9351d3 100644 --- a/src/components/com_tjucm/site/models/item.php +++ b/src/components/com_tjucm/site/models/item.php @@ -258,18 +258,31 @@ public function publish(&$id, $state = 1) $table->load($id); $table->state = $state; - if($table->store()) + // Only if item is published + if ($state == 1) + { + $table->draft = 0; + } + + if ($table->store()) { JLoader::import('components.com_tjucm.models.items', JPATH_SITE); $itemsModel = BaseDatabaseModel::getInstance('Items', 'TjucmModel', array('ignore_request' => true)); $itemsModel->setState("parent_id", $id); $children = $itemsModel->getItems(); - + foreach ($children as $child) { $childTable = $this->getTable(); $childTable->load($child->id); $childTable->state = $state; + + // Only if item is published + if ($state == 1) + { + $childTable->draft = 0; + } + $childTable->store(); } } From fe8f8b49c6cacc63035485f59b6046bfec92becd Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Mon, 13 Jul 2020 14:22:37 +0530 Subject: [PATCH 206/273] 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 447f4e3417ee73b6e66d1c16cf7a35960f9df686 Mon Sep 17 00:00:00 2001 From: Kishori Date: Wed, 22 Jul 2020 17:05:50 +0530 Subject: [PATCH 207/273] Task #162657 chore: Added trigger for on after publish the record --- src/components/com_tjucm/site/controllers/item.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/components/com_tjucm/site/controllers/item.php b/src/components/com_tjucm/site/controllers/item.php index ab40ac17..3c0fd406 100644 --- a/src/components/com_tjucm/site/controllers/item.php +++ b/src/components/com_tjucm/site/controllers/item.php @@ -167,6 +167,10 @@ public function publish() // If there isn't any menu item active, redirect to list view $itemId = $tjUcmFrontendHelper->getItemId('index.php?option=com_tjucm&view=items' . $this->client); $this->setRedirect(JRoute::_('index.php?option=com_tjucm&view=items' . $this->appendUrl . '&Itemid=' . $itemId, false)); + + // Call trigger on after publish the record + $dispatcher = JDispatcher::getInstance(); + $dispatcher->trigger('onAfterPublishUCMRecord', array($id)); } else { From df017048dece752b9ca5e5072048c670549a6657 Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Wed, 22 Jul 2020 17:40:04 +0530 Subject: [PATCH 208/273] 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; } From aa6ac940f75e465d46aa6071c7873244f4434ef7 Mon Sep 17 00:00:00 2001 From: Kishori Date: Thu, 23 Jul 2020 15:56:25 +0530 Subject: [PATCH 209/273] Task #162657 chore: Added trigger for on after publish the record --- src/components/com_tjucm/site/controllers/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/controllers/item.php b/src/components/com_tjucm/site/controllers/item.php index 298935ce..451c5b22 100644 --- a/src/components/com_tjucm/site/controllers/item.php +++ b/src/components/com_tjucm/site/controllers/item.php @@ -167,7 +167,7 @@ public function publish() // Call trigger on after publish the record $dispatcher = JDispatcher::getInstance(); - $dispatcher->trigger('onAfterPublishUCMRecord', array($id)); + $dispatcher->trigger('tjUcmOnAfterStateChangeItem', array($id, $state)); } else { From 8e03f7290d7fd2c166ae42216be7dc0d07b77046 Mon Sep 17 00:00:00 2001 From: Kishori Date: Thu, 23 Jul 2020 16:13:03 +0530 Subject: [PATCH 210/273] Task #162657 chore: Added trigger for on after publish the record --- src/components/com_tjucm/site/controllers/item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/com_tjucm/site/controllers/item.php b/src/components/com_tjucm/site/controllers/item.php index 451c5b22..b774f1c0 100644 --- a/src/components/com_tjucm/site/controllers/item.php +++ b/src/components/com_tjucm/site/controllers/item.php @@ -165,7 +165,7 @@ public function publish() $itemId = $tjUcmFrontendHelper->getItemId('index.php?option=com_tjucm&view=items' . $this->client); $this->setRedirect(JRoute::_('index.php?option=com_tjucm&view=items' . $this->appendUrl . '&Itemid=' . $itemId, false)); - // Call trigger on after publish the record + // Call trigger on after publish/unpublish the record $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('tjUcmOnAfterStateChangeItem', array($id, $state)); } From fc4c35d8758df37d95e956298882224bf83bd3d8 Mon Sep 17 00:00:00 2001 From: Ankush Maherwal Date: Fri, 24 Jul 2020 10:41:55 +0530 Subject: [PATCH 211/273] Task #369 feat: Add sort functionality using fields value on to the list view --- .../com_tjucm/site/layouts/list/list.php | 114 ++--------- .../com_tjucm/site/models/items.php | 183 ++++-------------- .../site/views/items/tmpl/default.php | 2 +- 3 files changed, 57 insertions(+), 242 deletions(-) diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 56fd4708..909861bb 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -43,10 +43,6 @@ 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']; @@ -141,100 +137,29 @@ field_values)) + if (!empty($item)) { - foreach ($item->field_values as $key => $fieldValue) + foreach ($item as $key => $fieldValue) { - $tjFieldsFieldTable = $fieldsData[$key]; - - $canView = false; - - if ($user->authorise('core.field.viewfieldvalue', 'com_tjfields.group.' . $tjFieldsFieldTable->group_id)) + if (array_key_exists($key, $displayData['listcolumn'])) { - $canView = $user->authorise('core.field.viewfieldvalue', 'com_tjfields.field.' . $tjFieldsFieldTable->id); - } - - $fieldXml = $formObject->getFieldXml($tjFieldsFieldTable->name); - ?> - - created_by == $user->id)) - { - $field = $formObject->getField($tjFieldsFieldTable->name); - $field->setValue($fieldValue); - - 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; + $tjFieldsFieldTable = $fieldsData[$key]; - if (!empty($ucmSubFormData)) - { - $count = 0; + $canView = false; - foreach ($ucmSubFormData as $subFormData) - { - $count++; - $contentIdFieldname = str_replace('.', '_', $ucmSubFormClient) . '_contentid'; + if ($user->authorise('core.field.viewfieldvalue', 'com_tjfields.group.' . $tjFieldsFieldTable->group_id)) + { + $canView = $user->authorise('core.field.viewfieldvalue', 'com_tjfields.field.' . $tjFieldsFieldTable->id); + } - $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 "
"; - } - } - } - ?> -
-
- getFieldXml($tjFieldsFieldTable->name); + ?> + + created_by == $user->id)) { + $field = $formObject->getField($tjFieldsFieldTable->name); + $field->setValue($fieldValue); $layoutToUse = ( array_key_exists( ucfirst($tjFieldsFieldTable->type), $fieldLayout @@ -244,9 +169,10 @@ $output = $layout->render(array('fieldXml' => $fieldXml, 'field' => $field)); echo $output; } - } - ?> - + + diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 03b24d34..3e3f2f15 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -197,22 +197,17 @@ protected function getListQuery() $query = $db->getQuery(true); // Select the required fields from the table. - $query->select( - $this->getState( - 'list.select', 'DISTINCT ' . $db->quoteName('a.id') . ', ' - . $db->quoteName('a.state') . ', ' - . $db->quoteName('a.cluster_id') . ', ' - . $db->quoteName('a.draft') . ', ' - . $db->quoteName('a.created_date') . ', ' - . $db->quoteName('a.created_by') - ) - ); + $query->select('a.*'); + + foreach ($this->fields as $fieldId => $field) + { + $query->select('MAX(CASE WHEN fv.field_id=' . $fieldId . ' THEN value END) `' . $fieldId . '`'); + } $query->from($db->quoteName('#__tj_ucm_data', 'a')); // Join over the users for the checked out user - $query->select($db->quoteName('uc.name', 'uEditor')); - $query->join("LEFT", $db->quoteName('#__users', 'uc') . ' ON (' . $db->quoteName('uc.id') . ' = ' . $db->quoteName('a.checked_out') . ')'); + $query->join("LEFT", $db->quoteName('#__tjfields_fields_value', 'fv') . ' ON (' . $db->quoteName('fv.content_id') . ' = ' . $db->quoteName('a.id') . ')'); $client = $this->getState('ucm.client'); @@ -325,21 +320,7 @@ protected function getListQuery() } // Search on fields data - $filteredItemIds = $this->filterContent($client); - - if ($filteredItemIds) - { - if (!empty($filteredItemIds) && is_array($filteredItemIds)) - { - $filteredItemIds = implode(',', $filteredItemIds); - $query->where($db->quoteName('a.id') . ' IN (' . $filteredItemIds . ')'); - } - else - { - // If no search results found then do not return any record - $query->where($db->quoteName('a.id') . '=0'); - } - } + $this->filterContent($client, $query); // Filter by cluster $clusterId = (int) $this->getState($client . '.filter.cluster_id'); @@ -353,9 +334,11 @@ protected function getListQuery() $orderCol = $this->state->get('list.ordering'); $orderDirn = $this->state->get('list.direction'); + $query->group($db->quoteName('a.id')); + if ($orderCol && $orderDirn) { - $query->order($db->escape($orderCol . ' ' . $orderDirn)); + $query->order($db->escape($db->qn($orderCol) . ' ' . $orderDirn)); } return $query; @@ -365,31 +348,26 @@ protected function getListQuery() * Function to filter content as per field values * * @param string $client Client + * + * @param OBJECT &$query query object * * @return Array Content Ids * * @since 1.2.1 */ - private function filterContent($client) + private function filterContent($client, &$query) { + $db = $this->getDbo(); + $subQuery = $db->getQuery(true); + $subQuery->select(1); + $subQuery->from($db->quoteName('#__tjfields_fields_value', 'v')); + // Flag to mark if field specific search is done from the search box $filterFieldFound = 0; - // Flag to mark if any filter is applied or not - $filterApplied = 0; - // Variable to store count of the self joins on the fields_value table $filterFieldsCount = 0; - // Apply search filter - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select('fv1.content_id'); - $query->from($db->quoteName('#__tjfields_fields_value', 'fv1')); - $query->join('INNER', $db->qn('#__tjfields_fields', 'f') . ' ON (' . $db->qn('fv1.field_id') . ' = ' . $db->qn('f.id') . ')'); - $query->where($db->quoteName('f.state') . ' =1'); - $query->where($db->quoteName('f.client') . ' = ' . $db->quote($client)); - // Filter by field value $search = $this->getState($client . '.filter.search'); @@ -402,17 +380,13 @@ private function filterContent($client) { $filterFieldsCount++; - if ($filterFieldsCount > 1) - { - $query->join('LEFT', $db->qn('#__tjfields_fields_value', 'fv' . $filterFieldsCount) . ' ON (' . $db->qn('fv' . - ($filterFieldsCount - 1) . '.content_id') . ' = ' . $db->qn('fv' . $filterFieldsCount . '.content_id') . ')'); - } + $subQuery->join('LEFT', $db->qn('#__tjfields_fields_value', 'v' . $filterFieldsCount) . ' ON (' . $db->qn('v' . + '.content_id') . ' = ' . $db->qn('v' . $filterFieldsCount . '.content_id') . ')'); $search = trim(str_replace($field . ':', '', $search)); - $query->where($db->qn('fv' . $filterFieldsCount . '.field_id') . ' = ' . $fieldId); - $query->where($db->qn('fv' . $filterFieldsCount . '.value') . ' LIKE ' . $db->q('%' . $search . '%')); + $subQuery->where($db->qn('v' . $filterFieldsCount . '.field_id') . ' = ' . $fieldId); + $subQuery->where($db->qn('v' . $filterFieldsCount . '.value') . ' LIKE ' . $db->q('%' . $search . '%')); $filterFieldFound = 1; - $filterApplied = 1; break; } @@ -424,14 +398,9 @@ private function filterContent($client) { $filterFieldsCount++; - if ($filterFieldsCount > 1) - { - $query->join('LEFT', $db->qn('#__tjfields_fields_value', 'fv' . $filterFieldsCount) . ' ON (' . $db->qn('fv' . - ($filterFieldsCount - 1) . '.content_id') . ' = ' . $db->qn('fv' . $filterFieldsCount . '.content_id') . ')'); - } - - $query->where($db->quoteName('fv' . $filterFieldsCount . '.value') . ' LIKE ' . $db->q('%' . $search . '%')); - $filterApplied = 1; + $subQuery->join('LEFT', $db->qn('#__tjfields_fields_value', 'v' . $filterFieldsCount) . ' ON (' . $db->qn('v' . + '.content_id') . ' = ' . $db->qn('v' . $filterFieldsCount . '.content_id') . ')'); + $subQuery->where($db->quoteName('v' . $filterFieldsCount . '.value') . ' LIKE ' . $db->q('%' . $search . '%')); } // For filterable fields @@ -450,51 +419,34 @@ private function filterContent($client) { $filterFieldsCount++; - if ($filterFieldsCount > 1) - { - $query->join('LEFT', $db->qn('#__tjfields_fields_value', 'fv' . $filterFieldsCount) . ' ON (' . $db->qn('fv' . - ($filterFieldsCount - 1) . '.content_id') . ' = ' . $db->qn('fv' . $filterFieldsCount . '.content_id') . ')'); - } - - $query->where($db->qn('fv' . $filterFieldsCount . '.field_id') . ' = ' . $field->id); + $subQuery->join('LEFT', $db->qn('#__tjfields_fields_value', 'v' . $filterFieldsCount) . ' ON (' . $db->qn('v' . + '.content_id') . ' = ' . $db->qn('v' . $filterFieldsCount . '.content_id') . ')'); + $subQuery->where($db->qn('v' . $filterFieldsCount . '.field_id') . ' = ' . $field->id); if ($filteroptionId) { // Check option id blank or null if ($filteroptionId == 'other') { - $query->where('(' . $db->qn('fv' . $filterFieldsCount . '.option_id') . - ' is null OR ' . $db->qn('fv' . $filterFieldsCount . '.option_id') . ' = 0 )'); + $subQuery->where('(' . $db->qn('v' . $filterFieldsCount . '.option_id') . + ' is null OR ' . $db->qn('v' . $filterFieldsCount . '.option_id') . ' = 0 )'); } else { - $query->where($db->qn('fv' . $filterFieldsCount . '.option_id') . ' = ' . $db->q($filteroptionId)); + $subQuery->where($db->qn('v' . $filterFieldsCount . '.option_id') . ' = ' . $db->q($filteroptionId)); } } else { - $query->where($db->qn('fv' . $filterFieldsCount . '.value') . ' = ' . $db->q($filterValue)); + $subQuery->where($db->qn('v' . $filterFieldsCount . '.value') . ' = ' . $db->q($filterValue)); } - - $filterApplied = 1; } } - $query->order('fv1.content_id DESC'); - $query->group('fv1.content_id'); - - // If there is any filter applied then only execute the query - if ($filterApplied) - { - $db->setQuery($query); - - $filteredRecord = $db->loadColumn(); - - return empty($filteredRecord)? true : $filteredRecord; - } - else + if ($filterFieldsCount > 0) { - return false; + $subQuery->where($db->qn('v.content_id') . '=' . $db->qn('a.id')); + $query->where("EXISTS (" . $subQuery . ")"); } } @@ -531,69 +483,6 @@ public function getFields() return $data; } - /** - * Get an array of data items - * - * @return mixed Array of data items on success, false on failure. - */ - public function getItems() - { - $items = parent::getItems(); - $itemsArray = (array) $items; - $contentIds = array_column($itemsArray, 'id'); - $fieldValues = $this->getFieldsData($contentIds); - - foreach ($items as &$item) - { - $item->field_values = array(); - - foreach ($fieldValues as $key => &$fieldValue) - { - if ($item->id == $fieldValue->content_id) - { - if (isset($item->field_values[$fieldValue->field_id])) - { - if (is_array($item->field_values[$fieldValue->field_id])) - { - $item->field_values[$fieldValue->field_id] = array_merge($item->field_values[$fieldValue->field_id], array($fieldValue->value)); - } - else - { - $item->field_values[$fieldValue->field_id] = array_merge(array($item->field_values[$fieldValue->field_id]), array($fieldValue->value)); - } - } - else - { - $item->field_values[$fieldValue->field_id] = $fieldValue->value; - } - - unset($fieldValues[$key]); - } - } - } - - foreach ($items as &$item) - { - $fieldValues = array(); - - foreach ($this->fields as $fieldId => $fieldValue) - { - if (!array_key_exists($fieldId, $item->field_values)) - { - $fieldValues[$fieldId] = ""; - } - else - { - $fieldValues[$fieldId] = $item->field_values[$fieldId]; - } - } - - $item->field_values = $fieldValues; - } - - return $items; - } - /** * Method to fields data for given content Ids * 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 e9b5df0a..f4d9cd24 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -192,7 +192,7 @@ function copyItem() ?> - + Date: Fri, 24 Jul 2020 11:05:55 +0530 Subject: [PATCH 212/273] Task #369 feat: Add sort functionality using fields value on to the list view --- .../com_tjucm/site/layouts/list/list.php | 182 +++++++++--------- 1 file changed, 93 insertions(+), 89 deletions(-) diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 56fd4708..47cdd2c3 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -141,112 +141,116 @@ field_values)) + if (!empty($item)) { - foreach ($item->field_values as $key => $fieldValue) + foreach ($item as $key => $fieldValue) { - $tjFieldsFieldTable = $fieldsData[$key]; - - $canView = false; - - if ($user->authorise('core.field.viewfieldvalue', 'com_tjfields.group.' . $tjFieldsFieldTable->group_id)) + if (array_key_exists($key, $displayData['listcolumn'])) { - $canView = $user->authorise('core.field.viewfieldvalue', 'com_tjfields.field.' . $tjFieldsFieldTable->id); - } + $tjFieldsFieldTable = $fieldsData[$key]; - $fieldXml = $formObject->getFieldXml($tjFieldsFieldTable->name); - ?> - - created_by == $user->id)) - { - $field = $formObject->getField($tjFieldsFieldTable->name); - $field->setValue($fieldValue); + $canView = false; - if ($field->type == 'Ucmsubform' && $fieldValue) + if ($user->authorise('core.field.viewfieldvalue', 'com_tjfields.group.' . $tjFieldsFieldTable->group_id)) + { + $canView = $user->authorise('core.field.viewfieldvalue', 'com_tjfields.field.' . $tjFieldsFieldTable->id); + } + + $fieldXml = $formObject->getFieldXml($tjFieldsFieldTable->name); + ?> + + created_by == $user->id)) { - $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)) - { + $field = $formObject->getField($tjFieldsFieldTable->name); + $field->setValue($fieldValue); + + if ($field->type == 'Ucmsubform' && $fieldValue) + { + $ucmSubFormData = json_decode($tjucmItemFormModel->getUcmSubFormFieldDataJson($item->id, $field)); + $field->setValue($ucmSubFormData); + ?> +
+
label; ?>:
+
+ getFormExtra( - array( - "clientComponent" => 'com_tjucm', - "client" => $ucmSubFormClient, - "view" => $view[1], - "layout" => 'default', - "content_id" => $subFormData->$contentIdFieldname) - ); + // Get Subform field data + $fieldData = $TjfieldsHelper->getFieldData($field->getAttribute('name')); - $ucmSubFormFormXml = simplexml_load_file($field->formsource); + $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; - $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 (!empty($ucmSubFormData)) + { + $count = 0; - if (count($ucmSubFormData) > $count) + foreach ($ucmSubFormData as $subFormData) { - echo "
"; + $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; + } } - else - { - $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; - } - } - ?> - + + From 832834fa46b59f96499973068c897e9ffdfb32fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Caishwarya?= <“aishwarya_b@techjoomla.com”> Date: Tue, 4 Aug 2020 14:17:23 +0530 Subject: [PATCH 213/273] Task #163718 feat:solving phpcs errors for various components --- src/components/com_tjucm/administrator/controllers/types.php | 2 +- .../administrator/houseKeeping/1.2.3/updateClientName.php | 4 ++-- src/components/com_tjucm/administrator/models/type.php | 5 +++-- src/components/com_tjucm/site/models/itemform.php | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/com_tjucm/administrator/controllers/types.php b/src/components/com_tjucm/administrator/controllers/types.php index 8fb4ed69..dd832451 100644 --- a/src/components/com_tjucm/administrator/controllers/types.php +++ b/src/components/com_tjucm/administrator/controllers/types.php @@ -320,7 +320,7 @@ public function import() foreach ($options as &$option) { - $fieldOptions['fieldoption'.$optionCount] = array("name" => $option->options, "value" => $option->value); + $fieldOptions['fieldoption' . $optionCount] = array("name" => $option->options, "value" => $option->value); $optionCount++; } } diff --git a/src/components/com_tjucm/administrator/houseKeeping/1.2.3/updateClientName.php b/src/components/com_tjucm/administrator/houseKeeping/1.2.3/updateClientName.php index 1d6015d8..3cd32a52 100644 --- a/src/components/com_tjucm/administrator/houseKeeping/1.2.3/updateClientName.php +++ b/src/components/com_tjucm/administrator/houseKeeping/1.2.3/updateClientName.php @@ -124,8 +124,8 @@ public function migrate() } else { - $tjfieldsFieldTable->name = str_replace('.', '_', $updatedUniqueIdentifier) . '_' . - strtolower(preg_replace("/[^a-zA-Z0-9]/", "", $field->label)); + $tjfieldsFieldTable->name = str_replace('.', '_', $updatedUniqueIdentifier) + . '_' . strtolower(preg_replace("/[^a-zA-Z0-9]/", "", $field->label)); } $tjfieldsFieldTable->store(); diff --git a/src/components/com_tjucm/administrator/models/type.php b/src/components/com_tjucm/administrator/models/type.php index d5723981..9fa2d43d 100644 --- a/src/components/com_tjucm/administrator/models/type.php +++ b/src/components/com_tjucm/administrator/models/type.php @@ -310,8 +310,9 @@ public function save($data) } // Remove white spaces from alias if any - //$data['alias'] = str_replace(" ", "_", trim($data['alias'])); - $data['alias'] =JFilterOutput::stringURLSafe($data['alias']); + // $data['alias'] = str_replace(" ", "_", trim($data['alias'])); + $data['alias'] = JFilterOutput::stringURLSafe($data['alias']); + if (!empty($data['id'])) { $field_group = $this->getGroupCount($data['unique_identifier']); diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index c754501a..6c231273 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -535,7 +535,7 @@ public function save($data) } $ucmTypeParams = new Registry($tjUcmTypeTable->params); - + // Check if UCM type is subform $isSubform = $ucmTypeParams->get('is_subform'); From 89a8e66e2cb18141956158a4d0c056875a291f85 Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Tue, 11 Aug 2020 09:07:40 +0530 Subject: [PATCH 214/273] Feature #163782 feat : Related Field : Auto Populate options without page refresh --- .../com_tjucm/media/js/services/item.js | 7 +++ .../com_tjucm/media/js/services/item.min.js | 2 +- .../com_tjucm/media/js/ui/itemform.js | 47 +++++++++++++++++++ .../com_tjucm/media/js/ui/itemform.min.js | 2 +- 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/media/js/services/item.js b/src/components/com_tjucm/media/js/services/item.js index 533f5ad8..7386c331 100755 --- a/src/components/com_tjucm/media/js/services/item.js +++ b/src/components/com_tjucm/media/js/services/item.js @@ -11,6 +11,7 @@ com_tjucm.Services.Item = new (com_tjucm.Services.Base.extend({ saveFormDataUrl: window.tjSiteRoot + "index.php?option=com_tjucm&format=json&task=itemform.saveFormData", autoSaveFieldDataUrl: window.tjSiteRoot + "index.php?option=com_tjucm&format=json&task=itemform.saveFieldData", getRelatedFieldUpdatedOptionsUrl: window.tjSiteRoot + "index.php?option=com_tjucm&format=json&task=itemform.getRelatedFieldOptions", + getUpdatedRelatedFieldOptions: window.tjSiteRoot + "index.php?option=com_tjucm&format=json&task=itemform.getUpdatedRelatedFieldOptions", config: { headers: {} }, @@ -32,6 +33,12 @@ com_tjucm.Services.Item = new (com_tjucm.Services.Base.extend({ getUpdatedRelatedFieldsOptions: function (tjUcmItemFormData, callback){ this.post(this.getRelatedFieldUpdatedOptionsUrl, tjUcmItemFormData, this.config, callback); }, + getRelatedFieldOptions: function (tjUcmItemFormData, callback){ + this.config.processData = false; + this.config.contentType = false; + this.config.async = false; + this.post(this.getUpdatedRelatedFieldOptions, tjUcmItemFormData, this.config, callback); + }, saveFormData: function (ucmFormData, callback) { this.config.processData = false; this.config.contentType = false; diff --git a/src/components/com_tjucm/media/js/services/item.min.js b/src/components/com_tjucm/media/js/services/item.min.js index d17d1695..f0f8c1db 100755 --- a/src/components/com_tjucm/media/js/services/item.min.js +++ b/src/components/com_tjucm/media/js/services/item.min.js @@ -1 +1 @@ -"use strict";com_tjucm.Services.Item=new(com_tjucm.Services.Base.extend({createNewRecordUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.save",saveFormDataUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.saveFormData",autoSaveFieldDataUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.saveFieldData",getRelatedFieldUpdatedOptionsUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.getRelatedFieldOptions",config:{headers:{}},response:{success:"",message:""},create:function(ucmTypeData,callback){this.config.processData=false;this.config.contentType=false;this.post(this.createNewRecordUrl,ucmTypeData,this.config,callback)},saveFieldData:function(ucmFormData,callback){this.config.processData=false;this.config.contentType=false;this.post(this.autoSaveFieldDataUrl,ucmFormData,this.config,callback)},getUpdatedRelatedFieldsOptions:function(tjUcmItemFormData,callback){this.post(this.getRelatedFieldUpdatedOptionsUrl,tjUcmItemFormData,this.config,callback)},saveFormData:function(ucmFormData,callback){this.config.processData=false;this.config.contentType=false;this.post(this.saveFormDataUrl,ucmFormData,this.config,callback)}})); \ No newline at end of file +'use strict';com_tjucm.Services.Item=new(com_tjucm.Services.Base.extend({createNewRecordUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.save",saveFormDataUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.saveFormData",autoSaveFieldDataUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.saveFieldData",getRelatedFieldUpdatedOptionsUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.getRelatedFieldOptions",getUpdatedRelatedFieldOptions:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.getUpdatedRelatedFieldOptions",config:{headers:{}},response:{success:"",message:""},create:function(a,b){this.config.processData=!1,this.config.contentType=!1,this.config.async=!1,this.post(this.createNewRecordUrl,a,this.config,b)},saveFieldData:function(a,b){this.config.processData=!1,this.config.contentType=!1,this.post(this.autoSaveFieldDataUrl,a,this.config,b)},getUpdatedRelatedFieldsOptions:function(a,b){this.post(this.getRelatedFieldUpdatedOptionsUrl,a,this.config,b)},getRelatedFieldOptions:function(a,b){this.config.processData=!1,this.config.contentType=!1,this.config.async=!1,this.post(this.getUpdatedRelatedFieldOptions,a,this.config,b)},saveFormData:function(a,b){this.config.processData=!1,this.config.contentType=!1,this.post(this.saveFormDataUrl,a,this.config,b)}})); diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 1ca1043c..659f05b8 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -1006,6 +1006,53 @@ var tjUcmItemForm = { jQuery("#previous_button").attr('disabled', true); } } + }, + getRelatedFieldOptions: function (fieldName, fieldId) { + var tjUcmItemFormData = new FormData(); + var FieldsData = {fieldName: fieldName , fieldId: fieldId}; + + var tjUcmUpdateRelatedFieldsOptions = function (error, response){ + response = JSON.parse(response); + tjucmRelatedFieldUpdatedOptions = response.data; + + if(tjucmRelatedFieldUpdatedOptions == '') + { + return false; + } + + var selectOption = ''; + var op = ''; + var data = response.data; + + for(var index = 0; index < data.length; ++index) + { + selectOption = ''; + if(typeof FieldsData.SelectedValues !== 'undefined' && FieldsData.SelectedValues.length > 0) + { + if (FieldsData.SelectedValues.includes(data[index].value)) + { + selectOption = ' selected="selected" '; + } + } + + op="" ; + jQuery('#'+relatedFieldId).append(op); + } + + // Update to chz-done selects + jQuery('#'+relatedFieldId).trigger("liszt:updated"); + }; + + var relatedFieldId = 'jform_'+fieldName; + FieldsData.SelectedValues = jQuery('#jform_'+fieldName).val(); + + if (jQuery.trim(fieldId) != '' && fieldId != 'undefined') + { + jQuery('#'+relatedFieldId+', .chzn-results').empty(); + tjUcmItemFormData.append('fieldId', fieldId); + tjUcmItemFormData.append('fieldName', fieldName); + com_tjucm.Services.Item.getRelatedFieldOptions(tjUcmItemFormData, tjUcmUpdateRelatedFieldsOptions); + } } }; 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 25388259..b836df51 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()):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")} +var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=[],tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=[],tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var a=+jQuery("#itemState").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){var d=jQuery("#item-form #tjucm-autosave").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==d){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)}),0"+c.text+"")}),jQuery(b).find("#"+e).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")){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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 if(tjUcmCurrentAutoSaveState){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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(a,b){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=new Promise(function(b,d){var e=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==e){var f=new FormData;""!=c&&f.append("client",c),f.append(Joomla.getOptions("csrf.token"),1);var g=function(a,c){if(c=JSON.parse(c),null==a)if(null!==c.data&&jQuery.isNumeric(c.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(c.data.id);var e=window.location.href.split("#")[0],f=-1===e.indexOf("?")?"?":"&",g="id="+c.data.id;0<=e.indexOf(g)||(e+=f+g),history.pushState(null,null,e),b(c.data.id)}else d(c)};f.append("draft",a),com_tjucm.Services.Item.create(f,g)}else jQuery.isNumeric(e)&&0!=e&&b(e)});d.then(function(a){b(a)}).catch(function(a){return console.log(a),!1})},onUcmFormChange:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(b){var c=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(a,c,b)})},initUcmFormFieldDataSave:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d="",e=new FormData;if(e.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(a).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(a).parent().parent().parent().parent().attr("data-base-name")){var f=jQuery(a).parent().parent().parent().attr("data-base-name");null==f&&(f=jQuery(a).parent().parent().parent().parent().attr("data-base-name"));var g=jQuery(a).attr("id");d=g.replace(g.split("_").pop(),"contentid");var h="com_tjucm."+d.split("__").pop().replace("_contentid","").replace("com_tjucm_",""),i=jQuery("#"+d).val();if(""==i){var j=function(g,i){if(i=JSON.parse(i),null==g){null!==i.data&&jQuery.isNumeric(i.data.id)&&jQuery("#"+d).val(i.data.id);var j=function(){var b=jQuery(a).attr("name"),c="[]"==b.slice(-2)?"[]":"",d="jform["+jQuery(a).attr("id").split("__").pop()+"]"+c;if("radio"==jQuery(a).attr("type"))var d="jform["+jQuery(a).attr("name").split("][").pop();jQuery(a).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(h,i.data.id,a),jQuery(a).attr("name",b)};return e.append("jform["+f+"]",h),e.append("client",b),e.append("recordid",c),com_tjucm.Services.Item.saveFieldData(e,j),!0}};e.append("parent_id",c),e.append("client",h),e.append("draft",1),com_tjucm.Services.Item.create(e,j)}else{if(jQuery.isNumeric(i)&&0!=i){var k=jQuery(a).attr("name"),l="[]"==k.slice(-2)?"[]":"",m="jform["+jQuery(a).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(a).attr("type"))var m="jform["+jQuery(a).attr("name").split("][").pop();return jQuery(a).attr("name",m),tjUcmItemForm.saveUcmFormFieldData(h,i,a),jQuery(a).attr("name",k),!0}null==i&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(b,c,a),!0},saveUcmFormFieldData:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d=new FormData;return d.append(Joomla.getOptions("csrf.token"),1),d.append("client",a),d.append("recordid",b),"checkbox"==jQuery(c).attr("type")?!0==jQuery(c).prop("checked")?d.append(jQuery(c).attr("name"),1):d.append(jQuery(c).attr("name"),0):jQuery(c).hasClass("tjfieldTjList")?(""!=jQuery(c).val()&&null!=jQuery(c).val()?d.append(jQuery(c).attr("name"),jQuery(c).val()):d.append(jQuery(c).attr("name"),""),""!=jQuery("input#"+jQuery(c).attr("id")).val()&&null!=jQuery("input#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("input#"+jQuery(c).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(c).attr("id")).data("role")?(""!=jQuery("#"+jQuery(c).attr("id")).val()&&null!=jQuery("#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("#"+jQuery(c).attr("id")).val()),""!=jQuery(c).val()&&null!=jQuery(c).val()&&d.append(jQuery(c).attr("name"),jQuery(c).val())):"file"==jQuery(c).attr("type")?d.append(jQuery(c).attr("name"),jQuery(c)[0].files[0]):null==jQuery(c).val()?d.append(jQuery(c).attr("name"),""):d.append(jQuery(c).attr("name"),jQuery(c).val()),""!=jQuery(c).attr("name")&&null!=jQuery(c).attr("name")&&com_tjucm.Services.Item.saveFieldData(d,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(a,b){if(jQuery("#item-form #tjucm_loader").hide(),b=JSON.parse(b),jQuery("#item-form").removeClass("dirty"),null==b)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=b.data&&b.data.childContentIds&&jQuery.each(b.data.childContentIds,function(a,b){jQuery("#"+a).val(b)}),b.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(),b.data){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(c,d)}tjUcmItemForm.renderResponseMessages(b)},renderResponseMessages:function(a){null!=a&&(null!==a.message&&(a.data?Joomla.renderMessages({success:[a.message]}):Joomla.renderMessages({error:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(a,b){var c=new FormData,d=function(a,b){return b=JSON.parse(b),tjucmRelatedFieldUpdatedOptions=b.data,""!=tjucmRelatedFieldUpdatedOptions&&void jQuery.each(b.data,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")})};c.append("client",a),c.append("content_id",b),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(c,d)},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),event===void 0?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):"tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?tjUcmFormSubmitCallingButtonId=event.target.id:tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave";var a=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(document.formvalidator.isValid(document.getElementById("item-form"))){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)}else 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;a=0}jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(a,function(){var a=document.getElementById("item-form"),b=new FormData(a);b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&b.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery("#item-form input[type=\"checkbox\"]").each(function(){!0==jQuery(this).prop("checked")?b.append(jQuery(this).attr("name"),1):b.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){null==jQuery(this).val()&&b.append(jQuery(this).attr("name"),"")}),tjUcmSaveFormInDraftWithNoMsg!==void 0&&(tjUcmSaveFormInDraftWithNoMsg=void 0,b.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()})},saveSectionData:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var b=new FormData,c=jQuery(a).find("input, textarea, select, fieldset");return tjUcmItemForm.validateSection(c)?void(jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),c.length&&c.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&b.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?!0==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&b.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(){b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),b.append("tjUcmFormSection",jQuery("a[href='"+a+"']").html()),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)})):(jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1)},validateSection:function(a){var b,c,d,e,f,g=!0,h=[];for(e=0,f=a.length;e "+g[h].text+"",jQuery("#"+f).append(e);jQuery("#"+f).trigger("liszt:updated")},f="jform_"+a;d.SelectedValues=jQuery("#jform_"+a).val(),""!=jQuery.trim(b)&&"undefined"!=b&&(jQuery("#"+f+", .chzn-results").empty(),c.append("fieldId",b),c.append("fieldName",a),com_tjucm.Services.Item.getRelatedFieldOptions(c,e))}};function steppedFormSave(a,b,c){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(){this.click()});var d=jQuery("#"+a),e=!1;if(jQuery("#form_status").val(b),"save"==b)if(document.formvalidator.isValid("#item-form")){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")}else 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;return d&&jQuery(d).ajaxSubmit({datatype:"JSON",async:!1,success:function(a){var d=JSON.parse(a);if(null!==d.messages&&null!==d.messages.error&&(jQuery.each(d.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.message&&""!=d.message&&(Joomla.renderMessages({info:[d.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.data){jQuery("#recordId").val(d.data.id),"save"==b?(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")):(e=!0,"1"===c&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var f=window.location.href.split("#")[0],g=-1===f.indexOf("?")?"?":"&",h="id="+d.data.id;jQuery.each(d.data.childContentIds,function(a,b){jQuery("input[name='"+b.elementName+"']").val(b.content_id)}),tjucmRelatedFieldUpdatedOptions=d.data.relatedFieldOptions,jQuery.each(d.data.relatedFieldOptions,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")}),0<=f.indexOf(h)||(f+=g+h),history.pushState(null,null,f)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(){this.click()})}}),e}function itemformactions(a,b){var c=jQuery("ul#tjucm_myTabTabs").find("li.active a");jQuery(c).next("li")==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),jQuery(c).prev("li")==null?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 d=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),e=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");d==null?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),e==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==b&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==b&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} From e91dfd9623eda3e38478e257e2a383411c01162c Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Tue, 11 Aug 2020 09:56:29 +0530 Subject: [PATCH 215/273] Feature #163782 feat : Related Field : Auto Populate options without page refresh --- .../site/controllers/itemform.json.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 9ca345f0..20c85305 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -754,4 +754,38 @@ public function copyItem() } } } + /** + * Method to get Related Field Options for the field. + * + * @return null + * + * @since 1.0.0 + */ + public function getUpdatedRelatedFieldOptions() + { + $app = Factory::getApplication(); + $FieldsData['fieldId'] = $app->input->get('fieldId', '', 'STRING'); + + // Check for request forgeries. + if (!Session::checkToken()) + { + echo new JsonResponse(null, Text::_('JINVALID_TOKEN'), true); + $app->close(); + } + + // Get object of TJ-Fields field model + JLoader::import('components.com_tjfields.models.field', JPATH_ADMINISTRATOR); + $tjFieldsModelField = JModelLegacy::getInstance('Field', 'TjfieldsModel'); + $options = $tjFieldsModelField->getRelatedFieldOptions($FieldsData['fieldId']); + + $relatedFieldOptions = array(); + + foreach ($options as $option) + { + $relatedFieldOptions[] = HTMLHelper::_('select.option', trim($option['value']), trim($option['text'])); + } + + echo new JsonResponse($relatedFieldOptions); + $app->close(); + } } From 1505af47fc52b06008e02f4b36e37af2d5df2497 Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Tue, 11 Aug 2020 11:00:12 +0530 Subject: [PATCH 216/273] Feature #163782 feat : Related Field : Auto Populate options without page refresh --- src/components/com_tjucm/media/js/services/item.js | 1 - src/components/com_tjucm/media/js/ui/itemform.js | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/com_tjucm/media/js/services/item.js b/src/components/com_tjucm/media/js/services/item.js index 7386c331..5cb2f6c6 100755 --- a/src/components/com_tjucm/media/js/services/item.js +++ b/src/components/com_tjucm/media/js/services/item.js @@ -36,7 +36,6 @@ com_tjucm.Services.Item = new (com_tjucm.Services.Base.extend({ getRelatedFieldOptions: function (tjUcmItemFormData, callback){ this.config.processData = false; this.config.contentType = false; - this.config.async = false; this.post(this.getUpdatedRelatedFieldOptions, tjUcmItemFormData, this.config, callback); }, saveFormData: function (ucmFormData, callback) { diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index 659f05b8..ae248779 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -1010,6 +1010,7 @@ var tjUcmItemForm = { getRelatedFieldOptions: function (fieldName, fieldId) { var tjUcmItemFormData = new FormData(); var FieldsData = {fieldName: fieldName , fieldId: fieldId}; + var ajaxUrl = Joomla.getOptions('system.paths').base + "/index.php?option=com_tjucm&task=itemform.getUpdatedRelatedFieldOptions&format=json"; var tjUcmUpdateRelatedFieldsOptions = function (error, response){ response = JSON.parse(response); @@ -1027,7 +1028,7 @@ var tjUcmItemForm = { for(var index = 0; index < data.length; ++index) { selectOption = ''; - if(typeof FieldsData.SelectedValues !== 'undefined' && FieldsData.SelectedValues.length > 0) + if(FieldsData.SelectedValues !== null && typeof FieldsData.SelectedValues !== 'undefined' && FieldsData.SelectedValues.length > 0) { if (FieldsData.SelectedValues.includes(data[index].value)) { @@ -1039,7 +1040,7 @@ var tjUcmItemForm = { jQuery('#'+relatedFieldId).append(op); } - // Update to chz-done selects + //~ /* IMP : to update to chz-done selects*/ jQuery('#'+relatedFieldId).trigger("liszt:updated"); }; @@ -1051,6 +1052,7 @@ var tjUcmItemForm = { jQuery('#'+relatedFieldId+', .chzn-results').empty(); tjUcmItemFormData.append('fieldId', fieldId); tjUcmItemFormData.append('fieldName', fieldName); + tjUcmItemFormData.append('FieldsData', FieldsData); com_tjucm.Services.Item.getRelatedFieldOptions(tjUcmItemFormData, tjUcmUpdateRelatedFieldsOptions); } } From 98c1329ba7d8e322e7d4bec9969091161dc36311 Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Tue, 11 Aug 2020 11:04:29 +0530 Subject: [PATCH 217/273] Feature #163782 feat : Related Field : Auto Populate options without page refresh --- src/components/com_tjucm/media/js/ui/itemform.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index ae248779..65b56f3d 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -1010,7 +1010,6 @@ var tjUcmItemForm = { getRelatedFieldOptions: function (fieldName, fieldId) { var tjUcmItemFormData = new FormData(); var FieldsData = {fieldName: fieldName , fieldId: fieldId}; - var ajaxUrl = Joomla.getOptions('system.paths').base + "/index.php?option=com_tjucm&task=itemform.getUpdatedRelatedFieldOptions&format=json"; var tjUcmUpdateRelatedFieldsOptions = function (error, response){ response = JSON.parse(response); From d1925f5aec0d189be39a81a27408e433b4cf57c1 Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Tue, 11 Aug 2020 11:07:23 +0530 Subject: [PATCH 218/273] Feature #163782 feat : Related Field : Auto Populate options without page refresh --- src/components/com_tjucm/site/controllers/itemform.json.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 20c85305..e8bd90d8 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -763,8 +763,8 @@ public function copyItem() */ public function getUpdatedRelatedFieldOptions() { - $app = Factory::getApplication(); - $FieldsData['fieldId'] = $app->input->get('fieldId', '', 'STRING'); + $app = Factory::getApplication(); + $fieldId = $app->input->get('fieldId', '', 'STRING'); // Check for request forgeries. if (!Session::checkToken()) @@ -776,7 +776,7 @@ public function getUpdatedRelatedFieldOptions() // Get object of TJ-Fields field model JLoader::import('components.com_tjfields.models.field', JPATH_ADMINISTRATOR); $tjFieldsModelField = JModelLegacy::getInstance('Field', 'TjfieldsModel'); - $options = $tjFieldsModelField->getRelatedFieldOptions($FieldsData['fieldId']); + $options = $tjFieldsModelField->getRelatedFieldOptions($fieldId); $relatedFieldOptions = array(); From 446fc79a0ff028febb895a7a9c4589b5531c9c99 Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Tue, 11 Aug 2020 15:21:11 +0530 Subject: [PATCH 219/273] Feature #163782 feat : Related Field : Auto Populate options without page refresh --- src/components/com_tjucm/media/js/services/item.min.js | 2 +- src/components/com_tjucm/media/js/ui/itemform.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/com_tjucm/media/js/services/item.min.js b/src/components/com_tjucm/media/js/services/item.min.js index f0f8c1db..48391c84 100755 --- a/src/components/com_tjucm/media/js/services/item.min.js +++ b/src/components/com_tjucm/media/js/services/item.min.js @@ -1 +1 @@ -'use strict';com_tjucm.Services.Item=new(com_tjucm.Services.Base.extend({createNewRecordUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.save",saveFormDataUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.saveFormData",autoSaveFieldDataUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.saveFieldData",getRelatedFieldUpdatedOptionsUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.getRelatedFieldOptions",getUpdatedRelatedFieldOptions:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.getUpdatedRelatedFieldOptions",config:{headers:{}},response:{success:"",message:""},create:function(a,b){this.config.processData=!1,this.config.contentType=!1,this.config.async=!1,this.post(this.createNewRecordUrl,a,this.config,b)},saveFieldData:function(a,b){this.config.processData=!1,this.config.contentType=!1,this.post(this.autoSaveFieldDataUrl,a,this.config,b)},getUpdatedRelatedFieldsOptions:function(a,b){this.post(this.getRelatedFieldUpdatedOptionsUrl,a,this.config,b)},getRelatedFieldOptions:function(a,b){this.config.processData=!1,this.config.contentType=!1,this.config.async=!1,this.post(this.getUpdatedRelatedFieldOptions,a,this.config,b)},saveFormData:function(a,b){this.config.processData=!1,this.config.contentType=!1,this.post(this.saveFormDataUrl,a,this.config,b)}})); +'use strict';com_tjucm.Services.Item=new(com_tjucm.Services.Base.extend({createNewRecordUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.save",saveFormDataUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.saveFormData",autoSaveFieldDataUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.saveFieldData",getRelatedFieldUpdatedOptionsUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.getRelatedFieldOptions",getUpdatedRelatedFieldOptions:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.getUpdatedRelatedFieldOptions",config:{headers:{}},response:{success:"",message:""},create:function(a,b){this.config.processData=!1,this.config.contentType=!1,this.config.async=!1,this.post(this.createNewRecordUrl,a,this.config,b)},saveFieldData:function(a,b){this.config.processData=!1,this.config.contentType=!1,this.post(this.autoSaveFieldDataUrl,a,this.config,b)},getUpdatedRelatedFieldsOptions:function(a,b){this.post(this.getRelatedFieldUpdatedOptionsUrl,a,this.config,b)},getRelatedFieldOptions:function(a,b){this.config.processData=!1,this.config.contentType=!1,this.post(this.getUpdatedRelatedFieldOptions,a,this.config,b)},saveFormData:function(a,b){this.config.processData=!1,this.config.contentType=!1,this.post(this.saveFormDataUrl,a,this.config,b)}})); 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 b836df51..36f895ca 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=[],tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=[],tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var a=+jQuery("#itemState").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){var d=jQuery("#item-form #tjucm-autosave").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==d){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)}),0"+c.text+"")}),jQuery(b).find("#"+e).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")){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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 if(tjUcmCurrentAutoSaveState){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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(a,b){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=new Promise(function(b,d){var e=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==e){var f=new FormData;""!=c&&f.append("client",c),f.append(Joomla.getOptions("csrf.token"),1);var g=function(a,c){if(c=JSON.parse(c),null==a)if(null!==c.data&&jQuery.isNumeric(c.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(c.data.id);var e=window.location.href.split("#")[0],f=-1===e.indexOf("?")?"?":"&",g="id="+c.data.id;0<=e.indexOf(g)||(e+=f+g),history.pushState(null,null,e),b(c.data.id)}else d(c)};f.append("draft",a),com_tjucm.Services.Item.create(f,g)}else jQuery.isNumeric(e)&&0!=e&&b(e)});d.then(function(a){b(a)}).catch(function(a){return console.log(a),!1})},onUcmFormChange:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(b){var c=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(a,c,b)})},initUcmFormFieldDataSave:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d="",e=new FormData;if(e.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(a).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(a).parent().parent().parent().parent().attr("data-base-name")){var f=jQuery(a).parent().parent().parent().attr("data-base-name");null==f&&(f=jQuery(a).parent().parent().parent().parent().attr("data-base-name"));var g=jQuery(a).attr("id");d=g.replace(g.split("_").pop(),"contentid");var h="com_tjucm."+d.split("__").pop().replace("_contentid","").replace("com_tjucm_",""),i=jQuery("#"+d).val();if(""==i){var j=function(g,i){if(i=JSON.parse(i),null==g){null!==i.data&&jQuery.isNumeric(i.data.id)&&jQuery("#"+d).val(i.data.id);var j=function(){var b=jQuery(a).attr("name"),c="[]"==b.slice(-2)?"[]":"",d="jform["+jQuery(a).attr("id").split("__").pop()+"]"+c;if("radio"==jQuery(a).attr("type"))var d="jform["+jQuery(a).attr("name").split("][").pop();jQuery(a).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(h,i.data.id,a),jQuery(a).attr("name",b)};return e.append("jform["+f+"]",h),e.append("client",b),e.append("recordid",c),com_tjucm.Services.Item.saveFieldData(e,j),!0}};e.append("parent_id",c),e.append("client",h),e.append("draft",1),com_tjucm.Services.Item.create(e,j)}else{if(jQuery.isNumeric(i)&&0!=i){var k=jQuery(a).attr("name"),l="[]"==k.slice(-2)?"[]":"",m="jform["+jQuery(a).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(a).attr("type"))var m="jform["+jQuery(a).attr("name").split("][").pop();return jQuery(a).attr("name",m),tjUcmItemForm.saveUcmFormFieldData(h,i,a),jQuery(a).attr("name",k),!0}null==i&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(b,c,a),!0},saveUcmFormFieldData:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d=new FormData;return d.append(Joomla.getOptions("csrf.token"),1),d.append("client",a),d.append("recordid",b),"checkbox"==jQuery(c).attr("type")?!0==jQuery(c).prop("checked")?d.append(jQuery(c).attr("name"),1):d.append(jQuery(c).attr("name"),0):jQuery(c).hasClass("tjfieldTjList")?(""!=jQuery(c).val()&&null!=jQuery(c).val()?d.append(jQuery(c).attr("name"),jQuery(c).val()):d.append(jQuery(c).attr("name"),""),""!=jQuery("input#"+jQuery(c).attr("id")).val()&&null!=jQuery("input#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("input#"+jQuery(c).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(c).attr("id")).data("role")?(""!=jQuery("#"+jQuery(c).attr("id")).val()&&null!=jQuery("#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("#"+jQuery(c).attr("id")).val()),""!=jQuery(c).val()&&null!=jQuery(c).val()&&d.append(jQuery(c).attr("name"),jQuery(c).val())):"file"==jQuery(c).attr("type")?d.append(jQuery(c).attr("name"),jQuery(c)[0].files[0]):null==jQuery(c).val()?d.append(jQuery(c).attr("name"),""):d.append(jQuery(c).attr("name"),jQuery(c).val()),""!=jQuery(c).attr("name")&&null!=jQuery(c).attr("name")&&com_tjucm.Services.Item.saveFieldData(d,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(a,b){if(jQuery("#item-form #tjucm_loader").hide(),b=JSON.parse(b),jQuery("#item-form").removeClass("dirty"),null==b)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=b.data&&b.data.childContentIds&&jQuery.each(b.data.childContentIds,function(a,b){jQuery("#"+a).val(b)}),b.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(),b.data){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(c,d)}tjUcmItemForm.renderResponseMessages(b)},renderResponseMessages:function(a){null!=a&&(null!==a.message&&(a.data?Joomla.renderMessages({success:[a.message]}):Joomla.renderMessages({error:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(a,b){var c=new FormData,d=function(a,b){return b=JSON.parse(b),tjucmRelatedFieldUpdatedOptions=b.data,""!=tjucmRelatedFieldUpdatedOptions&&void jQuery.each(b.data,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")})};c.append("client",a),c.append("content_id",b),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(c,d)},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),event===void 0?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):"tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?tjUcmFormSubmitCallingButtonId=event.target.id:tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave";var a=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(document.formvalidator.isValid(document.getElementById("item-form"))){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)}else 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;a=0}jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(a,function(){var a=document.getElementById("item-form"),b=new FormData(a);b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&b.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery("#item-form input[type=\"checkbox\"]").each(function(){!0==jQuery(this).prop("checked")?b.append(jQuery(this).attr("name"),1):b.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){null==jQuery(this).val()&&b.append(jQuery(this).attr("name"),"")}),tjUcmSaveFormInDraftWithNoMsg!==void 0&&(tjUcmSaveFormInDraftWithNoMsg=void 0,b.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()})},saveSectionData:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var b=new FormData,c=jQuery(a).find("input, textarea, select, fieldset");return tjUcmItemForm.validateSection(c)?void(jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),c.length&&c.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&b.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?!0==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&b.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(){b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),b.append("tjUcmFormSection",jQuery("a[href='"+a+"']").html()),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)})):(jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1)},validateSection:function(a){var b,c,d,e,f,g=!0,h=[];for(e=0,f=a.length;e "+g[h].text+"",jQuery("#"+f).append(e);jQuery("#"+f).trigger("liszt:updated")},f="jform_"+a;d.SelectedValues=jQuery("#jform_"+a).val(),""!=jQuery.trim(b)&&"undefined"!=b&&(jQuery("#"+f+", .chzn-results").empty(),c.append("fieldId",b),c.append("fieldName",a),com_tjucm.Services.Item.getRelatedFieldOptions(c,e))}};function steppedFormSave(a,b,c){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(){this.click()});var d=jQuery("#"+a),e=!1;if(jQuery("#form_status").val(b),"save"==b)if(document.formvalidator.isValid("#item-form")){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")}else 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;return d&&jQuery(d).ajaxSubmit({datatype:"JSON",async:!1,success:function(a){var d=JSON.parse(a);if(null!==d.messages&&null!==d.messages.error&&(jQuery.each(d.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.message&&""!=d.message&&(Joomla.renderMessages({info:[d.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.data){jQuery("#recordId").val(d.data.id),"save"==b?(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")):(e=!0,"1"===c&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var f=window.location.href.split("#")[0],g=-1===f.indexOf("?")?"?":"&",h="id="+d.data.id;jQuery.each(d.data.childContentIds,function(a,b){jQuery("input[name='"+b.elementName+"']").val(b.content_id)}),tjucmRelatedFieldUpdatedOptions=d.data.relatedFieldOptions,jQuery.each(d.data.relatedFieldOptions,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")}),0<=f.indexOf(h)||(f+=g+h),history.pushState(null,null,f)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(){this.click()})}}),e}function itemformactions(a,b){var c=jQuery("ul#tjucm_myTabTabs").find("li.active a");jQuery(c).next("li")==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),jQuery(c).prev("li")==null?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 d=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),e=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");d==null?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),e==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==b&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==b&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} +var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=[],tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=[],tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var a=+jQuery("#itemState").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){var d=jQuery("#item-form #tjucm-autosave").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==d){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)}),0"+c.text+"")}),jQuery(b).find("#"+e).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")){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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 if(tjUcmCurrentAutoSaveState){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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(a,b){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=new Promise(function(b,d){var e=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==e){var f=new FormData;""!=c&&f.append("client",c),f.append(Joomla.getOptions("csrf.token"),1);var g=function(a,c){if(c=JSON.parse(c),null==a)if(null!==c.data&&jQuery.isNumeric(c.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(c.data.id);var e=window.location.href.split("#")[0],f=-1===e.indexOf("?")?"?":"&",g="id="+c.data.id;0<=e.indexOf(g)||(e+=f+g),history.pushState(null,null,e),b(c.data.id)}else d(c)};f.append("draft",a),com_tjucm.Services.Item.create(f,g)}else jQuery.isNumeric(e)&&0!=e&&b(e)});d.then(function(a){b(a)}).catch(function(a){return console.log(a),!1})},onUcmFormChange:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(b){var c=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(a,c,b)})},initUcmFormFieldDataSave:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d="",e=new FormData;if(e.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(a).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(a).parent().parent().parent().parent().attr("data-base-name")){var f=jQuery(a).parent().parent().parent().attr("data-base-name");null==f&&(f=jQuery(a).parent().parent().parent().parent().attr("data-base-name"));var g=jQuery(a).attr("id");d=g.replace(g.split("_").pop(),"contentid");var h="com_tjucm."+d.split("__").pop().replace("_contentid","").replace("com_tjucm_",""),i=jQuery("#"+d).val();if(""==i){var j=function(g,i){if(i=JSON.parse(i),null==g){null!==i.data&&jQuery.isNumeric(i.data.id)&&jQuery("#"+d).val(i.data.id);var j=function(){var b=jQuery(a).attr("name"),c="[]"==b.slice(-2)?"[]":"",d="jform["+jQuery(a).attr("id").split("__").pop()+"]"+c;if("radio"==jQuery(a).attr("type"))var d="jform["+jQuery(a).attr("name").split("][").pop();jQuery(a).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(h,i.data.id,a),jQuery(a).attr("name",b)};return e.append("jform["+f+"]",h),e.append("client",b),e.append("recordid",c),com_tjucm.Services.Item.saveFieldData(e,j),!0}};e.append("parent_id",c),e.append("client",h),e.append("draft",1),com_tjucm.Services.Item.create(e,j)}else{if(jQuery.isNumeric(i)&&0!=i){var k=jQuery(a).attr("name"),l="[]"==k.slice(-2)?"[]":"",m="jform["+jQuery(a).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(a).attr("type"))var m="jform["+jQuery(a).attr("name").split("][").pop();return jQuery(a).attr("name",m),tjUcmItemForm.saveUcmFormFieldData(h,i,a),jQuery(a).attr("name",k),!0}null==i&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(b,c,a),!0},saveUcmFormFieldData:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d=new FormData;return d.append(Joomla.getOptions("csrf.token"),1),d.append("client",a),d.append("recordid",b),"checkbox"==jQuery(c).attr("type")?!0==jQuery(c).prop("checked")?d.append(jQuery(c).attr("name"),1):d.append(jQuery(c).attr("name"),0):jQuery(c).hasClass("tjfieldTjList")?(""!=jQuery(c).val()&&null!=jQuery(c).val()?d.append(jQuery(c).attr("name"),jQuery(c).val()):d.append(jQuery(c).attr("name"),""),""!=jQuery("input#"+jQuery(c).attr("id")).val()&&null!=jQuery("input#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("input#"+jQuery(c).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(c).attr("id")).data("role")?(""!=jQuery("#"+jQuery(c).attr("id")).val()&&null!=jQuery("#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("#"+jQuery(c).attr("id")).val()),""!=jQuery(c).val()&&null!=jQuery(c).val()&&d.append(jQuery(c).attr("name"),jQuery(c).val())):"file"==jQuery(c).attr("type")?d.append(jQuery(c).attr("name"),jQuery(c)[0].files[0]):null==jQuery(c).val()?d.append(jQuery(c).attr("name"),""):d.append(jQuery(c).attr("name"),jQuery(c).val()),""!=jQuery(c).attr("name")&&null!=jQuery(c).attr("name")&&com_tjucm.Services.Item.saveFieldData(d,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(a,b){if(jQuery("#item-form #tjucm_loader").hide(),b=JSON.parse(b),jQuery("#item-form").removeClass("dirty"),null==b)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=b.data&&b.data.childContentIds&&jQuery.each(b.data.childContentIds,function(a,b){jQuery("#"+a).val(b)}),b.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(),b.data){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(c,d)}tjUcmItemForm.renderResponseMessages(b)},renderResponseMessages:function(a){null!=a&&(null!==a.message&&(a.data?Joomla.renderMessages({success:[a.message]}):Joomla.renderMessages({error:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(a,b){var c=new FormData,d=function(a,b){return b=JSON.parse(b),tjucmRelatedFieldUpdatedOptions=b.data,""!=tjucmRelatedFieldUpdatedOptions&&void jQuery.each(b.data,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")})};c.append("client",a),c.append("content_id",b),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(c,d)},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),event===void 0?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):"tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?tjUcmFormSubmitCallingButtonId=event.target.id:tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave";var a=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(document.formvalidator.isValid(document.getElementById("item-form"))){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)}else 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;a=0}jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(a,function(){var a=document.getElementById("item-form"),b=new FormData(a);b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&b.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery("#item-form input[type=\"checkbox\"]").each(function(){!0==jQuery(this).prop("checked")?b.append(jQuery(this).attr("name"),1):b.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){null==jQuery(this).val()&&b.append(jQuery(this).attr("name"),"")}),tjUcmSaveFormInDraftWithNoMsg!==void 0&&(tjUcmSaveFormInDraftWithNoMsg=void 0,b.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()})},saveSectionData:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var b=new FormData,c=jQuery(a).find("input, textarea, select, fieldset");return tjUcmItemForm.validateSection(c)?void(jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),c.length&&c.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&b.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?!0==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&b.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(){b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),b.append("tjUcmFormSection",jQuery("a[href='"+a+"']").html()),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)})):(jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1)},validateSection:function(a){var b,c,d,e,f,g=!0,h=[];for(e=0,f=a.length;e "+g[h].text+"",jQuery("#"+f).append(e);jQuery("#"+f).trigger("liszt:updated")},f="jform_"+a;d.SelectedValues=jQuery("#jform_"+a).val(),""!=jQuery.trim(b)&&"undefined"!=b&&(jQuery("#"+f+", .chzn-results").empty(),c.append("fieldId",b),c.append("fieldName",a),c.append("FieldsData",d),com_tjucm.Services.Item.getRelatedFieldOptions(c,e))}};function steppedFormSave(a,b,c){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(){this.click()});var d=jQuery("#"+a),e=!1;if(jQuery("#form_status").val(b),"save"==b)if(document.formvalidator.isValid("#item-form")){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")}else 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;return d&&jQuery(d).ajaxSubmit({datatype:"JSON",async:!1,success:function(a){var d=JSON.parse(a);if(null!==d.messages&&null!==d.messages.error&&(jQuery.each(d.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.message&&""!=d.message&&(Joomla.renderMessages({info:[d.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.data){jQuery("#recordId").val(d.data.id),"save"==b?(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")):(e=!0,"1"===c&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var f=window.location.href.split("#")[0],g=-1===f.indexOf("?")?"?":"&",h="id="+d.data.id;jQuery.each(d.data.childContentIds,function(a,b){jQuery("input[name='"+b.elementName+"']").val(b.content_id)}),tjucmRelatedFieldUpdatedOptions=d.data.relatedFieldOptions,jQuery.each(d.data.relatedFieldOptions,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")}),0<=f.indexOf(h)||(f+=g+h),history.pushState(null,null,f)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(){this.click()})}}),e}function itemformactions(a,b){var c=jQuery("ul#tjucm_myTabTabs").find("li.active a");jQuery(c).next("li")==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),jQuery(c).prev("li")==null?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 d=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),e=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");d==null?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),e==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==b&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==b&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} From 0bee75321c840df155513017e265948802550c43 Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Tue, 11 Aug 2020 15:51:41 +0530 Subject: [PATCH 220/273] Feature #163782 feat : Related Field : Auto Populate options without page refresh --- src/components/com_tjucm/site/controllers/itemform.json.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index e8bd90d8..1f07c467 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -18,6 +18,8 @@ use Joomla\Registry\Registry; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Response\JsonResponse; jimport('joomla.filesystem.file'); From 4682e368b48cc29ce6c6596e1bb6907435af5779 Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Tue, 11 Aug 2020 21:15:48 +0530 Subject: [PATCH 221/273] Feature #163782 feat : Related Field : Auto populate options without page refresh --- src/components/com_tjucm/media/js/ui/itemform.js | 2 -- src/components/com_tjucm/media/js/ui/itemform.min.js | 2 +- 2 files changed, 1 insertion(+), 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 65b56f3d..adf820b7 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -1050,8 +1050,6 @@ var tjUcmItemForm = { { jQuery('#'+relatedFieldId+', .chzn-results').empty(); tjUcmItemFormData.append('fieldId', fieldId); - tjUcmItemFormData.append('fieldName', fieldName); - tjUcmItemFormData.append('FieldsData', FieldsData); com_tjucm.Services.Item.getRelatedFieldOptions(tjUcmItemFormData, tjUcmUpdateRelatedFieldsOptions); } } 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 36f895ca..76b46202 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=[],tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=[],tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var a=+jQuery("#itemState").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){var d=jQuery("#item-form #tjucm-autosave").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==d){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)}),0"+c.text+"")}),jQuery(b).find("#"+e).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")){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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 if(tjUcmCurrentAutoSaveState){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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(a,b){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=new Promise(function(b,d){var e=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==e){var f=new FormData;""!=c&&f.append("client",c),f.append(Joomla.getOptions("csrf.token"),1);var g=function(a,c){if(c=JSON.parse(c),null==a)if(null!==c.data&&jQuery.isNumeric(c.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(c.data.id);var e=window.location.href.split("#")[0],f=-1===e.indexOf("?")?"?":"&",g="id="+c.data.id;0<=e.indexOf(g)||(e+=f+g),history.pushState(null,null,e),b(c.data.id)}else d(c)};f.append("draft",a),com_tjucm.Services.Item.create(f,g)}else jQuery.isNumeric(e)&&0!=e&&b(e)});d.then(function(a){b(a)}).catch(function(a){return console.log(a),!1})},onUcmFormChange:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(b){var c=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(a,c,b)})},initUcmFormFieldDataSave:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d="",e=new FormData;if(e.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(a).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(a).parent().parent().parent().parent().attr("data-base-name")){var f=jQuery(a).parent().parent().parent().attr("data-base-name");null==f&&(f=jQuery(a).parent().parent().parent().parent().attr("data-base-name"));var g=jQuery(a).attr("id");d=g.replace(g.split("_").pop(),"contentid");var h="com_tjucm."+d.split("__").pop().replace("_contentid","").replace("com_tjucm_",""),i=jQuery("#"+d).val();if(""==i){var j=function(g,i){if(i=JSON.parse(i),null==g){null!==i.data&&jQuery.isNumeric(i.data.id)&&jQuery("#"+d).val(i.data.id);var j=function(){var b=jQuery(a).attr("name"),c="[]"==b.slice(-2)?"[]":"",d="jform["+jQuery(a).attr("id").split("__").pop()+"]"+c;if("radio"==jQuery(a).attr("type"))var d="jform["+jQuery(a).attr("name").split("][").pop();jQuery(a).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(h,i.data.id,a),jQuery(a).attr("name",b)};return e.append("jform["+f+"]",h),e.append("client",b),e.append("recordid",c),com_tjucm.Services.Item.saveFieldData(e,j),!0}};e.append("parent_id",c),e.append("client",h),e.append("draft",1),com_tjucm.Services.Item.create(e,j)}else{if(jQuery.isNumeric(i)&&0!=i){var k=jQuery(a).attr("name"),l="[]"==k.slice(-2)?"[]":"",m="jform["+jQuery(a).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(a).attr("type"))var m="jform["+jQuery(a).attr("name").split("][").pop();return jQuery(a).attr("name",m),tjUcmItemForm.saveUcmFormFieldData(h,i,a),jQuery(a).attr("name",k),!0}null==i&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(b,c,a),!0},saveUcmFormFieldData:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d=new FormData;return d.append(Joomla.getOptions("csrf.token"),1),d.append("client",a),d.append("recordid",b),"checkbox"==jQuery(c).attr("type")?!0==jQuery(c).prop("checked")?d.append(jQuery(c).attr("name"),1):d.append(jQuery(c).attr("name"),0):jQuery(c).hasClass("tjfieldTjList")?(""!=jQuery(c).val()&&null!=jQuery(c).val()?d.append(jQuery(c).attr("name"),jQuery(c).val()):d.append(jQuery(c).attr("name"),""),""!=jQuery("input#"+jQuery(c).attr("id")).val()&&null!=jQuery("input#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("input#"+jQuery(c).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(c).attr("id")).data("role")?(""!=jQuery("#"+jQuery(c).attr("id")).val()&&null!=jQuery("#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("#"+jQuery(c).attr("id")).val()),""!=jQuery(c).val()&&null!=jQuery(c).val()&&d.append(jQuery(c).attr("name"),jQuery(c).val())):"file"==jQuery(c).attr("type")?d.append(jQuery(c).attr("name"),jQuery(c)[0].files[0]):null==jQuery(c).val()?d.append(jQuery(c).attr("name"),""):d.append(jQuery(c).attr("name"),jQuery(c).val()),""!=jQuery(c).attr("name")&&null!=jQuery(c).attr("name")&&com_tjucm.Services.Item.saveFieldData(d,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(a,b){if(jQuery("#item-form #tjucm_loader").hide(),b=JSON.parse(b),jQuery("#item-form").removeClass("dirty"),null==b)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=b.data&&b.data.childContentIds&&jQuery.each(b.data.childContentIds,function(a,b){jQuery("#"+a).val(b)}),b.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(),b.data){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(c,d)}tjUcmItemForm.renderResponseMessages(b)},renderResponseMessages:function(a){null!=a&&(null!==a.message&&(a.data?Joomla.renderMessages({success:[a.message]}):Joomla.renderMessages({error:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(a,b){var c=new FormData,d=function(a,b){return b=JSON.parse(b),tjucmRelatedFieldUpdatedOptions=b.data,""!=tjucmRelatedFieldUpdatedOptions&&void jQuery.each(b.data,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")})};c.append("client",a),c.append("content_id",b),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(c,d)},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),event===void 0?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):"tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?tjUcmFormSubmitCallingButtonId=event.target.id:tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave";var a=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(document.formvalidator.isValid(document.getElementById("item-form"))){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)}else 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;a=0}jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(a,function(){var a=document.getElementById("item-form"),b=new FormData(a);b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&b.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery("#item-form input[type=\"checkbox\"]").each(function(){!0==jQuery(this).prop("checked")?b.append(jQuery(this).attr("name"),1):b.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){null==jQuery(this).val()&&b.append(jQuery(this).attr("name"),"")}),tjUcmSaveFormInDraftWithNoMsg!==void 0&&(tjUcmSaveFormInDraftWithNoMsg=void 0,b.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()})},saveSectionData:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var b=new FormData,c=jQuery(a).find("input, textarea, select, fieldset");return tjUcmItemForm.validateSection(c)?void(jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),c.length&&c.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&b.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?!0==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&b.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(){b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),b.append("tjUcmFormSection",jQuery("a[href='"+a+"']").html()),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)})):(jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1)},validateSection:function(a){var b,c,d,e,f,g=!0,h=[];for(e=0,f=a.length;e "+g[h].text+"",jQuery("#"+f).append(e);jQuery("#"+f).trigger("liszt:updated")},f="jform_"+a;d.SelectedValues=jQuery("#jform_"+a).val(),""!=jQuery.trim(b)&&"undefined"!=b&&(jQuery("#"+f+", .chzn-results").empty(),c.append("fieldId",b),c.append("fieldName",a),c.append("FieldsData",d),com_tjucm.Services.Item.getRelatedFieldOptions(c,e))}};function steppedFormSave(a,b,c){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(){this.click()});var d=jQuery("#"+a),e=!1;if(jQuery("#form_status").val(b),"save"==b)if(document.formvalidator.isValid("#item-form")){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")}else 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;return d&&jQuery(d).ajaxSubmit({datatype:"JSON",async:!1,success:function(a){var d=JSON.parse(a);if(null!==d.messages&&null!==d.messages.error&&(jQuery.each(d.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.message&&""!=d.message&&(Joomla.renderMessages({info:[d.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.data){jQuery("#recordId").val(d.data.id),"save"==b?(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")):(e=!0,"1"===c&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var f=window.location.href.split("#")[0],g=-1===f.indexOf("?")?"?":"&",h="id="+d.data.id;jQuery.each(d.data.childContentIds,function(a,b){jQuery("input[name='"+b.elementName+"']").val(b.content_id)}),tjucmRelatedFieldUpdatedOptions=d.data.relatedFieldOptions,jQuery.each(d.data.relatedFieldOptions,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")}),0<=f.indexOf(h)||(f+=g+h),history.pushState(null,null,f)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(){this.click()})}}),e}function itemformactions(a,b){var c=jQuery("ul#tjucm_myTabTabs").find("li.active a");jQuery(c).next("li")==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),jQuery(c).prev("li")==null?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 d=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),e=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");d==null?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),e==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==b&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==b&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} +var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=[],tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=[],tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var a=+jQuery("#itemState").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){var d=jQuery("#item-form #tjucm-autosave").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==d){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)}),0"+c.text+"")}),jQuery(b).find("#"+e).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")){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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 if(tjUcmCurrentAutoSaveState){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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(a,b){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=new Promise(function(b,d){var e=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==e){var f=new FormData;""!=c&&f.append("client",c),f.append(Joomla.getOptions("csrf.token"),1);var g=function(a,c){if(c=JSON.parse(c),null==a)if(null!==c.data&&jQuery.isNumeric(c.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(c.data.id);var e=window.location.href.split("#")[0],f=-1===e.indexOf("?")?"?":"&",g="id="+c.data.id;0<=e.indexOf(g)||(e+=f+g),history.pushState(null,null,e),b(c.data.id)}else d(c)};f.append("draft",a),com_tjucm.Services.Item.create(f,g)}else jQuery.isNumeric(e)&&0!=e&&b(e)});d.then(function(a){b(a)}).catch(function(a){return console.log(a),!1})},onUcmFormChange:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(b){var c=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(a,c,b)})},initUcmFormFieldDataSave:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d="",e=new FormData;if(e.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(a).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(a).parent().parent().parent().parent().attr("data-base-name")){var f=jQuery(a).parent().parent().parent().attr("data-base-name");null==f&&(f=jQuery(a).parent().parent().parent().parent().attr("data-base-name"));var g=jQuery(a).attr("id");d=g.replace(g.split("_").pop(),"contentid");var h="com_tjucm."+d.split("__").pop().replace("_contentid","").replace("com_tjucm_",""),i=jQuery("#"+d).val();if(""==i){var j=function(g,i){if(i=JSON.parse(i),null==g){null!==i.data&&jQuery.isNumeric(i.data.id)&&jQuery("#"+d).val(i.data.id);var j=function(){var b=jQuery(a).attr("name"),c="[]"==b.slice(-2)?"[]":"",d="jform["+jQuery(a).attr("id").split("__").pop()+"]"+c;if("radio"==jQuery(a).attr("type"))var d="jform["+jQuery(a).attr("name").split("][").pop();jQuery(a).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(h,i.data.id,a),jQuery(a).attr("name",b)};return e.append("jform["+f+"]",h),e.append("client",b),e.append("recordid",c),com_tjucm.Services.Item.saveFieldData(e,j),!0}};e.append("parent_id",c),e.append("client",h),e.append("draft",1),com_tjucm.Services.Item.create(e,j)}else{if(jQuery.isNumeric(i)&&0!=i){var k=jQuery(a).attr("name"),l="[]"==k.slice(-2)?"[]":"",m="jform["+jQuery(a).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(a).attr("type"))var m="jform["+jQuery(a).attr("name").split("][").pop();return jQuery(a).attr("name",m),tjUcmItemForm.saveUcmFormFieldData(h,i,a),jQuery(a).attr("name",k),!0}null==i&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(b,c,a),!0},saveUcmFormFieldData:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d=new FormData;return d.append(Joomla.getOptions("csrf.token"),1),d.append("client",a),d.append("recordid",b),"checkbox"==jQuery(c).attr("type")?!0==jQuery(c).prop("checked")?d.append(jQuery(c).attr("name"),1):d.append(jQuery(c).attr("name"),0):jQuery(c).hasClass("tjfieldTjList")?(""!=jQuery(c).val()&&null!=jQuery(c).val()?d.append(jQuery(c).attr("name"),jQuery(c).val()):d.append(jQuery(c).attr("name"),""),""!=jQuery("input#"+jQuery(c).attr("id")).val()&&null!=jQuery("input#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("input#"+jQuery(c).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(c).attr("id")).data("role")?(""!=jQuery("#"+jQuery(c).attr("id")).val()&&null!=jQuery("#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("#"+jQuery(c).attr("id")).val()),""!=jQuery(c).val()&&null!=jQuery(c).val()&&d.append(jQuery(c).attr("name"),jQuery(c).val())):"file"==jQuery(c).attr("type")?d.append(jQuery(c).attr("name"),jQuery(c)[0].files[0]):null==jQuery(c).val()?d.append(jQuery(c).attr("name"),""):d.append(jQuery(c).attr("name"),jQuery(c).val()),""!=jQuery(c).attr("name")&&null!=jQuery(c).attr("name")&&com_tjucm.Services.Item.saveFieldData(d,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(a,b){if(jQuery("#item-form #tjucm_loader").hide(),b=JSON.parse(b),jQuery("#item-form").removeClass("dirty"),null==b)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=b.data&&b.data.childContentIds&&jQuery.each(b.data.childContentIds,function(a,b){jQuery("#"+a).val(b)}),b.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(),b.data){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(c,d)}tjUcmItemForm.renderResponseMessages(b)},renderResponseMessages:function(a){null!=a&&(null!==a.message&&(a.data?Joomla.renderMessages({success:[a.message]}):Joomla.renderMessages({error:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(a,b){var c=new FormData,d=function(a,b){return b=JSON.parse(b),tjucmRelatedFieldUpdatedOptions=b.data,""!=tjucmRelatedFieldUpdatedOptions&&void jQuery.each(b.data,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")})};c.append("client",a),c.append("content_id",b),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(c,d)},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),event===void 0?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):"tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?tjUcmFormSubmitCallingButtonId=event.target.id:tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave";var a=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(document.formvalidator.isValid(document.getElementById("item-form"))){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)}else 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;a=0}jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(a,function(){var a=document.getElementById("item-form"),b=new FormData(a);b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&b.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery("#item-form input[type=\"checkbox\"]").each(function(){!0==jQuery(this).prop("checked")?b.append(jQuery(this).attr("name"),1):b.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){null==jQuery(this).val()&&b.append(jQuery(this).attr("name"),"")}),tjUcmSaveFormInDraftWithNoMsg!==void 0&&(tjUcmSaveFormInDraftWithNoMsg=void 0,b.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()})},saveSectionData:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var b=new FormData,c=jQuery(a).find("input, textarea, select, fieldset");return tjUcmItemForm.validateSection(c)?void(jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),c.length&&c.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&b.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?!0==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&b.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(){b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),b.append("tjUcmFormSection",jQuery("a[href='"+a+"']").html()),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)})):(jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1)},validateSection:function(a){var b,c,d,e,f,g=!0,h=[];for(e=0,f=a.length;e "+g[h].text+"",jQuery("#"+f).append(e);jQuery("#"+f).trigger("liszt:updated")},f="jform_"+a;d.SelectedValues=jQuery("#jform_"+a).val(),""!=jQuery.trim(b)&&"undefined"!=b&&(jQuery("#"+f+", .chzn-results").empty(),c.append("fieldId",b),com_tjucm.Services.Item.getRelatedFieldOptions(c,e))}};function steppedFormSave(a,b,c){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(){this.click()});var d=jQuery("#"+a),e=!1;if(jQuery("#form_status").val(b),"save"==b)if(document.formvalidator.isValid("#item-form")){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")}else 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;return d&&jQuery(d).ajaxSubmit({datatype:"JSON",async:!1,success:function(a){var d=JSON.parse(a);if(null!==d.messages&&null!==d.messages.error&&(jQuery.each(d.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.message&&""!=d.message&&(Joomla.renderMessages({info:[d.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.data){jQuery("#recordId").val(d.data.id),"save"==b?(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")):(e=!0,"1"===c&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var f=window.location.href.split("#")[0],g=-1===f.indexOf("?")?"?":"&",h="id="+d.data.id;jQuery.each(d.data.childContentIds,function(a,b){jQuery("input[name='"+b.elementName+"']").val(b.content_id)}),tjucmRelatedFieldUpdatedOptions=d.data.relatedFieldOptions,jQuery.each(d.data.relatedFieldOptions,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")}),0<=f.indexOf(h)||(f+=g+h),history.pushState(null,null,f)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(){this.click()})}}),e}function itemformactions(a,b){var c=jQuery("ul#tjucm_myTabTabs").find("li.active a");jQuery(c).next("li")==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),jQuery(c).prev("li")==null?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 d=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),e=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");d==null?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),e==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==b&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==b&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} From 0b7e668314aa7d8989df6f11a4c4dd705be46448 Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Wed, 12 Aug 2020 14:48:36 +0530 Subject: [PATCH 222/273] Feature #163782 feat : Related Field : Auto Populate options without page refresh --- src/components/com_tjucm/media/js/ui/itemform.js | 9 ++++----- 1 file changed, 4 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 adf820b7..e3d16134 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -1007,9 +1007,9 @@ var tjUcmItemForm = { } } }, - getRelatedFieldOptions: function (fieldName, fieldId) { + getRelatedFieldOptions: function (relatedFieldId, fieldId) { var tjUcmItemFormData = new FormData(); - var FieldsData = {fieldName: fieldName , fieldId: fieldId}; + var FieldsData = {fieldId: fieldId}; var tjUcmUpdateRelatedFieldsOptions = function (error, response){ response = JSON.parse(response); @@ -1039,12 +1039,11 @@ var tjUcmItemForm = { jQuery('#'+relatedFieldId).append(op); } - //~ /* IMP : to update to chz-done selects*/ + // Update to chz-done selects*/ jQuery('#'+relatedFieldId).trigger("liszt:updated"); }; - var relatedFieldId = 'jform_'+fieldName; - FieldsData.SelectedValues = jQuery('#jform_'+fieldName).val(); + FieldsData.SelectedValues = jQuery('#'+relatedFieldId).val(); if (jQuery.trim(fieldId) != '' && fieldId != 'undefined') { From d0848fd2fb678f0d94e902f5227eab628bd0c647 Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Wed, 12 Aug 2020 14:49:59 +0530 Subject: [PATCH 223/273] Feature #163782 feat : Related Field : Auto Populate options without page refresh --- src/components/com_tjucm/media/js/ui/itemform.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 76b46202..09da6486 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=[],tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=[],tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var a=+jQuery("#itemState").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){var d=jQuery("#item-form #tjucm-autosave").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==d){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)}),0"+c.text+"")}),jQuery(b).find("#"+e).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")){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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 if(tjUcmCurrentAutoSaveState){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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(a,b){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=new Promise(function(b,d){var e=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==e){var f=new FormData;""!=c&&f.append("client",c),f.append(Joomla.getOptions("csrf.token"),1);var g=function(a,c){if(c=JSON.parse(c),null==a)if(null!==c.data&&jQuery.isNumeric(c.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(c.data.id);var e=window.location.href.split("#")[0],f=-1===e.indexOf("?")?"?":"&",g="id="+c.data.id;0<=e.indexOf(g)||(e+=f+g),history.pushState(null,null,e),b(c.data.id)}else d(c)};f.append("draft",a),com_tjucm.Services.Item.create(f,g)}else jQuery.isNumeric(e)&&0!=e&&b(e)});d.then(function(a){b(a)}).catch(function(a){return console.log(a),!1})},onUcmFormChange:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(b){var c=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(a,c,b)})},initUcmFormFieldDataSave:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d="",e=new FormData;if(e.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(a).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(a).parent().parent().parent().parent().attr("data-base-name")){var f=jQuery(a).parent().parent().parent().attr("data-base-name");null==f&&(f=jQuery(a).parent().parent().parent().parent().attr("data-base-name"));var g=jQuery(a).attr("id");d=g.replace(g.split("_").pop(),"contentid");var h="com_tjucm."+d.split("__").pop().replace("_contentid","").replace("com_tjucm_",""),i=jQuery("#"+d).val();if(""==i){var j=function(g,i){if(i=JSON.parse(i),null==g){null!==i.data&&jQuery.isNumeric(i.data.id)&&jQuery("#"+d).val(i.data.id);var j=function(){var b=jQuery(a).attr("name"),c="[]"==b.slice(-2)?"[]":"",d="jform["+jQuery(a).attr("id").split("__").pop()+"]"+c;if("radio"==jQuery(a).attr("type"))var d="jform["+jQuery(a).attr("name").split("][").pop();jQuery(a).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(h,i.data.id,a),jQuery(a).attr("name",b)};return e.append("jform["+f+"]",h),e.append("client",b),e.append("recordid",c),com_tjucm.Services.Item.saveFieldData(e,j),!0}};e.append("parent_id",c),e.append("client",h),e.append("draft",1),com_tjucm.Services.Item.create(e,j)}else{if(jQuery.isNumeric(i)&&0!=i){var k=jQuery(a).attr("name"),l="[]"==k.slice(-2)?"[]":"",m="jform["+jQuery(a).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(a).attr("type"))var m="jform["+jQuery(a).attr("name").split("][").pop();return jQuery(a).attr("name",m),tjUcmItemForm.saveUcmFormFieldData(h,i,a),jQuery(a).attr("name",k),!0}null==i&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(b,c,a),!0},saveUcmFormFieldData:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d=new FormData;return d.append(Joomla.getOptions("csrf.token"),1),d.append("client",a),d.append("recordid",b),"checkbox"==jQuery(c).attr("type")?!0==jQuery(c).prop("checked")?d.append(jQuery(c).attr("name"),1):d.append(jQuery(c).attr("name"),0):jQuery(c).hasClass("tjfieldTjList")?(""!=jQuery(c).val()&&null!=jQuery(c).val()?d.append(jQuery(c).attr("name"),jQuery(c).val()):d.append(jQuery(c).attr("name"),""),""!=jQuery("input#"+jQuery(c).attr("id")).val()&&null!=jQuery("input#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("input#"+jQuery(c).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(c).attr("id")).data("role")?(""!=jQuery("#"+jQuery(c).attr("id")).val()&&null!=jQuery("#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("#"+jQuery(c).attr("id")).val()),""!=jQuery(c).val()&&null!=jQuery(c).val()&&d.append(jQuery(c).attr("name"),jQuery(c).val())):"file"==jQuery(c).attr("type")?d.append(jQuery(c).attr("name"),jQuery(c)[0].files[0]):null==jQuery(c).val()?d.append(jQuery(c).attr("name"),""):d.append(jQuery(c).attr("name"),jQuery(c).val()),""!=jQuery(c).attr("name")&&null!=jQuery(c).attr("name")&&com_tjucm.Services.Item.saveFieldData(d,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(a,b){if(jQuery("#item-form #tjucm_loader").hide(),b=JSON.parse(b),jQuery("#item-form").removeClass("dirty"),null==b)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=b.data&&b.data.childContentIds&&jQuery.each(b.data.childContentIds,function(a,b){jQuery("#"+a).val(b)}),b.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(),b.data){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(c,d)}tjUcmItemForm.renderResponseMessages(b)},renderResponseMessages:function(a){null!=a&&(null!==a.message&&(a.data?Joomla.renderMessages({success:[a.message]}):Joomla.renderMessages({error:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(a,b){var c=new FormData,d=function(a,b){return b=JSON.parse(b),tjucmRelatedFieldUpdatedOptions=b.data,""!=tjucmRelatedFieldUpdatedOptions&&void jQuery.each(b.data,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")})};c.append("client",a),c.append("content_id",b),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(c,d)},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),event===void 0?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):"tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?tjUcmFormSubmitCallingButtonId=event.target.id:tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave";var a=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(document.formvalidator.isValid(document.getElementById("item-form"))){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)}else 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;a=0}jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(a,function(){var a=document.getElementById("item-form"),b=new FormData(a);b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&b.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery("#item-form input[type=\"checkbox\"]").each(function(){!0==jQuery(this).prop("checked")?b.append(jQuery(this).attr("name"),1):b.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){null==jQuery(this).val()&&b.append(jQuery(this).attr("name"),"")}),tjUcmSaveFormInDraftWithNoMsg!==void 0&&(tjUcmSaveFormInDraftWithNoMsg=void 0,b.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()})},saveSectionData:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var b=new FormData,c=jQuery(a).find("input, textarea, select, fieldset");return tjUcmItemForm.validateSection(c)?void(jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),c.length&&c.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&b.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?!0==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&b.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(){b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),b.append("tjUcmFormSection",jQuery("a[href='"+a+"']").html()),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)})):(jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1)},validateSection:function(a){var b,c,d,e,f,g=!0,h=[];for(e=0,f=a.length;e "+g[h].text+"",jQuery("#"+f).append(e);jQuery("#"+f).trigger("liszt:updated")},f="jform_"+a;d.SelectedValues=jQuery("#jform_"+a).val(),""!=jQuery.trim(b)&&"undefined"!=b&&(jQuery("#"+f+", .chzn-results").empty(),c.append("fieldId",b),com_tjucm.Services.Item.getRelatedFieldOptions(c,e))}};function steppedFormSave(a,b,c){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(){this.click()});var d=jQuery("#"+a),e=!1;if(jQuery("#form_status").val(b),"save"==b)if(document.formvalidator.isValid("#item-form")){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")}else 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;return d&&jQuery(d).ajaxSubmit({datatype:"JSON",async:!1,success:function(a){var d=JSON.parse(a);if(null!==d.messages&&null!==d.messages.error&&(jQuery.each(d.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.message&&""!=d.message&&(Joomla.renderMessages({info:[d.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.data){jQuery("#recordId").val(d.data.id),"save"==b?(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")):(e=!0,"1"===c&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var f=window.location.href.split("#")[0],g=-1===f.indexOf("?")?"?":"&",h="id="+d.data.id;jQuery.each(d.data.childContentIds,function(a,b){jQuery("input[name='"+b.elementName+"']").val(b.content_id)}),tjucmRelatedFieldUpdatedOptions=d.data.relatedFieldOptions,jQuery.each(d.data.relatedFieldOptions,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")}),0<=f.indexOf(h)||(f+=g+h),history.pushState(null,null,f)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(){this.click()})}}),e}function itemformactions(a,b){var c=jQuery("ul#tjucm_myTabTabs").find("li.active a");jQuery(c).next("li")==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),jQuery(c).prev("li")==null?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 d=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),e=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");d==null?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),e==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==b&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==b&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} +var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=[],tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=[],tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var a=+jQuery("#itemState").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){var d=jQuery("#item-form #tjucm-autosave").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==d){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)}),0"+c.text+"")}),jQuery(b).find("#"+e).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")){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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 if(tjUcmCurrentAutoSaveState){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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(a,b){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=new Promise(function(b,d){var e=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==e){var f=new FormData;""!=c&&f.append("client",c),f.append(Joomla.getOptions("csrf.token"),1);var g=function(a,c){if(c=JSON.parse(c),null==a)if(null!==c.data&&jQuery.isNumeric(c.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(c.data.id);var e=window.location.href.split("#")[0],f=-1===e.indexOf("?")?"?":"&",g="id="+c.data.id;0<=e.indexOf(g)||(e+=f+g),history.pushState(null,null,e),b(c.data.id)}else d(c)};f.append("draft",a),com_tjucm.Services.Item.create(f,g)}else jQuery.isNumeric(e)&&0!=e&&b(e)});d.then(function(a){b(a)}).catch(function(a){return console.log(a),!1})},onUcmFormChange:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(b){var c=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(a,c,b)})},initUcmFormFieldDataSave:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d="",e=new FormData;if(e.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(a).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(a).parent().parent().parent().parent().attr("data-base-name")){var f=jQuery(a).parent().parent().parent().attr("data-base-name");null==f&&(f=jQuery(a).parent().parent().parent().parent().attr("data-base-name"));var g=jQuery(a).attr("id");d=g.replace(g.split("_").pop(),"contentid");var h="com_tjucm."+d.split("__").pop().replace("_contentid","").replace("com_tjucm_",""),i=jQuery("#"+d).val();if(""==i){var j=function(g,i){if(i=JSON.parse(i),null==g){null!==i.data&&jQuery.isNumeric(i.data.id)&&jQuery("#"+d).val(i.data.id);var j=function(){var b=jQuery(a).attr("name"),c="[]"==b.slice(-2)?"[]":"",d="jform["+jQuery(a).attr("id").split("__").pop()+"]"+c;if("radio"==jQuery(a).attr("type"))var d="jform["+jQuery(a).attr("name").split("][").pop();jQuery(a).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(h,i.data.id,a),jQuery(a).attr("name",b)};return e.append("jform["+f+"]",h),e.append("client",b),e.append("recordid",c),com_tjucm.Services.Item.saveFieldData(e,j),!0}};e.append("parent_id",c),e.append("client",h),e.append("draft",1),com_tjucm.Services.Item.create(e,j)}else{if(jQuery.isNumeric(i)&&0!=i){var k=jQuery(a).attr("name"),l="[]"==k.slice(-2)?"[]":"",m="jform["+jQuery(a).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(a).attr("type"))var m="jform["+jQuery(a).attr("name").split("][").pop();return jQuery(a).attr("name",m),tjUcmItemForm.saveUcmFormFieldData(h,i,a),jQuery(a).attr("name",k),!0}null==i&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(b,c,a),!0},saveUcmFormFieldData:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d=new FormData;return d.append(Joomla.getOptions("csrf.token"),1),d.append("client",a),d.append("recordid",b),"checkbox"==jQuery(c).attr("type")?!0==jQuery(c).prop("checked")?d.append(jQuery(c).attr("name"),1):d.append(jQuery(c).attr("name"),0):jQuery(c).hasClass("tjfieldTjList")?(""!=jQuery(c).val()&&null!=jQuery(c).val()?d.append(jQuery(c).attr("name"),jQuery(c).val()):d.append(jQuery(c).attr("name"),""),""!=jQuery("input#"+jQuery(c).attr("id")).val()&&null!=jQuery("input#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("input#"+jQuery(c).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(c).attr("id")).data("role")?(""!=jQuery("#"+jQuery(c).attr("id")).val()&&null!=jQuery("#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("#"+jQuery(c).attr("id")).val()),""!=jQuery(c).val()&&null!=jQuery(c).val()&&d.append(jQuery(c).attr("name"),jQuery(c).val())):"file"==jQuery(c).attr("type")?d.append(jQuery(c).attr("name"),jQuery(c)[0].files[0]):null==jQuery(c).val()?d.append(jQuery(c).attr("name"),""):d.append(jQuery(c).attr("name"),jQuery(c).val()),""!=jQuery(c).attr("name")&&null!=jQuery(c).attr("name")&&com_tjucm.Services.Item.saveFieldData(d,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(a,b){if(jQuery("#item-form #tjucm_loader").hide(),b=JSON.parse(b),jQuery("#item-form").removeClass("dirty"),null==b)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=b.data&&b.data.childContentIds&&jQuery.each(b.data.childContentIds,function(a,b){jQuery("#"+a).val(b)}),b.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(),b.data){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(c,d)}tjUcmItemForm.renderResponseMessages(b)},renderResponseMessages:function(a){null!=a&&(null!==a.message&&(a.data?Joomla.renderMessages({success:[a.message]}):Joomla.renderMessages({error:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(a,b){var c=new FormData,d=function(a,b){return b=JSON.parse(b),tjucmRelatedFieldUpdatedOptions=b.data,""!=tjucmRelatedFieldUpdatedOptions&&void jQuery.each(b.data,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")})};c.append("client",a),c.append("content_id",b),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(c,d)},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),event===void 0?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):"tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?tjUcmFormSubmitCallingButtonId=event.target.id:tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave";var a=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(document.formvalidator.isValid(document.getElementById("item-form"))){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)}else 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;a=0}jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(a,function(){var a=document.getElementById("item-form"),b=new FormData(a);b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&b.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery("#item-form input[type=\"checkbox\"]").each(function(){!0==jQuery(this).prop("checked")?b.append(jQuery(this).attr("name"),1):b.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){null==jQuery(this).val()&&b.append(jQuery(this).attr("name"),"")}),tjUcmSaveFormInDraftWithNoMsg!==void 0&&(tjUcmSaveFormInDraftWithNoMsg=void 0,b.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()})},saveSectionData:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var b=new FormData,c=jQuery(a).find("input, textarea, select, fieldset");return tjUcmItemForm.validateSection(c)?void(jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),c.length&&c.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&b.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?!0==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&b.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(){b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),b.append("tjUcmFormSection",jQuery("a[href='"+a+"']").html()),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)})):(jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1)},validateSection:function(a){var b,c,d,e,f,g=!0,h=[];for(e=0,f=a.length;e "+g[h].text+"",jQuery("#"+a).append(f);jQuery("#"+a).trigger("liszt:updated")};d.SelectedValues=jQuery("#"+a).val(),""!=jQuery.trim(b)&&"undefined"!=b&&(jQuery("#"+a+", .chzn-results").empty(),c.append("fieldId",b),com_tjucm.Services.Item.getRelatedFieldOptions(c,e))}};function steppedFormSave(a,b,c){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(){this.click()});var d=jQuery("#"+a),e=!1;if(jQuery("#form_status").val(b),"save"==b)if(document.formvalidator.isValid("#item-form")){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")}else 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;return d&&jQuery(d).ajaxSubmit({datatype:"JSON",async:!1,success:function(a){var d=JSON.parse(a);if(null!==d.messages&&null!==d.messages.error&&(jQuery.each(d.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.message&&""!=d.message&&(Joomla.renderMessages({info:[d.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.data){jQuery("#recordId").val(d.data.id),"save"==b?(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")):(e=!0,"1"===c&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var f=window.location.href.split("#")[0],g=-1===f.indexOf("?")?"?":"&",h="id="+d.data.id;jQuery.each(d.data.childContentIds,function(a,b){jQuery("input[name='"+b.elementName+"']").val(b.content_id)}),tjucmRelatedFieldUpdatedOptions=d.data.relatedFieldOptions,jQuery.each(d.data.relatedFieldOptions,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")}),0<=f.indexOf(h)||(f+=g+h),history.pushState(null,null,f)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(){this.click()})}}),e}function itemformactions(a,b){var c=jQuery("ul#tjucm_myTabTabs").find("li.active a");jQuery(c).next("li")==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),jQuery(c).prev("li")==null?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 d=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),e=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");d==null?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),e==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==b&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==b&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} From 974edf35292786e7ce83d759e4666990b6b1f455 Mon Sep 17 00:00:00 2001 From: Vijay Khollam Date: Thu, 13 Aug 2020 12:31:41 +0530 Subject: [PATCH 224/273] Feature #163782 feat: Related Field : Auto Populate added data without page refresh --- src/components/com_tjucm/media/js/ui/itemform.js | 3 ++- src/components/com_tjucm/media/js/ui/itemform.min.js | 2 +- .../com_tjucm/site/controllers/itemform.json.php | 12 ++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/com_tjucm/media/js/ui/itemform.js b/src/components/com_tjucm/media/js/ui/itemform.js index e3d16134..10442b92 100644 --- a/src/components/com_tjucm/media/js/ui/itemform.js +++ b/src/components/com_tjucm/media/js/ui/itemform.js @@ -1007,7 +1007,7 @@ var tjUcmItemForm = { } } }, - getRelatedFieldOptions: function (relatedFieldId, fieldId) { + getRelatedFieldOptions: function (relatedFieldId, fieldId, clusterId) { var tjUcmItemFormData = new FormData(); var FieldsData = {fieldId: fieldId}; @@ -1049,6 +1049,7 @@ var tjUcmItemForm = { { jQuery('#'+relatedFieldId+', .chzn-results').empty(); tjUcmItemFormData.append('fieldId', fieldId); + tjUcmItemFormData.append('fieldId', clusterId); com_tjucm.Services.Item.getRelatedFieldOptions(tjUcmItemFormData, tjUcmUpdateRelatedFieldsOptions); } } 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 09da6486..8925383b 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=[],tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=[],tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var a=+jQuery("#itemState").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){var d=jQuery("#item-form #tjucm-autosave").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==d){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)}),0"+c.text+"")}),jQuery(b).find("#"+e).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")){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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 if(tjUcmCurrentAutoSaveState){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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(a,b){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=new Promise(function(b,d){var e=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==e){var f=new FormData;""!=c&&f.append("client",c),f.append(Joomla.getOptions("csrf.token"),1);var g=function(a,c){if(c=JSON.parse(c),null==a)if(null!==c.data&&jQuery.isNumeric(c.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(c.data.id);var e=window.location.href.split("#")[0],f=-1===e.indexOf("?")?"?":"&",g="id="+c.data.id;0<=e.indexOf(g)||(e+=f+g),history.pushState(null,null,e),b(c.data.id)}else d(c)};f.append("draft",a),com_tjucm.Services.Item.create(f,g)}else jQuery.isNumeric(e)&&0!=e&&b(e)});d.then(function(a){b(a)}).catch(function(a){return console.log(a),!1})},onUcmFormChange:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(b){var c=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(a,c,b)})},initUcmFormFieldDataSave:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d="",e=new FormData;if(e.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(a).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(a).parent().parent().parent().parent().attr("data-base-name")){var f=jQuery(a).parent().parent().parent().attr("data-base-name");null==f&&(f=jQuery(a).parent().parent().parent().parent().attr("data-base-name"));var g=jQuery(a).attr("id");d=g.replace(g.split("_").pop(),"contentid");var h="com_tjucm."+d.split("__").pop().replace("_contentid","").replace("com_tjucm_",""),i=jQuery("#"+d).val();if(""==i){var j=function(g,i){if(i=JSON.parse(i),null==g){null!==i.data&&jQuery.isNumeric(i.data.id)&&jQuery("#"+d).val(i.data.id);var j=function(){var b=jQuery(a).attr("name"),c="[]"==b.slice(-2)?"[]":"",d="jform["+jQuery(a).attr("id").split("__").pop()+"]"+c;if("radio"==jQuery(a).attr("type"))var d="jform["+jQuery(a).attr("name").split("][").pop();jQuery(a).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(h,i.data.id,a),jQuery(a).attr("name",b)};return e.append("jform["+f+"]",h),e.append("client",b),e.append("recordid",c),com_tjucm.Services.Item.saveFieldData(e,j),!0}};e.append("parent_id",c),e.append("client",h),e.append("draft",1),com_tjucm.Services.Item.create(e,j)}else{if(jQuery.isNumeric(i)&&0!=i){var k=jQuery(a).attr("name"),l="[]"==k.slice(-2)?"[]":"",m="jform["+jQuery(a).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(a).attr("type"))var m="jform["+jQuery(a).attr("name").split("][").pop();return jQuery(a).attr("name",m),tjUcmItemForm.saveUcmFormFieldData(h,i,a),jQuery(a).attr("name",k),!0}null==i&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(b,c,a),!0},saveUcmFormFieldData:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d=new FormData;return d.append(Joomla.getOptions("csrf.token"),1),d.append("client",a),d.append("recordid",b),"checkbox"==jQuery(c).attr("type")?!0==jQuery(c).prop("checked")?d.append(jQuery(c).attr("name"),1):d.append(jQuery(c).attr("name"),0):jQuery(c).hasClass("tjfieldTjList")?(""!=jQuery(c).val()&&null!=jQuery(c).val()?d.append(jQuery(c).attr("name"),jQuery(c).val()):d.append(jQuery(c).attr("name"),""),""!=jQuery("input#"+jQuery(c).attr("id")).val()&&null!=jQuery("input#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("input#"+jQuery(c).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(c).attr("id")).data("role")?(""!=jQuery("#"+jQuery(c).attr("id")).val()&&null!=jQuery("#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("#"+jQuery(c).attr("id")).val()),""!=jQuery(c).val()&&null!=jQuery(c).val()&&d.append(jQuery(c).attr("name"),jQuery(c).val())):"file"==jQuery(c).attr("type")?d.append(jQuery(c).attr("name"),jQuery(c)[0].files[0]):null==jQuery(c).val()?d.append(jQuery(c).attr("name"),""):d.append(jQuery(c).attr("name"),jQuery(c).val()),""!=jQuery(c).attr("name")&&null!=jQuery(c).attr("name")&&com_tjucm.Services.Item.saveFieldData(d,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(a,b){if(jQuery("#item-form #tjucm_loader").hide(),b=JSON.parse(b),jQuery("#item-form").removeClass("dirty"),null==b)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=b.data&&b.data.childContentIds&&jQuery.each(b.data.childContentIds,function(a,b){jQuery("#"+a).val(b)}),b.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(),b.data){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(c,d)}tjUcmItemForm.renderResponseMessages(b)},renderResponseMessages:function(a){null!=a&&(null!==a.message&&(a.data?Joomla.renderMessages({success:[a.message]}):Joomla.renderMessages({error:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(a,b){var c=new FormData,d=function(a,b){return b=JSON.parse(b),tjucmRelatedFieldUpdatedOptions=b.data,""!=tjucmRelatedFieldUpdatedOptions&&void jQuery.each(b.data,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")})};c.append("client",a),c.append("content_id",b),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(c,d)},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),event===void 0?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):"tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?tjUcmFormSubmitCallingButtonId=event.target.id:tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave";var a=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(document.formvalidator.isValid(document.getElementById("item-form"))){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)}else 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;a=0}jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(a,function(){var a=document.getElementById("item-form"),b=new FormData(a);b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&b.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery("#item-form input[type=\"checkbox\"]").each(function(){!0==jQuery(this).prop("checked")?b.append(jQuery(this).attr("name"),1):b.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){null==jQuery(this).val()&&b.append(jQuery(this).attr("name"),"")}),tjUcmSaveFormInDraftWithNoMsg!==void 0&&(tjUcmSaveFormInDraftWithNoMsg=void 0,b.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()})},saveSectionData:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var b=new FormData,c=jQuery(a).find("input, textarea, select, fieldset");return tjUcmItemForm.validateSection(c)?void(jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),c.length&&c.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&b.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?!0==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&b.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(){b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),b.append("tjUcmFormSection",jQuery("a[href='"+a+"']").html()),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)})):(jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1)},validateSection:function(a){var b,c,d,e,f,g=!0,h=[];for(e=0,f=a.length;e "+g[h].text+"",jQuery("#"+a).append(f);jQuery("#"+a).trigger("liszt:updated")};d.SelectedValues=jQuery("#"+a).val(),""!=jQuery.trim(b)&&"undefined"!=b&&(jQuery("#"+a+", .chzn-results").empty(),c.append("fieldId",b),com_tjucm.Services.Item.getRelatedFieldOptions(c,e))}};function steppedFormSave(a,b,c){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(){this.click()});var d=jQuery("#"+a),e=!1;if(jQuery("#form_status").val(b),"save"==b)if(document.formvalidator.isValid("#item-form")){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")}else 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;return d&&jQuery(d).ajaxSubmit({datatype:"JSON",async:!1,success:function(a){var d=JSON.parse(a);if(null!==d.messages&&null!==d.messages.error&&(jQuery.each(d.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.message&&""!=d.message&&(Joomla.renderMessages({info:[d.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.data){jQuery("#recordId").val(d.data.id),"save"==b?(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")):(e=!0,"1"===c&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var f=window.location.href.split("#")[0],g=-1===f.indexOf("?")?"?":"&",h="id="+d.data.id;jQuery.each(d.data.childContentIds,function(a,b){jQuery("input[name='"+b.elementName+"']").val(b.content_id)}),tjucmRelatedFieldUpdatedOptions=d.data.relatedFieldOptions,jQuery.each(d.data.relatedFieldOptions,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")}),0<=f.indexOf(h)||(f+=g+h),history.pushState(null,null,f)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(){this.click()})}}),e}function itemformactions(a,b){var c=jQuery("ul#tjucm_myTabTabs").find("li.active a");jQuery(c).next("li")==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),jQuery(c).prev("li")==null?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 d=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),e=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");d==null?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),e==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==b&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==b&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} +var tjucmRelatedFieldUpdatedOptions="",tjUcmTinyMCEFieldIds=[],tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0,tjUcmCurrentAutoSaveState=0,tjUcmFormFinalSave=0,tjUcmJCEFieldIds=[],tjUcmFormSavedByBitRateConfig=0,tjUcmSaveFormInDraftWithNoMsg=void 0,tjUcmFormSubmitCallingButtonId="";jQuery(window).load(function(){var a=+jQuery("#itemState").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==a){var d=jQuery("#item-form #tjucm-autosave").val(),b=jQuery("#item-form #tjucm-bitrate").val(),c=jQuery("#item-form #tjucm-bitrate_seconds").val();if(1==d){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)}),0"+c.text+"")}),jQuery(b).find("#"+e).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")){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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 if(tjUcmCurrentAutoSaveState){var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?tjUcmItemForm.saveSectionData(jQuery("#tjucm_myTabTabs > .active a").attr("href")):(tjUcmClickedOnNext=0,tjUcmClickedOnPrev=0)}else{var a=jQuery(jQuery("#tjucm_myTabTabs > .active a").attr("href")).find("input, textarea, select, fieldset");tjUcmItemForm.validateSection(a)?(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(a,b){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=new Promise(function(b,d){var e=jQuery("#item-form").find("input[name='jform[id]']").val();if(""==e){var f=new FormData;""!=c&&f.append("client",c),f.append(Joomla.getOptions("csrf.token"),1);var g=function(a,c){if(c=JSON.parse(c),null==a)if(null!==c.data&&jQuery.isNumeric(c.data.id)){jQuery("#item-form").find("input[name='jform[id]']").val(c.data.id);var e=window.location.href.split("#")[0],f=-1===e.indexOf("?")?"?":"&",g="id="+c.data.id;0<=e.indexOf(g)||(e+=f+g),history.pushState(null,null,e),b(c.data.id)}else d(c)};f.append("draft",a),com_tjucm.Services.Item.create(f,g)}else jQuery.isNumeric(e)&&0!=e&&b(e)});d.then(function(a){b(a)}).catch(function(a){return console.log(a),!1})},onUcmFormChange:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),tjUcmItemForm.getUcmParentRecordId(1,function(b){var c=jQuery("#item-form").find("input[name='jform[client]']").val();tjUcmItemForm.initUcmFormFieldDataSave(a,c,b)})},initUcmFormFieldDataSave:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d="",e=new FormData;if(e.append(Joomla.getOptions("csrf.token"),1),void 0!==jQuery(a).parent().parent().parent().attr("data-base-name")||void 0!==jQuery(a).parent().parent().parent().parent().attr("data-base-name")){var f=jQuery(a).parent().parent().parent().attr("data-base-name");null==f&&(f=jQuery(a).parent().parent().parent().parent().attr("data-base-name"));var g=jQuery(a).attr("id");d=g.replace(g.split("_").pop(),"contentid");var h="com_tjucm."+d.split("__").pop().replace("_contentid","").replace("com_tjucm_",""),i=jQuery("#"+d).val();if(""==i){var j=function(g,i){if(i=JSON.parse(i),null==g){null!==i.data&&jQuery.isNumeric(i.data.id)&&jQuery("#"+d).val(i.data.id);var j=function(){var b=jQuery(a).attr("name"),c="[]"==b.slice(-2)?"[]":"",d="jform["+jQuery(a).attr("id").split("__").pop()+"]"+c;if("radio"==jQuery(a).attr("type"))var d="jform["+jQuery(a).attr("name").split("][").pop();jQuery(a).attr("name",d),tjUcmItemForm.saveUcmFormFieldData(h,i.data.id,a),jQuery(a).attr("name",b)};return e.append("jform["+f+"]",h),e.append("client",b),e.append("recordid",c),com_tjucm.Services.Item.saveFieldData(e,j),!0}};e.append("parent_id",c),e.append("client",h),e.append("draft",1),com_tjucm.Services.Item.create(e,j)}else{if(jQuery.isNumeric(i)&&0!=i){var k=jQuery(a).attr("name"),l="[]"==k.slice(-2)?"[]":"",m="jform["+jQuery(a).attr("id").split("__").pop()+"]"+l;if("radio"==jQuery(a).attr("type"))var m="jform["+jQuery(a).attr("name").split("][").pop();return jQuery(a).attr("name",m),tjUcmItemForm.saveUcmFormFieldData(h,i,a),jQuery(a).attr("name",k),!0}null==i&&(tjUcmSaveFormInDraftWithNoMsg=1,tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",jQuery("#tjUcmSectionDraftSave").click())}return!1}return tjUcmItemForm.saveUcmFormFieldData(b,c,a),!0},saveUcmFormFieldData:function(a,b,c){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var d=new FormData;return d.append(Joomla.getOptions("csrf.token"),1),d.append("client",a),d.append("recordid",b),"checkbox"==jQuery(c).attr("type")?!0==jQuery(c).prop("checked")?d.append(jQuery(c).attr("name"),1):d.append(jQuery(c).attr("name"),0):jQuery(c).hasClass("tjfieldTjList")?(""!=jQuery(c).val()&&null!=jQuery(c).val()?d.append(jQuery(c).attr("name"),jQuery(c).val()):d.append(jQuery(c).attr("name"),""),""!=jQuery("input#"+jQuery(c).attr("id")).val()&&null!=jQuery("input#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("input#"+jQuery(c).attr("id")).val())):"tagsinput"==jQuery("input#"+jQuery(c).attr("id")).data("role")?(""!=jQuery("#"+jQuery(c).attr("id")).val()&&null!=jQuery("#"+jQuery(c).attr("id")).val()&&d.append(jQuery(c).attr("name"),jQuery("#"+jQuery(c).attr("id")).val()),""!=jQuery(c).val()&&null!=jQuery(c).val()&&d.append(jQuery(c).attr("name"),jQuery(c).val())):"file"==jQuery(c).attr("type")?d.append(jQuery(c).attr("name"),jQuery(c)[0].files[0]):null==jQuery(c).val()?d.append(jQuery(c).attr("name"),""):d.append(jQuery(c).attr("name"),jQuery(c).val()),""!=jQuery(c).attr("name")&&null!=jQuery(c).attr("name")&&com_tjucm.Services.Item.saveFieldData(d,tjUcmItemForm.afterDataSave),!0},afterDataSave:function(a,b){if(jQuery("#item-form #tjucm_loader").hide(),b=JSON.parse(b),jQuery("#item-form").removeClass("dirty"),null==b)return!1;if(jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!1),null!=b.data&&b.data.childContentIds&&jQuery.each(b.data.childContentIds,function(a,b){jQuery("#"+a).val(b)}),b.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(),b.data){var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();tjUcmItemForm.updateRelatedFieldsOptions(c,d)}tjUcmItemForm.renderResponseMessages(b)},renderResponseMessages:function(a){null!=a&&(null!==a.message&&(a.data?Joomla.renderMessages({success:[a.message]}):Joomla.renderMessages({error:[a.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==a.messages&&null!==a.messages.error&&(jQuery.each(a.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")))},updateRelatedFieldsOptions:function(a,b){var c=new FormData,d=function(a,b){return b=JSON.parse(b),tjucmRelatedFieldUpdatedOptions=b.data,""!=tjucmRelatedFieldUpdatedOptions&&void jQuery.each(b.data,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")})};c.append("client",a),c.append("content_id",b),com_tjucm.Services.Item.getUpdatedRelatedFieldsOptions(c,d)},saveUcmFormData:function(){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0),event===void 0?(tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave",tjUcmSaveFormInDraftWithNoMsg=1):"tjUcmSectionDraftSave"==event.target.id||"tjUcmSectionFinalSave"==event.target.id?tjUcmFormSubmitCallingButtonId=event.target.id:tjUcmFormSubmitCallingButtonId="tjUcmSectionDraftSave";var a=1;if("tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId){if(document.formvalidator.isValid(document.getElementById("item-form"))){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)}else 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;a=0}jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()}),jQuery("#item-form #tjucm_loader").show(),jQuery("html, body").animate({scrollTop:jQuery("#item-form #tjucm_loader").position().top},"slow"),tjUcmItemForm.getUcmParentRecordId(a,function(){var a=document.getElementById("item-form"),b=new FormData(a);b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),"tjUcmSectionDraftSave"==tjUcmFormSubmitCallingButtonId&&b.append("draft",1),"tjUcmSectionFinalSave"==tjUcmFormSubmitCallingButtonId&&(tjUcmFormFinalSave=1),tjUcmFormSubmitCallingButtonId="",jQuery("#item-form input[type=\"checkbox\"]").each(function(){!0==jQuery(this).prop("checked")?b.append(jQuery(this).attr("name"),1):b.append(jQuery(this).attr("name"),0)}),jQuery("#item-form select").each(function(){null==jQuery(this).val()&&b.append(jQuery(this).attr("name"),"")}),tjUcmSaveFormInDraftWithNoMsg!==void 0&&(tjUcmSaveFormInDraftWithNoMsg=void 0,b.append("showDraftMessage",0)),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)}),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),jQuery("#item-form .wf-editor-toggle").each(function(){this.click()})},saveSectionData:function(a){jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr("disabled",!0);var b=new FormData,c=jQuery(a).find("input, textarea, select, fieldset");return tjUcmItemForm.validateSection(c)?void(jQuery("#system-message-container").html(""),jQuery("#item-form .toggle-editor a").each(function(){this.click()}),c.length&&c.each(function(){"file"==jQuery(this).attr("type")?null!=jQuery(this)[0].files[0]&&b.append(jQuery(this).attr("name"),jQuery(this)[0].files[0]):"checkbox"==jQuery(this).attr("type")?!0==jQuery(this).prop("checked")?jQuery(this).val(1):jQuery(this).val(0):null!=jQuery(this).val()&&b.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(){b.delete("task"),b.delete("option"),b.delete("view"),b.delete("layout");var c=jQuery("#item-form").find("input[name='jform[client]']").val(),d=jQuery("#item-form").find("input[name='jform[id]']").val();b.append(Joomla.getOptions("csrf.token"),1),b.append("client",c),b.append("recordid",d),b.append("tjUcmFormSection",jQuery("a[href='"+a+"']").html()),com_tjucm.Services.Item.saveFormData(b,tjUcmItemForm.afterDataSave)})):(jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow"),!1)},validateSection:function(a){var b,c,d,e,f,g=!0,h=[];for(e=0,f=a.length;e "+g[h].text+"",jQuery("#"+a).append(f);jQuery("#"+a).trigger("liszt:updated")};e.SelectedValues=jQuery("#"+a).val(),""!=jQuery.trim(b)&&"undefined"!=b&&(jQuery("#"+a+", .chzn-results").empty(),d.append("fieldId",b),d.append("fieldId",c),com_tjucm.Services.Item.getRelatedFieldOptions(d,f))}};function steppedFormSave(a,b,c){window.onbeforeunload=null,jQuery("#item-form .toggle-editor a").each(function(){this.click()});var d=jQuery("#"+a),e=!1;if(jQuery("#form_status").val(b),"save"==b)if(document.formvalidator.isValid("#item-form")){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")}else 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;return d&&jQuery(d).ajaxSubmit({datatype:"JSON",async:!1,success:function(a){var d=JSON.parse(a);if(null!==d.messages&&null!==d.messages.error&&(jQuery.each(d.messages.error,function(a,b){Joomla.renderMessages({error:[b]})}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.message&&""!=d.message&&(Joomla.renderMessages({info:[d.message]}),jQuery("html, body").animate({scrollTop:jQuery("#system-message-container").position().top},"slow")),null!==d.data){jQuery("#recordId").val(d.data.id),"save"==b?(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")):(e=!0,"1"===c&&(jQuery("#draft_msg").show(),setTimeout(function(){jQuery("#draft_msg").hide()},5e3)));var f=window.location.href.split("#")[0],g=-1===f.indexOf("?")?"?":"&",h="id="+d.data.id;jQuery.each(d.data.childContentIds,function(a,b){jQuery("input[name='"+b.elementName+"']").val(b.content_id)}),tjucmRelatedFieldUpdatedOptions=d.data.relatedFieldOptions,jQuery.each(d.data.relatedFieldOptions,function(a,b){jQuery("#"+b.elementId).html(""),jQuery.each(b.options,function(a,c){var d="";"1"==c.selected&&(d=" selected=\"selected\" "),jQuery("#"+b.elementId).append("")}),jQuery("#"+b.elementId).trigger("liszt:updated")}),0<=f.indexOf(h)||(f+=g+h),history.pushState(null,null,f)}jQuery("#tjUcmSectionDraftSave").attr("disabled",!1),jQuery("#tjUcmSectionFinalSave").attr("disabled",!1),jQuery("#item-form .toggle-editor a").each(function(){this.click()})}}),e}function itemformactions(a,b){var c=jQuery("ul#tjucm_myTabTabs").find("li.active a");jQuery(c).next("li")==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),jQuery(c).prev("li")==null?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 d=jQuery("ul#"+getTabId).find("li.active").next("li").children("a").attr("href"),e=jQuery("ul#"+getTabId).find("li.active").prev("li").children("a").attr("href");d==null?jQuery("#next_button").attr("disabled",!0):jQuery("#next_button").attr("disabled",!1),e==null?jQuery("#previous_button").attr("disabled",!0):jQuery("#previous_button").attr("disabled",!1),steppedFormSave("item-form","draft",1),"next"==b&&jQuery("#"+getTabId+" > .active").next("li").find("a").trigger("click"),"prev"==b&&jQuery("#"+getTabId+" > .active").prev("li").find("a").trigger("click")} diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 1f07c467..01d66c77 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -756,6 +756,7 @@ public function copyItem() } } } + /** * Method to get Related Field Options for the field. * @@ -765,8 +766,15 @@ public function copyItem() */ public function getUpdatedRelatedFieldOptions() { - $app = Factory::getApplication(); - $fieldId = $app->input->get('fieldId', '', 'STRING'); + $app = Factory::getApplication(); + $fieldId = $app->input->get('fieldId', '', 'STRING'); + $clusterId = $app->input->get('clusterId', 0, 'STRING'); + + // Set Cluster ID + if ($clusterId) + { + $app->input->set('cluster_id', $clusterId); + } // Check for request forgeries. if (!Session::checkToken()) From 51982bf84ebc917a4623e827d92d9c73ae0cc3ec Mon Sep 17 00:00:00 2001 From: shraddha Date: Wed, 26 Aug 2020 11:00:17 +0530 Subject: [PATCH 225/273] Task #163912 chore: copy ucm multiple items --- .../administrator/en-GB/en-GB.com_tjucm.ini | 4 ++ .../languages/site/en-GB/en-GB.com_tjucm.ini | 6 ++ .../site/controllers/itemform.json.php | 26 +++++++- .../com_tjucm/site/controllers/type.php | 55 ++++++++++++++++ .../com_tjucm/site/layouts/list/list.php | 7 ++- .../com_tjucm/site/models/items.php | 51 ++++++++++++++- .../site/views/items/tmpl/default.php | 63 ++++++++++--------- .../com_tjucm/site/views/items/view.html.php | 3 + 8 files changed, 182 insertions(+), 33 deletions(-) diff --git a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini index ba95bfda..42c66711 100644 --- a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini @@ -194,3 +194,7 @@ COM_TJUCM_FORM_DESC_LBL_TYPE_ALLOW_BITRATE_ON="Set to 'YES' if you want to allow COM_TJUCM_FORM_LBL_TYPE_BITRATE_SECONDS="Autosave Interval (seconds)" COM_TJUCM_FORM_DESC_LBL_TYPE_BITRATE_SECONDS="Enter time in seconds to save data repeatedly for this ucm type" COM_TJUCM_SEARCH_FILTER_SUBMIT="Search" + +; Added in version 1.2.4 +COM_TJUCM_PERMISSION_TYPE_ITEM_COPYITEM="Copy Item" +COM_TJUCM_PERMISSION_TYPE_ITEM_COPYITEM_DESC="Copy Item from one UCM to another UCM or same UCM type" 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 037d7831..70e58be9 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 @@ -214,3 +214,9 @@ COM_TJUCM_LOGIN_MSG="Please login" COM_TJUCM_SELECT_SOURCE_FORM="Select data source" COM_TJUCM_PROCESS_DATA="Process" COM_TJUCM_CANCEL_COPY="Cancel" + +COM_TJUCM_COPY_ITEMS="Copy Items" +COM_TJUCM_COPY_ITEMS_SELECT_UCM_TYPE="Select UCM Type" +COM_TJUCM_COPY_ITEMS_BUTTON="Process" +COM_TJUCM_COPY_ITEMS_SELECT_CLUSTER="Select Cluster" + diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 1f07c467..03b975e5 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -558,15 +558,29 @@ public function copyItem() $app = Factory::getApplication(); $post = $app->input->post; - $sourceClient = $app->input->get('sourceClient', '', 'string'); + $sourceClient = $app->input->get('client', '', 'string'); $filter = $app->input->get('filter', '', 'ARRAY'); $targetClient = $filter['ucm_list']; + if (!$targetClient) + { + $targetClient = $sourceClient; + } + + $clusterId = $filter['cluster_list']; + JLoader::import('components.com_tjucm.models.type', JPATH_ADMINISTRATOR); $typeModel = BaseDatabaseModel::getInstance('Type', 'TjucmModel'); - // Server side Validation for source and UCM Type - $result = $typeModel->getCompatableUcmType($sourceClient, $targetClient); + if ($sourceClient != $targetClient) + { + // Server side Validation for source and UCM Type + $result = $typeModel->getCompatableUcmType($sourceClient, $targetClient); + } + else + { + $result = true; + } if ($result) { @@ -716,6 +730,11 @@ public function copyItem() $ucmData['state'] = 0; $ucmData['draft'] = 1; + if ($clusterId) + { + $ucmData['cluster_id'] = $clusterId; + } + // Save data into UCM data table $result = $model->save($ucmData); $recordId = $model->getState($model->getName() . '.id'); @@ -756,6 +775,7 @@ public function copyItem() } } } + /** * Method to get Related Field Options for the field. * diff --git a/src/components/com_tjucm/site/controllers/type.php b/src/components/com_tjucm/site/controllers/type.php index 34c27107..b1002d75 100644 --- a/src/components/com_tjucm/site/controllers/type.php +++ b/src/components/com_tjucm/site/controllers/type.php @@ -15,6 +15,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Component\ComponentHelper; /** * Type controller class. @@ -79,7 +80,61 @@ public function getCompatableUcmType() } } + if (count($validUcmType) <= 1) + { + $validUcmType = false; + } + echo new JResponseJson($validUcmType); $app->close(); } + + /** + * Method to get Cluster field + * + * @return boolean + * + * @since __DEPLOY_VERSION__ + */ + public function getClusterField() + { + // Check for request forgeries. + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + + $app = Factory::getApplication(); + $post = $app->input->post; + $client = $post->get('client', '', 'STRING'); + + if (empty($client)) + { + echo new JResponseJson(null); + $app->close(); + } + + // Show records belonging to users cluster if com_cluster is installed and enabled - start + $clusterExist = ComponentHelper::getComponent('com_cluster', true)->enabled; + + if (empty($clusterExist)) + { + echo new JResponseJson(null); + $app->close(); + } + + JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR); + $fieldTable = JTable::getInstance('Field', 'TjfieldsTable', array('dbo', $db)); + $fieldTable->load(array('client' => $client, 'type' => 'cluster')); + + if (!$fieldTable->id) + { + echo new JResponseJson(null); + $app->close(); + } + + JFormHelper::addFieldPath(JPATH_ADMINISTRATOR . '/components/com_tjfields/models/fields/'); + $cluster = JFormHelper::loadFieldType('cluster', false); + $clusterList = $cluster->getOptionsExternally(); + + echo new JResponseJson($clusterList); + $app->close(); + } } diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 47cdd2c3..256f1a46 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -55,6 +55,7 @@ $formObject = $displayData['formObject']; $ucmTypeId = $displayData['ucmTypeId']; $allowDraftSave = $displayData['ucmTypeParams']->allow_draft_save; +$i = $displayData['key']; $appendUrl = ''; $csrf = "&" . Session::getFormToken() . '=1'; @@ -65,6 +66,8 @@ $canEdit = TjucmAccess::canEdit($ucmTypeId, $item->id); $canDelete = TjucmAccess::canDelete($ucmTypeId, $item->id); +$canCopyItem = $user->authorise('core.type.copyitem', 'com_tjucm.type.' . $ucmTypeId); + if (!empty($created_by)) { $appendUrl .= "&created_by=" . $created_by; @@ -98,10 +101,12 @@ ?>
+ - id); ?> + id); ?> + state)) { diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 3e3f2f15..c9093e87 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -13,6 +13,7 @@ jimport('joomla.application.component.modellist'); use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\MVC\Model\BaseDatabaseModel; /** * Methods supporting a list of Tjucm records. @@ -207,7 +208,9 @@ protected function getListQuery() $query->from($db->quoteName('#__tj_ucm_data', 'a')); // Join over the users for the checked out user - $query->join("LEFT", $db->quoteName('#__tjfields_fields_value', 'fv') . ' ON (' . $db->quoteName('fv.content_id') . ' = ' . $db->quoteName('a.id') . ')'); + $query->join( + "LEFT", $db->quoteName('#__tjfields_fields_value', 'fv') . ' ON (' . $db->quoteName('fv.content_id') . ' = ' . $db->quoteName('a.id') . ')' + ); $client = $this->getState('ucm.client'); @@ -541,4 +544,50 @@ public function showListCheck($client) return false; } } + + /** + * Method to check the compatibility between ucm types + * + * @param string $client Client + * + * @return mixed + * + * @since __DEPLOY_VERSION__ + */ + public function canCopyToSameUcmType($client) + { + JLoader::import('components.com_tjucm.models.types', JPATH_ADMINISTRATOR); + $typesModel = BaseDatabaseModel::getInstance('Types', 'TjucmModel'); + $typesModel->setState('filter.state', 1); + $ucmTypes = $typesModel->getItems(); + + JLoader::import('components.com_tjucm.models.type', JPATH_ADMINISTRATOR); + $typeModel = BaseDatabaseModel::getInstance('Type', 'TjucmModel'); + + $checkUcmCompatability = false; + + foreach ($ucmTypes as $key => $type) + { + if ($client != $type->unique_identifier) + { + $result = $typeModel->getCompatableUcmType($client, $type->unique_identifier); + + if ($result) + { + $checkUcmCompatability = true; + } + } + } + + JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR); + $fieldTable = JTable::getInstance('Field', 'TjfieldsTable', array('dbo', $db)); + $fieldTable->load(array('client' => $client, 'type' => 'cluster')); + + if (!$checkUcmCompatability && !$fieldTable->id) + { + return true; + } + + return false; + } } 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 f4d9cd24..aab7b381 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -20,6 +20,7 @@ JHtml::_('jquery.token'); $importItemsPopUpUrl = JUri::root() . '/index.php?option=com_tjucm&view=items&layout=importitems&tmpl=component&client=' . $this->client; +$copyItemPopupUrl = JUri::root() . 'index.php?option=com_tjucm&view=items&layout=copyitems&tmpl=component&client=' . $this->client; JFactory::getDocument()->addScriptDeclaration(' jQuery(document).ready(function(){ jQuery("#adminForm #import-items").click(function() { @@ -51,47 +52,24 @@ $fieldsData = array(); JFactory::getDocument()->addScriptDeclaration(" - jQuery(window).load(function() - { - var currentUcmType = new FormData(); - currentUcmType.append('client', '" . $this->client . "'); - var afterCheckCompatibilityOfUcmType = function(error, response){ - response = JSON.parse(response); - - if (response.data.length > 0) - { - jQuery('.copyToOther').removeClass('hide'); - jQuery.each(response.data, function(key, value) { - jQuery('#ucm_list').append(jQuery('').attr('value',value.value).text(value.text)); - jQuery('#ucm_list').trigger('liszt:updated'); - }); - } - }; - - // Code to check ucm type compatibility to copy item - com_tjucm.Services.Items.chekCompatibility(currentUcmType, afterCheckCompatibilityOfUcmType); - }); - - function copyItem() + function copySameUcmTypeItem() { var afterCopyItem = function(error, response){ response = JSON.parse(response); - - // Close pop up and display message - jQuery( '#copyModal' ).modal('hide'); - + console.log(response); if(response.data !== null) { Joomla.renderMessages({'success':[response.message]}); + window.parent.location.reload(); } else { Joomla.renderMessages({'error':[response.message]}); } } - + var copyItemData = jQuery('#adminForm').serialize(); - + // Code to copy item to ucm type com_tjucm.Services.Items.copyItem(copyItemData, afterCopyItem); } @@ -132,6 +110,33 @@ function copyItem() canCopyItem) + { + if ($this->canCopyToSameeUcmType) + {?> + + + + + + + + JText::_('COM_TJUCM_COPY_ITEMS'), + ), + $this->loadTemplate('copyitems') + ); ?> +
@@ -148,10 +153,12 @@ function copyItem() {?> + canCopyItem) { ?> + items[0]->state)) { diff --git a/src/components/com_tjucm/site/views/items/view.html.php b/src/components/com_tjucm/site/views/items/view.html.php index 44424768..b14639c3 100644 --- a/src/components/com_tjucm/site/views/items/view.html.php +++ b/src/components/com_tjucm/site/views/items/view.html.php @@ -100,6 +100,9 @@ public function display($tpl = null) $this->canImport = TjucmAccess::canImport($this->ucmTypeId); $this->draft = array("" => JText::_('COM_TJUCM_DATA_STATUS_SELECT_OPTION'), "0" => JText::_("COM_TJUCM_DATA_STATUS_SAVE"), "1" => JText::_('COM_TJUCM_DATA_STATUS_DRAFT')); + $this->canCopyItem = $user->authorise('core.type.copyitem', 'com_tjucm.type.' . $this->ucmTypeId); + $this->canCopyToSameeUcmType = $model->canCopyToSameUcmType($this->client); + // If did not get the client from url then get if from menu param if (empty($this->client)) { From ed1842653255a2c53eba70f20de058ebfcb3bcc4 Mon Sep 17 00:00:00 2001 From: shraddha Date: Tue, 1 Sep 2020 21:18:28 +0530 Subject: [PATCH 226/273] Feature #163832 chore: Implement Multiple Copy feature on the frontend listing --- .../com_tjucm/administrator/access.xml | 1 + .../com_tjucm/administrator/config.xml | 8 +- .../administrator/en-GB/en-GB.com_tjucm.ini | 5 + .../com_tjucm/media/js/services/items.js | 6 + .../site/controllers/itemform.json.php | 304 +++++++++--------- .../com_tjucm/site/controllers/type.php | 4 + .../com_tjucm/site/layouts/list/list.php | 2 +- .../com_tjucm/site/models/itemform.php | 75 ++++- .../site/views/items/tmpl/default.php | 30 +- .../views/items/tmpl/default_copyitems.php | 111 +++++++ 10 files changed, 366 insertions(+), 180 deletions(-) create mode 100755 src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php diff --git a/src/components/com_tjucm/administrator/access.xml b/src/components/com_tjucm/administrator/access.xml index 689379fa..d634a3f0 100644 --- a/src/components/com_tjucm/administrator/access.xml +++ b/src/components/com_tjucm/administrator/access.xml @@ -21,5 +21,6 @@ + diff --git a/src/components/com_tjucm/administrator/config.xml b/src/components/com_tjucm/administrator/config.xml index 0b33201a..b16184f0 100644 --- a/src/components/com_tjucm/administrator/config.xml +++ b/src/components/com_tjucm/administrator/config.xml @@ -3,4 +3,10 @@
- \ No newline at end of file +
+ + + + +
+ diff --git a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini index 42c66711..3b6d33af 100644 --- a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini @@ -198,3 +198,8 @@ COM_TJUCM_SEARCH_FILTER_SUBMIT="Search" ; Added in version 1.2.4 COM_TJUCM_PERMISSION_TYPE_ITEM_COPYITEM="Copy Item" COM_TJUCM_PERMISSION_TYPE_ITEM_COPYITEM_DESC="Copy Item from one UCM to another UCM or same UCM type" +JCONFIG_COPY_ITEM_SETTING_LABEL="Copy Item" +COM_TJUCM_USE_TJQUEUE_WHILE_COPY_ITEM="Use TjQueue While Copy Item" +COM_TJUCM_USE_TJQUEUE_WHILE_COPY_ITEM_DESC="Set to 'Yes' if you want to use TjQueue while copying items" +COM_TJUCM_YES="Yes" +COM_TJUCM_NO="No" diff --git a/src/components/com_tjucm/media/js/services/items.js b/src/components/com_tjucm/media/js/services/items.js index 8b8baf42..a1a4b55f 100755 --- a/src/components/com_tjucm/media/js/services/items.js +++ b/src/components/com_tjucm/media/js/services/items.js @@ -9,6 +9,7 @@ com_tjucm.Services.Items = new (com_tjucm.Services.Base.extend({ checkCompatibilityUrl: window.tjSiteRoot + "index.php?option=com_tjucm&task=type.getCompatableUcmType", copyItemUrl: window.tjSiteRoot + "index.php?option=com_tjucm&format=json&task=itemform.copyItem", + getClusterFieldUrl: window.tjSiteRoot + "index.php?option=com_tjucm&&task=type.getClusterField", config: { headers: {} }, @@ -21,6 +22,11 @@ com_tjucm.Services.Items = new (com_tjucm.Services.Base.extend({ this.config.contentType = false; this.post(this.checkCompatibilityUrl, currentUcmType, this.config, callback); }, + getClusterField: function (currentUcmType, callback){ + this.config.processData = false; + this.config.contentType = false; + this.post(this.checkCompatibilityUrl, currentUcmType, this.config, callback); + }, copyItem: function (copyItemData, callback){ this.config.processData = false; this.config.contentType = 'application/x-www-form-urlencoded; charset=UTF-8'; diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 03b975e5..9c112fe4 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -20,6 +20,7 @@ use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Response\JsonResponse; +use Joomla\CMS\Component\ComponentHelper; jimport('joomla.filesystem.file'); @@ -591,182 +592,197 @@ public function copyItem() if (count($copyIds)) { $model = $this->getModel('itemform'); - $model->setClient($targetClient); + $ucmConfigs = ComponentHelper::getParams('com_tjucm'); + $useTjQueue = $ucmConfigs->get('tjqueue_copy_items'); - foreach ($copyIds as $cid) + if ($useTjQueue) { - $ucmOldData = array(); - $ucmOldData['clientComponent'] = 'com_tjucm'; - $ucmOldData['content_id'] = $cid; - $ucmOldData['layout'] = 'edit'; - $ucmOldData['client'] = $sourceClient; - $fileFieldArray = array(); - - // Get the field values - $extraFieldsData = $model->loadFormDataExtra($ucmOldData); - - // Code to replace source field name with destination field name - foreach ($extraFieldsData as $fieldKey => $fieldValue) + foreach ($copyIds as $cid) { - $prefixSourceClient = str_replace(".", "_", $sourceClient); - $fieldName = explode($prefixSourceClient . "_", $fieldKey); - $prefixTargetClient = str_replace(".", "_", $targetClient); - $targetFieldName = $prefixTargetClient . '_' . $fieldName[1]; - $tjFieldsTable = $tjFieldsHelper->getFieldData($targetFieldName); - $fieldId = $tjFieldsTable->id; - $fieldType = $tjFieldsTable->type; - $fielParams = json_decode($tjFieldsTable->params); - $sourceTjFieldsTable = $tjFieldsHelper->getFieldData($fieldKey); - $sourceFieldParams = json_decode($sourceTjFieldsTable->params); - $subFormData = array(); - - if ($tjFieldsTable->type == 'ucmsubform' || $tjFieldsTable->type == 'subform') - { - $params = json_decode($tjFieldsTable->params)->formsource; - $subFormClient = explode('components/com_tjucm/models/forms/', $params); - $subFormClient = explode('form_extra.xml', $subFormClient[1]); - $subFormClient = 'com_tjucm.' . $subFormClient[0]; - - $params = $sourceFieldParams->formsource; - $subFormSourceClient = explode('components/com_tjucm/models/forms/', $params); - $subFormSourceClient = explode('form_extra.xml', $subFormSourceClient[1]); - $subFormSourceClient = 'com_tjucm.' . $subFormSourceClient[0]; + $response = $model->pushDataToQueue($cid, $sourceClient, $targetClient, Factory::getuser()->id, $clusterId); - $subFormData = (array) json_decode($fieldValue); - } + $msg = ($response) ? Text::_("COM_TJUCM_ITEM_COPY_SUCCESSFULLY") : Text::_("COM_TJUCM_FORM_SAVE_FAILED"); + } + } + else + { + $model->setClient($targetClient); - if ($fieldType == 'file') + foreach ($copyIds as $cid) + { + $ucmOldData = array(); + $ucmOldData['clientComponent'] = 'com_tjucm'; + $ucmOldData['content_id'] = $cid; + $ucmOldData['layout'] = 'edit'; + $ucmOldData['client'] = $sourceClient; + $fileFieldArray = array(); + + // Get the field values + $extraFieldsData = $model->loadFormDataExtra($ucmOldData); + + // Code to replace source field name with destination field name + foreach ($extraFieldsData as $fieldKey => $fieldValue) { - $fileData = array(); - $fileData['field_id'] = $fieldId; - $fileData['value'] = $fieldValue; - $fileData['params'] = $fielParams; - $fileData['sourceparams'] = $sourceFieldParams; - $fileFieldArray[] = $fileData; - } + $prefixSourceClient = str_replace(".", "_", $sourceClient); + $fieldName = explode($prefixSourceClient . "_", $fieldKey); + $prefixTargetClient = str_replace(".", "_", $targetClient); + $targetFieldName = $prefixTargetClient . '_' . $fieldName[1]; + $tjFieldsTable = $tjFieldsHelper->getFieldData($targetFieldName); + $fieldId = $tjFieldsTable->id; + $fieldType = $tjFieldsTable->type; + $fielParams = json_decode($tjFieldsTable->params); + $sourceTjFieldsTable = $tjFieldsHelper->getFieldData($fieldKey); + $sourceFieldParams = json_decode($sourceTjFieldsTable->params); + $subFormData = array(); + + if ($tjFieldsTable->type == 'ucmsubform' || $tjFieldsTable->type == 'subform') + { + $params = json_decode($tjFieldsTable->params)->formsource; + $subFormClient = explode('components/com_tjucm/models/forms/', $params); + $subFormClient = explode('form_extra.xml', $subFormClient[1]); + $subFormClient = 'com_tjucm.' . $subFormClient[0]; - if ($subFormData) - { - foreach ($subFormData as $keyData => $data) + $params = $sourceFieldParams->formsource; + $subFormSourceClient = explode('components/com_tjucm/models/forms/', $params); + $subFormSourceClient = explode('form_extra.xml', $subFormSourceClient[1]); + $subFormSourceClient = 'com_tjucm.' . $subFormSourceClient[0]; + + $subFormData = (array) json_decode($fieldValue); + } + + if ($fieldType == 'file') { - $prefixSourceClient = str_replace(".", "_", $sourceClient); - $fieldName = explode($prefixSourceClient . "_", $keyData); - $prefixTargetClient = str_replace(".", "_", $targetClient); - $subTargetFieldName = $prefixTargetClient . '_' . $fieldName[1]; - $data = (array) $data; + $fileData = array(); + $fileData['field_id'] = $fieldId; + $fileData['value'] = $fieldValue; + $fileData['params'] = $fielParams; + $fileData['sourceparams'] = $sourceFieldParams; + $fileFieldArray[] = $fileData; + } - foreach ((array) $data as $key => $d) + if ($subFormData) + { + foreach ($subFormData as $keyData => $data) { - $prefixSourceClient = str_replace(".", "_", $subFormSourceClient); - $fieldName = explode($prefixSourceClient . "_", $key); - $prefixTargetClient = str_replace(".", "_", $subFormClient); - $subFieldName = $prefixTargetClient . '_' . $fieldName[1]; + $prefixSourceClient = str_replace(".", "_", $sourceClient); + $fieldName = explode($prefixSourceClient . "_", $keyData); + $prefixTargetClient = str_replace(".", "_", $targetClient); + $subTargetFieldName = $prefixTargetClient . '_' . $fieldName[1]; + $data = (array) $data; - JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/tables'); - $fieldTable = JTable::getInstance('field', 'TjfieldsTable'); + foreach ((array) $data as $key => $d) + { + $prefixSourceClient = str_replace(".", "_", $subFormSourceClient); + $fieldName = explode($prefixSourceClient . "_", $key); + $prefixTargetClient = str_replace(".", "_", $subFormClient); + $subFieldName = $prefixTargetClient . '_' . $fieldName[1]; - $fieldTable->load(array('name' => $key)); + JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/tables'); + $fieldTable = JTable::getInstance('field', 'TjfieldsTable'); - if ($fieldName[1] == 'contentid') - { - $d = ''; - } + $fieldTable->load(array('name' => $key)); + + if ($fieldName[1] == 'contentid') + { + $d = ''; + } - $temp = array(); - unset($data[$key]); + $temp = array(); + unset($data[$key]); - if (is_array($d)) - { - // TODO Temprary used switch case need to modify code - switch ($fieldTable->type) + if (is_array($d)) { - case 'tjlist': - case 'related': - case 'multi_select': - foreach ($d as $option) - { - $temp[] = $option->value; - } - - if (!empty($temp)) - { - $data[$subFieldName] = $temp; - } - - break; - - default: - foreach ($d as $option) - { - $data[$subFieldName] = $option->value; - } - break; + // TODO Temprary used switch case need to modify code + switch ($fieldTable->type) + { + case 'tjlist': + case 'related': + case 'multi_select': + foreach ($d as $option) + { + $temp[] = $option->value; + } + + if (!empty($temp)) + { + $data[$subFieldName] = $temp; + } + + break; + + default: + foreach ($d as $option) + { + $data[$subFieldName] = $option->value; + } + break; + } + } + else + { + $data[$subFieldName] = $d; } } - else - { - $data[$subFieldName] = $d; - } + + unset($subFormData[$keyData]); + $subFormData[$subTargetFieldName] = $data; } - unset($subFormData[$keyData]); - $subFormData[$subTargetFieldName] = $data; + unset($extraFieldsData[$fieldKey]); + $extraFieldsData[$targetFieldName] = $subFormData; + } + else + { + unset($extraFieldsData[$fieldKey]); + $extraFieldsData[$targetFieldName] = $fieldValue; } - - unset($extraFieldsData[$fieldKey]); - $extraFieldsData[$targetFieldName] = $subFormData; - } - else - { - unset($extraFieldsData[$fieldKey]); - $extraFieldsData[$targetFieldName] = $fieldValue; } - } - $ucmData = array(); - $ucmData['id'] = 0; - $ucmData['client'] = $targetClient; - $ucmData['parent_id'] = 0; - $ucmData['state'] = 0; - $ucmData['draft'] = 1; + $ucmData = array(); + $ucmData['id'] = 0; + $ucmData['client'] = $targetClient; + $ucmData['parent_id'] = 0; + $ucmData['state'] = 0; + $ucmData['draft'] = 1; - if ($clusterId) - { - $ucmData['cluster_id'] = $clusterId; - } + if ($clusterId) + { + $ucmData['cluster_id'] = $clusterId; + } - // Save data into UCM data table - $result = $model->save($ucmData); - $recordId = $model->getState($model->getName() . '.id'); + // Save data into UCM data table + $result = $model->save($ucmData); + $recordId = $model->getState($model->getName() . '.id'); - if ($recordId) - { - foreach ($fileFieldArray as $fileField) + if ($recordId) { - $fileFieldValue = round(microtime(true)) . "_" . JUserHelper::genRandomPassword(5) . "_" . $fileField['value']; - - if (copy($fileField['sourceparams']->uploadpath . $fileField['value'], $fileField['params']->uploadpath . $fileFieldValue)) + foreach ($fileFieldArray as $fileField) { - JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/tables'); - $fielValuedTable = JTable::getInstance('fieldsvalue', 'TjfieldsTable'); - $fielValuedTable->field_id = $fileField['field_id']; - $fielValuedTable->content_id = $recordId; - $fielValuedTable->value = $fileFieldValue; - $fielValuedTable->user_id = Factory::getUser()->id; - $fielValuedTable->client = $targetClient; - $fielValuedTable->store(); + $fileFieldValue = round(microtime(true)) . "_" . JUserHelper::genRandomPassword(5) . "_" . $fileField['value']; + + if (copy($fileField['sourceparams']->uploadpath . $fileField['value'], $fileField['params']->uploadpath . $fileFieldValue)) + { + JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tjfields/tables'); + $fielValuedTable = JTable::getInstance('fieldsvalue', 'TjfieldsTable'); + $fielValuedTable->field_id = $fileField['field_id']; + $fielValuedTable->content_id = $recordId; + $fielValuedTable->value = $fileFieldValue; + $fielValuedTable->user_id = Factory::getUser()->id; + $fielValuedTable->client = $targetClient; + $fielValuedTable->store(); + } } - } - $formData = array(); - $formData['content_id'] = $recordId; - $formData['fieldsvalue'] = $extraFieldsData; - $formData['client'] = $targetClient; + $formData = array(); + $formData['content_id'] = $recordId; + $formData['fieldsvalue'] = $extraFieldsData; + $formData['client'] = $targetClient; - // If data is valid then save the data into DB - $response = $model->saveExtraFields($formData); + // If data is valid then save the data into DB + $response = $model->saveExtraFields($formData); - $msg = ($response) ? Text::_("COM_TJUCM_ITEM_COPY_SUCCESSFULLY") : Text::_("COM_TJUCM_FORM_SAVE_FAILED"); + $msg = ($response) ? Text::_("COM_TJUCM_ITEM_COPY_SUCCESSFULLY") : Text::_("COM_TJUCM_FORM_SAVE_FAILED"); + } } } diff --git a/src/components/com_tjucm/site/controllers/type.php b/src/components/com_tjucm/site/controllers/type.php index b1002d75..73447a76 100644 --- a/src/components/com_tjucm/site/controllers/type.php +++ b/src/components/com_tjucm/site/controllers/type.php @@ -102,6 +102,10 @@ public function getClusterField() Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); $app = Factory::getApplication(); + + $lang = Factory::getLanguage(); + $lang->load('com_tjfields', JPATH_SITE); + $post = $app->input->post; $client = $post->get('client', '', 'STRING'); diff --git a/src/components/com_tjucm/site/layouts/list/list.php b/src/components/com_tjucm/site/layouts/list/list.php index 256f1a46..771b7c53 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -103,7 +103,7 @@ - + id); ?> diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index c754501a..85ad98e6 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -22,6 +22,12 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\Registry\Registry; use Joomla\CMS\Language\Text; +use TJQueue\Admin\TJQueueProduce; + +if (ComponentHelper::getComponent('com_tjqueue', true)->enabled) +{ + jimport('tjqueueproduce', JPATH_SITE . '/administrator/components/com_tjqueue/libraries'); +} JLoader::register('TjucmAccess', JPATH_SITE . '/components/com_tjucm/includes/access.php'); @@ -499,7 +505,7 @@ protected function loadFormData() */ public function save($data) { - $user = JFactory::getUser(); + $user = JFactory::getUser($data['created_by']); // Guest users are not allowed to add the records if (empty($user->id)) @@ -567,14 +573,17 @@ 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 = TjucmAccess::canCreate($data['type_id']); - - if (!$canAdd) + if (!$data['isCli']) { - $this->setError(JText::_('COM_TJUCM_FORM_SAVE_FAILED_AUTHORIZATION_ERROR')); + // Check if the user is allowed to add record for given UCM type + $canAdd = TjucmAccess::canCreate($data['type_id']); - return false; + if (!$canAdd) + { + $this->setError(JText::_('COM_TJUCM_FORM_SAVE_FAILED_AUTHORIZATION_ERROR')); + + return false; + } } // Check allowed limit if its set for given UCM type @@ -1119,4 +1128,56 @@ public function getUdatedRelatedFieldOptions($client, $contentId) return $returnData; } + + /** + * Method to push data in queue. + * + * @param string $ucmId Ucm id + * @param string $sourceClient Source client + * @param array $targetClient Target client + * @param Object $clusterId Cluster id + * + * @return boolean value. + * + * @since __DEPLOY_VERSION__ + */ + public static function pushDataToQueue($ucmId, $sourceClient, $targetClient, $userId, $clusterId=0) + { + $return = []; + + $messageBody = new stdClass; + $messageBody->ucmId = $ucmId; + $messageBody->sourceClient = $sourceClient; + $messageBody->targetClient = $targetClient; + $messageBody->userId = $userId; + + if ($clusterId) + { + $messageBody->clusterId = $clusterId; + } + + try + { + $TJQueueProduce = new TJQueueProduce; + + // Set message body + $TJQueueProduce->message->setBody(json_encode($messageBody)); + + // @Params client, value + $TJQueueProduce->message->setProperty('client', 'core.copyitem'); + $TJQueueProduce->produce(); + } + catch (Exception $e) + { + $return['success'] = 0; + $return['message'] = $e->getMessage(); + + return $return; + } + + $return['success'] = 1; + $return['message'] = ''; + + return $return; + } } 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 aab7b381..0a270390 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -59,8 +59,8 @@ function copySameUcmTypeItem() console.log(response); if(response.data !== null) { - Joomla.renderMessages({'success':[response.message]}); window.parent.location.reload(); + Joomla.renderMessages({'success':[response.message]}); } else { @@ -155,7 +155,7 @@ function copySameUcmTypeItem() canCopyItem) { ?> - + @@ -305,34 +305,10 @@ class="btn btn-success btn-small"> } } ?> + - - -
diff --git a/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php b/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php new file mode 100755 index 00000000..14ece1e5 --- /dev/null +++ b/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php @@ -0,0 +1,111 @@ + + * @copyright Copyright (c) 2009-2019 TechJoomla. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +// No direct access +defined('_JEXEC') or die; + +use Joomla\CMS\HTML\HTMLHelper; +use Joomla\CMS\Factory; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Session\Session; + +Factory::getDocument()->addScriptDeclaration(" + jQuery(window).load(function() + { + var currentUcmType = new FormData(); + currentUcmType.append('client', '" . $this->client . "'); + var afterCheckCompatibilityOfUcmType = function(error, response){ + response = JSON.parse(response); + + if (response.data) + { + jQuery.each(response.data, function(key, value) { + jQuery('#ucm_list').append(jQuery('').attr('value',value.value).text(value.text)); + jQuery('#ucm_list').trigger('liszt:updated'); + }); + } + else + { + jQuery('.ucmListField').addClass('hide'); + } + }; + + // Code to check ucm type compatibility to copy item + com_tjucm.Services.Items.chekCompatibility(currentUcmType, afterCheckCompatibilityOfUcmType); + + var afterGetClusterField = function(error, response){ + response = JSON.parse(response); + if (response.data != null) + { + jQuery.each(response.data, function(key, value) { + jQuery('#cluster_list').append(jQuery('').attr('value',value.value).text(value.text)); + jQuery('#cluster_list').trigger('liszt:updated'); + }); + } + else + { + jQuery('.clusterListField').addClass('hide'); + } + }; + com_tjucm.Services.Items.getClusterField(currentUcmType, afterGetClusterField); + }); + + function copyItem() + { + var afterCopyItem = function(error, response){ + response = JSON.parse(response); + console.log(response); + if(response.data !== null) + { + Joomla.renderMessages({'success':[response.message]}); + } + else + { + Joomla.renderMessages({'error':[response.message]}); + } + } + + var copyItemData = jQuery('#adminForm').serialize(); + + // Code to copy item to ucm type + com_tjucm.Services.Items.copyItem(copyItemData, afterCopyItem); + } +"); +?> + +
+ + +
 
+
+ +
+
+ From d4f337c7eddc34d061437531ea1d097c652f64c8 Mon Sep 17 00:00:00 2001 From: shraddha Date: Wed, 2 Sep 2020 10:09:18 +0530 Subject: [PATCH 227/273] Task #163912 chore: copy ucm multiple items --- src/components/com_tjucm/site/controllers/type.php | 3 ++- src/components/com_tjucm/site/models/items.php | 3 ++- .../com_tjucm/site/views/items/tmpl/default.php | 1 - .../site/views/items/tmpl/default_copyitems.php | 10 ---------- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/components/com_tjucm/site/controllers/type.php b/src/components/com_tjucm/site/controllers/type.php index 73447a76..2e833266 100644 --- a/src/components/com_tjucm/site/controllers/type.php +++ b/src/components/com_tjucm/site/controllers/type.php @@ -16,6 +16,7 @@ use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\Table\Table; /** * Type controller class. @@ -125,7 +126,7 @@ public function getClusterField() } JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR); - $fieldTable = JTable::getInstance('Field', 'TjfieldsTable', array('dbo', $db)); + $fieldTable = Table::getInstance('Field', 'TjfieldsTable', array('dbo', $db)); $fieldTable->load(array('client' => $client, 'type' => 'cluster')); if (!$fieldTable->id) diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index c9093e87..db99ad3b 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -14,6 +14,7 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\BaseDatabaseModel; +use Joomla\CMS\Table\Table; /** * Methods supporting a list of Tjucm records. @@ -580,7 +581,7 @@ public function canCopyToSameUcmType($client) } JLoader::import('components.com_tjfields.tables.field', JPATH_ADMINISTRATOR); - $fieldTable = JTable::getInstance('Field', 'TjfieldsTable', array('dbo', $db)); + $fieldTable = Table::getInstance('Field', 'TjfieldsTable', array('dbo', $db)); $fieldTable->load(array('client' => $client, 'type' => 'cluster')); if (!$checkUcmCompatability && !$fieldTable->id) 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 0a270390..f7770e83 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -56,7 +56,6 @@ function copySameUcmTypeItem() { var afterCopyItem = function(error, response){ response = JSON.parse(response); - console.log(response); if(response.data !== null) { window.parent.location.reload(); diff --git a/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php b/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php index 14ece1e5..254d37f8 100755 --- a/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php @@ -10,11 +10,8 @@ // No direct access defined('_JEXEC') or die; -use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\Factory; -use Joomla\CMS\Uri\Uri; use Joomla\CMS\Language\Text; -use Joomla\CMS\Session\Session; Factory::getDocument()->addScriptDeclaration(" jQuery(window).load(function() @@ -79,9 +76,6 @@ function copyItem() } "); ?> -
From 9086ad0dfe88fc9a1b1550226391cf12f55528d2 Mon Sep 17 00:00:00 2001 From: shraddha Date: Wed, 2 Sep 2020 16:00:06 +0530 Subject: [PATCH 228/273] Task #163912 chore: copy ucm multiple items --- .../com_tjucm/administrator/config.xml | 2 +- .../com_tjucm/administrator/models/type.php | 2 +- .../administrator/en-GB/en-GB.com_tjucm.ini | 2 +- .../com_tjucm/media/js/services/items.js | 8 ++++---- .../com_tjucm/media/js/services/items.min.js | 2 +- .../site/controllers/itemform.json.php | 6 +++--- .../com_tjucm/site/controllers/type.php | 6 +++--- .../com_tjucm/site/models/itemform.php | 2 +- .../com_tjucm/site/models/items.php | 2 +- .../site/views/items/tmpl/default.php | 19 +++++++++++++++++-- .../views/items/tmpl/default_copyitems.php | 17 +++++++++-------- 11 files changed, 42 insertions(+), 26 deletions(-) diff --git a/src/components/com_tjucm/administrator/config.xml b/src/components/com_tjucm/administrator/config.xml index b16184f0..0c76c8d1 100644 --- a/src/components/com_tjucm/administrator/config.xml +++ b/src/components/com_tjucm/administrator/config.xml @@ -3,7 +3,7 @@
-
+
diff --git a/src/components/com_tjucm/administrator/models/type.php b/src/components/com_tjucm/administrator/models/type.php index d5723981..afeff299 100644 --- a/src/components/com_tjucm/administrator/models/type.php +++ b/src/components/com_tjucm/administrator/models/type.php @@ -554,7 +554,7 @@ public function delete(&$pks) * * @since __DEPLOY_VERSION__ */ - public function getCompatableUcmType($sourceClient, $targetClient) + public function getCompatibleUcmTypes($sourceClient, $targetClient) { $validUcmType = array(); diff --git a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini index 3b6d33af..b95375a3 100644 --- a/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini +++ b/src/components/com_tjucm/languages/administrator/en-GB/en-GB.com_tjucm.ini @@ -198,7 +198,7 @@ COM_TJUCM_SEARCH_FILTER_SUBMIT="Search" ; Added in version 1.2.4 COM_TJUCM_PERMISSION_TYPE_ITEM_COPYITEM="Copy Item" COM_TJUCM_PERMISSION_TYPE_ITEM_COPYITEM_DESC="Copy Item from one UCM to another UCM or same UCM type" -JCONFIG_COPY_ITEM_SETTING_LABEL="Copy Item" +COM_TJUCM_COPY_ITEM_SETTING_LABEL="Copy Item" COM_TJUCM_USE_TJQUEUE_WHILE_COPY_ITEM="Use TjQueue While Copy Item" COM_TJUCM_USE_TJQUEUE_WHILE_COPY_ITEM_DESC="Set to 'Yes' if you want to use TjQueue while copying items" COM_TJUCM_YES="Yes" diff --git a/src/components/com_tjucm/media/js/services/items.js b/src/components/com_tjucm/media/js/services/items.js index a1a4b55f..ac24491b 100755 --- a/src/components/com_tjucm/media/js/services/items.js +++ b/src/components/com_tjucm/media/js/services/items.js @@ -7,9 +7,9 @@ 'use strict'; /** global: com_tjucm */ com_tjucm.Services.Items = new (com_tjucm.Services.Base.extend({ - checkCompatibilityUrl: window.tjSiteRoot + "index.php?option=com_tjucm&task=type.getCompatableUcmType", + checkCompatibilityUrl: window.tjSiteRoot + "index.php?option=com_tjucm&task=type.getCompatibleUcmTypes", copyItemUrl: window.tjSiteRoot + "index.php?option=com_tjucm&format=json&task=itemform.copyItem", - getClusterFieldUrl: window.tjSiteRoot + "index.php?option=com_tjucm&&task=type.getClusterField", + getClusterFieldUrl: window.tjSiteRoot + "index.php?option=com_tjucm&&task=type.getClusterFieldOptions", config: { headers: {} }, @@ -22,10 +22,10 @@ com_tjucm.Services.Items = new (com_tjucm.Services.Base.extend({ this.config.contentType = false; this.post(this.checkCompatibilityUrl, currentUcmType, this.config, callback); }, - getClusterField: function (currentUcmType, callback){ + getClusterFieldOptions: function (currentUcmType, callback){ this.config.processData = false; this.config.contentType = false; - this.post(this.checkCompatibilityUrl, currentUcmType, this.config, callback); + this.post(this.getClusterFieldUrl, currentUcmType, this.config, callback); }, copyItem: function (copyItemData, callback){ this.config.processData = false; diff --git a/src/components/com_tjucm/media/js/services/items.min.js b/src/components/com_tjucm/media/js/services/items.min.js index e6ea44df..378b0d6f 100644 --- a/src/components/com_tjucm/media/js/services/items.min.js +++ b/src/components/com_tjucm/media/js/services/items.min.js @@ -1 +1 @@ -"use strict";com_tjucm.Services.Items=new(com_tjucm.Services.Base.extend({checkCompatibilityUrl:window.tjSiteRoot+"index.php?option=com_tjucm&task=type.getCompatableUcmType",copyItemUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.copyItem",config:{headers:{}},response:{success:"",message:""},chekCompatibility:function(t,o){this.config.processData=!1,this.config.contentType=!1,this.post(this.checkCompatibilityUrl,t,this.config,o)},copyItem:function(t,o){this.config.processData=!1,this.config.contentType="application/x-www-form-urlencoded; charset=UTF-8",this.post(this.copyItemUrl,t,this.config,o)}})); \ No newline at end of file +"use strict";com_tjucm.Services.Items=new(com_tjucm.Services.Base.extend({checkCompatibilityUrl:window.tjSiteRoot+"index.php?option=com_tjucm&task=type.getCompatibleUcmTypes",copyItemUrl:window.tjSiteRoot+"index.php?option=com_tjucm&format=json&task=itemform.copyItem",getClusterFieldUrl:window.tjSiteRoot+"index.php?option=com_tjucm&&task=type.getClusterFieldOptions",config:{headers:{}},response:{success:"",message:""},chekCompatibility:function(t,i){this.config.processData=!1,this.config.contentType=!1,this.post(this.checkCompatibilityUrl,t,this.config,i)},getClusterFieldOptions:function(t,i){this.config.processData=!1,this.config.contentType=!1,this.post(this.getClusterFieldUrl,t,this.config,i)},copyItem:function(t,i){this.config.processData=!1,this.config.contentType="application/x-www-form-urlencoded; charset=UTF-8",this.post(this.copyItemUrl,t,this.config,i)}})); diff --git a/src/components/com_tjucm/site/controllers/itemform.json.php b/src/components/com_tjucm/site/controllers/itemform.json.php index 9c112fe4..5d2fb5a3 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -561,7 +561,7 @@ public function copyItem() $sourceClient = $app->input->get('client', '', 'string'); $filter = $app->input->get('filter', '', 'ARRAY'); - $targetClient = $filter['ucm_list']; + $targetClient = $filter['target_ucm']; if (!$targetClient) { @@ -576,7 +576,7 @@ public function copyItem() if ($sourceClient != $targetClient) { // Server side Validation for source and UCM Type - $result = $typeModel->getCompatableUcmType($sourceClient, $targetClient); + $result = $typeModel->getCompatibleUcmTypes($sourceClient, $targetClient); } else { @@ -599,7 +599,7 @@ public function copyItem() { foreach ($copyIds as $cid) { - $response = $model->pushDataToQueue($cid, $sourceClient, $targetClient, Factory::getuser()->id, $clusterId); + $response = $model->queueItemCopy($cid, $sourceClient, $targetClient, Factory::getuser()->id, $clusterId); $msg = ($response) ? Text::_("COM_TJUCM_ITEM_COPY_SUCCESSFULLY") : Text::_("COM_TJUCM_FORM_SAVE_FAILED"); } diff --git a/src/components/com_tjucm/site/controllers/type.php b/src/components/com_tjucm/site/controllers/type.php index 2e833266..c3f737ae 100644 --- a/src/components/com_tjucm/site/controllers/type.php +++ b/src/components/com_tjucm/site/controllers/type.php @@ -43,7 +43,7 @@ public function __construct() * * @since __DEPLOY_VERSION__ */ - public function getCompatableUcmType() + public function getCompatibleUcmTypes() { Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); @@ -71,7 +71,7 @@ public function getCompatableUcmType() { if ($type->unique_identifier != $client) { - $result = $typeModel->getCompatableUcmType($client, $type->unique_identifier); + $result = $typeModel->getCompatibleUcmTypes($client, $type->unique_identifier); if ($result) { @@ -97,7 +97,7 @@ public function getCompatableUcmType() * * @since __DEPLOY_VERSION__ */ - public function getClusterField() + public function getClusterFieldOptions() { // Check for request forgeries. Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); diff --git a/src/components/com_tjucm/site/models/itemform.php b/src/components/com_tjucm/site/models/itemform.php index 85ad98e6..99859206 100644 --- a/src/components/com_tjucm/site/models/itemform.php +++ b/src/components/com_tjucm/site/models/itemform.php @@ -1141,7 +1141,7 @@ public function getUdatedRelatedFieldOptions($client, $contentId) * * @since __DEPLOY_VERSION__ */ - public static function pushDataToQueue($ucmId, $sourceClient, $targetClient, $userId, $clusterId=0) + public static function queueItemCopy($ucmId, $sourceClient, $targetClient, $userId, $clusterId=0) { $return = []; diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index db99ad3b..24c171d1 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -571,7 +571,7 @@ public function canCopyToSameUcmType($client) { if ($client != $type->unique_identifier) { - $result = $typeModel->getCompatableUcmType($client, $type->unique_identifier); + $result = $typeModel->getCompatibleUcmTypes($client, $type->unique_identifier); if ($result) { 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 f7770e83..aa587f7c 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -56,14 +56,16 @@ function copySameUcmTypeItem() { var afterCopyItem = function(error, response){ response = JSON.parse(response); + + sessionStorage.setItem('message', response.message); if(response.data !== null) { window.parent.location.reload(); - Joomla.renderMessages({'success':[response.message]}); + sessionStorage.setItem('class', 'alert alert-success'); } else { - Joomla.renderMessages({'error':[response.message]}); + sessionStorage.setItem('class', 'alert alert-danger'); } } @@ -77,8 +79,21 @@ function copySameUcmTypeItem() $statusColumnWidth = 0; ?> + +
+
items)) { diff --git a/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php b/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php index 254d37f8..1dfd4a7c 100755 --- a/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php @@ -24,8 +24,8 @@ if (response.data) { jQuery.each(response.data, function(key, value) { - jQuery('#ucm_list').append(jQuery('').attr('value',value.value).text(value.text)); - jQuery('#ucm_list').trigger('liszt:updated'); + jQuery('#target_ucm').append(jQuery('').attr('value',value.value).text(value.text)); + jQuery('#target_ucm').trigger('liszt:updated'); }); } else @@ -51,21 +51,22 @@ jQuery('.clusterListField').addClass('hide'); } }; - com_tjucm.Services.Items.getClusterField(currentUcmType, afterGetClusterField); + com_tjucm.Services.Items.getClusterFieldOptions(currentUcmType, afterGetClusterField); }); function copyItem() { var afterCopyItem = function(error, response){ response = JSON.parse(response); - console.log(response); + + sessionStorage.setItem('message', response.message); if(response.data !== null) { - Joomla.renderMessages({'success':[response.message]}); + sessionStorage.setItem('class', 'alert alert-success'); } else { - Joomla.renderMessages({'error':[response.message]}); + sessionStorage.setItem('class', 'alert alert-danger'); } } @@ -81,7 +82,7 @@ function copyItem()
- state->get('filter.ucm_list'), 'ucm_list' ); ?> + state->get('filter.target_ucm'), 'target_ucm' ); ?>
@@ -90,7 +91,7 @@ function copyItem()