<commit_before>define(function(require) {
    var Backbone = require('Backbone');
    
    var RegisterGameDefinitionForm = Backbone.View.extend({
        el: '#registerGameDefinitionForm',
        
        events: {
            'click #registerGameDefinitionButton': 'register'
        },
        
        initialize: function() {
            var self = this;
            
            self.$size = self.$('.size').val(self.model.get('size'));
            self.$message = self.$('.message');
            
            self.model.on('invalid', function() {
                self.$message.text(self.model.validationError);
            });
        },
        
        register: function() {
            console.log('register');
            var self = this;
            
            self.$message.text('');
            self.model.set('size', self.$size.val());
            
            var request = self.model.register();
            
            if (!request) {
                return;
            }
            
            request
                .done(function(response) {
                    self.trigger('register-game-definition', {id: response.id});
                })
                .fail(function(xhr) {
                    self.$message.text('登録失敗');
                });
        },
        
        onInvalidRegister: function() {
            this.$message.text(this.model.validationError);
        }
    });
    
    return RegisterGameDefinitionForm;
});<commit_msg>登録画面のエラー制御追加<commit_after>define(function(require) {
    var Backbone = require('Backbone');
    
    var RegisterGameDefinitionForm = Backbone.View.extend({
        el: '#registerGameDefinitionForm',
        
        events: {
            'click #registerGameDefinitionButton': 'register'
        },
        
        initialize: function() {
            var self = this;
            
            self.$size = self.$('.size').val(self.model.get('size'));
            self.$message = self.$('.message').empty();
            self.$registerButton = self.$('#registerGameDefinitionButton').attr('disabled', false);
            
            self.model.on('invalid', function() {
                self.$message.text(self.model.validationError);
            });
        },
        
        register: function() {
            var self = this;
            
            self.$message.text('');
            self.model.set('size', self.$size.val());
            
            var request = self.model.register();
            
            if (!request) {
                return;
            }
            
            self.$registerButton.attr('disabled', true);
            
            request
                .done(function(response) {
                    self.trigger('register-game-definition', {id: response.id});
                })
                .fail(function(xhr) {
                    self.$message.text('failed to register game definition.');
                })
                .always(function() {
                    self.$registerButton.attr('disabled', false);
                });
        },
        
        onInvalidRegister: function() {
            this.$message.text(this.model.validationError);
        }
    });
    
    return RegisterGameDefinitionForm;
});
{'fraction_non_alphanumeric': 0.13259327782917052, 'fraction_numerical': 0.0, 'mean_word_length': 1.3388608507570297, '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': '1786595', 'n_tokens_mistral': 792, 'n_tokens_neox': 783, 'n_words': 115}