2019-12-26 22:10:19 +05:30
|
|
|
/* eslint-disable no-return-assign */
|
2018-03-17 18:26:18 +05:30
|
|
|
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');
|
2018-12-13 13:39:08 +05:30
|
|
|
this.createMergeRequestContainer = form.find('.js-create-merge-request-container');
|
2018-03-17 18:26:18 +05:30
|
|
|
this.branchName.keyup(this.renderDestination);
|
|
|
|
this.renderDestination();
|
|
|
|
}
|
|
|
|
renderDestination() {
|
2019-12-26 22:10:19 +05:30
|
|
|
const different = this.branchName.val() !== this.originalBranch.val();
|
2018-03-17 18:26:18 +05:30
|
|
|
if (different) {
|
|
|
|
this.createMergeRequestContainer.show();
|
|
|
|
if (!this.wasDifferent) {
|
|
|
|
this.createMergeRequest.prop('checked', true);
|
2016-09-13 17:45:13 +05:30
|
|
|
}
|
2018-03-17 18:26:18 +05:30
|
|
|
} else {
|
|
|
|
this.createMergeRequestContainer.hide();
|
|
|
|
this.createMergeRequest.prop('checked', false);
|
|
|
|
}
|
|
|
|
return (this.wasDifferent = different);
|
|
|
|
}
|
|
|
|
}
|