Răsfoiți Sursa

Ticket #5425 - Tasks: Functionality improvements. Stage 2.

AntonLV 6 luni în urmă
părinte
comite
7cb3054d88

+ 9 - 0
modules/boonex/artificer/data/template/system/css/forms.css

@@ -412,6 +412,15 @@ import url(../../../../../../../template/css/forms.css);
     -webkit-appearance:none;
 }
 
+/* MiniColors plug-in */
+.bx-form-input-wrapper.bx-form-input-wrapper-text .minicolors-theme-bootstrap .minicolors-swatch {
+    top: 0.5rem;
+    left: 0.5rem;
+
+    width: 1.5625rem;
+    height: 1.5625rem;
+}
+
 /* tiny mce */
 .bx-form-input-wrapper-html .gray-theme.fr-toolbar.fr-top{
    border-radius: .375rem .375rem 0 0 !important; 

+ 0 - 1
modules/boonex/russian/data/langs/bx_tasks/ru.xml

@@ -147,7 +147,6 @@
 
     <string name="_bx_tasks_form_pv_input_title"><![CDATA[Заголовок]]></string>
     <string name="_bx_tasks_form_pv_input_color"><![CDATA[Цвет]]></string>
-    <string name="_bx_tasks_form_pv_input_color_inf"><![CDATA[Используйте цветовую кодировку RGB.]]></string>
     <string name="_bx_tasks_form_pv_input_submit"><![CDATA[Выполнить]]></string>
     <string name="_bx_tasks_form_pv_input_cancel"><![CDATA[Отменить]]></string>
     <string name="_bx_tasks_form_pv_input_err"><![CDATA[This field is essential. Please, fill it in.]]></string>

+ 1 - 0
modules/boonex/tasks/classes/BxTasksConfig.php

@@ -104,6 +104,7 @@ class BxTasksConfig extends BxBaseModTextConfig
             'URL_UPDATED' => 'page.php?i=tasks-updated',
             'URL_MANAGE_COMMON' => 'page.php?i=tasks-manage',
             'URL_MANAGE_ADMINISTRATION' => 'page.php?i=tasks-administration',
+            'URL_CONTEXT_VALUES' => 'page.php?i=tasks-context-values',
 
             // some params
             'PARAM_AUTO_APPROVE' => 'bx_tasks_enable_auto_approve',

+ 1 - 0
modules/boonex/tasks/classes/BxTasksDb.php

@@ -519,6 +519,7 @@ class BxTasksDb extends BxBaseModTextDb
                     ];
 
                     $sWhereClause = "AND `tpv`.`context_id` = :context_id AND `tpv`.`list` = :list";
+                    $sOrderClause = "`tpv`.`order` ASC";
                     break;
             }
 

+ 4 - 4
modules/boonex/tasks/classes/BxTasksFormEntry.php

@@ -206,14 +206,14 @@ class BxTasksFormEntry extends BxBaseModTextFormEntry
 
     protected function genCustomViewRowValueStickers (&$aInput)
     {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
         if(empty($aInput['value']) || !is_array($aInput['value']))
-            return '';
+            return null;
 
         $aStickers = $this->_oModule->getStickers($aInput['value'], $this->_iContextId);
+        if(!$aStickers)
+            return null;
 
-        return $aStickers ? $this->_oModule->_oTemplate->getStickers($aStickers) : '';
+        return $this->_oModule->_oTemplate->getStickers($aStickers);
     }
 
     protected function genCustomViewRowValueGhIssueUrl(&$aInput)

+ 41 - 47
modules/boonex/tasks/classes/BxTasksGridPreValues.php

@@ -11,11 +11,8 @@
 class BxTasksGridPreValues extends BxBaseModGeneralGrid
 {
     protected $_iContextPid;
-    
-    protected $_sFilter1Name;   //--- list
-    protected $_sFilter1Value;
-    protected $_aFilter1Values;
 
+    protected $_sList;
     protected $_aListInfo;
 
     public function __construct ($aOptions, $oTemplate = false)
@@ -26,20 +23,9 @@ class BxTasksGridPreValues extends BxBaseModGeneralGrid
 
         if(($sFfName = 'profile_id') && ($iValue = bx_get($sFfName)) !== false) 
             $this->setContextPid($iValue);
-
-        /*
-         * Filter by list
-         */
-        $this->_initFilter(1, $this->_oModule->getPreLists());
-
-        if(($sFfName = 'filter') && ($sValue = bx_get($sFfName)) !== false) 
-            $this->_parseFilterValue($sValue);
-
-        if($this->_sFilter1Value)
-            $this->_aListInfo = $this->_oModule->_oDb->getPreLists([
-                'sample' => 'name', 
-                'name' => $this->_sFilter1Value
-            ]);
+        
+        if(($sFfName = 'list') && ($sValue = bx_get($sFfName)) !== false) 
+            $this->setList($sValue);
     }
 
     public function setContextPid($iContextPid)
@@ -48,9 +34,20 @@ class BxTasksGridPreValues extends BxBaseModGeneralGrid
         $this->_aQueryAppend['profile_id'] = $this->_iContextPid;
     }
 
+    public function setList($sList)
+    {
+        $this->_sList = bx_process_input($sList);
+        $this->_aQueryAppend['list'] = $this->_sList;
+
+        $this->_aListInfo = $this->_oModule->_oDb->getPreLists([
+            'sample' => 'name', 
+            'name' => $this->_sList
+        ]);
+    }
+
     public function performActionAdd()
     {
-        if(!$this->_sFilter1Value)
+        if(!$this->_sList)
             return echoJson(['msg' => _t('_bx_tasks_txt_err_empty_pre_list')]);
 
         $sAction = 'add';
@@ -58,7 +55,7 @@ class BxTasksGridPreValues extends BxBaseModGeneralGrid
         $oForm = $this->_getForm($sAction);
         $oForm->initChecker();
         if($oForm->isSubmittedAndValid()) {
-            if(($iId = (int)$oForm->insert(['context_id' => $this->_iContextPid])) != 0)
+            if(($iId = (int)$oForm->insert(['context_id' => $this->_iContextPid, 'list' => $this->_sList])) != 0)
                 $aRes = ['grid' => $this->getCode(false), 'blink' => $iId];
             else
                 $aRes = ['msg' => _t('_bx_tasks_txt_err_cannot_perform_action')];
@@ -105,28 +102,34 @@ class BxTasksGridPreValues extends BxBaseModGeneralGrid
         echoJson(['popup' => ['html' => $sContent, 'options' => ['closeOnOuterClick' => false]]]);
     }
 
+    protected function _getActionAdd($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = [])
+    {
+        if(!$this->_sList)
+            $isDisabled = true;
+
+        return parent::_getActionDefault($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
+    }
+
     protected function _getFilterOnChange()
     {
-        return $this->_oModule->_oConfig->getJsObject('pre_values') . '.onChangeFilter(this)';
+        return $this->_oModule->_oConfig->getJsObject('pre_values') . '.onChangeList(this)';
     }
 
     protected function _getFilterControls()
     {
         parent::_getFilterControls();
 
-        $sContent = $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values, '_bx_tasks_grid_filter_item_title_pv_select_one_list');
+        $sContent = $this->_getFilterSelectOne('list', $this->_sList, $this->_oModule->getPreLists(), '_bx_tasks_grid_filter_item_title_pv_select_one_list');
         $sContent .= $this->_getSearchInput();
         return $sContent;
     }
 
     protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
     {
-        $this->_parseFilterValue($sFilter);
-
-        if(!$this->_iContextPid || !$this->_sFilter1Value)
+        if(!$this->_iContextPid || !$this->_sList)
             return [];
 
-        $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(' AND `context_id`=? AND `list`=?', $this->_iContextPid, $this->_sFilter1Value);
+        $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(' AND `context_id`=? AND `list`=?', $this->_iContextPid, $this->_sList);
 
         return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
     }
@@ -139,7 +142,7 @@ class BxTasksGridPreValues extends BxBaseModGeneralGrid
             'o' => $this->_sObject, 
             'a' => $sAction,
             'profile_id' => $this->_iContextPid,
-            $this->_sFilter1Name => $this->_sFilter1Value
+            'list' => $this->_sList
         ];
 
         if($aItem)
@@ -161,26 +164,28 @@ class BxTasksGridPreValues extends BxBaseModGeneralGrid
                 ],
             ],
             'inputs' => [
-                'list' => [
-                    'type' => 'hidden',
-                    'name' => 'list',
-                    'value' => $this->_sFilter1Value,
-                    'db' => [
-                        'pass' => 'Xss',
-                    ],
-                ],
                 'value' => [
                     'type' => 'hidden',
                     'name' => 'value',
                     'value' => (int)$this->_oModule->_oDb->getPreValues([
                         'sample' => 'value_to_use', 
                         'context_id' => $this->_iContextPid, 
-                        'list' => $this->_sFilter1Value
+                        'list' => $this->_sList
                     ]),
                     'db' => [
                         'pass' => 'Int',
                     ]
                 ],
+                'color' => [
+                    'type' => 'rgb',
+                    'name' => 'color',
+                    'caption' => _t('_bx_tasks_form_pv_input_color'),
+                    'value' => '',
+                    'required' => '0',
+                    'db' => [
+                        'pass' => 'Xss',
+                    ]
+                ],
                 'title' => [
                     'type' => 'text',
                     'name' => 'title',
@@ -196,17 +201,6 @@ class BxTasksGridPreValues extends BxBaseModGeneralGrid
                         'error' => _t('_bx_tasks_form_pv_input_err'),
                     ],
                 ],
-                'color' => [
-                    'type' => 'text',
-                    'name' => 'color',
-                    'caption' => _t('_bx_tasks_form_pv_input_color'),
-                    'info' => _t('_bx_tasks_form_pv_input_color_inf'),
-                    'value' => '',
-                    'required' => '0',
-                    'db' => [
-                        'pass' => 'Xss',
-                    ]
-                ],
                 'controls' => [
                     'name' => 'controls',
                     'type' => 'input_set',

+ 2 - 1
modules/boonex/tasks/classes/BxTasksModule.php

@@ -476,7 +476,8 @@ class BxTasksModule extends BxBaseModTextModule implements iBxDolCalendarService
         $this->_oTemplate->addJsTranslation(['_sys_grid_search']);
         $aResult = [
             'content' => $this->_oTemplate->getJsCode('pre_values', [
-                'sObjNameGrid' => $sGrid
+                'sObjNameGrid' => $sGrid,
+                'sPageUrl' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($CNF['URL_CONTEXT_VALUES'], ['profile_id' => $iContextPid])
             ]) . $oGrid->getCode()
         ];
 

+ 0 - 1
modules/boonex/tasks/install/langs/en.xml

@@ -147,7 +147,6 @@
 
     <string name="_bx_tasks_form_pv_input_title"><![CDATA[Title]]></string>
     <string name="_bx_tasks_form_pv_input_color"><![CDATA[Color]]></string>
-    <string name="_bx_tasks_form_pv_input_color_inf"><![CDATA[Use RGB color code.]]></string>
     <string name="_bx_tasks_form_pv_input_submit"><![CDATA[Submit]]></string>
     <string name="_bx_tasks_form_pv_input_cancel"><![CDATA[Cancel]]></string>
     <string name="_bx_tasks_form_pv_input_err"><![CDATA[This field is essential. Please, fill it in.]]></string>

+ 1 - 1
modules/boonex/tasks/install/sql/install.sql

@@ -93,7 +93,7 @@ CREATE TABLE IF NOT EXISTS `bx_tasks_pre_values` (
   `value` varchar(255) NOT NULL DEFAULT '',
   `order` int(11) NOT NULL DEFAULT '0',
   `title` varchar(255) NOT NULL DEFAULT '',
-  `color` text NOT NULL DEFAULT '',
+  `color` varchar(128) NOT NULL DEFAULT '',
   PRIMARY KEY (`id`),
   UNIQUE KEY `list_value` (`list`, `value`)
 );

+ 8 - 3
modules/boonex/tasks/js/pre_values.js

@@ -12,15 +12,20 @@ function BxTasksPreValues(oOptions)
     BxBaseModTextManageTools.call(this, oOptions);
 
     this._sObjName = oOptions.sObjName == undefined ? 'oBxTasksPreValues' : oOptions.sObjName;
+    this._sPageUrl = oOptions.sPageUrl == undefined ? '' : oOptions.sPageUrl;
+    
 }
 
 BxTasksPreValues.prototype = Object.create(BxBaseModTextManageTools.prototype);
 BxTasksPreValues.prototype.constructor = BxTasksPreValues;
 
+BxTasksPreValues.prototype.onChangeList = function(oElement) {
+    var sList = $(oElement).val();
+    document.location.href = this._sPageUrl + (sList.length > 0 ? '&list=' + sList : ''); 
+};
+
 BxTasksPreValues.prototype.onChangeFilter = function(oFilter) {
     var $this = this;
-    var oFilter1 = $('#bx-grid-filter1-' + this._sObjNameGrid);
-    var sValueFilter1 = oFilter1.length > 0 ? oFilter1.val() : '';
 
     var oSearch = $('#bx-grid-search-' + this._sObjNameGrid);
     var sValueSearch = oSearch.length > 0 ? oSearch.val() : '';
@@ -29,7 +34,7 @@ BxTasksPreValues.prototype.onChangeFilter = function(oFilter) {
 
     clearTimeout($this._iSearchTimeoutId);
     $this._iSearchTimeoutId = setTimeout(function () {
-        glGrids[$this._sObjNameGrid].setFilter(sValueFilter1 + $this._sParamsDivider + sValueSearch, true);
+        glGrids[$this._sObjNameGrid].setFilter(sValueSearch, true);
     }, 500);
 };