<commit_before>(function(viewModel, root, utils) {
    /* Inneholder all data om et dataelement. Planen er å etterhvert utvide dette til å også inneholde skip logic*/
    root.DataElement = function(dataelement) {
        var self = this;
        self.id = dataelement.id;
        self.name = dataelement.name;
        self.formName = dataelement.formName ? dataelement.formName : dataelement.name;
        self.description = dataelement.description;
        self.type =  dataelement.type;
		
		self.isOptionSet = ko.observable(false);
		self.optionSet = ko.observableArray();
		if (dataelement.optionSet) {
			self.isOptionSet(true);
			for (var i = 0; i < dataelement.optionSet.options.length; i++) {
				self.optionSet.push(dataelement.optionSet.options[i]);
			}
		}
		

        self.dependencies = [];

        self.value = ko.observable();
        self.dropDownOpts = ko.observableArray();
        self.dropDownOpts.push("Yes"); //Do this when dataElement is inserted in viewModel
        self.dropDownOpts.push("No");   //instead of this hard coded edition :P

        //skip logic
        self.triggerOption = ko.observable(); //If adding dep to bool dataElement

        self.interval = ko.observable();
        self.commaList = ko.observable(); //If adding dep to int, string or date(only one) dataElement with specific values

        self.lowerLimit = ko.observable(); //If adding dep to int dataElement with interval
        self.upperLimit = ko.observable();  //If adding dep to int dataElement with interval


        self.isDependent = ko.observable(false);
        self.isInSkipLogic = ko.observable(false);
        self.addingSkipLogic = ko.observable(false);

        self.resetSkipLogicUI = function() {
            self.triggerOption("");
            self.interval(false);
            self.commaList("");
            self.lowerLimit("");
            self.upperLimit("");
            self.isDependent(false);
            self.isInSkipLogic(false);
        };

        self.setSkipLogicUIElements = function(dataElement) {
            $.each(self.dependencies, function(i, dep) {
                if(dep.id === dataElement.id) {
                    if(dep.triggers[0].from !== undefined) {
                        self.interval(true)
                        if(dataElement.type === "int") {
                            self.lowerLimit(dep.triggers[0].from);
                            self.upperLimit(dep.triggers[0].to);
                        } else {
                            var date = dep.triggers[0].from;
                            self.lowerLimit(utils.getDateFormattedForInput(date));
                            date = dep.triggers[0].to;
                            self.upperLimit(utils.getDateFormattedForInput(date));
                        }
                    } else {
                        if(dataElement.type === "bool") {
                            var value = dep.triggers[0] == true ? "Yes" : "No";
                            self.triggerOption(value);
                        } else if(dataElement.type === "date") {
                            self.commaList(utils.getDateFormattedForInput(dep.triggers[0]));
                        } else {
                            self.commaList(dep.triggers.join(","));
                        }
                    }

                }
            });
        }
    };
})(survey.viewModel, survey.models = survey.models || {}, survey.utils);<commit_msg>BugFix: Dependencies not added in DataElement constructor<commit_after>(function(viewModel, root, utils) {
    /* Inneholder all data om et dataelement. Planen er å etterhvert utvide dette til å også inneholde skip logic*/
    root.DataElement = function(dataelement) {
        var self = this;
        self.id = dataelement.id;
        self.name = dataelement.name;
        self.formName = dataelement.formName ? dataelement.formName : dataelement.name;
        self.description = dataelement.description;
        self.type =  dataelement.type;
		
		self.isOptionSet = ko.observable(false);
		self.optionSet = ko.observableArray();
		if (dataelement.optionSet) {
			self.isOptionSet(true);
			for (var i = 0; i < dataelement.optionSet.options.length; i++) {
				self.optionSet.push(dataelement.optionSet.options[i]);
			}
		}
		

        self.dependencies = dataelement.dependencies;

        self.value = ko.observable();
        self.dropDownOpts = ko.observableArray();
        self.dropDownOpts.push("Yes"); //Do this when dataElement is inserted in viewModel
        self.dropDownOpts.push("No");   //instead of this hard coded edition :P

        //skip logic
        self.triggerOption = ko.observable(); //If adding dep to bool dataElement

        self.interval = ko.observable();
        self.commaList = ko.observable(); //If adding dep to int, string or date(only one) dataElement with specific values

        self.lowerLimit = ko.observable(); //If adding dep to int dataElement with interval
        self.upperLimit = ko.observable();  //If adding dep to int dataElement with interval


        self.isDependent = ko.observable(false);
        self.isInSkipLogic = ko.observable(false);
        self.addingSkipLogic = ko.observable(false);

        self.resetSkipLogicUI = function() {
            self.triggerOption("");
            self.interval(false);
            self.commaList("");
            self.lowerLimit("");
            self.upperLimit("");
            self.isDependent(false);
            self.isInSkipLogic(false);
        };

        self.setSkipLogicUIElements = function(dataElement) {
            $.each(self.dependencies, function(i, dep) {
                if(dep.id === dataElement.id) {
                    if(dep.triggers[0].from !== undefined) {
                        self.interval(true)
                        if(dataElement.type === "int") {
                            self.lowerLimit(dep.triggers[0].from);
                            self.upperLimit(dep.triggers[0].to);
                        } else {
                            var date = dep.triggers[0].from;
                            self.lowerLimit(utils.getDateFormattedForInput(date));
                            date = dep.triggers[0].to;
                            self.upperLimit(utils.getDateFormattedForInput(date));
                        }
                    } else {
                        if(dataElement.type === "bool") {
                            var value = dep.triggers[0] == true ? "Yes" : "No";
                            self.triggerOption(value);
                        } else if(dataElement.type === "date") {
                            self.commaList(dep.triggers[0]);
                        } else {
                            self.commaList(dep.triggers.join(","));
                        }
                    }

                }
            });
        }
    };
})(survey.viewModel, survey.models = survey.models || {}, survey.utils);
{'fraction_non_alphanumeric': 0.11590646651270207, 'fraction_numerical': 0.0023094688221709007, 'mean_word_length': 1.701364522417154, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4789428', 'n_tokens_mistral': 1907, 'n_tokens_neox': 1823, 'n_words': 364}