All files / app/assets/javascripts new_commit_form.js

81.25% Statements 13/16
25% Branches 1/4
100% Functions 2/2
81.25% Lines 13/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26    6x 6x 6x 6x 6x 6x 6x 6x     6x 6x           6x 6x   6x      
export default class NewCommitForm {
  constructor(form) {
    this.form = form;
    this.renderDestination = this.renderDestination.bind(this);
    this.branchName = form.find('.js-branch-name');
    this.originalBranch = form.find('.js-original-branch');
    this.createMergeRequest = form.find('.js-create-merge-request');
    this.createMergeRequestContainer = form.find('.js-create-merge-request-container');
    this.branchName.keyup(this.renderDestination);
    this.renderDestination();
  }
  renderDestination() {
    const different = this.branchName.val() !== this.originalBranch.val();
    Iif (different) {
      this.createMergeRequestContainer.show();
      if (!this.wasDifferent) {
        this.createMergeRequest.prop('checked', true);
      }
    } else {
      this.createMergeRequestContainer.hide();
      this.createMergeRequest.prop('checked', false);
    }
    this.wasDifferent = different;
  }
}