<commit_before>angular.module('concertoPanel').directive('wizardParamSetter', ["$compile", "$templateCache", "$uibModal", "$filter", "uiGridConstants", "GridService", "RDocumentation", "$http", "DataTableCollectionService", "TestCollectionService", "ViewTemplateCollectionService", "TestWizardParam", function ($compile, $templateCache, $uibModal, $filter, uiGridConstants, GridService, RDocumentation, $http, DataTableCollectionService, TestCollectionService, ViewTemplateCollectionService, TestWizardParam) {
        return {
            restrict: 'E',
            scope: {
                param: "=",
                output: "=",
                values: "=",
                parent: "=",
                wizardObject: "=",
                underList: "="
            },
            link: function (scope, element, attrs, controllers) {
                scope.RDocumentation = RDocumentation;
                scope.testWizardParamService = TestWizardParam;
                scope.gridService = GridService;
                scope.dataTableCollectionService = DataTableCollectionService;
                scope.testCollectionService = TestCollectionService;
                scope.viewTemplateCollectionService = ViewTemplateCollectionService;
                scope.htmlEditorOptions = Defaults.ckeditorTestContentOptions;

                scope.codeEditorOptions = {
                    lineWrapping: true,
                    lineNumbers: true,
                    mode: 'r',
                    viewportMargin: Infinity,
                    hintOptions: {
                        completeSingle: false,
                        wizardService: RDocumentation
                    },
                    extraKeys: {
                        "F11": function (cm) {
                            cm.setOption("fullScreen", !cm.getOption("fullScreen"));
                        },
                        "Esc": function (cm) {
                            if (cm.getOption("fullScreen"))
                                cm.setOption("fullScreen", false);
                        },
                        "Ctrl-Space": "autocomplete"
                    }
                };
                if (RDocumentation.functionIndex === null) {
                    $http.get(RDocumentation.rCacheDirectory + 'functionIndex.json').success(function (data) {
                        if (data !== null) {
                            RDocumentation.functionIndex = data;
                            scope.codeEditorOptions.hintOptions.functionIndex = data;
                        }
                    });
                } else {
                    scope.codeEditorOptions.hintOptions.functionIndex = RDocumentation.functionIndex;
                }

                scope.mode = "dialog";
                scope.wizardMode = "prod";
                scope.complexSetters = [1, 2, 7, 9, 10, 11];
                scope.isSetterComplex = false;
                scope.title = "";
                scope.summary = "";
                if ("mode" in attrs) {
                    scope.mode = attrs.mode;
                }
                if ("wizardMode" in attrs) {
                    scope.wizardMode = attrs.wizardMode;
                }

                scope.onPrimitiveValueChange = function (value) {
                    scope.output = value;
                    if (scope.wizardMode == "dev" && value != null && !scope.underList) {
                        scope.param.definition.defvalue = value;
                    }
                    if (scope.parent === null)
                        scope.values[scope.param.name] = value;
                };

                scope.updateSeterComplexity = function () {
                    scope.isSetterComplex = scope.complexSetters.indexOf(parseInt(scope.param.type)) !== -1;
                };
                scope.updateTitle = function () {
                    scope.title = scope.testWizardParamService.getSetterTitle(scope.param);
                };
                scope.updateSummary = function () {
                    scope.summary = scope.testWizardParamService.getSetterSummary(scope.param, scope.output);
                };
                scope.listOptions = {
                    enableFiltering: true,
                    enableGridMenu: true,
                    exporterMenuCsv: false,
                    exporterMenuPdf: false,
                    importerShowMenu: false,
                    data: "output",
                    exporterCsvFilename: 'export.csv',
                    exporterHeaderFilterUseName: true,
                    exporterHeaderFilter: function (name) {
                        return name;
                    },
                    showGridFooter: true,
                    columnDefs: [],
                    onRegisterApi: function (gridApi) {
                        scope.listGridApi = gridApi;
                    },
                    importerDataAddCallback: function (grid, newObjects) {
                        for (var i = 0; i < newObjects.length; i++) {
                            for (var key in newObjects[i]) {
                                for (var j = 0; j < scope.listOptions.columnDefs.length; j++) {
                                    var col = scope.listOptions.columnDefs[j];
                                    if (col.name === key) {
                                        if (col.type == 4) {
                                            newObjects[i][key] = newObjects[i][key].toString();
                                        }
                                        if (col.type == 9 || col.type == 10) {
                                            newObjects[i][key] = angular.fromJson(newObjects[i][key]);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                        scope.output = scope.output.concat(newObjects);
                    },
                    exporterFieldCallback: function (grid, row, col, value) {
                        if (value !== undefined && value.constructor == Array) {
                            value = angular.toJson(value);
                        }
                        return value;
                    },
                    enableCellEditOnFocus: false
                };
                scope.$watch("output.length", function (newValue) {
                    scope.listOptions.enableFiltering = newValue > 0;
                    if (scope.listGridApi && uiGridConstants.dataChange) {
                        scope.listGridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN);
                    }
                });
                scope.getColumnDefs = function (obj, param, parent, output, isGroupField) {
                    if (!obj)
                        return [];
                    if (!isGroupField && obj.type == 9) {
                        var fields = [];
                        for (var i = 0; i < obj.definition.fields.length; i++) {
                            var field = obj.definition.fields[i];
                            var param = "grid.appScope.param.definition.element.definition.fields[" + i + "]";
                            var parent = "row.entity";
                            var output = "row.entity['" + field.name + "']";
                            var add = scope.getColumnDefs(field, param, parent, output, true);
                            for (var j = 0; j < add.length; j++) {
                                fields.push(add[j]);
                            }
                        }
                        return fields;
                    }

                    return [{
                            type: obj.type,
                            displayName: isGroupField ? obj.label : Trans.TEST_WIZARD_PARAM_LIST_COLUMN_ELEMENT,
                            name: isGroupField ? obj.name : "element",
                            cellTemplate:
                                    "<div class='ui-grid-cell-contents'>" +
                                    scope.getParamSetterCellTemplate(param, parent, output) +
                                    "</div>"
                        }];
                };
                scope.getParamSetterCellTemplate = function (param, parent, output) {
                    var cell = '<wizard-param-setter param="' + param + '" parent="' + parent + '" output="' + output + '" mode="grid" wizard-mode="' + scope.wizardMode + '" under-list="true" values="grid.appScope.values" wizard-object="grid.appScope.wizardObject"></wizard-param-setter>';
                    return cell;
                };
                scope.initializeListColumnDefs = function () {
                    var defs = [];
                    var param = "grid.appScope.param.definition.element";
                    var parent = "grid.appScope.output";
                    var output = "row.entity.value";
                    var cd = scope.getColumnDefs(scope.param.definition.element, param, parent, output, false);
                    for (var i = 0; i < cd.length; i++) {
                        defs.push(cd[i]);
                    }

                    defs.push({
                        displayName: "",
                        name: "_action",
                        enableSorting: false,
                        enableFiltering: false,<commit_msg>turned off list setter grid row virtualization<commit_after>angular.module('concertoPanel').directive('wizardParamSetter', ["$compile", "$templateCache", "$uibModal", "$filter", "uiGridConstants", "GridService", "RDocumentation", "$http", "DataTableCollectionService", "TestCollectionService", "ViewTemplateCollectionService", "TestWizardParam", function ($compile, $templateCache, $uibModal, $filter, uiGridConstants, GridService, RDocumentation, $http, DataTableCollectionService, TestCollectionService, ViewTemplateCollectionService, TestWizardParam) {
        return {
            restrict: 'E',
            scope: {
                param: "=",
                output: "=",
                values: "=",
                parent: "=",
                wizardObject: "=",
                underList: "="
            },
            link: function (scope, element, attrs, controllers) {
                scope.RDocumentation = RDocumentation;
                scope.testWizardParamService = TestWizardParam;
                scope.gridService = GridService;
                scope.dataTableCollectionService = DataTableCollectionService;
                scope.testCollectionService = TestCollectionService;
                scope.viewTemplateCollectionService = ViewTemplateCollectionService;
                scope.htmlEditorOptions = Defaults.ckeditorTestContentOptions;

                scope.codeEditorOptions = {
                    lineWrapping: true,
                    lineNumbers: true,
                    mode: 'r',
                    viewportMargin: Infinity,
                    hintOptions: {
                        completeSingle: false,
                        wizardService: RDocumentation
                    },
                    extraKeys: {
                        "F11": function (cm) {
                            cm.setOption("fullScreen", !cm.getOption("fullScreen"));
                        },
                        "Esc": function (cm) {
                            if (cm.getOption("fullScreen"))
                                cm.setOption("fullScreen", false);
                        },
                        "Ctrl-Space": "autocomplete"
                    }
                };
                if (RDocumentation.functionIndex === null) {
                    $http.get(RDocumentation.rCacheDirectory + 'functionIndex.json').success(function (data) {
                        if (data !== null) {
                            RDocumentation.functionIndex = data;
                            scope.codeEditorOptions.hintOptions.functionIndex = data;
                        }
                    });
                } else {
                    scope.codeEditorOptions.hintOptions.functionIndex = RDocumentation.functionIndex;
                }

                scope.mode = "dialog";
                scope.wizardMode = "prod";
                scope.complexSetters = [1, 2, 7, 9, 10, 11];
                scope.isSetterComplex = false;
                scope.title = "";
                scope.summary = "";
                if ("mode" in attrs) {
                    scope.mode = attrs.mode;
                }
                if ("wizardMode" in attrs) {
                    scope.wizardMode = attrs.wizardMode;
                }

                scope.onPrimitiveValueChange = function (value) {
                    scope.output = value;
                    if (scope.wizardMode == "dev" && value != null && !scope.underList) {
                        scope.param.definition.defvalue = value;
                    }
                    if (scope.parent === null)
                        scope.values[scope.param.name] = value;
                };

                scope.updateSeterComplexity = function () {
                    scope.isSetterComplex = scope.complexSetters.indexOf(parseInt(scope.param.type)) !== -1;
                };
                scope.updateTitle = function () {
                    scope.title = scope.testWizardParamService.getSetterTitle(scope.param);
                };
                scope.updateSummary = function () {
                    scope.summary = scope.testWizardParamService.getSetterSummary(scope.param, scope.output);
                };
                scope.listOptions = {
                    //grid virtialization <-> setter directive workaround
                    virtualizationThreshold: 64000,
                    enableFiltering: true,
                    enableGridMenu: true,
                    exporterMenuCsv: false,
                    exporterMenuPdf: false,
                    importerShowMenu: false,
                    data: "output",
                    exporterCsvFilename: 'export.csv',
                    exporterHeaderFilterUseName: true,
                    exporterHeaderFilter: function (name) {
                        return name;
                    },
                    showGridFooter: true,
                    columnDefs: [],
                    onRegisterApi: function (gridApi) {
                        scope.listGridApi = gridApi;
                    },
                    importerDataAddCallback: function (grid, newObjects) {
                        for (var i = 0; i < newObjects.length; i++) {
                            for (var key in newObjects[i]) {
                                for (var j = 0; j < scope.listOptions.columnDefs.length; j++) {
                                    var col = scope.listOptions.columnDefs[j];
                                    if (col.name === key) {
                                        if (col.type == 4) {
                                            newObjects[i][key] = newObjects[i][key].toString();
                                        }
                                        if (col.type == 9 || col.type == 10) {
                                            newObjects[i][key] = angular.fromJson(newObjects[i][key]);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                        scope.output = scope.output.concat(newObjects);
                    },
                    exporterFieldCallback: function (grid, row, col, value) {
                        if (value !== undefined && value.constructor == Array) {
                            value = angular.toJson(value);
                        }
                        return value;
                    },
                    enableCellEditOnFocus: false
                };
                scope.$watch("output.length", function (newValue) {
                    scope.listOptions.enableFiltering = newValue > 0;
                    if (scope.listGridApi && uiGridConstants.dataChange) {
                        scope.listGridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN);
                    }
                });
                scope.getColumnDefs = function (obj, param, parent, output, isGroupField) {
                    if (!obj)
                        return [];
                    if (!isGroupField && obj.type == 9) {
                        var fields = [];
                        for (var i = 0; i < obj.definition.fields.length; i++) {
                            var field = obj.definition.fields[i];
                            var param = "grid.appScope.param.definition.element.definition.fields[" + i + "]";
                            var parent = "grid.appScope.output[grid.appScope.output.indexOf(row.entity)]";
                            var output = "grid.appScope.output[grid.appScope.output.indexOf(row.entity)]." + field.name;
                            var add = scope.getColumnDefs(field, param, parent, output, true);
                            for (var j = 0; j < add.length; j++) {
                                fields.push(add[j]);
                            }
                        }
                        return fields;
                    }

                    return [{
                            type: obj.type,
                            displayName: isGroupField ? obj.label : Trans.TEST_WIZARD_PARAM_LIST_COLUMN_ELEMENT,
                            name: isGroupField ? obj.name : "element",
                            cellTemplate:
                                    "<div class='ui-grid-cell-contents'>" +
                                    scope.getParamSetterCellTemplate(param, parent, output) +
                                    "</div>"
                        }];
                };
                scope.getParamSetterCellTemplate = function (param, parent, output) {
                    var cell = '<wizard-param-setter param="' + param + '" parent="' + parent + '" output="' + output + '" mode="grid" wizard-mode="' + scope.wizardMode + '" under-list="true" values="grid.appScope.values" wizard-object="grid.appScope.wizardObject"></wizard-param-setter>';
                    return cell;
                };
                scope.initializeListColumnDefs = function () {
                    var defs = [];
                    var param = "grid.appScope.param.definition.element";
                    var parent = "grid.appScope.output";
                    var output = "grid.appScope.output[grid.appScope.output.indexOf(row.entity)]";
                    var cd = scope.getColumnDefs(scope.param.definition.element, param, parent, output, false);
                    for (var i = 0; i < cd.length; i++) {
                        defs.push(cd[i]);
                    }

                    defs.push({
                        displayName: "",
                        name: "_action",
                        enableSorting: false,
                        enableFiltering: false,
{'fraction_non_alphanumeric': 0.09810044236273745, 'fraction_numerical': 0.0025500910746812386, 'mean_word_length': 1.103097296705702, 'pattern_counts': {'":': 6, '<': 22, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 40, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1701120', 'n_tokens_mistral': 4471, 'n_tokens_neox': 4119, 'n_words': 794}