AntonLV 5 лет назад
Родитель
Сommit
bfb8034d45

+ 2 - 0
inc/classes/BxDolFormQuery.php

@@ -132,6 +132,8 @@ class BxDolFormQuery extends BxDolDb
                 'caption' => _t($a['caption']),
             	'info_src' => $a['info'] ? $a['info'] : '',
                 'info' => $a['info'] ? _t($a['info']) : '',
+                'help_src' => $a['help'] ? $a['help'] : '',
+                'help' => $a['help'] ? _t($a['help']) : '',
                 'required' => $a['required'] ? true : false,
             	'unique' => $a['unique'] ? true : false,
                 'collapsed' => $a['collapsed'] ? true : false,

+ 15 - 1
inc/js/classes/BxDolForm.js

@@ -23,6 +23,20 @@ function BxDolForm(oOptions)
     this._aHtmlIds = oOptions.aHtmlIds;
 }
 
+BxDolForm.prototype.showHelp = function(oLink, sInputName)
+{
+    var oData = this._getDefaultParams();
+    oData['a'] = 'get_help';
+    oData['input'] = sInputName;
+
+    $(oLink).dolPopupAjax({
+        id: {value:this._aHtmlIds['help_popup'] + sInputName, force:1}, 
+        url: bx_append_url_params(this._sActionsUri, oData),
+        closeOnOuterClick: true,
+        removeOnClose: false,
+    });
+};
+
 BxDolForm.prototype.pgcTogglePopup = function(oLink, iInputId, sPrivacyObject)
 {
     var oData = this._getDefaultParams();
@@ -31,7 +45,7 @@ BxDolForm.prototype.pgcTogglePopup = function(oLink, iInputId, sPrivacyObject)
     oData['privacy_object'] = sPrivacyObject;
 
     $(oLink).dolPopupAjax({
-        id: this._aHtmlIds['pgc_popup'] + iInputId, 
+        id: {value:this._aHtmlIds['pgc_popup'] + iInputId, force:1},
         url: bx_append_url_params(this._sActionsUri, oData),
         closeOnOuterClick: false,
         removeOnClose: true,

+ 1 - 0
install/sql/system.sql

@@ -3267,6 +3267,7 @@ CREATE TABLE IF NOT EXISTS `sys_form_inputs` (
   `caption_system` varchar(255) NOT NULL,
   `caption` varchar(255) NOT NULL,
   `info` varchar(255) NOT NULL,
+  `help` varchar(255) NOT NULL,
   `required` tinyint(4) NOT NULL DEFAULT '0',
   `unique` tinyint(4) NOT NULL DEFAULT '0',
   `collapsed` tinyint(4) NOT NULL DEFAULT '0',

+ 2 - 0
modules/boonex/english/data/langs/system/en.xml

@@ -763,6 +763,7 @@
 	<string name="_adm_form_dsc_field_collapsed"><![CDATA[Pack down the group of this field by default]]></string>
 	<string name="_adm_form_dsc_field_html"><![CDATA[Select type of HTML editor]]></string>
 	<string name="_adm_form_dsc_field_info"><![CDATA[Enter field description (optional)]]></string>
+        <string name="_adm_form_dsc_field_help"><![CDATA[Enter help information for the field (optional)]]></string>
   <string name="_adm_form_dsc_field_privacy"><![CDATA[Check it if privacy settings can be changed for the field]]></string>
   <string name="_adm_form_dsc_field_rateable"><![CDATA[Make this field rateable]]></string>
 	<string name="_adm_form_dsc_field_required"><![CDATA[Check it if the field should have value]]></string>
@@ -908,6 +909,7 @@
 	<string name="_adm_form_txt_field_html_none"><![CDATA[No Editor]]></string>
 	<string name="_adm_form_txt_field_html_standard"><![CDATA[Standard]]></string>
 	<string name="_adm_form_txt_field_info"><![CDATA[Description]]></string>
+        <string name="_adm_form_txt_field_help"><![CDATA[Help]]></string>
 	<string name="_adm_form_txt_field_module"><![CDATA[Module]]></string>
 	<string name="_adm_form_txt_field_name"><![CDATA[Name]]></string>
 	<string name="_adm_form_txt_field_object"><![CDATA[Form]]></string>

+ 2 - 0
modules/boonex/russian/data/langs/system/ru.xml

@@ -759,6 +759,7 @@
 	<string name="_adm_form_dsc_field_collapsed"><![CDATA[Упаковать группу данного поля по умолчанию]]></string>
 	<string name="_adm_form_dsc_field_html"><![CDATA[Выбрать тип HTML-редактора]]></string>
 	<string name="_adm_form_dsc_field_info"><![CDATA[Введите описание поля (необязательно)]]></string>
+        <string name="_adm_form_dsc_field_help"><![CDATA[Добавьте вспомогательную информацию для поля (необязательно)]]></string>
         <string name="_adm_form_dsc_field_privacy"><![CDATA[Отметьте, если для данного поля настройки "Конфиденциальности" могут быть изменены]]></string>
   <string name="_adm_form_dsc_field_rateable"><![CDATA[Добавляет возможность оценки значений]]></string>
 	<string name="_adm_form_dsc_field_required"><![CDATA[Отметьте, если поле должно иметь значение]]></string>
@@ -903,6 +904,7 @@
 	<string name="_adm_form_txt_field_html_none"><![CDATA[Без редактора]]></string>
 	<string name="_adm_form_txt_field_html_standard"><![CDATA[Стандартный]]></string>
 	<string name="_adm_form_txt_field_info"><![CDATA[Описание]]></string>
+        <string name="_adm_form_txt_field_help"><![CDATA[Помощь]]></string>
 	<string name="_adm_form_txt_field_module"><![CDATA[Модуль]]></string>
 	<string name="_adm_form_txt_field_name"><![CDATA[Имя]]></string>
 	<string name="_adm_form_txt_field_object"><![CDATA[Форма]]></string>

+ 5 - 4
studio/js/forms.js

@@ -52,10 +52,10 @@ function fvtTogglePopup(sName, oLink) {
 };
 
 function fvtSelectLanguage(sName, sLangName, oLink) {
-	var oTranslator = $(oLink).parents('.bx-form-input-translator:first');
+    var oTranslator = $(oLink).parents('.bx-form-input-translator:first');
 
-	//--- Update popup languages
-	var sId = '#bx-form-language-' + sName + '-' + sLangName;
+    //--- Update popup languages
+    var sId = '#bx-form-language-' + sName + '-' + sLangName;
     $(oLink).parent().siblings('.active:visible').hide().siblings('.not-active:hidden').show().siblings(sId + '-pas:visible').hide().siblings(sId + '-act:hidden').show();
 
     //--- Update current language
@@ -65,7 +65,8 @@ function fvtSelectLanguage(sName, sLangName, oLink) {
     oTranslator.find('#bx-form-field-translator-popup-' + sName).dolPopupHide();
 
     //--- Update inputs
-    $(oLink).parents('#bx-form-element-' + sName + ':first').find('.bx-form-input-text:visible, .bx-form-input-textarea:visible').hide().siblings('#bx-form-input-' + sName + '-' + sLangName + ':hidden').show();    
+    $(oLink).parents('#bx-form-element-' + sName + ':first').find('.bx-form-input-text:visible').hide().siblings('#bx-form-input-' + sName + '-' + sLangName + ':hidden').show();
+    $(oLink).parents('#bx-form-element-' + sName + ':first').find('.bx-form-input-translation:visible').hide().siblings('.bx-form-input-translation-' + sName + '-' + sLangName + ':hidden').show();
 };
 
 /** @} */

+ 1 - 0
studio/template/form_input_translation.html

@@ -0,0 +1 @@
+<div class="bx-form-input-translation__class__" __attrs__>__content__</div>

+ 11 - 4
studio/template/scripts/BxBaseStudioFormView.php

@@ -52,7 +52,6 @@ class BxBaseStudioFormView extends BxDolStudioForm
                 break;
 
             case 'textarea_translatable':
-                $aInput['html'] = 0;
                 $sInput = $this->genInputTranslatable($aInput, 'textarea');
                 break;
 
@@ -172,10 +171,18 @@ class BxBaseStudioFormView extends BxDolStudioForm
             $aInput['name'] = $sInputName . '-' . $aLanguage['name'];
             $aInput['value'] = $sValue;
             $aInput['attrs'] = array_merge($aInputAttrs, array(
-                'id' => $sInputIdPrefix . $aInput['name'],
-                'style' => !$bLanguage ? 'display:none;' : ''
+                'id' => $sInputIdPrefix . $aInput['name']
             ));
-            $sInput .= $this->{$aInputMethod[$sType]}($aInput);
+
+            $sInput .= $this->oTemplate->parseHtmlByName('form_input_translation.html', array(
+                'class' => ' bx-form-input-translation-' . $aInput['name'],
+                'attrs' => bx_convert_array2attrs(array(
+                    'style' => !$bLanguage ? 'display:none;' : ''
+                )),
+                'content' => $this->{$aInputMethod[$sType]}($aInput)
+            ));
+                    
+                    
 
             $aTmplVarValue = array(
                 'condition' => $bValue,

+ 15 - 3
studio/template/scripts/BxBaseStudioFormsField.php

@@ -1226,8 +1226,8 @@ class BxBaseStudioFormsFieldText extends BxBaseStudioFormsFieldBlockHeader
     protected $aFieldUnique;
 
     public function init()
-	{
-		parent::init();
+    {
+        parent::init();
 
         $this->aParams['table_alter'] = true;
         $this->aParams['table_field_type'] = 'varchar(255)';
@@ -1273,6 +1273,18 @@ class BxBaseStudioFormsFieldText extends BxBaseStudioFormsFieldBlockHeader
                     'pass' => 'Xss',
                 )
             ),
+            'help' => array(
+                'type' => 'textarea_translatable',
+                'name' => 'help',
+                'caption' => _t('_adm_form_txt_field_help'),
+                'info' => _t('_adm_form_dsc_field_help'),
+                'value' => '_sys_form_txt_field',
+                'required' => '0',
+                'html' => 2,
+                'db' => array (
+                    'pass' => 'Xss',
+                )
+            ),
             'required' => array(
                 'type' => 'switcher',
                 'name' => 'required',
@@ -1344,7 +1356,7 @@ class BxBaseStudioFormsFieldTextarea extends BxBaseStudioFormsFieldText
             ),
         );
 
-        $this->aForm['inputs'] = $this->addInArray($this->aForm['inputs'], 'info', $aFields);
+        $this->aForm['inputs'] = $this->addInArray($this->aForm['inputs'], 'help', $aFields);
         unset($this->aForm['inputs']['unique']);
     }
 }

+ 7 - 1
template/css/forms.css

@@ -324,8 +324,14 @@
     align-items: center;
 }
 
-/* switcher */
+/* help popup */
+.bx-form-input-help-popup {
+    max-width: 25rem;
+    max-height: 25rem;
+    overflow: auto;
+}
 
+/* switcher */
 .bx-switcher-cont {
 	position:relative;
     width:60px;

+ 3 - 0
template/form_field_help_popup.html

@@ -0,0 +1,3 @@
+<div class="bx-form-input-help-popup bx-popup-max-width">
+    <div class="bx-form-input-help-popup-cnt">__content__</div>
+</div>

+ 0 - 1
template/form_field_privacy.html

@@ -2,5 +2,4 @@
     <div class="bx-form-input-pgc-current">
         <a class="bx-form-input-pgc-current" href="javascript:void(0)" onclick="javascript:__js_object__.pgcTogglePopup(this, __id__, '__privacy_object__')"><i class="sys-icon __icon__"></i></a>
     </div>
-    <div id="__html_id_popup__"></div>
 </div>

+ 2 - 2
template/form_row_standard.html

@@ -3,12 +3,12 @@
         <bx_if:show_one_line>
             <div class="bx-form-value bx-clearfix__class_value__">__value__</div>
             <bx_if:show_caption>
-                <div class="bx-form-caption__class_caption__">__caption____required__</div>
+                <div class="bx-form-caption__class_caption__">__caption____required____help__</div>
             </bx_if:show_caption>
         </bx_if:show_one_line>
         <bx_if:show_lined>
             <bx_if:show_caption>
-                <div class="bx-form-caption__class_caption__">__caption____required__</div>
+                <div class="bx-form-caption__class_caption__">__caption____required____help__</div>
             </bx_if:show_caption>
             <div class="bx-form-value bx-clearfix__class_value__">__value__</div>
         </bx_if:show_lined>

+ 17 - 5
template/scripts/BxBaseFormView.php

@@ -133,12 +133,24 @@ class BxBaseFormView extends BxDolForm
 
         $sHtmlId = str_replace(array('_' , ' '), array('-', '-'), $sName);
         $this->_aHtmlIds = array(
+            'help_popup' => $sHtmlId . '-help-popup-',
             'pgc' =>  $sHtmlId . '-pgc-',
             'pgc_popup' => $sHtmlId . '-pgc-popup-',
             'pgc_form' => $sHtmlId . '-pgc-form-',
         );
     }
 
+    public function performActionGetHelp()
+    {
+        $sInput = bx_process_input(bx_get('input'));
+        if(empty($sInput) || empty($this->aInputs[$sInput]['help']))
+            return;
+
+        echo $this->oTemplate->parseHtmlByName('form_field_help_popup.html', array(
+            'content' => _t($this->aInputs[$sInput]['help'])
+        ));
+    }
+
     public function performActionChangePrivacyGroup()
     {
         $iAuthorId = (int)bx_get_logged_profile_id();
@@ -334,9 +346,7 @@ class BxBaseFormView extends BxDolForm
             'sObject' => isset($this->aParams['object']) ? $this->aParams['object'] : '',
             'sDisplay' => isset($this->aParams['display']) ? $this->aParams['display'] : '',
             'sRootUrl' => BX_DOL_URL_ROOT,
-            'aHtmlIds' => array(
-                'pgc_popup' => 'bx-form-input-pgc-popup'
-            ),
+            'aHtmlIds' => $this->_aHtmlIds,
         )) . ");";
 
         return $bWrap ? $this->oTemplate->_wrapInTagJsCode($sCode) : $sCode;
@@ -792,6 +802,8 @@ BLAH;
         $sCaption = isset($aInput['caption']) ? bx_process_output($aInput['caption'], BX_DATA_HTML) : '';
 
         $sRequired = !empty($aInput['required']) ? '<span class="bx-form-required">*</span> ' : '';
+        
+        $sHelp = !empty($aInput['help']) ? '<a href="javascript:void(0)" onclick="javascript:' . $this->getJsObjectName() . '.showHelp(this, \'' . $aInput['name'] . '\')"><i class="sys-icon question-circle"></i></a> ' : '';
 
         $sClassAdd = !empty($aInput['error']) ? ' bx-form-error' : '';
         $sInfoIcon = !empty($aInput['info']) ? $this->genInfoIcon($aInput['info']) : '';
@@ -829,7 +841,8 @@ BLAH;
                 'content' => array(
                     'class_caption' => $sClassOneLineCaption,
                     'caption' => $sCaption,
-                    'required' => $sRequired
+                    'required' => $sRequired,
+                    'help' => $sHelp,
                 )
             ),
             'class_value' => $sClassAdd . $sClassOneLineValue,
@@ -1835,7 +1848,6 @@ BLAH;
         return $this->oTemplate->parseHtmlByName('form_field_privacy.html', array(
             'js_object' => $this->getJsObjectName(),
             'html_id' => $this->_aHtmlIds['pgc'] . $iInputId,
-            'html_id_popup' => $this->_aHtmlIds['pgc_popup'] . $iInputId,
             'id' => $iInputId,
             'privacy_object' => $sPrivacyObject,
             'icon' => $this->_getPrivacyIcon($mixedPrivacyGroup)