Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Front end>> Editor field not showing data at front end once user select editor JCE. #327

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/components/com_tjucm/administrator/models/forms/type.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="bitrate_on" type="radio" class="btn-group" default="0" label="COM_TJUCM_FORM_LBL_TYPE_ALLOW_BITRATE_ON" description="COM_TJUCM_FORM_DESC_LBL_TYPE_ALLOW_BITRATE_ON" hint="COM_TJUCM_FORM_LBL_TYPE_ALLOW_BITRATE_ON" showon="allow_auto_save:1">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="bitrate_seconds" type="number" filter="raw" label="COM_TJUCM_FORM_LBL_TYPE_BITRATE_SECONDS" description="COM_TJUCM_FORM_DESC_LBL_TYPE_BITRATE_SECONDS" hint="COM_TJUCM_FORM_LBL_TYPE_BITRATE_SECONDS" showon="bitrate_on:1"/>
<field name="layout" type="componentlayout" label="COM_TJUCM_FORM_LBL_TYPE_LAYOUT" description="COM_TJUCM_FORM_DESC_TYPE_LAYOUT" useglobal="true" extension="com_tjucm" view="itemform" />
<field name="details_layout" type="componentlayout" label="COM_TJUCM_DETAILS_LBL_TYPE_LAYOUT" description="COM_TJUCM_DETAILS_DESC_TYPE_LAYOUT" useglobal="true" extension="com_tjucm" view="item" />
<field name="list_layout" type="componentlayout" label="COM_TJUCM_LIST_LBL_TYPE_LAYOUT" description="COM_TJUCM_LIST_DESC_TYPE_LAYOUT" useglobal="true" extension="com_tjucm" view="items" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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="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. <b>Note:If you have used editor field in your UCM type then you should enable this configuration</b>"
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"
108 changes: 51 additions & 57 deletions src/components/com_tjucm/media/js/ui/itemform.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ jQuery(window).load(function()
{
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)
{
Expand All @@ -43,53 +49,15 @@ jQuery(window).load(function()
}
});

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)
{
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);
}
}
}
}
},7000);
if (jQuery("#item-form #tjUcmSectionDraftSave").length >= 1)
{
setInterval(function(){
jQuery("#tjUcmSectionDraftSave").click();
}, tjUcmBitrateSeconds*1000);
}
}
}
}
Expand Down Expand Up @@ -625,7 +593,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')
Expand Down Expand Up @@ -657,11 +635,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 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 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);
Expand All @@ -688,23 +671,34 @@ 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 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*/
Expand Down
4 changes: 2 additions & 2 deletions src/components/com_tjucm/site/layouts/list/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,12 @@
{
?>
<td class="center">
<a target="_blank" href="<?php echo $link; ?>" type="button" title="<?php echo Text::_('COM_TJUCM_VIEW_RECORD');?>"><i class="icon-eye-open"></i></a>
<a href="<?php echo $link; ?>" type="button" title="<?php echo Text::_('COM_TJUCM_VIEW_RECORD');?>"><i class="icon-eye-open"></i></a>
<?php
if ($canEdit || $editown)
{
?>
<a target="_blank" href="<?php echo 'index.php?option=com_tjucm&task=itemform.edit&id=' . $item->id . $appendUrl; ?>" type="button" title="<?php echo Text::_('COM_TJUCM_EDIT_ITEM');?>"> | <i class="icon-apply" aria-hidden="true"></i></a>
<a href="<?php echo 'index.php?option=com_tjucm&task=itemform.edit&id=' . $item->id . $appendUrl; ?>" type="button" title="<?php echo Text::_('COM_TJUCM_EDIT_ITEM');?>"> | <i class="icon-apply" aria-hidden="true"></i></a>
<?php
}
if ($canDelete || $deleteOwn)
Expand Down
2 changes: 2 additions & 0 deletions src/components/com_tjucm/site/views/itemform/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,7 @@
<input type="hidden" name="task" value="itemform.save"/>
<input type="hidden" name="form_status" id="form_status" value=""/>
<input type="hidden" name="tjucm-autosave" id="tjucm-autosave" value="<?php echo $this->allow_auto_save;?>"/>
<input type="hidden" name="tjucm-bitrate" id="tjucm-bitrate" value="<?php echo $this->allow_bit_rate;?>"/>
<input type="hidden" name="tjucm-bitrate_seconds" id="tjucm-bitrate_seconds" value="<?php echo $this->allow_bit_rate_seconds;?>"/>
<?php echo HTMLHelper::_('form.token'); ?>
</form>
17 changes: 16 additions & 1 deletion src/components/com_tjucm/site/views/itemform/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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')))
{
Expand Down