<commit_before>/* exported BuilderDirective */
/* global SurveyTemplateApp */
'use strict';
function BuilderDirective($rootScope, $restApi, $routeTo) {
    return {
        link: function (scope, element) {
            /*jshint validthis: true */
            var surveyDraftApi = $restApi.createSurveyDraftApi();

            function saveCallback() {
                if (this.validateSurvey()) {
                    surveyDraftApi.save({
                            body: this.survey.toCSV(),
                            description: this.survey.get('description'),
                            title: this.survey.settings.get('form_title')
                        }, $routeTo.forms);
                }
            }

            if (scope.routeParams.id){
                surveyDraftApi.get({id: scope.routeParams.id}, function builder_get_callback(response) {
                    scope.xlfSurvey = response;
                    new SurveyApp({el: element, survey: scope.xlfSurvey, save: saveCallback}).render();
                });
            } else {
                new SurveyTemplateApp({el: element, survey: scope.xlfSurvey, save: saveCallback}).render();
            }
        }<commit_msg>parsing response into XLF.Survey object<commit_after>/* exported BuilderDirective */
/* global SurveyTemplateApp */
'use strict';
function BuilderDirective($rootScope, $restApi, $routeTo) {
    return {
        link: function (scope, element) {
            /*jshint validthis: true */
            var surveyDraftApi = $restApi.createSurveyDraftApi();

            function saveCallback() {
                if (this.validateSurvey()) {
                    surveyDraftApi.save({
                            body: this.survey.toCSV(),
                            description: this.survey.get('description'),
                            title: this.survey.settings.get('form_title')
                        }, $routeTo.forms);
                }
            }

            if (scope.routeParams.id){
                surveyDraftApi.get({id: scope.routeParams.id}, function builder_get_callback(response) {
                    scope.xlfSurvey = XLF.createSurveyFromCsv(response.body);
                    // temporarily saving response in __djangoModelDetails
                    scope.xlfSurvey.__djangoModelDetails = response;
                    new SurveyApp({el: element, survey: scope.xlfSurvey, save: saveCallback}).render();
                });
            } else {
                new SurveyTemplateApp({el: element, survey: scope.xlfSurvey, save: saveCallback}).render();
            }
        }
{'fraction_non_alphanumeric': 0.10824345146379044, 'fraction_numerical': 0.0, 'mean_word_length': 1.6635897435897435, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3136025', 'n_tokens_mistral': 664, 'n_tokens_neox': 640, 'n_words': 125}