HomeHelpTrac

Changeset 15682 for trunk/inc


Ignore:
Timestamp:
11/17/11 03:43:50 (6 months ago)
Author:
Alexander Trofimov
Message:

Grid - fixes + new webforms and jQuery

Location:
trunk/inc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/inc/classes/BxDolForm.php

    r15599 r15682  
    175175    } 
    176176 
    177     function insert ($aValsToAdd = array()) { 
     177    function insert ($aValsToAdd = array(), $isIgnore = false) { 
    178178        $oChecker = new BxDolFormChecker($this->_sCheckerHelper); 
    179179        $oChecker->setFormMethod($this->aFormAttrs['method']); 
    180         $sSql = $oChecker->dbInsert($this->aParams['db'], $this->aInputs, $aValsToAdd); 
     180        $sSql = $oChecker->dbInsert($this->aParams['db'], $this->aInputs, $aValsToAdd, $isIgnore); 
    181181        if (!$sSql) return false; 
    182182        if (db_res ($sSql)) 
     
    434434        foreach ($aInputs as $k => $a) { 
    435435            if (!isset ($a['db'])) continue; 
    436             $valClean = $this->get ($a['name'], $a['db']['pass'], $a['db']['params'] ? $a['db']['params'] : array()); 
     436            $valClean = $this->get ($a['name'], $a['db']['pass'], !empty($a['db']['params']) ? $a['db']['params'] : array()); 
    437437            $s .= $oDb->prepare("`{$a['name']}` = ?,", $valClean); 
    438438            $aInputs[$k]['db']['value'] = $valClean; 
     
    444444    } 
    445445 
    446     function dbInsert (&$aDb, &$aInputs, $aValsToAdd = array()) { 
     446    function dbInsert (&$aDb, &$aInputs, $aValsToAdd = array(), $isIgnore = false) { 
    447447        if (!$aDb['table']) return ''; 
    448448        $sFields = $this->serializeDbValues ($aInputs, $aValsToAdd); 
    449449        if (!$sFields) return ''; 
    450         return "INSERT INTO `{$aDb['table']}` SET $sFields"; 
     450        return "INSERT " . ($isIgnore ? 'IGNORE' : '') . " INTO `{$aDb['table']}` SET $sFields"; 
    451451    } 
    452452 
  • trunk/inc/js/classes/BxDolGrid.js

    r15675 r15682  
    1111    this._sIdTable = 'bx-grid-table-' + sObject; 
    1212    this._oOptions = oOptions; 
    13     this._sFilter = ''; 
    14     this._sOrderField = ''; 
    15     this._sOrderDir = 'ASC'; 
    16     this._sSearchInputText = ''; 
     13    this._sFilter = undefined == oOptions.filter ? '' : oOptions.filter; 
     14    this._sOrderField = undefined == oOptions.order_field ? '' : oOptions.order_field; 
     15    this._sOrderDir = undefined == oOptions.order_dir ? 'ASC' : oOptions.order_dir; 
     16    this._sSearchInputText = undefined == oOptions.text_search_input ? '' : oOptions.text_search_input; 
     17    this._oPopupOptions = {}; 
     18 
     19    if (this._sFilter.length) 
     20        this._sSearchInputText = this._sFilter; 
     21 
     22    $('#bx-grid-search-' + this._sObject).val(this._sSearchInputText); 
    1723 
    1824    this._onDataReloaded(); 
    19 } 
    20  
    21 BxDolGrid.prototype.setSearchInputText = function (sText) { 
    22     this._sSearchInputText = sText; 
     25 
     26    if (this._sOrderField.length) 
     27        this.setSorting (this._sOrderField, this._sOrderDir, true); 
    2328} 
    2429 
     
    173178 
    174179    if (typeof(isDisableLoading) == 'undefined' || !isDisableLoading) 
    175         bx_loading(this._sIdContainer, true); 
     180        this.loading(true); 
    176181 
    177182    $.getJSON(sUrl, function (oData) { 
    178  
    179         if (typeof(isDisableLoading) == 'undefined' || !isDisableLoading) 
    180             bx_loading($this._sIdContainer, false); 
    181  
    182         if (oData && undefined != oData.grid) { 
    183             $('#' + $this._sIdContainer).html(oData.grid); 
    184             $this._onDataReloaded(true); 
    185         } 
    186         if (oData && undefined != oData.msg) { 
    187             alert(oData.msg); 
    188         } 
    189         if (oData && undefined != oData.popup) { 
    190             alert('TODO: popup'); 
    191         } 
    192  
    193     }); 
    194  
     183        $this.processJson(oData, sAction, isDisableLoading); 
     184    }); 
     185 
     186} 
     187 
     188BxDolGrid.prototype.processJson = function (oData, sAction, isDisableLoading) { 
     189    if (typeof(isDisableLoading) == 'undefined' || !isDisableLoading) 
     190        this.loading(false); 
     191 
     192    if (oData && undefined != oData.grid) { 
     193        $('#' + this._sIdContainer).html(oData.grid); 
     194        this._onDataReloaded(true); 
     195    } 
     196    if (oData && undefined != oData.msg) { 
     197        alert(oData.msg); 
     198    } 
     199    if (oData && undefined != oData.blink) { 
     200        if ('object' == typeof(oData.blink)) { 
     201            for(var i in oData.blink) 
     202                this.blink(this._sObject + '_row_' + oData.blink[i]); 
     203        } else { 
     204            this.blink(this._sObject + '_row_' + oData.blink); 
     205        } 
     206    } 
     207    if (oData && undefined != oData.popup) { 
     208        var sId = 'grid-popup-' + this._sObject + '-' + sAction; 
     209        $('#' + sId).remove(); 
     210        $('<div id="' + sId + '" style="display: none;"></div>').prependTo('body').html(oData.popup); 
     211        $('#' + sId).dolPopup(this._oPopupOptions); 
     212    } 
     213} 
     214 
     215BxDolGrid.prototype.loading = function (bShow) { 
     216    bx_loading(this._sIdContainer, bShow); 
    195217} 
    196218 
     
    236258        var sAction = $(this).attr('bx_grid_action_independent'); 
    237259        var sActionConfirm = $(this).attr('bx_grid_action_confirm'); 
    238         $this.action (sActionData, sAction, {}, '', false, sActionConfirm); 
     260        $this.action (sAction, {}, '', false, sActionConfirm); 
    239261    }); 
    240262 
  • trunk/inc/utils.inc.php

    r15675 r15682  
    11351135} 
    11361136 
    1137 function bx_append_url_params ($sUrl, $aParams) { 
     1137function bx_append_url_params ($sUrl, $mixedParams) { 
    11381138    $sParams = false == strpos($sUrl, '?') ? '?' : '&'; 
    1139     foreach($aParams as $sKey => $sValue) 
    1140         $sParams .= $sKey . '=' . $sValue . '&'; 
    1141     $sParams = substr($sParams, 0, -1); 
     1139         
     1140    if (is_array($mixedParams)) { 
     1141        foreach($mixedParams as $sKey => $sValue) 
     1142            $sParams .= $sKey . '=' . $sValue . '&'; 
     1143        $sParams = substr($sParams, 0, -1); 
     1144    } else { 
     1145        $sParams .= $mixedParams; 
     1146    }     
    11421147    return $sUrl . $sParams; 
    11431148} 
Note: See TracChangeset for help on using the changeset viewer.