Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-init repo on license, .gitignore select #12202

Merged
merged 8 commits into from
Jul 23, 2020
11 changes: 11 additions & 0 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,17 @@ async function initRepository() {
});
}

// Repo Creation
if ($('.repository.new.repo').length > 0) {
$('input[name="gitignores"], input[name="license"]').on('change', () => {
const gitignores = $('input[name="gitignores"]').prop('checked');
const license = $('input[name="license"]').prop('checked');
Comment on lines +761 to +762
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that these are not checkboxes :D These lines should have been:

      const gitignores = $('input[name="gitignores"]').val() !== '';
      const license = $('input[name="license"]').val() !== '';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right I missed it too. .val() should be sufficient and possible more future-proof just in case the value of a empty select box ever changes to null or undefined.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for PR. I don't think jQuery would return null or undefined but not sure. Have not used jQuery for quite some time already 😂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to do with jQuery, but I guess DOM <input> value is probably guaranteed to be a string (even for type=number 😆).

if (gitignores || license) {
$('input[name="auto_init"]').prop('checked', true);
}
});
}

// Issues
if ($('.repository.view.issue').length > 0) {
// Edit issue title
Expand Down