Skip to content

Commit

Permalink
4.43v forms improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Jul 5, 2024
1 parent a500557 commit 378b33e
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 74 deletions.
2 changes: 1 addition & 1 deletion lhc_web/design/defaulttheme/js/widgetv2/react.app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lhc_web/design/defaulttheme/js/widgetv2/react.app.js.map

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions lhc_web/design/defaulttheme/tpl/lhform/fill.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@
<h1><?php echo htmlspecialchars($form->name)?></h1>
<?php endif; ?>

<?php if (erLhcoreClassFormRenderer::isCollected()) : $msg = erTranslationClassLhTranslation::getInstance()->getTranslation('form/fill','Information collected');$hideSuccessButton = true; ?>
<?php include(erLhcoreClassDesign::designtpl('lhkernel/alert_success.tpl.php'));?>
<?php if (erLhcoreClassFormRenderer::isCollected()) : $msg = erTranslationClassLhTranslation::getInstance()->getTranslation('form/fill','Information collected'); $hideSuccessButton = true; ?>

<?php if (!isset($form->configuration_array['hide_content_on_success']) || $form->configuration_array['hide_content_on_success'] == false) : ?>
<?php include(erLhcoreClassDesign::designtpl('lhkernel/alert_success.tpl.php'));?>
<?php endif; ?>

<?php if (isset($replace_array)) : ?>
<?php echo str_replace(array_keys($replace_array), array_values($replace_array), $form->post_content);?>
<?php echo str_replace(array_keys($replace_array), array_values($replace_array), $form->post_content);?>
<?php else : ?>
<?php echo $form->post_content?>
<?php endif; ?>

<?php if (strpos($form->post_content,'name="ReturnButton"') === false) : ?>
<a class="btn btn-secondary btn-sm" name="ReturnButton" href="<?php if (isset($action_url)) : ?><?php echo $action_url?><?php else : ?><?php echo erLhcoreClassDesign::baseurl('form/fill')?><?php endif;?>/<?php echo $form->id?>?new"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('form/fill','Return');?></a>
<?php if ((!isset($form->configuration_array['hide_content_on_success']) || $form->configuration_array['hide_content_on_success'] == false) && strpos($form->post_content,'name="ReturnButton"') === false) : ?>
<a class="btn btn-secondary btn-sm" name="ReturnButton" href="<?php if (isset($action_url)) : ?><?php echo $action_url?><?php else : ?><?php echo erLhcoreClassDesign::baseurl('form/fill')?><?php endif;?>/<?php echo $form->id?>?new"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('form/fill','Return');?></a>
<?php endif; ?>

<?php else : ?>
Expand Down
4 changes: 2 additions & 2 deletions lhc_web/design/defaulttheme/tpl/pagelayouts/userchat2.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@
) : ?>
<?php if (!isset($Result['voice_call'])) : ?>
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/widgetv2/vendor.ie.js')?>?v=a3"></script>
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/widgetv2/react.app.ie.js')?>?t=329"></script>
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/widgetv2/react.app.ie.js')?>?t=330"></script>
<?php else : ?>
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/voice/voice.call.js')?>?t=3"></script>
<?php endif; ?>
<?php else : ?>
<?php if (!isset($Result['voice_call'])) : ?>
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/widgetv2/vendor.js')?>?v=a3"></script>
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/widgetv2/react.app.js')?>?t=329"></script>
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/widgetv2/react.app.js')?>?t=330"></script>
<?php else : ?>
<script <?php isset($Result['app_scope']) ? print 'scope="' . htmlspecialchars($Result['app_scope']) . '"' : '' ?> src="<?php echo erLhcoreClassDesign::design('js/voice/voice.call.js')?>?t=2"></script>
<?php endif; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,25 @@ const chatWidgetReducer = (state = initialState, action) => {
return state.set('chat_ui', state.get('chat_ui').merge(fromJS(action.data.chat_ui)));
}

case 'REMOVE_CHAT_MESSAGE' : {
let index = state.getIn(['chatLiveData','messages']).findIndex(msg => {
if (msg.msg.includes("id=\"msg-"+action.data.msg_id+"\"")) {
return true;
}
});

if (index !== -1) {
var nodeParse = document.createElement('div');
nodeParse.innerHTML = state.getIn(["chatLiveData", "messages", index, "msg"]);
var messageExtractor = nodeParse.querySelector("#msg-"+action.data.id);
if (messageExtractor) {
nodeParse.innerHTML = nodeParse.innerHTML.replace(messageExtractor.outerHTML,"");
state = state.setIn(["chatLiveData", "messages", index, "msg"], nodeParse.innerHTML);
}
}
return state;
}

case 'FETCH_MESSAGE_SUBMITTED' : {

let index = state.getIn(['chatLiveData','messages']).findIndex(msg => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,20 +254,30 @@ export default function (dispatch, getState) {
} else if (action == 'lhc_update_msg') {
const parts = e.data.replace('lhc_update_msg:','').split('::');
const state = getState();

// In all those actions message content is always removed, so we can update UI faster
if (parts[1] == 'iframe_close' || parts[1] == 'iframe_inline_close') {
let elm = document.getElementById('msg-'+parts[0]); elm && elm.parentNode.removeChild(elm);
dispatch({type: "REMOVE_CHAT_MESSAGE", data: {'msg_id' : parts[0]}});
}

updateMessageData({
'id' : state.chatwidget.getIn(['chatData','id']),
'hash' : state.chatwidget.getIn(['chatData','hash']),
'msg_id' : parts[0]
}, {'action' : parts[1]}).then(() => {
dispatch(updateMessage({
'msg_id' : parts[0],
'lmgsid' : state.chatwidget.getIn(['chatLiveData','lmsgid']),
'mode' : state.chatwidget.get('mode'),
'theme' : state.chatwidget.get('theme'),
'id' : state.chatwidget.getIn(['chatData','id']),
'hash' : state.chatwidget.getIn(['chatData','hash']),
'no_scroll' : true
}));
// Update only if it's non standard action
if (parts[1] != 'iframe_close' && parts[1] != 'iframe_inline_close') {
dispatch(updateMessage({
'msg_id' : parts[0],
'lmgsid' : state.chatwidget.getIn(['chatLiveData','lmsgid']),
'mode' : state.chatwidget.get('mode'),
'theme' : state.chatwidget.get('theme'),
'id' : state.chatwidget.getIn(['chatData','id']),
'hash' : state.chatwidget.getIn(['chatData','hash']),
'no_scroll' : true
}));
}
});
} else if (action == 'lhc_trigger_click') {
const parts = e.data.replace('lhc_trigger_click:','').split('::');
Expand Down
7 changes: 7 additions & 0 deletions lhc_web/doc/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
4.43v

1. Embedded forms in chat now can completely hide form content on success submission.
2. If embeded form is submitted it's content will be hidden instantly to improve UI

execute doc/update_db/update_313.sql for update

4.42v

1. Composer dependencies bumped to 8.2 PHP version. In order to run on older PHP version reinstall composer dependencies.
Expand Down
11 changes: 10 additions & 1 deletion lhc_web/doc/update_db/structure.json
Original file line number Diff line number Diff line change
Expand Up @@ -3009,6 +3009,15 @@
"extra": "",
"collation": "utf8mb4_unicode_ci"
},
{
"field": "configuration",
"type": "longtext",
"null": "NO",
"key": "",
"default": null,
"extra": "",
"collation": "utf8mb4_unicode_ci"
},
{
"field": "recipient",
"type": "varchar(250)",
Expand Down Expand Up @@ -11908,7 +11917,7 @@
"lh_abstract_auto_responder_chat": "CREATE TABLE `lh_abstract_auto_responder_chat` ( `id` int(11) NOT NULL AUTO_INCREMENT,\n `chat_id` int(11) NOT NULL,\n `auto_responder_id` int(11) NOT NULL,\n `wait_timeout_send` int(11) NOT NULL,`pending_send_status` int(11) NOT NULL, `active_send_status` int(11) NOT NULL, \n PRIMARY KEY (`id`),\n KEY `chat_id` (`chat_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
"lh_abstract_browse_offer_invitation": "CREATE TABLE `lh_abstract_browse_offer_invitation` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `siteaccess` varchar(10) NOT NULL,\n `time_on_site` int(11) NOT NULL,\n `content` longtext NOT NULL,\n `callback_content` longtext NOT NULL,\n `lhc_iframe_content` tinyint(4) NOT NULL,\n `custom_iframe_url` varchar(250) NOT NULL,\n `name` varchar(250) NOT NULL,\n `identifier` varchar(50) NOT NULL,\n `executed_times` int(11) NOT NULL,\n `url` varchar(250) NOT NULL,\n `active` int(11) NOT NULL,\n `has_url` int(11) NOT NULL,\n `is_wildcard` int(11) NOT NULL,\n `referrer` varchar(250) NOT NULL,\n `priority` varchar(250) NOT NULL,\n `hash` varchar(40) NOT NULL,\n `width` int(11) NOT NULL,\n `height` int(11) NOT NULL,\n `unit` varchar(10) NOT NULL,\n PRIMARY KEY (`id`),\n KEY `active` (`active`),\n KEY `identifier` (`identifier`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
"lh_abstract_email_template": "CREATE TABLE `lh_abstract_email_template` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `name` varchar(250) NOT NULL,\n `from_name` varchar(150) NOT NULL,\n `from_name_ac` tinyint(4) NOT NULL,\n `from_email` varchar(150) NOT NULL,\n `from_email_ac` tinyint(4) NOT NULL,\n `content` text NOT NULL,\n `subject` varchar(250) NOT NULL,\n `bcc_recipients` varchar(200) NOT NULL,\n `subject_ac` tinyint(4) NOT NULL,\n `reply_to` varchar(150) NOT NULL,\n `reply_to_ac` tinyint(4) NOT NULL,\n `recipient` varchar(150) NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
"lh_abstract_form": "CREATE TABLE `lh_abstract_form` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `name` varchar(100) NOT NULL,\n `content` longtext NOT NULL,\n `recipient` varchar(250) NOT NULL,\n `active` int(11) NOT NULL,\n `name_attr` varchar(250) NOT NULL,\n `intro_attr` varchar(250) NOT NULL,\n `xls_columns` text NOT NULL,\n `pagelayout` varchar(200) NOT NULL,\n `post_content` text NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
"lh_abstract_form": "CREATE TABLE `lh_abstract_form` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `name` varchar(100) NOT NULL,\n `configuration` longtext NOT NULL, `content` longtext NOT NULL,\n `recipient` varchar(250) NOT NULL,\n `active` int(11) NOT NULL,\n `name_attr` varchar(250) NOT NULL,\n `intro_attr` varchar(250) NOT NULL,\n `xls_columns` text NOT NULL,\n `pagelayout` varchar(200) NOT NULL,\n `post_content` text NOT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
"lh_abstract_form_collected": "CREATE TABLE `lh_abstract_form_collected` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `form_id` int(11) NOT NULL,\n `ctime` int(11) NOT NULL,\n `ip` varchar(250) NOT NULL,\n `content` longtext NOT NULL,\n PRIMARY KEY (`id`),\n KEY `form_id` (`form_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
"lh_abstract_proactive_chat_invitation": "CREATE TABLE `lh_abstract_proactive_chat_invitation` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `siteaccess` varchar(10) NOT NULL,\n `time_on_site` int(11) NOT NULL,\n `pageviews` int(11) NOT NULL,\n `message` text NOT NULL,\n `executed_times` int(11) NOT NULL,\n `dep_id` int(11) NOT NULL,\n `hide_after_ntimes` int(11) NOT NULL,\n `name` varchar(50) NOT NULL,\n `operator_ids` varchar(100) NOT NULL,\n `wait_message` varchar(250) NOT NULL,\n `timeout_message` varchar(250) NOT NULL,\n `referrer` varchar(250) NOT NULL,\n `wait_timeout` int(11) NOT NULL,\n `show_random_operator` int(11) NOT NULL,\n `operator_name` varchar(100) NOT NULL,\n `position` int(11) NOT NULL,\n `identifier` varchar(50) NOT NULL,\n `requires_email` int(11) NOT NULL,\n `requires_username` int(11) NOT NULL,\n PRIMARY KEY (`id`),\n KEY `time_on_site_pageviews_siteaccess_position` (`time_on_site`,`pageviews`,`siteaccess`,`identifier`,`position`),\n KEY `identifier` (`identifier`),\n KEY `dep_id` (`dep_id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
"lh_abstract_widget_theme": "CREATE TABLE `lh_abstract_widget_theme` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `name` varchar(250) NOT NULL,\n `onl_bcolor` varchar(10) NOT NULL,\n `text_color` varchar(10) NOT NULL,\n `online_image` varchar(250) NOT NULL,\n `online_image_path` varchar(250) NOT NULL,\n `offline_image` varchar(250) NOT NULL,\n `offline_image_path` varchar(250) NOT NULL,\n `logo_image` varchar(250) NOT NULL,\n `logo_image_path` varchar(250) NOT NULL,\n `need_help_image` varchar(250) NOT NULL,\n `header_background` varchar(10) NOT NULL,\n `widget_border_color` varchar(10) NOT NULL,\n `need_help_tcolor` varchar(10) NOT NULL,\n `need_help_bcolor` varchar(10) NOT NULL,\n `need_help_border` varchar(10) NOT NULL,\n `need_help_close_bg` varchar(10) NOT NULL,\n `need_help_hover_bg` varchar(10) NOT NULL,\n `need_help_close_hover_bg` varchar(10) NOT NULL,\n `need_help_image_path` varchar(250) NOT NULL,\n `custom_status_css` text NOT NULL, `bot_configuration` text NOT NULL ,\n `custom_container_css` text NOT NULL,\n `custom_widget_css` text NOT NULL, `custom_popup_css` text NOT NULL, \n `need_help_header` varchar(250) NOT NULL,\n `need_help_text` varchar(250) NOT NULL, `alias` varchar(50) NOT NULL,\n `online_text` varchar(250) NOT NULL,\n `offline_text` varchar(250) NOT NULL,\n PRIMARY KEY (`id`), KEY `alias` (`alias`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci",
Expand Down
10 changes: 10 additions & 0 deletions lhc_web/lib/core/lhabstract/fields/erlhabstractmodelform.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@
'validation_definition' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'
)),
'hide_content_on_success' => array(
'type' => 'checkbox',
'main_attr' => 'configuration_array',
'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/widgettheme','Do not show default content on success form submit.'),
'required' => false,
'hidden' => true,
'nginit' => true,
'validation_definition' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::OPTIONAL, 'unsafe_raw'
)),
'active' => array (
'type' => 'checkbox',
'trans' => erTranslationClassLhTranslation::getInstance()->getTranslation('abstract/browserofferinvitation','Active'),
Expand Down
4 changes: 2 additions & 2 deletions lhc_web/lib/core/lhcore/lhupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
class erLhcoreClassUpdate
{

const DB_VERSION = 312;
const LHC_RELEASE = 442;
const DB_VERSION = 313;
const LHC_RELEASE = 443;

public static function doTablesUpdate($definition){
$updateInformation = self::getTablesStatus($definition);
Expand Down
41 changes: 33 additions & 8 deletions lhc_web/lib/models/lhabstract/erlhabstractmodelform.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public function getState()
'intro_attr' => $this->intro_attr,
'xls_columns' => $this->xls_columns,
'pagelayout' => $this->pagelayout,
'post_content' => $this->post_content
'post_content' => $this->post_content,
'configuration' => $this->configuration
);

return $stateArray;
Expand Down Expand Up @@ -114,26 +115,50 @@ public function __get($var)

return $this->xls_columns_data = $totalParts;


case 'hide_delete':
return $this->hide_delete = !erLhcoreClassUser::instance()->hasAccessTo('lhform','delete_fm');

case 'configuration_array':
$attr = str_replace('_array','',$var);
if (!empty($this->{$attr})) {
$jsonData = json_decode($this->{$attr},true);
if ($jsonData !== null) {
$this->{$var} = $jsonData;
} else {
$this->{$var} = array();
}
} else {
$this->{$var} = array();
}
return $this->{$var};

default:
break;
}
}

public function beforeUpdate()
{
$this->configuration = json_encode($this->configuration_array);
}

public function beforeSave()
{
$this->configuration = json_encode($this->configuration_array);
}

public $id = null;
public $name = '';
public $content = '';
public $content = '';
public $active = 1;
public $recipient = '';
public $name_attr = '';
public $intro_attr = '';
public $xls_columns = '';
public $pagelayout = '';
public $post_content = '';

public $intro_attr = '';
public $xls_columns = '';
public $pagelayout = '';
public $post_content = '';
public $configuration = '';

public $hide_add = false;

}
Expand Down
1 change: 1 addition & 0 deletions lhc_web/modules/lhinstall/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,7 @@
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL,
`content` longtext NOT NULL,
`configuration` longtext NOT NULL,
`recipient` varchar(250) NOT NULL,
`active` int(11) NOT NULL,
`name_attr` varchar(250) NOT NULL,
Expand Down
2 changes: 1 addition & 1 deletion lhc_web/modules/lhwidgetrestapi/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@
$outputResponse['wv'] = 229;

// React APP versions
$outputResponse['v'] = 329;
$outputResponse['v'] = 330;

$outputResponse['hash'] = sha1(erLhcoreClassIPDetect::getIP() . $ts . erConfigClassLhConfig::getInstance()->getSetting( 'site', 'secrethash' ));
$outputResponse['hash_ts'] = $ts;
Expand Down
Loading

0 comments on commit 378b33e

Please sign in to comment.