<commit_before>odoo.define('website_product_configurator.config_form', function (require) {
    'use strict';

    var ajax = require('web.ajax');
    var time = require('web.time');

    $(document).ready(function () {
        var config_form = $("#product_config_form");
        var datetimepickers_options = {
            calendarWeeks: true,
            icons : {
                time: 'fa fa-clock-o',
                date: 'fa fa-calendar',
                next: 'fa fa-chevron-right',
                previous: 'fa fa-chevron-left',
                up: 'fa fa-chevron-up',
                down: 'fa fa-chevron-down',
               },
            locale : moment.locale(),
            widgetParent: 'body',
            allowInputToggle: true,
            showClose: true,
            format : time.getLangDatetimeFormat(),
            keyBinds: null,
        };

        var datepickers_options = $.extend({}, datetimepickers_options, {format: time.getLangDateFormat()})

        config_form.find('.product_config_datetimepicker').datetimepicker(datetimepickers_options);
        config_form.find('.product_config_datepicker').datetimepicker(datepickers_options);

        /* Monitor input changes in the configuration form and call the backend onchange method*/
        config_form.find('.config_attribute').change(function(ev) {
            ajax.jsonRpc("/website_product_configurator/onchange", 'call', {
                form_values: config_form.serializeArray(),
                field_name: $(this)[0].name,
            }).then(function(data) {
                if (data.error) {
                    alert(data.error);
                };
                var values = data.value;
                var domains = data.domain;

                var open_cfg_step_line_ids = data.open_cfg_step_line_ids;
                var config_image_vals = data.config_image_vals;

                _applyDomainOnValues(domains);
                _handleOpenSteps(open_cfg_step_line_ids);
                _setImageUrl(config_image_vals);
                _setWeightPrice(values.weight, values.price);
            });
            _handleCustomAttribute(ev)
        });

        function _setWeightPrice(weight, price) {
            var formatted_price = _.str.sprintf('%.2f', price);
            var formatted_weight = _.str.sprintf('%.1f', weight);
            $('.config_product_weight').text(formatted_weight);
            $('.config_product_price').find('.oe_currency_value').text(formatted_price);
        }

        function _setImageUrl(config_image_vals) {
            var images = '';
            if (config_image_vals){
                var model = config_image_vals.name
                config_image_vals.config_image_ids.forEach(function(line){
                    images += ""
                })
            }
            $('#product_config_image').html(images);
        };

        function _handleCustomAttribute(event) {
            var container = $(event.currentTarget).closest('.tab-pane.container');
            var attribute_id = $(event.currentTarget).attr('data-oe-id');
            var custom_value = container.find('.custom_config_value[data-oe-id=' + attribute_id + ']');
            var custom_value_container = custom_value.closest('.custom_field_container[data-oe-id=' + attribute_id + ']');
            if ($(event.currentTarget.selectedOptions[0]).hasClass('custom_config_attr_value') && custom_value_container.hasClass('hidden')) {
                custom_value_container.removeClass('hidden');
                custom_value.addClass('required_config_attrib');
            } else if (!custom_value_container.hasClass('hidden')){
                custom_value_container.addClass('hidden');
                if (custom_value.hasClass('required_config_attrib')) {
                    custom_value.removeClass('required_config_attrib');
                }
            }
        }

        function _handleOpenSteps(open_cfg_step_line_ids) {
            var $steps = config_form.find('.config_step');
            _.each($steps, function (step) {
                step = $(step);
                var step_id = step.attr('data-step-id');
                if ($.inArray(step_id, open_cfg_step_line_ids) < 0) {
                    if (!step.hasClass('hidden')) {
                        step.addClass('hidden');
                    };
                } else {
                    if (step.hasClass('hidden')) {
                        step.removeClass('hidden');
                    };
                };
            });
        }

        function _applyDomainOnValues(domains) {
            _.each(domains, function (domain, attr_id) {
                var $selection = config_form.find('#' + attr_id);
                var $options = $selection.find('.config_attr_value');
                _.each($options, function (option) {
                    var condition = domain[0][1];
                    if (condition == 'in' || config_form == '=') {
                        if ($.inArray(parseInt(option.value), domain[0][2]) < 0) {
                            $(option).attr('disabled', true);
                            if (option.selected) {
                                option.selected = false;
                            };
                        } else {
                            $(option).attr('disabled', false);
                        };
                    } else if (condition == 'not in' || config_form == '!=') {
                        if ($.inArray(parseInt(option.value), domain[0][2]) < 0) {
                            $(option).attr('disabled', false);
                        } else {
                            $(option).attr('disabled', true);
                            if (option.selected) {
                                option.selected = false;
                            };
                        };
                    };
                });
            });
        }

        function _onChangeConfigStep(event, next_step) {
            var flag = _checkRequiredFields(event)
            var config_step_header = config_form.find('.nav.nav-tabs');
            var current_config_step = config_step_header.find('.nav-item.config_step.active').attr('data-step-id');
            if (flag) {
                return ajax.jsonRpc("/website_product_configurator/save_configuration", 'call', {
                    form_values: config_form.serializeArray(),
                    next_step: next_step || false,
                    current_step: current_config_step || false,
                }).then(function(data) {
                    if (data.error) {
                        alert(data.error);
                    };
                    return data;
                });
            } else {
                return false;
            }
        };

        function _displayTooltip(config_attribut, message) {
            $(config_attribut).tooltip({
                title: message,
                placement: "bottom",
                trigger: "manual",
                delay: {show: 500, hide: 500},
                template: "

"
            }).tooltip('show');
            setTimeout(function(){
                $(config_attribut).tooltip('destroy');
            }, 4000);
        };

        function _checkRequiredFields(event) {
            var active_step = config_form.find('.tab-content').find('.tab-pane.active.in');
            var config_attr = active_step.find('.form-control.required_config_attrib');
            var flag = true;
            for (var i = 0; i < config_attr.length; i++) {
                var cfg_attr_value = config_attr[i].value.trim()
                if (!cfg_attr_value  || cfg_attr_value == '0') {
                    $(config_attr[i]).addClass('textbox-border-color');
                    flag = false;
                    // if (config_attr[i].tagName == 'SELECT') {
                    //     var message = "Please select an item in the list."
                    // } else if (config_attr[i].tagName == 'INPUT') {
                    //     var message = "Please enter value."
                    // }
                    // _displayTooltip(config_attr[i], message);
                }
                else if (cfg_attr_value && $(config_attr[i]).hasClass('textbox-border-color')) {
                    $(config_attr[i]).removeClass('textbox-border-color');
                };
            };
            return flag;
        };

        config_form.find('.config_attribute').change(function (event) {
            var attribute = event.currentTarget;
            if (attribute.value.trim() && attribute.value.trim() != '0' && $(attribute).hasClass('textbox-border-color')) {
                $(attribute).removeClass('textbox-border-color');
            };
        });
        config_form.find('.custom_config_value').change(function (event) {
            var attribute = event.currentTarget;
            if (attribute.value.trim() && attribute.value.trim() != '0' && $(attribute).hasClass('textbox-border-color')) {
                $(attribute).removeClass('textbox-border-color');
            };
        });

        config_form.find('.config_step').click(function (event) {
            var next_step = event.currentTarget.getAttribute('data-step-id');
            var result = _onChangeConfigStep(event, next_step);
            if (!result) {
                event.preventDefault();
                event.stopPropagation();
            };
        });

        function _openNextStep(step) {
            var config_step_header = config_form.find('.nav.nav-tabs');
            var config_step = config_step_header.find('.nav-item.config_step.active');
            if (config_step.length) {
                config_step.removeClass('active');
            }
            var active_step = config_form.find('.tab-content').find('.tab-pane.active.in');
            active_step.removeClass('active in');

            var next_step = config_step_header.find('.nav-item.config_step[data-step-id=' + step + ']');
            if (next_step.length) {
                next_step.addClass('active');
                var selector = next_step.find('a:first-child').attr('href');
                var step_to_active = config_form.find('.tab-content').find(selector);
                step_to_active.addClass('active in');
            }
        };

        function addRequiredAttr(config_step) {
            config_step = config_form.find('.tab-content').find('tab-pane container[data-step-id=' + config_step + ']');
            _.each(config_step.find('.form-control.config_attribute'), function(attribute_field) {
                $(attribute_field).attr('required', true);
            });
        };

        // Save Values
        config_form.submit(function (event) {
            event.preventDefault();
            event.stopPropagation();

            var result = _onChangeConfigStep(event);
            if (result) {
                result.then(function (data) {
                    if (data) {
                        if (data.next_step) {
                            _openNextStep(data.next_step);
                        };
                        if (data.redirect_url) {
                            window.location = data.redirect_url;
                        };
                    };
                });
            }
        });

        // quantty sppiner
        function _disableEnableAddRemoveQtyButton(quantity, max_val, min_val) {
            if (quantity >= max_val) {
                $('.js_add_qty').addClass('btn-disabled');
            } else if (quantity < max_val && $('.js_add_qty').hasClass('btn-disabled')) {
                $('.js_add_qty').removeClass('btn-disabled');
            }
            if (quantity <= min_val) {
                $('.js_remove_qty').addClass('btn-disabled');
            } else if (quantity > min_val && $('.js_remove_qty').hasClass('btn-disabled')) {
                $('.js_remove_qty').removeClass('btn-disabled');
            }
        }

        function _handleSppinerCustomValue(ev) {
            ev.preventDefault();
            ev.stopPropagation();

            var current_target = $(ev.currentTarget);
            var custom_value = current_target.parent().find('input.custom_config_value');
            var quantity = parseFloat(custom_value.val() || 0);
            var max_val = parseFloat(custom_value.attr('max') || Infinity);
            var min_val = parseFloat(custom_value.attr('min') || 0);

            var new_qty = quantity;
            if (current_target.has(".fa-minus").length) {
                new_qty = quantity - 1;
            } else if (current_target.has(".fa-plus").length) {
                new_qty = quantity + 1;
            }
            if (new_qty > max_val) {
                var attribute_name = custom_value.closest('.tab-pane').find('label[data-oe-id="' + custom_value.attr('data-oe-id') + '"]');
                var message = "Selected custom value " + attribute_name.text() + " must be lower than " + (max_val + 1);
                _displayTooltip(custom_value, message);
                new_qty = max_val;
            }
            else if (new_qty < min_val) {
                var attribute_name = custom_value.closest('.tab-pane').find('label[data-oe-id="' + custom_value.attr('data-oe-id') + '"]');
                var message = "Selected custom value " + attribute_name.text() + " must be at least " + min_val;
                _displayTooltip(custom_value, message);
                new_qty = min_val;
            }
            custom_value.val(new_qty);
            _disableEnableAddRemoveQtyButton(new_qty ,max_val ,min_val)
        }

        $('.custom_config_value.quantity').change(function(ev) {
            _handleSppinerCustomValue(ev);
        });

        $('.js_add_qty').on('click', function(ev) {
            _handleSppinerCustomValue(ev);
        });

        $('.js_remove_qty').on('click', function(ev) {
            _handleSppinerCustomValue(ev);
        });
    });

})
<commit_msg>[FIX]display weight upto 2 decimal precision<commit_after>odoo.define('website_product_configurator.config_form', function (require) {
    'use strict';

    var ajax = require('web.ajax');
    var time = require('web.time');

    $(document).ready(function () {
        var config_form = $("#product_config_form");
        var datetimepickers_options = {
            calendarWeeks: true,
            icons : {
                time: 'fa fa-clock-o',
                date: 'fa fa-calendar',
                next: 'fa fa-chevron-right',
                previous: 'fa fa-chevron-left',
                up: 'fa fa-chevron-up',
                down: 'fa fa-chevron-down',
               },
            locale : moment.locale(),
            widgetParent: 'body',
            allowInputToggle: true,
            showClose: true,
            format : time.getLangDatetimeFormat(),
            keyBinds: null,
        };

        var datepickers_options = $.extend({}, datetimepickers_options, {format: time.getLangDateFormat()})

        config_form.find('.product_config_datetimepicker').datetimepicker(datetimepickers_options);
        config_form.find('.product_config_datepicker').datetimepicker(datepickers_options);

        /* Monitor input changes in the configuration form and call the backend onchange method*/
        config_form.find('.config_attribute').change(function(ev) {
            ajax.jsonRpc("/website_product_configurator/onchange", 'call', {
                form_values: config_form.serializeArray(),
                field_name: $(this)[0].name,
            }).then(function(data) {
                if (data.error) {
                    alert(data.error);
                };
                var values = data.value;
                var domains = data.domain;

                var open_cfg_step_line_ids = data.open_cfg_step_line_ids;
                var config_image_vals = data.config_image_vals;

                _applyDomainOnValues(domains);
                _handleOpenSteps(open_cfg_step_line_ids);
                _setImageUrl(config_image_vals);
                _setWeightPrice(values.weight, values.price);
            });
            _handleCustomAttribute(ev)
        });

        function _setWeightPrice(weight, price) {
            var formatted_price = _.str.sprintf('%.2f', price);
            var formatted_weight = _.str.sprintf('%.2f', weight);
            $('.config_product_weight').text(formatted_weight);
            $('.config_product_price').find('.oe_currency_value').text(formatted_price);
        }

        function _setImageUrl(config_image_vals) {
            var images = '';
            if (config_image_vals){
                var model = config_image_vals.name
                config_image_vals.config_image_ids.forEach(function(line){
                    images += ""
                })
            }
            $('#product_config_image').html(images);
        };

        function _handleCustomAttribute(event) {
            var container = $(event.currentTarget).closest('.tab-pane.container');
            var attribute_id = $(event.currentTarget).attr('data-oe-id');
            var custom_value = container.find('.custom_config_value[data-oe-id=' + attribute_id + ']');
            var custom_value_container = custom_value.closest('.custom_field_container[data-oe-id=' + attribute_id + ']');
            if ($(event.currentTarget.selectedOptions[0]).hasClass('custom_config_attr_value') && custom_value_container.hasClass('hidden')) {
                custom_value_container.removeClass('hidden');
                custom_value.addClass('required_config_attrib');
            } else if (!custom_value_container.hasClass('hidden')){
                custom_value_container.addClass('hidden');
                if (custom_value.hasClass('required_config_attrib')) {
                    custom_value.removeClass('required_config_attrib');
                }
            }
        }

        function _handleOpenSteps(open_cfg_step_line_ids) {
            var $steps = config_form.find('.config_step');
            _.each($steps, function (step) {
                step = $(step);
                var step_id = step.attr('data-step-id');
                if ($.inArray(step_id, open_cfg_step_line_ids) < 0) {
                    if (!step.hasClass('hidden')) {
                        step.addClass('hidden');
                    };
                } else {
                    if (step.hasClass('hidden')) {
                        step.removeClass('hidden');
                    };
                };
            });
        }

        function _applyDomainOnValues(domains) {
            _.each(domains, function (domain, attr_id) {
                var $selection = config_form.find('#' + attr_id);
                var $options = $selection.find('.config_attr_value');
                _.each($options, function (option) {
                    var condition = domain[0][1];
                    if (condition == 'in' || config_form == '=') {
                        if ($.inArray(parseInt(option.value), domain[0][2]) < 0) {
                            $(option).attr('disabled', true);
                            if (option.selected) {
                                option.selected = false;
                            };
                        } else {
                            $(option).attr('disabled', false);
                        };
                    } else if (condition == 'not in' || config_form == '!=') {
                        if ($.inArray(parseInt(option.value), domain[0][2]) < 0) {
                            $(option).attr('disabled', false);
                        } else {
                            $(option).attr('disabled', true);
                            if (option.selected) {
                                option.selected = false;
                            };
                        };
                    };
                });
            });
        }

        function _onChangeConfigStep(event, next_step) {
            var flag = _checkRequiredFields(event)
            var config_step_header = config_form.find('.nav.nav-tabs');
            var current_config_step = config_step_header.find('.nav-item.config_step.active').attr('data-step-id');
            if (flag) {
                return ajax.jsonRpc("/website_product_configurator/save_configuration", 'call', {
                    form_values: config_form.serializeArray(),
                    next_step: next_step || false,
                    current_step: current_config_step || false,
                }).then(function(data) {
                    if (data.error) {
                        alert(data.error);
                    };
                    return data;
                });
            } else {
                return false;
            }
        };

        function _displayTooltip(config_attribut, message) {
            $(config_attribut).tooltip({
                title: message,
                placement: "bottom",
                trigger: "manual",
                delay: {show: 500, hide: 500},
                template: "

"
            }).tooltip('show');
            setTimeout(function(){
                $(config_attribut).tooltip('destroy');
            }, 4000);
        };

        function _checkRequiredFields(event) {
            var active_step = config_form.find('.tab-content').find('.tab-pane.active.in');
            var config_attr = active_step.find('.form-control.required_config_attrib');
            var flag = true;
            for (var i = 0; i < config_attr.length; i++) {
                var cfg_attr_value = config_attr[i].value.trim()
                if (!cfg_attr_value  || cfg_attr_value == '0') {
                    $(config_attr[i]).addClass('textbox-border-color');
                    flag = false;
                    // if (config_attr[i].tagName == 'SELECT') {
                    //     var message = "Please select an item in the list."
                    // } else if (config_attr[i].tagName == 'INPUT') {
                    //     var message = "Please enter value."
                    // }
                    // _displayTooltip(config_attr[i], message);
                }
                else if (cfg_attr_value && $(config_attr[i]).hasClass('textbox-border-color')) {
                    $(config_attr[i]).removeClass('textbox-border-color');
                };
            };
            return flag;
        };

        config_form.find('.config_attribute').change(function (event) {
            var attribute = event.currentTarget;
            if (attribute.value.trim() && attribute.value.trim() != '0' && $(attribute).hasClass('textbox-border-color')) {
                $(attribute).removeClass('textbox-border-color');
            };
        });
        config_form.find('.custom_config_value').change(function (event) {
            var attribute = event.currentTarget;
            if (attribute.value.trim() && attribute.value.trim() != '0' && $(attribute).hasClass('textbox-border-color')) {
                $(attribute).removeClass('textbox-border-color');
            };
        });

        config_form.find('.config_step').click(function (event) {
            var next_step = event.currentTarget.getAttribute('data-step-id');
            var result = _onChangeConfigStep(event, next_step);
            if (!result) {
                event.preventDefault();
                event.stopPropagation();
            };
        });

        function _openNextStep(step) {
            var config_step_header = config_form.find('.nav.nav-tabs');
            var config_step = config_step_header.find('.nav-item.config_step.active');
            if (config_step.length) {
                config_step.removeClass('active');
            }
            var active_step = config_form.find('.tab-content').find('.tab-pane.active.in');
            active_step.removeClass('active in');

            var next_step = config_step_header.find('.nav-item.config_step[data-step-id=' + step + ']');
            if (next_step.length) {
                next_step.addClass('active');
                var selector = next_step.find('a:first-child').attr('href');
                var step_to_active = config_form.find('.tab-content').find(selector);
                step_to_active.addClass('active in');
            }
        };

        function addRequiredAttr(config_step) {
            config_step = config_form.find('.tab-content').find('tab-pane container[data-step-id=' + config_step + ']');
            _.each(config_step.find('.form-control.config_attribute'), function(attribute_field) {
                $(attribute_field).attr('required', true);
            });
        };

        // Save Values
        config_form.submit(function (event) {
            event.preventDefault();
            event.stopPropagation();

            var result = _onChangeConfigStep(event);
            if (result) {
                result.then(function (data) {
                    if (data) {
                        if (data.next_step) {
                            _openNextStep(data.next_step);
                        };
                        if (data.redirect_url) {
                            window.location = data.redirect_url;
                        };
                    };
                });
            }
        });

        // quantty sppiner
        function _disableEnableAddRemoveQtyButton(quantity, max_val, min_val) {
            if (quantity >= max_val) {
                $('.js_add_qty').addClass('btn-disabled');
            } else if (quantity < max_val && $('.js_add_qty').hasClass('btn-disabled')) {
                $('.js_add_qty').removeClass('btn-disabled');
            }
            if (quantity <= min_val) {
                $('.js_remove_qty').addClass('btn-disabled');
            } else if (quantity > min_val && $('.js_remove_qty').hasClass('btn-disabled')) {
                $('.js_remove_qty').removeClass('btn-disabled');
            }
        }

        function _handleSppinerCustomValue(ev) {
            ev.preventDefault();
            ev.stopPropagation();

            var current_target = $(ev.currentTarget);
            var custom_value = current_target.parent().find('input.custom_config_value');
            var quantity = parseFloat(custom_value.val() || 0);
            var max_val = parseFloat(custom_value.attr('max') || Infinity);
            var min_val = parseFloat(custom_value.attr('min') || 0);

            var new_qty = quantity;
            if (current_target.has(".fa-minus").length) {
                new_qty = quantity - 1;
            } else if (current_target.has(".fa-plus").length) {
                new_qty = quantity + 1;
            }
            if (new_qty > max_val) {
                var attribute_name = custom_value.closest('.tab-pane').find('label[data-oe-id="' + custom_value.attr('data-oe-id') + '"]');
                var message = "Selected custom value " + attribute_name.text() + " must be lower than " + (max_val + 1);
                _displayTooltip(custom_value, message);
                new_qty = max_val;
            }
            else if (new_qty < min_val) {
                var attribute_name = custom_value.closest('.tab-pane').find('label[data-oe-id="' + custom_value.attr('data-oe-id') + '"]');
                var message = "Selected custom value " + attribute_name.text() + " must be at least " + min_val;
                _displayTooltip(custom_value, message);
                new_qty = min_val;
            }
            custom_value.val(new_qty);
            _disableEnableAddRemoveQtyButton(new_qty ,max_val ,min_val)
        }

        $('.custom_config_value.quantity').change(function(ev) {
            _handleSppinerCustomValue(ev);
        });

        $('.js_add_qty').on('click', function(ev) {
            _handleSppinerCustomValue(ev);
        });

        $('.js_remove_qty').on('click', function(ev) {
            _handleSppinerCustomValue(ev);
        });
    });

})
<|endoftext|>


<commit_before>/*
 * Copyright (C) 2012 B3Partners B.V.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * DataSelection and Filter component
 * Creates a dialog where filter and selection settings can be set.
 * A dataselectionfilter contains 1..n filters, a filter contains 1..n attributefilters.
 * @author Meine Toonen
 */
Ext.define ("viewer.components.DataSelection",{
    extend: "viewer.components.Component",
    dataTab : null,
    filterTab : null,
    attributes:null,
    layerSelector:null,
    appLayer: null,
    filters:null,
    filterActive:null,
    uniqueValuesAttributes : null,
    // 0 when the datatab is fully initialized, otherwise false
    itemsLoaded : null,
    config: {
        layers:null,
        title:null,
        iconUrl:null,
        tooltip:null,
        details:{
            width: null,
            height:null
        }
    },
    constructor: function (conf){
        this.attributes =[];
        viewer.components.DataSelection.superclass.constructor.call(this, conf);
        this.filters = new Array();
        this.initConfig(conf);
        var me = this;
        this.renderButton({
            handler: function(){
                me.showWindow();
            },
            text: me.title,
            icon: me.iconUrl,
            tooltip: me.tooltip
        });
        this.loadWindow();
        return this;
    },
    showWindow : function (){
        this.layerSelector.initLayers();
        this.popup.show();
    },
    /** ???
     * @param layer the application Layer
     */
    showAndForceLayer : function (layer){
        this.layerSelector.addForcedLayer(layer);
        this.showWindow();
    },
    removeForcedLayer : function (layer){
        this.layerSelector.removeForcedLayer(layer);
        this.layerSelector.initLayers();
    },
    loadWindow : function(){
        this.itemsLoaded = 0;
        var config = {
            viewerController : this.viewerController,
            div: this.getContentDiv(),
            layers : this.layers
        };
        this.layerSelector = Ext.create("viewer.components.LayerSelector",config);
        this.layerSelector.addListener(viewer.viewercontroller.controller.Event.ON_LAYERSELECTOR_CHANGE,this.layerChanged,this);

        // Make the tabs
        this.tabpanel = Ext.create('Ext.tab.Panel', {
            height: parseInt(this.details.height) - 100,
            width: parseInt(this.details.width)-40,
            hideMode: 'offsets',
            autoScroll:true,
            layout: {
                type: 'fit'
            },
            tabBar:{
                style: 'background:#fff;'
            },
            items: [
            {
                id   : 'filterTab',
                title: 'Filter',// TODO Do renaming of variables dataselection-->filter
                hideMode: 'offsets',
                autoScroll:true,
                html: "

"
            },
            {
                id : "dataTab",
                title: 'Dataselectie',// TODO Do renaming of variables filter->dataselection
                hideMode: 'offsets',
                autoScroll:true,
                html: "

"
            }
            ],
            activeTab : "dataTab",
            renderTo : this.getContentDiv()
        });

        // Make panels in tabs and save them
        this.dataTab = Ext.create('Ext.panel.Panel', {
            autoScroll: true,
            renderTo: 'dataTabDiv'
        });

        this.filterTab = Ext.create('Ext.panel.Panel', {
            autoScroll: true,
            renderTo: 'filterTabDiv'
        });
        this.createFilterTab();
        // Make lower buttons
        this.button1 = Ext.create('Ext.Button', {
            text : 'Toepassen',
            renderTo: this.getContentDiv(),
            listeners: {
                click:{
                    scope: this,
                    fn: this.applyFilter
                }
            }
        });

        this.button2 = Ext.create('Ext.Button', {
            text : 'Annuleren',
            renderTo: this.getContentDiv(),
            listeners: {
                click:{
                    scope: this,
                    fn: this.cancel
                }
            }
        });

        this.button3 = Ext.create('Ext.Button', {
            text : 'Reset',
            renderTo: this.getContentDiv(),
            listeners: {
                click:{
                    scope: this,
                    fn: this.removeFilter
                }
            }
        });
    },
    createDataTab : function (appLayer){
        var attributes = appLayer.attributes;
        var dataSelectieAttributes = new Array();
        this.uniqueValuesAttributes = new Array();
        var minMaxAttrs = new Array();

        for(var i= 0 ; i < attributes.length ;i++){
            var attribute = attributes[i];
            if(attribute.selectable){
                var defaultVal = "";
                if(attribute.defaultValue != undefined){
                    defaultVal = attribute.defaultValue;
                    if(defaultVal == "#MAX#" || defaultVal == "#MIN#"){
                        minMaxAttrs.push({
                            attribute : attribute,
                            operator: defaultVal
                        });
                        defaultVal = "";
                    }
                }
                dataSelectieAttributes.push({
                    xtype: "combobox",
                    id: attribute.name,
                    queryMode : 'local',
                    disabled: true,
                    dataType: attribute.type,
                    editable: false,
                    name: attribute.name,
                    fieldLabel: attribute.alias || attribute.name,
                    labelWidth:150,
                    displayField: 'id',
                    valueField: 'id',
                    value : defaultVal,
                    width: 400,
                    emptyText:'Maak uw keuze',
                    store: {
                        fields: [{name:'id',convert:function(v,row){if(row.raw){return row.raw;}else{return "";}}}],
                        data : []
                    }
                });

                this.uniqueValuesAttributes.push(attribute.name);
            }
        }
        this.dataTab.removeAll();
        var defaultText = 'Kaart wordt pas zichtbaar na het toepassen van een dataselectie';
        if(this.uniqueValuesAttributes.length == 0){
            defaultText = '';
        }
        this.dataTab.add({
            xtype : 'label',
            text: defaultText
        });
        this.getUniques();
        this.dataTab.add(dataSelectieAttributes);
        this.initMinMaxValues(minMaxAttrs,appLayer);
    },

    createFilterTab : function (){
        this.filterTab.removeAll();
        this.filters = new Array();
        // Add the button to the filtertab
        var addFilter = Ext.create('Ext.Button', {
            text : 'Voeg filter toe',
            listeners: {
                click:{
                    scope: this,
                    fn: this.addFilter
                }
            }
        });
        this.filterTab.add(addFilter);
        this.filterActive = Ext.create ("Ext.form.field.Checkbox",{
            boxLabel  : 'Filter is actief',
            name      : 'filterActive',
            inputValue: true,
            checked   : false

        });
        this.filterTab.add(this.filterActive);
        // Add the first filter
        this.addFilter();
    },
    initMinMaxValues : function (minMaxAttrs,appLayer){
        for(var i = 0 ; i < minMaxAttrs.length ; i++){
            var attr = minMaxAttrs[i];
            this.itemsLoaded++;
            this.getMinMax(attr.operator, attr.attribute, appLayer);
        }
    },
    getMinMax : function (operator, attribute,appLayer){
        var cb = Ext.getCmp(attribute.name);
        cb.setDisabled(true);
        Ext.Ajax.request({
            url: actionBeans.unique,
            timeout: 240000,
            scope:this,
            params: {
                attribute: attribute.name,
                applicationLayer: appLayer.id,
                getMinMaxValue: 't',
                operator: operator
            },
            success: function ( result, request ) {
                var res = Ext.JSON.decode(result.responseText);
                if(res.success){
                    var value = res.value;
                    cb.setValue(value);
                }else{
                    Ext.MessageBox.alert('Foutmelding', "Kan geen minmax waardes ophalen: " + res.msg);
                }

                this.itemsLoaded--;
                cb.setDisabled(false);
            },
            failure: function ( result, request) {
                Ext.MessageBox.alert('Foutmelding', "Kan geen minmax waardes ophalen: " + result.responseText);
                cb.setDisabled(false);
                this.itemsLoaded--;
            }
        });
    },
    getUniques : function (){
        var appLayer = this.layerSelector.getValue();
        if(this.uniqueValuesAttributes.length > 0){
            this.dataTab.getEl().mask("Laad unieke waardes...");
            Ext.Ajax.request({
                url: actionBeans.unique,
                timeout: 240000,
                scope:this,
                params: {
                    attributes: this.uniqueValuesAttributes,
                    applicationLayer: appLayer.id
                },
                success: function ( result, request ) {
                    var res = Ext.JSON.decode(result.responseText);
                    if(res.success){
                        var values = res.uniqueValues;
                        if(res.msg){
                            Ext.MessageBox.alert('Info', res.msg);
                        }
                        this.receiveUniqueValues(values);
                    }else{
                        Ext.MessageBox.alert('Foutmelding', "Kan geen unieke waardes ophalen: " + res.msg);
                    }
                },
                failure: function ( result, request) {
                    Ext.MessageBox.alert('Foutmelding', "Kan geen unieke waardes ophalen: " + result.responseText);
                    this.itemsLoaded--;
                }
            });
        }
    },
    receiveUniqueValues : function (values){
        for(var attribute in values){
            var unique = values[attribute];
            this.addValuesToCombobox(unique, attribute);
        }
        this.dataTab.getEl().unmask();
        this.itemsLoaded--;
    },
    addValuesToCombobox : function (values, attribute){
        var combobox = Ext.getCmp (attribute);
        if(combobox){   // In case there are more than one layer with dataselection fields. This method can be called with an attribute of layer 1, when layer 2 is initialized
            combobox.setDisabled(false);
            combobox.getEl().unmask();
            var SingleArray = Ext.define('SingleArray', {
                extend: 'Ext.data.Model',
                fields: [{name: 'id'  , convert:function(v,row){if(row.raw){return row.raw;}else{return "";}}}]
            });

            var myReader = new Ext.data.reader.Array({
                model: 'SingleArray'
            }, SingleArray);
            var rs =  myReader.read(values);
            combobox.getStore().add(rs.records);
        }
    },

    /**
     *  Add a filter to the current filterlist.
     */
    addFilter : function (){
        var logicOperator = null;
        if(this.filters.length != 0){
            var logicStore = Ext.create('Ext.data.Store', {
                fields: ['id','title'],
                data : [{
                    id:"OR",
                    title:"of"
                }, {
                    id:"AND",
                    title:"en"
                }]
            });

            logicOperator = Ext.create('Ext.form.ComboBox', {
                fieldLabel: '',
                store: logicStore,
                queryMode: 'local',
                displayField: 'title',
                width:50,
                value:'OR',
                valueField: 'id'
            });
            // Insert before the checkbox
            this.filterTab.insert(this.filterTab.items.length - 1,logicOperator);

        }
        var config = {
            width: parseInt(this.details.width),
            height: parseInt(this.details.height),
            attributes:this.attributes,
            logicOperator:logicOperator
        };
        var filter = Ext.create("viewer.components.Filter",config);
        this.filters.push(filter);
        // Insert before the checkbox
        this.filterTab.insert(this.filterTab.items.length - 1,filter.getUI());
    },
    selectAppLayer : function (appLayer){
        if(appLayer){
            this.layerSelector.setValue(appLayer);
        }
    },
    isDatatabLoaded : function(){
        if(this.itemsLoaded == 0){
            return true;
        }else{
            return false;
        }
    },
    applyFilterWithDefaults : function (){
        if(this.isDatatabLoaded){
            this.applyFilter();
        }else{
            setTimeout(function(){
                        this.applyFilterWithDefaults();}, 100);
        }
    },
    applyFilter : function (){
        var cql = "";

        cql += this.getDataTabCQL();
        if(this.filterActive.getValue()){
            if(cql != ""){
                cql += " AND ";
            }
            for ( var i = 0 ; i < this.filters.length;i++){
                var filter = this.filters[i];
                cql += filter.getCQL();
            }

        }
        if(cql != ""){
            cql = "(" + cql + ")";
        }
        var layer = this.layerSelector.getValue();
        if(layer){
            var filterWrapper =  Ext.create("viewer.components.CQLFilterWrapper",{
                id: this.name + this.layerSelector.getValue().layerName,
                cql: cql,
                operator : "AND",
                type: "ATTRIBUTE"
            });

            this.viewerController.setFilter(filterWrapper,layer);
        }

    //console.log("CQL: " + layer.filter.getCQL());
    },
    getDataTabCQL : function (){
        var items = this.dataTab.items.items;
        var cql = "";
        for ( var i = 1 ; i < items.length;i++){ // Skip the default text for dataselection.
            var item = items[i];
            if(item.getValue() != ""){
                if(i > 1 ){
                    cql += " AND ";
                }
                cql += "\"" +item.id + "\"=";
                var attributeType = item.dataType;
                if(attributeType && attributeType.toLowerCase() == "string"){
                    cql += "\'";
                }
                cql += item.getValue();
                if(attributeType && attributeType.toLowerCase() == "string"){
                    cql += "\'";
                }
            }
        }
        return cql;
    },
    cancel : function (){
        this.popup.hide();
    },
    removeFilter : function (){
        var appLayer = this.layerSelector.getValue();
        if(appLayer){
            var filterId = this.name + appLayer.layerName;
            this.viewerController.removeFilter(filterId,appLayer);
        }
        this.layerSelector.setValue();
        this.resetForm();
    },
    /**
     *  Reset all comboboxes when a different layer is selected
     */
    layerChanged : function (item,prev){
        this.appLayer = item;

        if(this.appLayer != null){
            this.featureService = this.viewerController.getAppLayerFeatureService(this.appLayer);
            var me = this;
            // check if featuretype was loaded
            if(this.appLayer.attributes == undefined) {
                this.featureService.loadAttributes(me.appLayer, function(attributes) {
                    me.changeAttributes(me.appLayer);
                });
            } else {
                this.changeAttributes(me.appLayer);
            }
        }

        if(prev != undefined){
            if(this.appLayer){
                var prevLayer = this.viewerController.getLayer(this.appLayer);
                prevLayer.setQuery(null);
            }
        }
    },
    // Change the comboboxes of the attributefilters. Happens when a new layer is chosen.
    changeAttributes : function (appLayer){
        var attributes = appLayer.attributes;
        var attributeList = new Array();
        for(var i= 0 ; i < attributes.length ;i++){
            var attribute = attributes[i];
            if(attribute.filterable){
                attributeList.push({
                    id: attribute.id,
                    title: attribute.alias || attribute.name,
                    value: attribute.name,
                    type: attribute.type
                });
            }
        }
        this.attributes = attributeList;
        for (var j = 0 ; j < this.filters.length ;j++){
            var filter = this.filters[j];
            filter.setNewAttributeList(attributeList);
        }
        this.createDataTab(appLayer);
    },
    getExtComponents: function() {
        return Ext.Array.merge(
            this.layerSelector.getExtComponents(),
            [
            this.tabpanel.getId(),
            this.dataTab.getId(),
            this.filterTab.getId(),
            this.button1.getId(),
            this.button2.getId()
            ]
            );
    },
    resetForm :function(){
        this.dataTab.removeAll();
        this.createFilterTab();
    }
});
<commit_msg>Bugfix for min/max values for dataselection<commit_after>/*
 * Copyright (C) 2012 B3Partners B.V.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * DataSelection and Filter component
 * Creates a dialog where filter and selection settings can be set.
 * A dataselectionfilter contains 1..n filters, a filter contains 1..n attributefilters.
 * @author Meine Toonen
 */
Ext.define ("viewer.components.DataSelection",{
    extend: "viewer.components.Component",
    dataTab : null,
    filterTab : null,
    attributes:null,
    layerSelector:null,
    appLayer: null,
    filters:null,
    filterActive:null,
    uniqueValuesAttributes : null,
    // 0 when the datatab is fully initialized, otherwise false
    itemsLoaded : null,
    config: {
        layers:null,
        title:null,
        iconUrl:null,
        tooltip:null,
        details:{
            width: null,
            height:null
        }
    },
    constructor: function (conf){
        this.attributes =[];
        viewer.components.DataSelection.superclass.constructor.call(this, conf);
        this.filters = new Array();
        this.initConfig(conf);
        var me = this;
        this.renderButton({
            handler: function(){
                me.showWindow();
            },
            text: me.title,
            icon: me.iconUrl,
            tooltip: me.tooltip
        });
        this.loadWindow();
        return this;
    },
    showWindow : function (){
        this.layerSelector.initLayers();
        this.popup.show();
    },
    /** ???
     * @param layer the application Layer
     */
    showAndForceLayer : function (layer){
        this.layerSelector.addForcedLayer(layer);
        this.showWindow();
    },
    removeForcedLayer : function (layer){
        this.layerSelector.removeForcedLayer(layer);
        this.layerSelector.initLayers();
    },
    loadWindow : function(){
        this.itemsLoaded = 0;
        var config = {
            viewerController : this.viewerController,
            div: this.getContentDiv(),
            layers : this.layers
        };
        this.layerSelector = Ext.create("viewer.components.LayerSelector",config);
        this.layerSelector.addListener(viewer.viewercontroller.controller.Event.ON_LAYERSELECTOR_CHANGE,this.layerChanged,this);

        // Make the tabs
        this.tabpanel = Ext.create('Ext.tab.Panel', {
            height: parseInt(this.details.height) - 100,
            width: parseInt(this.details.width)-40,
            hideMode: 'offsets',
            autoScroll:true,
            layout: {
                type: 'fit'
            },
            tabBar:{
                style: 'background:#fff;'
            },
            items: [
            {
                id   : 'filterTab',
                title: 'Filter',// TODO Do renaming of variables dataselection-->filter
                hideMode: 'offsets',
                autoScroll:true,
                html: "

"
            },
            {
                id : "dataTab",
                title: 'Dataselectie',// TODO Do renaming of variables filter->dataselection
                hideMode: 'offsets',
                autoScroll:true,
                html: "

"
            }
            ],
            activeTab : "dataTab",
            renderTo : this.getContentDiv()
        });

        // Make panels in tabs and save them
        this.dataTab = Ext.create('Ext.panel.Panel', {
            autoScroll: true,
            renderTo: 'dataTabDiv'
        });

        this.filterTab = Ext.create('Ext.panel.Panel', {
            autoScroll: true,
            renderTo: 'filterTabDiv'
        });
        this.createFilterTab();
        // Make lower buttons
        this.button1 = Ext.create('Ext.Button', {
            text : 'Toepassen',
            renderTo: this.getContentDiv(),
            listeners: {
                click:{
                    scope: this,
                    fn: this.applyFilter
                }
            }
        });

        this.button2 = Ext.create('Ext.Button', {
            text : 'Annuleren',
            renderTo: this.getContentDiv(),
            listeners: {
                click:{
                    scope: this,
                    fn: this.cancel
                }
            }
        });

        this.button3 = Ext.create('Ext.Button', {
            text : 'Reset',
            renderTo: this.getContentDiv(),
            listeners: {
                click:{
                    scope: this,
                    fn: this.removeFilter
                }
            }
        });
    },
    createDataTab : function (appLayer){
        var attributes = appLayer.attributes;
        var dataSelectieAttributes = new Array();
        this.uniqueValuesAttributes = new Array();
        var minMaxAttrs = new Array();

        for(var i= 0 ; i < attributes.length ;i++){
            var attribute = attributes[i];
            if(attribute.selectable){
                var defaultVal = "";
                if(attribute.defaultValue != undefined){
                    defaultVal = attribute.defaultValue;
                    if(defaultVal == "#MAX#" || defaultVal == "#MIN#"){
                        minMaxAttrs.push({
                            attribute : attribute,
                            operator: defaultVal
                        });
                        defaultVal = "";
                    }
                }
                dataSelectieAttributes.push({
                    xtype: "combobox",
                    id: attribute.name,
                    queryMode : 'local',
                    disabled: true,
                    dataType: attribute.type,
                    editable: false,
                    name: attribute.name,
                    fieldLabel: attribute.alias || attribute.name,
                    labelWidth:150,
                    displayField: 'id',
                    valueField: 'id',
                    value : defaultVal,
                    width: 400,
                    emptyText:'Maak uw keuze',
                    store: {
                        fields: [{name:'id',convert:function(v,row){if(row.raw){return row.raw;}else{return "";}}}],
                        data : []
                    }
                });

                this.uniqueValuesAttributes.push(attribute.name);
            }
        }
        this.dataTab.removeAll();
        var defaultText = 'Kaart wordt pas zichtbaar na het toepassen van een dataselectie';
        if(this.uniqueValuesAttributes.length == 0){
            defaultText = '';
        }
        this.dataTab.add({
            xtype : 'label',
            text: defaultText
        });
        this.getUniques();
        this.dataTab.add(dataSelectieAttributes);
        this.initMinMaxValues(minMaxAttrs,appLayer);
    },

    createFilterTab : function (){
        this.filterTab.removeAll();
        this.filters = new Array();
        // Add the button to the filtertab
        var addFilter = Ext.create('Ext.Button', {
            text : 'Voeg filter toe',
            listeners: {
                click:{
                    scope: this,
                    fn: this.addFilter
                }
            }
        });
        this.filterTab.add(addFilter);
        this.filterActive = Ext.create ("Ext.form.field.Checkbox",{
            boxLabel  : 'Filter is actief',
            name      : 'filterActive',
            inputValue: true,
            checked   : false

        });
        this.filterTab.add(this.filterActive);
        // Add the first filter
        this.addFilter();
    },
    initMinMaxValues : function (minMaxAttrs,appLayer){
        for(var i = 0 ; i < minMaxAttrs.length ; i++){
            var attr = minMaxAttrs[i];
            this.itemsLoaded++;
            this.getMinMax(attr.operator, attr.attribute, appLayer);
        }
    },
    getMinMax : function (operator, attribute,appLayer){
        var cb = Ext.getCmp(attribute.name);
        cb.setDisabled(true);
        Ext.Ajax.request({
            url: actionBeans.unique,
            timeout: 240000,
            scope:this,
            params: {
                attribute: attribute.name,
                applicationLayer: appLayer.id,
                getMinMaxValue: 't',
                operator: operator
            },
            success: function ( result, request ) {
                var res = Ext.JSON.decode(result.responseText);
                if(res.success){
                    var value = res.value;
                    cb.setValue(value);
                }else{
                    Ext.MessageBox.alert('Foutmelding', "Kan geen minmax waardes ophalen: " + res.msg);
                }

                this.itemsLoaded--;
                cb.setDisabled(false);
            },
            failure: function ( result, request) {
                Ext.MessageBox.alert('Foutmelding', "Kan geen minmax waardes ophalen: " + result.responseText);
                cb.setDisabled(false);
                this.itemsLoaded--;
            }
        });
    },
    getUniques : function (){
        var appLayer = this.layerSelector.getValue();
        if(this.uniqueValuesAttributes.length > 0){
            this.itemsLoaded++;
            this.dataTab.getEl().mask("Laad unieke waardes...");
            Ext.Ajax.request({
                url: actionBeans.unique,
                timeout: 240000,
                scope:this,
                params: {
                    attributes: this.uniqueValuesAttributes,
                    applicationLayer: appLayer.id
                },
                success: function ( result, request ) {
                    var res = Ext.JSON.decode(result.responseText);
                    if(res.success){
                        var values = res.uniqueValues;
                        if(res.msg){
                            Ext.MessageBox.alert('Info', res.msg);
                        }
                        this.receiveUniqueValues(values);
                    }else{
                        Ext.MessageBox.alert('Foutmelding', "Kan geen unieke waardes ophalen: " + res.msg);
                    }
                },
                failure: function ( result, request) {
                    Ext.MessageBox.alert('Foutmelding', "Kan geen unieke waardes ophalen: " + result.responseText);
                    this.itemsLoaded--;
                }
            });
        }
    },
    receiveUniqueValues : function (values){
        for(var attribute in values){
            var unique = values[attribute];
            this.addValuesToCombobox(unique, attribute);
        }
        this.dataTab.getEl().unmask();
        this.itemsLoaded--;
    },
    addValuesToCombobox : function (values, attribute){
        var combobox = Ext.getCmp (attribute);
        if(combobox){   // In case there are more than one layer with dataselection fields. This method can be called with an attribute of layer 1, when layer 2 is initialized
            combobox.setDisabled(false);
            combobox.getEl().unmask();
            var SingleArray = Ext.define('SingleArray', {
                extend: 'Ext.data.Model',
                fields: [{name: 'id'  , convert:function(v,row){if(row.raw){return row.raw;}else{return "";}}}]
            });

            var myReader = new Ext.data.reader.Array({
                model: 'SingleArray'
            }, SingleArray);
            var rs =  myReader.read(values);
            combobox.getStore().add(rs.records);
        }
    },

    /**
     *  Add a filter to the current filterlist.
     */
    addFilter : function (){
        var logicOperator = null;
        if(this.filters.length != 0){
            var logicStore = Ext.create('Ext.data.Store', {
                fields: ['id','title'],
                data : [{
                    id:"OR",
                    title:"of"
                }, {
                    id:"AND",
                    title:"en"
                }]
            });

            logicOperator = Ext.create('Ext.form.ComboBox', {
                fieldLabel: '',
                store: logicStore,
                queryMode: 'local',
                displayField: 'title',
                width:50,
                value:'OR',
                valueField: 'id'
            });
            // Insert before the checkbox
            this.filterTab.insert(this.filterTab.items.length - 1,logicOperator);

        }
        var config = {
            width: parseInt(this.details.width),
            height: parseInt(this.details.height),
            attributes:this.attributes,
            logicOperator:logicOperator
        };
        var filter = Ext.create("viewer.components.Filter",config);
        this.filters.push(filter);
        // Insert before the checkbox
        this.filterTab.insert(this.filterTab.items.length - 1,filter.getUI());
    },
    selectAppLayer : function (appLayer){
        if(appLayer){
            this.layerSelector.setValue(appLayer);
        }
    },
    isDatatabLoaded : function(){
        if(this.itemsLoaded == 0){
            return true;
        }else{
            return false;
        }
    },
    applyFilterWithDefaults : function (){
        if(this.isDatatabLoaded()){
            this.applyFilter();
        }else{
            var me = this;
            setTimeout(function(){
                        me.applyFilterWithDefaults();}, 100);
        }
    },
    applyFilter : function (){
        var cql = "";

        cql += this.getDataTabCQL();
        if(this.filterActive.getValue()){
            if(cql != ""){
                cql += " AND ";
            }
            for ( var i = 0 ; i < this.filters.length;i++){
                var filter = this.filters[i];
                cql += filter.getCQL();
            }

        }
        if(cql != ""){
            cql = "(" + cql + ")";
        }
        var layer = this.layerSelector.getValue();
        if(layer){
            var filterWrapper =  Ext.create("viewer.components.CQLFilterWrapper",{
                id: this.name + this.layerSelector.getValue().layerName,
                cql: cql,
                operator : "AND",
                type: "ATTRIBUTE"
            });

            this.viewerController.setFilter(filterWrapper,layer);
        }

    //console.log("CQL: " + layer.filter.getCQL());
    },
    getDataTabCQL : function (){
        var items = this.dataTab.items.items;
        var cql = "";
        for ( var i = 1 ; i < items.length;i++){ // Skip the default text for dataselection.
            var item = items[i];
            if(item.getValue() != ""){
                if(i > 1 ){
                    cql += " AND ";
                }
                cql += "\"" +item.id + "\"=";
                var attributeType = item.dataType;
                if(attributeType && attributeType.toLowerCase() == "string"){
                    cql += "\'";
                }
                cql += item.getValue();
                if(attributeType && attributeType.toLowerCase() == "string"){
                    cql += "\'";
                }
            }
        }
        return cql;
    },
    cancel : function (){
        this.popup.hide();
    },
    removeFilter : function (){
        var appLayer = this.layerSelector.getValue();
        if(appLayer){
            var filterId = this.name + appLayer.layerName;
            this.viewerController.removeFilter(filterId,appLayer);
        }
        this.layerSelector.setValue();
        this.resetForm();
    },
    /**
     *  Reset all comboboxes when a different layer is selected
     */
    layerChanged : function (item,prev){
        this.appLayer = item;

        if(this.appLayer != null){
            this.featureService = this.viewerController.getAppLayerFeatureService(this.appLayer);
            var me = this;
            // check if featuretype was loaded
            if(this.appLayer.attributes == undefined) {
                this.featureService.loadAttributes(me.appLayer, function(attributes) {
                    me.changeAttributes(me.appLayer);
                });
            } else {
                this.changeAttributes(me.appLayer);
            }
        }

        if(prev != undefined){
            if(this.appLayer){
                var prevLayer = this.viewerController.getLayer(this.appLayer);
                prevLayer.setQuery(null);
            }
        }
    },
    // Change the comboboxes of the attributefilters. Happens when a new layer is chosen.
    changeAttributes : function (appLayer){
        var attributes = appLayer.attributes;
        var attributeList = new Array();
        for(var i= 0 ; i < attributes.length ;i++){
            var attribute = attributes[i];
            if(attribute.filterable){
                attributeList.push({
                    id: attribute.id,
                    title: attribute.alias || attribute.name,
                    value: attribute.name,
                    type: attribute.type
                });
            }
        }
        this.attributes = attributeList;
        for (var j = 0 ; j < this.filters.length ;j++){
            var filter = this.filters[j];
            filter.setNewAttributeList(attributeList);
        }
        this.createDataTab(appLayer);
    },
    getExtComponents: function() {
        return Ext.Array.merge(
            this.layerSelector.getExtComponents(),
            [
            this.tabpanel.getId(),
            this.dataTab.getId(),
            this.filterTab.getId(),
            this.button1.getId(),
            this.button2.getId()
            ]
            );
    },
    resetForm :function(){
        this.dataTab.removeAll();
        this.createFilterTab();
    }
});
<|endoftext|>


<commit_before>var gracenode = require('../gracenode');
var log = gracenode.log.create('server-response');
var hook = require('./responseHook');
var zlib = require('zlib');
var mime = require('./mime');

module.exports.create = function (resource, requestObj) {
	return new Response(resource, requestObj);
};

function Response(resource, requestObj) {
	this._resource = resource;
	this._requestObj = requestObj;
	this._defaultStatus = 200;
}

Response.prototype.header = function (name, value) {
	this._resource.rawResponse.setHeader(name, value);
};

Response.prototype.json = function (content, status) {
	log.verbose('response content type: JSON');
	this.respond(null, respondJSON, content, status);
};

Response.prototype.html = function (content, status) {
	log.verbose('response content type: HTML');
	this.respond(null, respondHTML, content, status);
};

Response.prototype.data = function (content, status) {
	log.verbose('response content type: Data');
	this.respond(null, respondData, content, status);
};

Response.prototype.file = function (content, status) {
	log.verbose('response content type: File');
	this.respond(null, respondFILE, content, status);
};

Response.prototype.error = function (content, status) {
	this._errorHandler(content, status);
};

Response.prototype.download = function (content, fileName, status) {
	var fileType = fileName.substring(fileName.lastIndexOf('.') + 1);
	log.verbose('response content type:', fileType);
	this.respond({ 'Content-Disposition': 'attachment; filename=' + fileName }, respondDownload, content, status);
};

Response.prototype.redirect = function (content) {
	log.verbose('response content type: Redirect');
	this.respond(null, respondRedirect, content, 307);
};

// internal use only
Response.prototype._setDefaultStatus = function (status) {
	this._defaultStatus = status;
};

Response.prototype.respond = function (headers, respondFunc, content, status) {

	// check for duplicated response
	if (this._resource.responded) {
		var rawReq = this._resource.rawRequest;
		var dupResError = new Error('responded more than once: (url:' + rawReq.url + ') (id:' + rawReq.uniqueId + ')');
		log.error(dupResError);
		log.error('content:', content, 'stauts:', (status || 200));
	}

	var that = this;
	hook.exec(this, function () {
		// this callback will NOT be executed on error of the hook
		for (var headerName in headers) {
			that.header(headerName, headers[headername]);
		}
		setupFinish(that._resource.rawRequest, that._resource.rawResponse, that._resource.server, that._resource.startTime);
		respondFunc(that._resource.rawRequest, that._resource.rawResponse, content, status || that._defaultStatus);
		finish(that._resource.rawRequest, that._resource.rawResponse, that._resource.server);
		that._resource.responded = true;
	});
};

// overrriden by controller
Response.prototype._errorHandler = function () {

};

Response.prototype._error = function (content, status) {
	log.verbose('response content type: Error');
	setupFinish(this._resource.rawRequest, this._resource.rawResponse, this._resource.server, this._resource.startTime);
	respondERROR(this._resource.rawRequest, this._resource.rawResponse, content, status);
	finish(this._resource.rawRequest, this._resource.rawResponse, this._resource.server);
};

// sets up events for response finish. The events will be called when the request response has all been sent.
function setupFinish(req, res, server, startTime) {
	// this will be called when the server sends the response data and finishes it.
	res.once('finish', function () {
		var execTime = Date.now() - startTime;
		var msg = 'request responded: (url:' + req.url + ') (id:' + req.uniqueId + ') (took:' + execTime + 'ms) (status:' + res.statusCode + ')';
		if (res.statusCode > 399) {
			log.error(msg);
		} else {
			log.info(msg);
		}
		server.emit('requestFinish', req.url, execTime);
	});
}

function finish(req, res, server) {
	res.emit('end', req.url);
	// this will be called when the server finishes all operation (not when the response data sent)
	server.emit('requestEnd', req.url);
}

function compressContent(req, content, cb) {
	if (content instanceof Buffer) {
		// we do not compress binary
		log.verbose('skip compressing binary data: (url:' + req.url + ') ' + (content.length / 1024) + 'KB');
		cb(null, content);
	}
	zlib.gzip(content, function (error, compressedData) {
		if (error) {
			return cb(error);
		}
		log.verbose('compressed content size: (url:' + req.url + ') ' + (compressedData.length / 1024) + ' KB');

		cb(null, compressedData);
	});
}

function respondJSON(req, res, content, status) {
	content = content || null;
	compressContent(req, JSON.stringify(content), function (error, data) {

		if (error) {
			log.error('compression error: (url:' + req.url, + ')', error);
			status = 500;
			data = error;
		}

		res.writeHead(status, {
			'Cache-Control': 'no-cache, must-revalidate',
			'Connection': 'Keep-Alive',
			'Content-Encoding': 'gzip',
			'Content-Type': 'application/json; charset=UTF-8',
			'Pragma': 'no-cache',
			'Vary': 'Accept-Encoding',
			'Content-Length': data.length
		});

		res.end(data, 'binary');

	});

}

function respondHTML(req, res, content, status) {
	content = content || null;
	compressContent(req, content, function (error, data) {

		if (error) {
			log.error('compression error: (url:' + req.url, + ')', error);
			status = 500;
			data = error;
		}

		res.writeHead(status, {
			'Cache-Control': 'no-cache, must-revalidate',
			'Connection': 'Keep-Alive',
			'Content-Encoding': 'gzip',
			'Content-Type': 'text/html; charset=UTF-8',
			'Pragma': 'no-cache',
			'Vary': 'Accept-Encoding',
			'Content-Length': data.length
		});

		res.end(data, 'binary');

	});
}

function respondData(req, res, content, status) {
	content = content || null;
	compressContent(req, content, function (error, data) {

		if (error) {
			log.error('compression error: (url:' + req.url + ')', error);
			status = 500;
			data = error;
		}

		res.writeHead(status, {
			'Cache-Control': 'no-cache, must-revalidate',
			'Connection': 'Keep-Alive',
			'Content-Encoding': 'gzip',
			'Content-Type': 'text/plain; charset=UTF-8',
			'Pragma': 'no-cache',
			'Vary': 'Accept-Encoding',
			'Content-Length': data.length
		});

		res.end(data, 'binary');

	});
}

function respondDownload(req, res, content, type, status) {
	content = content || null;
	compressContent(req, content, function (error, data) {

		if (error) {
			log.error('compression error: (url:' + req.url + ')', error);
			status = 500;
			data = error;
		}

		res.writeHead(status, {
			'Cache-Control': 'no-cache, must-revalidate',
			'Connection': 'Keep-Alive',
			'Content-Encoding': 'gzip',
			'Content-Type': mime.get(type) + '; charset=UTF-8',
			'Pragma': 'no-cache',
			'Vary': 'Accept-Encoding',
			'Content-Length': data.length
		});

		res.end(data, 'binary');

	});
}

function respondRedirect(req, res, content) {
	content = content || null;
	var status = 301;
	// content needs to be redirect URL
	res.writeHead(status, {
		Location: content
	});

	log.verbose('redirect to: ', content);

	res.end();
}

function respondFILE(req, res, content, status) {
	content = content || null;
	var type = req.url.substring(req.url.lastIndexOf('.') + 1);
	var contentSize = content.length;
	res.writeHead(status, {
		'Content-Length': contentSize,
		'Content-Type': mime.get(type)
	});

	log.verbose('response content size: (url:' + req.url + ') ' + (contentSize / 1024) + ' KB');

	res.end(content, 'binary');

}

function respondERROR(req, res, content, status) {
	var contentType = 'text/plain';
	content = content || null;
	if (content !== null && typeof content === 'object') {
		content = JSON.stringify(content);
		contentType = 'application/json';
	}
	status = status || 400;
	compressContent(req, content, function (error, data) {

		if (error) {
			log.error('(url:' + req.url + ')', error);
			status = 500;
			data = error;
		}

		var contentSize = data.length;
		res.writeHead(status, {
			'Cache-Control': 'no-cache, must-revalidate',
			'Connection': 'Keep-Alive',
			'Content-Encoding': 'gzip',
			'Content-Type': contentType + '; charset=UTF-8',
			'Pragma': 'no-cache',
			'Vary': 'Accept-Encoding',
			'Content-Length': data.length
		});

		log.verbose('response content size: (url:' + req.url + ') ' + (contentSize / 1024) + ' KB');

		res.end(data, 'binary');

	});
}
<commit_msg>better id per request<commit_after>var gracenode = require('../gracenode');
var log = gracenode.log.create('server-response');
var hook = require('./responseHook');
var zlib = require('zlib');
var mime = require('./mime');

module.exports.create = function (resource, requestObj) {
	return new Response(resource, requestObj);
};

function Response(resource, requestObj) {
	this._resource = resource;
	this._requestObj = requestObj;
	this._defaultStatus = 200;
}

Response.prototype.header = function (name, value) {
	this._resource.rawResponse.setHeader(name, value);
};

Response.prototype.json = function (content, status) {
	log.verbose('response content type: JSON');
	this.respond(null, respondJSON, content, status);
};

Response.prototype.html = function (content, status) {
	log.verbose('response content type: HTML');
	this.respond(null, respondHTML, content, status);
};

Response.prototype.data = function (content, status) {
	log.verbose('response content type: Data');
	this.respond(null, respondData, content, status);
};

Response.prototype.file = function (content, status) {
	log.verbose('response content type: File');
	this.respond(null, respondFILE, content, status);
};

Response.prototype.error = function (content, status) {
	this._errorHandler(content, status);
};

Response.prototype.download = function (content, fileName, status) {
	var fileType = fileName.substring(fileName.lastIndexOf('.') + 1);
	log.verbose('response content type:', fileType);
	this.respond({ 'Content-Disposition': 'attachment; filename=' + fileName }, respondDownload, content, status);
};

Response.prototype.redirect = function (content) {
	log.verbose('response content type: Redirect');
	this.respond(null, respondRedirect, content, 307);
};

// internal use only
Response.prototype._setDefaultStatus = function (status) {
	this._defaultStatus = status;
};

Response.prototype.respond = function (headers, respondFunc, content, status) {

	// check for duplicated response
	if (this._resource.responded) {
		var rawReq = this._resource.rawRequest;
		var dupResError = new Error('responded more than once: (url:' + rawReq.url + ') (id:' + rawReq.uniqueId + ')');
		log.error(dupResError);
		log.error('content:', content, 'stauts:', (status || 200));
		// do not send response to the client anymore
		return;
	}

	var that = this;
	hook.exec(this, function () {
		// this callback will NOT be executed on error of the hook
		for (var headerName in headers) {
			that.header(headerName, headers[headername]);
		}
		setupFinish(that._resource.rawRequest, that._resource.rawResponse, that._resource.server, that._resource.startTime);
		respondFunc(that._resource.rawRequest, that._resource.rawResponse, content, status || that._defaultStatus);
		finish(that._resource.rawRequest, that._resource.rawResponse, that._resource.server);
		that._resource.responded = true;
	});
};

// overrriden by controller
Response.prototype._errorHandler = function () {

};

Response.prototype._error = function (content, status) {
	log.verbose('response content type: Error');
	setupFinish(this._resource.rawRequest, this._resource.rawResponse, this._resource.server, this._resource.startTime);
	respondERROR(this._resource.rawRequest, this._resource.rawResponse, content, status);
	finish(this._resource.rawRequest, this._resource.rawResponse, this._resource.server);
};

// sets up events for response finish. The events will be called when the request response has all been sent.
function setupFinish(req, res, server, startTime) {
	// this will be called when the server sends the response data and finishes it.
	res.once('finish', function () {
		var execTime = Date.now() - startTime;
		var msg = 'request responded: (url:' + req.url + ') (id:' + req.uniqueId + ') (took:' + execTime + 'ms) (status:' + res.statusCode + ')';
		if (res.statusCode > 399) {
			log.error(msg);
		} else {
			log.info(msg);
		}
		server.emit('requestFinish', req.url, execTime);
	});
}

function finish(req, res, server) {
	res.emit('end', req.url);
	// this will be called when the server finishes all operation (not when the response data sent)
	server.emit('requestEnd', req.url);
}

function compressContent(req, content, cb) {
	if (content instanceof Buffer) {
		// we do not compress binary
		log.verbose('skip compressing binary data: (url:' + req.url + ') ' + (content.length / 1024) + 'KB');
		cb(null, content);
	}
	zlib.gzip(content, function (error, compressedData) {
		if (error) {
			return cb(error);
		}
		log.verbose('compressed content size: (url:' + req.url + ') ' + (compressedData.length / 1024) + ' KB');

		cb(null, compressedData);
	});
}

function respondJSON(req, res, content, status) {
	content = content || null;
	compressContent(req, JSON.stringify(content), function (error, data) {

		if (error) {
			log.error('compression error: (url:' + req.url, + ')', error);
			status = 500;
			data = error;
		}

		res.writeHead(status, {
			'Cache-Control': 'no-cache, must-revalidate',
			'Connection': 'Keep-Alive',
			'Content-Encoding': 'gzip',
			'Content-Type': 'application/json; charset=UTF-8',
			'Pragma': 'no-cache',
			'Vary': 'Accept-Encoding',
			'Content-Length': data.length
		});

		res.end(data, 'binary');

	});

}

function respondHTML(req, res, content, status) {
	content = content || null;
	compressContent(req, content, function (error, data) {

		if (error) {
			log.error('compression error: (url:' + req.url, + ')', error);
			status = 500;
			data = error;
		}

		res.writeHead(status, {
			'Cache-Control': 'no-cache, must-revalidate',
			'Connection': 'Keep-Alive',
			'Content-Encoding': 'gzip',
			'Content-Type': 'text/html; charset=UTF-8',
			'Pragma': 'no-cache',
			'Vary': 'Accept-Encoding',
			'Content-Length': data.length
		});

		res.end(data, 'binary');

	});
}

function respondData(req, res, content, status) {
	content = content || null;
	compressContent(req, content, function (error, data) {

		if (error) {
			log.error('compression error: (url:' + req.url + ')', error);
			status = 500;
			data = error;
		}

		res.writeHead(status, {
			'Cache-Control': 'no-cache, must-revalidate',
			'Connection': 'Keep-Alive',
			'Content-Encoding': 'gzip',
			'Content-Type': 'text/plain; charset=UTF-8',
			'Pragma': 'no-cache',
			'Vary': 'Accept-Encoding',
			'Content-Length': data.length
		});

		res.end(data, 'binary');

	});
}

function respondDownload(req, res, content, type, status) {
	content = content || null;
	compressContent(req, content, function (error, data) {

		if (error) {
			log.error('compression error: (url:' + req.url + ')', error);
			status = 500;
			data = error;
		}

		res.writeHead(status, {
			'Cache-Control': 'no-cache, must-revalidate',
			'Connection': 'Keep-Alive',
			'Content-Encoding': 'gzip',
			'Content-Type': mime.get(type) + '; charset=UTF-8',
			'Pragma': 'no-cache',
			'Vary': 'Accept-Encoding',
			'Content-Length': data.length
		});

		res.end(data, 'binary');

	});
}

function respondRedirect(req, res, content) {
	content = content || null;
	var status = 301;
	// content needs to be redirect URL
	res.writeHead(status, {
		Location: content
	});

	log.verbose('redirect to: ', content);

	res.end();
}

function respondFILE(req, res, content, status) {
	content = content || null;
	var type = req.url.substring(req.url.lastIndexOf('.') + 1);
	var contentSize = content.length;
	res.writeHead(status, {
		'Content-Length': contentSize,
		'Content-Type': mime.get(type)
	});

	log.verbose('response content size: (url:' + req.url + ') ' + (contentSize / 1024) + ' KB');

	res.end(content, 'binary');

}

function respondERROR(req, res, content, status) {
	var contentType = 'text/plain';
	content = content || null;
	if (content !== null && typeof content === 'object') {
		content = JSON.stringify(content);
		contentType = 'application/json';
	}
	status = status || 400;
	compressContent(req, content, function (error, data) {

		if (error) {
			log.error('(url:' + req.url + ')', error);
			status = 500;
			data = error;
		}

		var contentSize = data.length;
		res.writeHead(status, {
			'Cache-Control': 'no-cache, must-revalidate',
			'Connection': 'Keep-Alive',
			'Content-Encoding': 'gzip',
			'Content-Type': contentType + '; charset=UTF-8',
			'Pragma': 'no-cache',
			'Vary': 'Accept-Encoding',
			'Content-Length': data.length
		});

		log.verbose('response content size: (url:' + req.url + ') ' + (contentSize / 1024) + ' KB');

		res.end(data, 'binary');

	});
}
<|endoftext|>


<commit_before>/*
	Each Enyo-provided library will annotate this structure with its own
	version info. Why? In general, Enyo and its libraries are versioned
	and released together, but libraries may be versioned separately in
	the future. Also, since libraries are checked out and updated
	individually, a project may be using "mismatched" libraries at any
	given time (e.g., the last stable release of Enyo, but an
	unreleased checkout from the master branch of layout).

	Enyo uses semantic versioning. Official releases have version
	numbers	of the form "X.y.z". Prereleases are indicated by a suffix
	of the form "-pre.N" where N is incremented for each prerelease.
	Between releases, version numbers include an additional "-dev"
	suffix.
*/

enyo.version = {
	enyo: "2.3.0-rc.3"
};
<commit_msg>Update version string to 2.3.0-rc.4<commit_after>/*
	Each Enyo-provided library will annotate this structure with its own
	version info. Why? In general, Enyo and its libraries are versioned
	and released together, but libraries may be versioned separately in
	the future. Also, since libraries are checked out and updated
	individually, a project may be using "mismatched" libraries at any
	given time (e.g., the last stable release of Enyo, but an
	unreleased checkout from the master branch of layout).

	Enyo uses semantic versioning. Official releases have version
	numbers	of the form "X.y.z". Prereleases are indicated by a suffix
	of the form "-pre.N" where N is incremented for each prerelease.
	Between releases, version numbers include an additional "-dev"
	suffix.
*/

enyo.version = {
	enyo: "2.3.0-rc.4"
};
<|endoftext|>


<commit_before>/**
 * MapboxGL 示例配置文件：包含示例的分类、名称、缩略图、文件路径
 */
var identification = {
    name: "MapboxGL"
};

var exampleConfig = {
    "iServer": {
        name: "iServer",
        content: {
            "map": {
                name: "地图",
                content: [
                    {
                        name: "3857底图",
                        thumbnail: "mb_TileLayer.png",
                        fileName: "01_tiledMapLayer"
                    }
                ]
            },
            "data": {
                name: "数据",
                content: [{
                    name: "ID查询",
                    thumbnail: "mb_getFeatureByIDs.png",
                    fileName: "02_getFeatureByIDs"
                }
                ]

            },
            "spatialAnalyst": {
                name: "空间分析",
                content: [{
                    name: "缓冲区分析",
                    thumbnail: "mb_bufferAnalystService.png",
                    fileName: "04_bufferAnalystService"
                }]
            },
            "addressMatch": {
                name: "地址匹配",
                content: [{
                    name: "地址匹配",
                    thumbnail: "mb_addressService.png",
                    fileName: "addressMatchService"
                }]
            },
            "processingService": {
                name: "分布式空间分析",
                content: [{
                    name: "密度分析",
                    thumbnail: "kernelDensityJobService.png",
                    fileName: "kernelDensityJobService"
                }]
            }
        }
    },
    "viz": {
        name: "可视化",
        content: {

            "VectorTileLayer": {
                name: "矢量瓦片",
                content: [
                    {
                        name: "China-矢量瓦片",
                        thumbnail: "mvtVectorTile.png",
                        fileName: "mvtVectorTile"
                    },
                    {
                        name: "北京",
                        thumbnail: "mvt_Beijing.png",
                        fileName: "mvtVectorTile_Beijing"
                    },
                    {
                        name: "北京-暗夜风格",
                        thumbnail: "mvt_Beijing_dark.png",
                        fileName: "mvtVectorTile_Beijing_dark"
                    },
                    {
                        name: "北京-深海风格",
                        thumbnail: "mvt_Beijing_fiordcolor.png",
                        fileName: "mvtVectorTile_Beijing_fiordcolor"
                    },
                    {
                        name: "北京-淡绿风格",
                        thumbnail: "mvt_Beijing_klokantech.png",
                        fileName: "mvtVectorTile_Beijing_klokantech"
                    },
                    {
                        name: "北京-OSM风格",
                        thumbnail: "mvt_Beijing_osm.png",
                        fileName: "mvtVectorTile_Beijing_OSM"
                    },
                    {
                        name: "北京-淡灰风格",
                        thumbnail: "mvt_Beijing_positron.png",
                        fileName: "mvtVectorTile_Beijing_positron"
                    },
                    {
                        name: "风格切换",
                        thumbnail: "mvt_changeStyle.png",
                        fileName: "mvtVectorTile_changeStyle"
                    }
                ]
            },
            "Echarts": {
                name: "Echarts",
                content: [
                    {
                        name: "全国主要城市空气质量图",
                        thumbnail: "echarts_effectScatter.png",
                        fileName: "echarts_effectScatter"
                    },
                    {
                        name: "模拟迁徙图",
                        thumbnail: "echarts_geoline.png",
                        fileName: "echarts_geoline"
                    },
                    {
                        name: "世界飞机航线图",
                        thumbnail: "echarts_linesAirline.png",
                        fileName: "echarts_linesAirline"
                    },
                    {
                        name: "微博签到图",
                        thumbnail: "echarts_scatterWeibo.png",
                        fileName: "echarts_scatterWeibo"
                    }
                ]
            },
            "MapV": {
                name: "MapV",
                content: [
                    {
                        name: "通勤图",
                        thumbnail: "mapvCsvcar.png",
                        fileName: "mapvCsvcar"
                    },
                    {
                        name: "强边界图",
                        thumbnail: "mapvForceEdgeBuilding.png",
                        fileName: "mapvForceEdgeBuilding"
                    },
                    {
                        name: "强度线",
                        thumbnail: "mapvPolylineIntensity.png",
                        fileName: "mapvPolylineIntensity"
                    },
                    {
                        name: "简单线",
                        thumbnail: "mapvPolylineSimple.png",
                        fileName: "mapvPolylineSimple"
                    },
                    {
                        name: "动态轨迹",
                        thumbnail: "mapvPolylineTime.png",
                        fileName: "mapvPolylineTime"
                    },
                    {
                        name: "迁徙时序图",
                        thumbnail: "mapvQianxiTime.png",
                        fileName: "mapvQianxiTime"
                    },
                    {
                        name: "迁徙图",
                        thumbnail: "mapvQianxi.png",
                        fileName: "mapvQianxi"
                    },
                    {
                        name: "北京村庄分布图",
                        thumbnail: "mapvBeijingVillage.png",
                        fileName: "mapvBeijingVillage"
                    }
                ]
            }
        }
    },
    "GTC": {
        name: "GTC",
        content: {
            "GTC2017": {
                name: "GTC2017",
                content: [
                    {
                        name: "",
                        thumbnail: "gtc2017.png",
                        fileName: "GTC2017"
                    }
                ]
            }
        }
    },
};
/**
 *key值：为exampleConfig配置的key值或者fileName值
 *      （为中间节点时是key值，叶结点是fileName值）
 *value值：fontawesome字体icon名
 *不分层
 */
var sideBarIconConfig = {
    "iServer": "fa-server",
    "viz": "fa-map",
    "GTC": "fa-globe",
};

/**
 *key值：为exampleConfig配置的key值
 *value值：fontawesome字体icon名
 *与sideBarIconConfig的区别：sideBarIconConfig包括侧边栏所有层级目录的图标，exampleIconConfig仅包括一级标题的图标
 */
var exampleIconConfig = {
    "iServer": "fa-server",
    "viz": "fa-map",
    "GTC": "fa-globe",
};<commit_msg>fix mbgl gtc示例左侧菜单标题<commit_after>/**
 * MapboxGL 示例配置文件：包含示例的分类、名称、缩略图、文件路径
 */
var identification = {
    name: "MapboxGL"
};

var exampleConfig = {
    "iServer": {
        name: "iServer",
        content: {
            "map": {
                name: "地图",
                content: [
                    {
                        name: "3857底图",
                        thumbnail: "mb_TileLayer.png",
                        fileName: "01_tiledMapLayer"
                    }
                ]
            },
            "data": {
                name: "数据",
                content: [{
                    name: "ID查询",
                    thumbnail: "mb_getFeatureByIDs.png",
                    fileName: "02_getFeatureByIDs"
                }
                ]

            },
            "spatialAnalyst": {
                name: "空间分析",
                content: [{
                    name: "缓冲区分析",
                    thumbnail: "mb_bufferAnalystService.png",
                    fileName: "04_bufferAnalystService"
                }]
            },
            "addressMatch": {
                name: "地址匹配",
                content: [{
                    name: "地址匹配",
                    thumbnail: "mb_addressService.png",
                    fileName: "addressMatchService"
                }]
            },
            "processingService": {
                name: "分布式空间分析",
                content: [{
                    name: "密度分析",
                    thumbnail: "kernelDensityJobService.png",
                    fileName: "kernelDensityJobService"
                }]
            }
        }
    },
    "viz": {
        name: "可视化",
        content: {

            "VectorTileLayer": {
                name: "矢量瓦片",
                content: [
                    {
                        name: "China-矢量瓦片",
                        thumbnail: "mvtVectorTile.png",
                        fileName: "mvtVectorTile"
                    },
                    {
                        name: "北京",
                        thumbnail: "mvt_Beijing.png",
                        fileName: "mvtVectorTile_Beijing"
                    },
                    {
                        name: "北京-暗夜风格",
                        thumbnail: "mvt_Beijing_dark.png",
                        fileName: "mvtVectorTile_Beijing_dark"
                    },
                    {
                        name: "北京-深海风格",
                        thumbnail: "mvt_Beijing_fiordcolor.png",
                        fileName: "mvtVectorTile_Beijing_fiordcolor"
                    },
                    {
                        name: "北京-淡绿风格",
                        thumbnail: "mvt_Beijing_klokantech.png",
                        fileName: "mvtVectorTile_Beijing_klokantech"
                    },
                    {
                        name: "北京-OSM风格",
                        thumbnail: "mvt_Beijing_osm.png",
                        fileName: "mvtVectorTile_Beijing_OSM"
                    },
                    {
                        name: "北京-淡灰风格",
                        thumbnail: "mvt_Beijing_positron.png",
                        fileName: "mvtVectorTile_Beijing_positron"
                    },
                    {
                        name: "风格切换",
                        thumbnail: "mvt_changeStyle.png",
                        fileName: "mvtVectorTile_changeStyle"
                    }
                ]
            },
            "Echarts": {
                name: "Echarts",
                content: [
                    {
                        name: "全国主要城市空气质量图",
                        thumbnail: "echarts_effectScatter.png",
                        fileName: "echarts_effectScatter"
                    },
                    {
                        name: "模拟迁徙图",
                        thumbnail: "echarts_geoline.png",
                        fileName: "echarts_geoline"
                    },
                    {
                        name: "世界飞机航线图",
                        thumbnail: "echarts_linesAirline.png",
                        fileName: "echarts_linesAirline"
                    },
                    {
                        name: "微博签到图",
                        thumbnail: "echarts_scatterWeibo.png",
                        fileName: "echarts_scatterWeibo"
                    }
                ]
            },
            "MapV": {
                name: "MapV",
                content: [
                    {
                        name: "通勤图",
                        thumbnail: "mapvCsvcar.png",
                        fileName: "mapvCsvcar"
                    },
                    {
                        name: "强边界图",
                        thumbnail: "mapvForceEdgeBuilding.png",
                        fileName: "mapvForceEdgeBuilding"
                    },
                    {
                        name: "强度线",
                        thumbnail: "mapvPolylineIntensity.png",
                        fileName: "mapvPolylineIntensity"
                    },
                    {
                        name: "简单线",
                        thumbnail: "mapvPolylineSimple.png",
                        fileName: "mapvPolylineSimple"
                    },
                    {
                        name: "动态轨迹",
                        thumbnail: "mapvPolylineTime.png",
                        fileName: "mapvPolylineTime"
                    },
                    {
                        name: "迁徙时序图",
                        thumbnail: "mapvQianxiTime.png",
                        fileName: "mapvQianxiTime"
                    },
                    {
                        name: "迁徙图",
                        thumbnail: "mapvQianxi.png",
                        fileName: "mapvQianxi"
                    },
                    {
                        name: "北京村庄分布图",
                        thumbnail: "mapvBeijingVillage.png",
                        fileName: "mapvBeijingVillage"
                    }
                ]
            }
        }
    },
    "GTC": {
        name: "GTC",
        content: {
            "GTC2017": {
                name: "2017",
                content: [
                    {
                        name: "GTC2017",
                        thumbnail: "gtc2017.png",
                        fileName: "GTC2017"
                    }
                ]
            }
        }
    },
};
/**
 *key值：为exampleConfig配置的key值或者fileName值
 *      （为中间节点时是key值，叶结点是fileName值）
 *value值：fontawesome字体icon名
 *不分层
 */
var sideBarIconConfig = {
    "iServer": "fa-server",
    "viz": "fa-map",
    "GTC": "fa-globe",
};

/**
 *key值：为exampleConfig配置的key值
 *value值：fontawesome字体icon名
 *与sideBarIconConfig的区别：sideBarIconConfig包括侧边栏所有层级目录的图标，exampleIconConfig仅包括一级标题的图标
 */
var exampleIconConfig = {
    "iServer": "fa-server",
    "viz": "fa-map",
    "GTC": "fa-globe",
};<|endoftext|>