<commit_before>define(['knockout', 
        'knockout-mapping',
        'viewmodels/function', 
        'models/card',
        'chosen'], 
function (ko, koMapping, FunctionViewModel, CardModel, data) {
    return ko.components.register('views/functions/primary-name', {
        viewModel: function(params) {
            FunctionViewModel.apply(this, params);
            this.cards = ko.observableArray();
            this.graph.cards.forEach(function(card){
                var c = new CardModel({'data':card});
                if(c.isContainer()){
                    c.get('cards').forEach(function(innercard){
                        this.cards.push(innercard);
                    }, this);
                }else{
                    this.cards.push(card);
                }
            }, this);

            this.string_template = params.config.string_template;
            this.nodegroup_id = params.config.nodegroup_id;
            this.nodegroup_id.subscribe(function(nodegroup_id){
                this.string_template(nodegroup_id);
                var nodes = _.filter(this.graph.nodes, function(node){
                    return node.nodegroup_id === nodegroup_id;
                }, this);
                var templateFragments = [];
                _.each(nodes, function(node){
                    templateFragments.push('<' + node.name + '>');
                }, this);


                var template = templateFragments.join(', ');
                this.string_template(template);

            }, this);

            // koMapping.fromJS({
            //     string_template: this.string_template,
            //     nodegroup_id: this.nodegroup_id
            // },params);
        },
        template: {
            require: 'text!function-templates/primary-name'
        }
    });
})<commit_msg>chosen binding needs to be updated after changing it's visibility state from hidden to shown (https://github.com/harvesthq/chosen/issues/92), this is a little be of a hack, but works, so.... in she goes, re #997<commit_after>define(['knockout', 
        'knockout-mapping',
        'viewmodels/function', 
        'models/card',
        'bindings/chosen'], 
function (ko, koMapping, FunctionViewModel, CardModel, chosen) {
    return ko.components.register('views/functions/primary-name', {
        viewModel: function(params) {
            FunctionViewModel.apply(this, params);
            this.cards = ko.observableArray();
            this.graph.cards.forEach(function(card){
                var c = new CardModel({'data':card});
                if(c.isContainer()){
                    c.get('cards').forEach(function(innercard){
                        this.cards.push(innercard);
                    }, this);
                }else{
                    this.cards.push(card);
                }
            }, this);

            this.string_template = params.config.string_template;
            this.nodegroup_id = params.config.nodegroup_id;
            this.nodegroup_id.subscribe(function(nodegroup_id){
                this.string_template(nodegroup_id);
                var nodes = _.filter(this.graph.nodes, function(node){
                    return node.nodegroup_id === nodegroup_id;
                }, this);
                var templateFragments = [];
                _.each(nodes, function(node){
                    templateFragments.push('<' + node.name + '>');
                }, this);


                var template = templateFragments.join(', ');
                this.string_template(template);

            }, this);

            window.setTimeout(function(){$("select[data-bind^=chosen]").trigger("chosen:updated")}, 300);
        },
        template: {
            require: 'text!function-templates/primary-name'
        }
    });
})
{'fraction_non_alphanumeric': 0.1271186440677966, 'fraction_numerical': 0.00211864406779661, 'mean_word_length': 1.6940085592011411, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '2007615', 'n_tokens_mistral': 1021, 'n_tokens_neox': 957, 'n_words': 159}