Skip to content

Commit

Permalink
Merge pull request #364 from ankush-maherwal/actionlogs
Browse files Browse the repository at this point in the history
Actionlogs
  • Loading branch information
ankush-maherwal authored Jul 22, 2020
2 parents c923076 + df01704 commit 8d75474
Show file tree
Hide file tree
Showing 36 changed files with 1,404 additions and 288 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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";
}
}

Expand All @@ -101,6 +103,7 @@ public function migrate()
$result['status'] = false;
$result['message'] = $e->getMessage();
}

return $result;
}
}
23 changes: 23 additions & 0 deletions src/components/com_tjucm/administrator/models/type.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ class TjucmModelType extends JModelAdmin
*/
protected $item = null;

/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
*
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
$config['event_after_delete'] = 'tjUcmOnAfterTypeDelete';
$config['event_change_state'] = 'tjUcmOnAfterTypeChangeState';

parent::__construct($config);
}

/**
* Returns a reference to the a Table object, always creating it.
*
Expand Down Expand Up @@ -351,6 +367,13 @@ public function save($data)

if (parent::save($data))
{
$id = (int) $this->getState($this->getName() . '.id');
$data['typeId'] = $id;
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('actionlog', 'tjucm');
$isNew = ($data['id'] != 0) ? false : true;
$dispatcher->trigger('tjUcmOnAfterTypeSave', array($data, $isNew));

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -211,3 +210,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"
9 changes: 9 additions & 0 deletions src/components/com_tjucm/media/css/tjucm.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions src/components/com_tjucm/media/gif/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<FilesMatch ".*">
Allow from All
</FilesMatch>
Binary file added src/components/com_tjucm/media/gif/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 40 additions & 16 deletions src/components/com_tjucm/media/js/ui/itemform.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ jQuery(window).load(function()
tjUcmClickedOnPrev = 0;
}

jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow");
jQuery("html, body").animate({scrollTop: jQuery("#system-message-container").position().top}, "slow");
}
}
else
Expand Down Expand Up @@ -334,7 +334,7 @@ jQuery(window).load(function()
tjUcmClickedOnPrev = 0;
}

jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow");
jQuery("html, body").animate({scrollTop: jQuery("#system-message-container").position().top}, "slow");
}
});
});
Expand Down Expand Up @@ -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)
Expand All @@ -585,13 +588,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
Expand All @@ -603,6 +613,10 @@ var tjUcmItemForm = {
return true;
},
afterDataSave: function (error, response){

/* Hide loader when record is saved*/
jQuery("#item-form #tjucm_loader").hide();

response = JSON.parse(response);
/* Remove the dirty class fromt the form once the field data is saved*/
jQuery('#item-form').removeClass('dirty');
Expand Down Expand Up @@ -675,7 +689,7 @@ var tjUcmItemForm = {
Joomla.renderMessages({'error':[response.message]});
}

jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow");
jQuery("html, body").animate({scrollTop: jQuery("#system-message-container").position().top}, "slow");
}

if (response.messages !== null)
Expand All @@ -686,7 +700,7 @@ var tjUcmItemForm = {
Joomla.renderMessages({'error':[value]});
});

jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow");
jQuery("html, body").animate({scrollTop: jQuery("#system-message-container").position().top}, "slow");
}
}
}
Expand Down Expand Up @@ -769,7 +783,7 @@ var tjUcmItemForm = {
{
tjUcmItemForm.setVisibilityOfNavigationButtons();
jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', false);
jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow");
jQuery("html, body").animate({scrollTop: jQuery("#system-message-container").position().top}, "slow");

return false;
}
Expand All @@ -787,6 +801,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);
Expand Down Expand Up @@ -815,7 +833,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);
Expand All @@ -826,6 +844,13 @@ var tjUcmItemForm = {
}
});

jQuery('#item-form select').each(function (){
if (jQuery(this).val() == null)
{
tjUcmItemFormData.append(jQuery(this).attr('name'), '');
}
});

/* Do not show draft save msg if the save is triggered as per bitrate config*/
if (tjUcmSaveFormInDraftWithNoMsg !== undefined)
{
Expand Down Expand Up @@ -897,7 +922,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');
Expand All @@ -917,7 +941,7 @@ var tjUcmItemForm = {
}
else
{
jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow");
jQuery("html, body").animate({scrollTop: jQuery("#system-message-container").position().top}, "slow");

return false;
}
Expand Down Expand Up @@ -1007,7 +1031,7 @@ function steppedFormSave(form_id, status, showDraftSuccessMsg)
if(!confirm(Joomla.JText._("COM_TJUCM_ITEMFORM_SUBMIT_ALERT")))
{
jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', false);
jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow");
jQuery("html, body").animate({scrollTop: jQuery("#system-message-container").position().top}, "slow");

return false;
}
Expand All @@ -1018,7 +1042,7 @@ function steppedFormSave(form_id, status, showDraftSuccessMsg)
else
{
jQuery(".form-actions button[type='button'], .form-actions input[type='button']").attr('disabled', false);
jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow");
jQuery("html, body").animate({scrollTop: jQuery("#system-message-container").position().top}, "slow");

return false;
}
Expand All @@ -1040,15 +1064,15 @@ function steppedFormSave(form_id, status, showDraftSuccessMsg)
Joomla.renderMessages({'error':[value]});
});

jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow");
jQuery("html, body").animate({scrollTop: jQuery("#system-message-container").position().top}, "slow");
}
}

if (returnedData.message !== null && returnedData.message != '')
{
Joomla.renderMessages({'info':[returnedData.message]});

jQuery("html, body").animate({scrollTop: jQuery("#item-form").position().top}, "slow");
jQuery("html, body").animate({scrollTop: jQuery("#system-message-container").position().top}, "slow");
}

if (returnedData.data !== null)
Expand Down
2 changes: 1 addition & 1 deletion src/components/com_tjucm/media/js/ui/itemform.min.js

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions src/components/com_tjucm/site/controllers/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public function edit()

// Get the model.
$model = $this->getModel('Item', 'TjucmModel');


// Check out the item
if ($editId)
Expand Down Expand Up @@ -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');

Expand Down Expand Up @@ -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)
{
Expand Down
Loading

0 comments on commit 8d75474

Please sign in to comment.