Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    SmartClient 7.0rc2:Patch for issue with FilterBuilder and validOperators

    This patch corrects a problem in the 7.0RC2 FilterBuilder where the operators drop-down list was not always correctly populated for fields with special sets of valid operators. This problem manifested itself a couple of ways, for example as an incorrect initial selection.

    Code:
    //----------------------------------------------------------------------------
    // Isomorphic SmartClient 7.0rc2 patch
    // Purpose: Fix FilterBuilder issues with fields that define validOperators or
    //          DataSources that define typeOperators
    // 
    // Applies to SmartClient 7.0RC2 builds only
    //----------------------------------------------------------------------------
    if (window.isc && isc.version.startsWith("7.0rc2/")) {
        isc.FilterBuilder.addProperties({
            addNewClause : function(_1) {
                var _2 = isc.clone(this.filterRow);
                var _3 = this.getDataSource().getFieldNames(true);
                var _4 = {};
                for(var i = 0; i < _3.length; i++) {
                    var _6 = _3[i];
                    if(this.showFieldTitles) {
                        var _7 = this.getDataSource().getField(_6).title;
                        _7 = _7 ? _7 : _6;
                        _4[_6] = _7
                    } else {
                        _4[_6] = _6
                    }
                }
                _2[0].valueMap = _4;
                if (_1 && _1.fieldName) {
                    if (_3.contains(_1.fieldName)) {
                        _2[0].defaultValue = _1.fieldName
                    } else {
                        isc.logWarn("Criterion specified field " + _1.fieldName + ", which is not" +
                                    " in the record. Using the first record field (" +
                                    _3[0] + ") instead");
                        _2[0].defaultValue = _3[0]
                    }
                } else {
                    _2[0].defaultValue = _3[0]
                }
                var _8 = this.getDataSource().getFieldOperatorMap(_2[0].defaultValue,false,"criteria",true);
                _2[1].valueMap = _8;
                if(_1 && _1.operator) {
                    _2[1].defaultValue = _1.operator
                } else {
                    _2[1].defaultValue = isc.firstKey(_8)
                }
                var _9 = this.getDataSource().getSearchOperator(_2[1].defaultValue),
                    _10 = this.getDataSource().getField(_2[0].defaultValue);
                if(!_9) {
                    isc.logWarn("Criterion specified unknown operator " + _1.operator + ". Using the first valid operator (" +
                                isc.firstKey(_8) + ") instead");
                    _2[1].defaultValue = isc.firstKey(_8);
                    _9=this.getDataSource().getSearchOperator(_2[1].defaultValue)
                }
                var _11 = this.buildValueItemList(_10,_9);
                if (_1) {
                    if (_1.value != null && _11.containsProperty("name","value")) {
                        _11.find("name","value").defaultValue=_1.value
                    }
                    if (_1.start != null && _11.containsProperty("name","start")) {
                        _11.find("name","start").defaultValue = _1.start
                    }
                    if (_1.end != null && _11.containsProperty("name","end")) {
                        _11.find("name","end").defaultValue=_1.end
                    }
                }
                _2.addList(_11);
                var _12 = this.createAutoChild("clause",{flattenItems:true,items:_2});
                this.clauses.add(_12);
                this.updateFields(_12);
                var _13 = this.createAutoChild("removeButton");
                var _14 = [_13];
                _14.add(_12);
                var _15 = this.createAutoChild("clauseLayout",{visibility:"hidden",members:_14});
                _12.removeButton = _13;
                _12.clauseLayout = _15;
                _13.clause = _12;
                var _16=this.clauseStack;
                var _17 = Math.max(0,_16.getMemberNumber(this.buttonBar));
                _16.addMember(_15,_17);
                _16.showMember(_15,function(){_12.focusInItem("fieldName")});
                this.updateFirstRemoveButton()
            }
        });
    } else if (window.isc) {
        isc.logWarn("Patch code included for SmartClient build version 7.0rc2. This page loads " +
        "SmartClient version:" + isc.version + ". The patch code will be disabled for this build and " +
        "should be removed.");
    }
Working...
X