From 7acb3f10af99845720bbf53723123cf5f0afceef Mon Sep 17 00:00:00 2001 From: prvnpuri Date: Thu, 12 Mar 2020 14:31:25 +0530 Subject: [PATCH 1/4] Feature #158773 chore: Rating Field in TjUcm --- src/components/com_tjucm/media/css/tjucm.css | 63 +++++++++++++++++++ .../com_tjucm/site/layouts/detail/fields.php | 1 + 2 files changed, 64 insertions(+) diff --git a/src/components/com_tjucm/media/css/tjucm.css b/src/components/com_tjucm/media/css/tjucm.css index 5641015a..8334dbff 100644 --- a/src/components/com_tjucm/media/css/tjucm.css +++ b/src/components/com_tjucm/media/css/tjucm.css @@ -22,3 +22,66 @@ width:200px !important; .tjucm-wrapper .tj-wordwrap{ word-break: break-word; } + +/****** Style Star Rating Widget *****/ +fieldset, label { margin: 0; padding: 0; } +body{ margin: 20px; } +h1 { font-size: 1.5em; margin: 10px; } + +.rating { + border: none; + float: left; +} + +.rating > input { display: none; } +.rating > label:before { + margin: 5px; + font-size: 1.25em; + font-family: FontAwesome; + display: inline-block; + content: "\f005"; + position: relative; +} + +.rating.heart > label:before { + content: "\f004"; +} + +.rating > .half:before { + content: "\f089"; + position: absolute; +} + +.rating.heart > .half:before { + content: "\f08a"; + position: absolute; +} + +.rating > label { + color: #ddd; + float: right; +} + +.rating > label:empty{ +display:block !important; +} +/***** CSS Magic to Highlight Stars on Hover *****/ + +.rating > input:checked ~ label, /* show gold star when clicked */ +.rating:not(:checked) > label:hover, /* hover current star */ +.rating:not(:checked) > label:hover ~ label { color: #FFD700; } /* hover previous stars in list */ + +.rating > input:checked + label:hover, /* hover current star when changing rating */ +.rating > input:checked ~ label:hover, +.rating > label:hover ~ input:checked ~ label, /* lighten current selection */ +.rating > input:checked ~ label:hover ~ label { color: #FFED85; } + +/****** Css implementad for Detail view ******/ + +.rating.nohover:not(:checked) > label:hover, /* hover current star */ +.rating.nohover:not(:checked) > label:hover ~ label { color: #ddd; } /* hover previous stars in list */ + +.rating.nohover > input:checked + label:hover, /* hover current star when changing rating */ +.rating.nohover > input:checked ~ label:hover, +.rating.nohover > label:hover ~ input:checked ~ label, /* lighten current selection */ +.rating.nohover > input:checked ~ label:hover ~ label { color: #FFD700; } diff --git a/src/components/com_tjucm/site/layouts/detail/fields.php b/src/components/com_tjucm/site/layouts/detail/fields.php index acec8160..fcadf6df 100644 --- a/src/components/com_tjucm/site/layouts/detail/fields.php +++ b/src/components/com_tjucm/site/layouts/detail/fields.php @@ -32,6 +32,7 @@ $fieldLayout['Subform'] = "subform"; $fieldLayout['Ownership'] = "ownership"; $fieldLayout['Editor'] = "editor"; +$fieldLayout['rating'] = "rating"; // Load the tj-fields helper JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); From 6a44d9a54236cacef625c869e1201c98bccf7d61 Mon Sep 17 00:00:00 2001 From: shraddha Date: Mon, 17 Aug 2020 09:27:54 +0530 Subject: [PATCH 2/4] Feature #163832 chore: Implement Multiple Copy feature on the frontend listing --- .../com_tjucm/administrator/access.xml | 1 + .../administrator/en-GB/en-GB.com_tjucm.ini | 4 + .../languages/site/en-GB/en-GB.com_tjucm.ini | 5 + .../site/controllers/itemform.json.php | 28 ++++- .../com_tjucm/site/controllers/type.php | 63 +++++++++- .../com_tjucm/site/layouts/list/list.php | 7 +- .../com_tjucm/site/models/items.php | 45 +++++++ .../site/views/items/tmpl/default.php | 101 +++++++-------- .../views/items/tmpl/default_copyitems.php | 116 ++++++++++++++++++ .../com_tjucm/site/views/items/view.html.php | 3 + 10 files changed, 303 insertions(+), 70 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/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 0c368d5a..9475e25c 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 @@ -209,3 +209,8 @@ 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_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 74462925..827e4281 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -519,24 +519,39 @@ public function getRelatedFieldOptions() public function copyItem() { // Check for request forgeries. - Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + //~ Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); $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) { $copyIds = $app->input->get('cid'); + JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); $tjFieldsHelper = new TjfieldsHelper; @@ -681,6 +696,11 @@ public function copyItem() $ucmData['parent_id'] = 0; $ucmData['state'] = 0; $ucmData['draft'] = 1; + + if ($clusterId) + { + $ucmData['cluster_id'] = $clusterId; + } // Save data into UCM data table $result = $model->save($ucmData); diff --git a/src/components/com_tjucm/site/controllers/type.php b/src/components/com_tjucm/site/controllers/type.php index 6e266dfe..b0625365 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. @@ -43,7 +44,7 @@ public function __construct() */ public function getCompatableUcmType() { - Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + //~ Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); $app = Factory::getApplication(); $post = $app->input->post; @@ -71,14 +72,68 @@ public function getCompatableUcmType() { $result = $typeModel->getCompatableUcmType($client, $type->unique_identifier); - if ($result) + if ($result && $client != $type->unique_identifier) { - $validUcmType[$key]['value'] = $type->unique_identifier; - $validUcmType[$key]['text'] = $type->title; + $validUcmType[$key+1]['value'] = $type->unique_identifier; + $validUcmType[$key+1]['text'] = $type->title; } } + 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 6ff9d6a7..c6da5c6d 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -51,7 +51,7 @@ $formObject = $displayData['formObject']; $ucmTypeId = $displayData['ucmTypeId']; $allowDraftSave = $displayData['ucmTypeParams']->allow_draft_save; - +$i = $displayData['key']; $appendUrl = ''; $csrf = "&" . Session::getFormToken() . '=1'; @@ -60,6 +60,7 @@ $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); +$canCopyItem = $user->authorise('core.type.copyitem', 'com_tjucm.type.' . $ucmTypeId); if (!empty($created_by)) { @@ -94,9 +95,11 @@ ?>
+ - id); ?> + id); ?> + state)) { diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 7a48084a..61061da6 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. @@ -647,4 +648,48 @@ public function showListCheck($client) return false; } } + + /** + * Method to check the compatibility between ucm types + * + * @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 be991251..c57f9fdf 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -20,11 +20,16 @@ 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() { SqueezeBox.open("' . $importItemsPopUpUrl . '" ,{handler: "iframe", size: {x: window.innerWidth-250, y: window.innerHeight-150}}); }); + //~ jQuery("#adminForm #copy-items").click(function() { + //~ if (document.adminForm.boxchecked.value==0){alert(Joomla.JText._("JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST"));}else{ + //~ SqueezeBox.open("' . $copyItemPopupUrl . '" ,{handler: "iframe", size: {x: window.innerWidth-250, y: window.innerHeight-150}});} + //~ }); }); '); @@ -51,38 +56,15 @@ $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 !== null) - { - 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 { @@ -94,7 +76,7 @@ function copyItem() // Code to copy item to ucm type com_tjucm.Services.Items.copyItem(copyItemData, afterCopyItem); - } + } "); $statusColumnWidth = 0; @@ -132,6 +114,33 @@ function copyItem() canCopyItem) + { + if ($this->canCopyToSameeUcmType) + {?> + + + + + + + + JText::_('COM_TJUCM_COPY_ITEMS'), + ), + $this->loadTemplate('copyitems') + ); ?> +
@@ -148,9 +157,11 @@ function copyItem() {?> + canCopyItem) { ?> + items[0]->state)) { @@ -246,7 +257,8 @@ function copyItem() 'fieldsData' => $fieldsData, 'formObject' => $formObject, 'statusColumnWidth' => $statusColumnWidth, - 'listcolumn' => $this->listcolumn + 'listcolumn' => $this->listcolumn, + 'key' => $i, ) ); } @@ -286,44 +298,13 @@ 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..da0b6820 --- /dev/null +++ b/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php @@ -0,0 +1,116 @@ + + * @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); + } +"); +?> + +
+
+ + state->get('filter.ucm_list'), 'ucm_list' ); ?> +
+
+ + state->get('filter.cluster_list'), 'cluster_list' ); ?> +
+
+
 
+ +
+
 
+
+ +
+
+ + + + + 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 9d79de02..91f42733 100644 --- a/src/components/com_tjucm/site/views/items/view.html.php +++ b/src/components/com_tjucm/site/views/items/view.html.php @@ -102,9 +102,12 @@ 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->canCopyItem = $user->authorise('core.type.copyitem', 'com_tjucm.type.' . $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->canCopyToSameeUcmType = $model->canCopyToSameUcmType($this->client); + // If did not get the client from url then get if from menu param if (empty($this->client)) { From de8fb89685097d963963a577df1c1993e68b551e Mon Sep 17 00:00:00 2001 From: shraddha Date: Mon, 17 Aug 2020 09:29:50 +0530 Subject: [PATCH 3/4] Feature #163832 chore: Implement Multiple Copy feature on the frontend listing --- src/components/com_tjucm/site/views/itemform/view.html.php | 5 +++-- 1 file changed, 3 insertions(+), 2 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 6f8e5301..2c9c25d6 100644 --- a/src/components/com_tjucm/site/views/itemform/view.html.php +++ b/src/components/com_tjucm/site/views/itemform/view.html.php @@ -203,14 +203,15 @@ 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'); From 3337d46250e90fbece1f3ac2afb2ad9f179aac5f Mon Sep 17 00:00:00 2001 From: shraddha Date: Tue, 25 Aug 2020 16:25:02 +0530 Subject: [PATCH 4/4] Feature #158773 chore: Rating Field in TjUcm --- .../com_tjucm/administrator/access.xml | 1 - .../administrator/en-GB/en-GB.com_tjucm.ini | 4 - .../languages/site/en-GB/en-GB.com_tjucm.ini | 5 - .../site/controllers/itemform.json.php | 26 +-- .../com_tjucm/site/controllers/type.php | 63 +------- .../com_tjucm/site/layouts/list/list.php | 6 +- .../com_tjucm/site/models/items.php | 45 ------ .../site/views/items/tmpl/default.php | 150 +++++++++--------- .../views/items/tmpl/default_copyitems.php | 116 -------------- .../com_tjucm/site/views/items/view.html.php | 3 - 10 files changed, 87 insertions(+), 332 deletions(-) delete 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 d634a3f0..689379fa 100644 --- a/src/components/com_tjucm/administrator/access.xml +++ b/src/components/com_tjucm/administrator/access.xml @@ -21,6 +21,5 @@ - 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..ba95bfda 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,7 +194,3 @@ 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 9475e25c..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 @@ -209,8 +209,3 @@ 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_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 827e4281..cfa93142 100644 --- a/src/components/com_tjucm/site/controllers/itemform.json.php +++ b/src/components/com_tjucm/site/controllers/itemform.json.php @@ -524,34 +524,19 @@ public function copyItem() $app = Factory::getApplication(); $post = $app->input->post; - $sourceClient = $app->input->get('client', '', 'string'); + $sourceClient = $app->input->get('sourceClient', '', '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'); - if ($sourceClient != $targetClient) - { - // Server side Validation for source and UCM Type - $result = $typeModel->getCompatableUcmType($sourceClient, $targetClient); - } - else - { - $result = true; - } + // Server side Validation for source and UCM Type + $result = $typeModel->getCompatableUcmType($sourceClient, $targetClient); if ($result) { $copyIds = $app->input->get('cid'); - JLoader::import('components.com_tjfields.helpers.tjfields', JPATH_SITE); $tjFieldsHelper = new TjfieldsHelper; @@ -696,11 +681,6 @@ public function copyItem() $ucmData['parent_id'] = 0; $ucmData['state'] = 0; $ucmData['draft'] = 1; - - if ($clusterId) - { - $ucmData['cluster_id'] = $clusterId; - } // Save data into UCM data table $result = $model->save($ucmData); diff --git a/src/components/com_tjucm/site/controllers/type.php b/src/components/com_tjucm/site/controllers/type.php index b0625365..6e266dfe 100644 --- a/src/components/com_tjucm/site/controllers/type.php +++ b/src/components/com_tjucm/site/controllers/type.php @@ -15,7 +15,6 @@ use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\Model\BaseDatabaseModel; -use Joomla\CMS\Component\ComponentHelper; /** * Type controller class. @@ -44,7 +43,7 @@ public function __construct() */ public function getCompatableUcmType() { - //~ Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); + Session::checkToken() or jexit(Text::_('JINVALID_TOKEN')); $app = Factory::getApplication(); $post = $app->input->post; @@ -72,68 +71,14 @@ public function getCompatableUcmType() { $result = $typeModel->getCompatableUcmType($client, $type->unique_identifier); - if ($result && $client != $type->unique_identifier) + if ($result) { - $validUcmType[$key+1]['value'] = $type->unique_identifier; - $validUcmType[$key+1]['text'] = $type->title; + $validUcmType[$key]['value'] = $type->unique_identifier; + $validUcmType[$key]['text'] = $type->title; } } - 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 c6da5c6d..8abedfc6 100644 --- a/src/components/com_tjucm/site/layouts/list/list.php +++ b/src/components/com_tjucm/site/layouts/list/list.php @@ -51,7 +51,6 @@ $formObject = $displayData['formObject']; $ucmTypeId = $displayData['ucmTypeId']; $allowDraftSave = $displayData['ucmTypeParams']->allow_draft_save; -$i = $displayData['key']; $appendUrl = ''; $csrf = "&" . Session::getFormToken() . '=1'; @@ -60,7 +59,6 @@ $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); -$canCopyItem = $user->authorise('core.type.copyitem', 'com_tjucm.type.' . $ucmTypeId); if (!empty($created_by)) { @@ -95,11 +93,9 @@ ?>
- - id); ?> + id); ?> - state)) { diff --git a/src/components/com_tjucm/site/models/items.php b/src/components/com_tjucm/site/models/items.php index 61061da6..7a48084a 100644 --- a/src/components/com_tjucm/site/models/items.php +++ b/src/components/com_tjucm/site/models/items.php @@ -13,7 +13,6 @@ jimport('joomla.application.component.modellist'); use Joomla\CMS\Component\ComponentHelper; -use Joomla\CMS\MVC\Model\BaseDatabaseModel; /** * Methods supporting a list of Tjucm records. @@ -648,48 +647,4 @@ public function showListCheck($client) return false; } } - - /** - * Method to check the compatibility between ucm types - * - * @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 c57f9fdf..3274f4e8 100644 --- a/src/components/com_tjucm/site/views/items/tmpl/default.php +++ b/src/components/com_tjucm/site/views/items/tmpl/default.php @@ -20,16 +20,11 @@ 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() { SqueezeBox.open("' . $importItemsPopUpUrl . '" ,{handler: "iframe", size: {x: window.innerWidth-250, y: window.innerHeight-150}}); }); - //~ jQuery("#adminForm #copy-items").click(function() { - //~ if (document.adminForm.boxchecked.value==0){alert(Joomla.JText._("JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST"));}else{ - //~ SqueezeBox.open("' . $copyItemPopupUrl . '" ,{handler: "iframe", size: {x: window.innerWidth-250, y: window.innerHeight-150}});} - //~ }); }); '); @@ -56,24 +51,40 @@ $fieldsData = array(); JFactory::getDocument()->addScriptDeclaration(" - function copySameUcmTypeItem() + 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() { var afterCopyItem = function(error, response){ response = JSON.parse(response); - console.log(response); + // Close pop up and display message + jQuery( '#copyModal' ).modal('hide'); 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); } @@ -90,7 +101,7 @@ function copySameUcmTypeItem() ?> canCopyItem) - { - if ($this->canCopyToSameeUcmType) - {?> - - - - - - - - JText::_('COM_TJUCM_COPY_ITEMS'), - ), - $this->loadTemplate('copyitems') - ); ?> -
@@ -157,11 +141,10 @@ function copySameUcmTypeItem() {?> - canCopyItem) { ?> - + + - items[0]->state)) { @@ -201,21 +184,15 @@ function copySameUcmTypeItem() } ?> - - + + canEdit || $this->canDelete) - { ?> - $fieldsData, 'formObject' => $formObject, 'statusColumnWidth' => $statusColumnWidth, - 'listcolumn' => $this->listcolumn, - 'key' => $i, + 'listcolumn' => $this->listcolumn ) ); } @@ -281,10 +257,10 @@ function copySameUcmTypeItem() items)) - { - echo $this->pagination->getListFooter(); - } + if (!empty($this->items)) + { + echo $this->pagination->getPagesLinks(); + } ?> @@ -299,31 +275,63 @@ class="btn btn-success btn-small"> canImport) + { + ?> + + + - + + + -canDelete) -{ - ?> - - 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 deleted file mode 100755 index da0b6820..00000000 --- a/src/components/com_tjucm/site/views/items/tmpl/default_copyitems.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @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); - } -"); -?> - -
-
- - state->get('filter.ucm_list'), 'ucm_list' ); ?> -
-
- - state->get('filter.cluster_list'), 'cluster_list' ); ?> -
-
-
 
- -
-
 
-
- -
-
- - - - - 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 91f42733..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,12 +102,9 @@ 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->canCopyItem = $user->authorise('core.type.copyitem', 'com_tjucm.type.' . $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->canCopyToSameeUcmType = $model->canCopyToSameUcmType($this->client); - // If did not get the client from url then get if from menu param if (empty($this->client)) {