#2162 improve repository advance options UI display

Enable/disable input based on user chosen options for wiki and issue tracker.
This commit is contained in:
Unknwon 2016-07-31 01:26:43 +08:00
parent 10dc330640
commit 991ce42c48
4 changed files with 77 additions and 41 deletions

View File

@ -579,11 +579,13 @@ settings.site = Official Site
settings.update_settings = Update Settings settings.update_settings = Update Settings
settings.change_reponame_prompt = This change will affect how links relate to the repository. settings.change_reponame_prompt = This change will affect how links relate to the repository.
settings.advanced_settings = Advanced Settings settings.advanced_settings = Advanced Settings
settings.wiki_desc = Enable wiki to allow people write documents settings.wiki_desc = Enable wiki system
settings.use_internal_wiki = Use builtin wiki
settings.use_external_wiki = Use external wiki settings.use_external_wiki = Use external wiki
settings.external_wiki_url = External Wiki URL settings.external_wiki_url = External Wiki URL
settings.external_wiki_url_desc = Visitors will be redirected to URL when they click on the tab. settings.external_wiki_url_desc = Visitors will be redirected to URL when they click on the tab.
settings.issues_desc = Enable builtin lightweight issue tracker settings.issues_desc = Enable issue tracker
settings.use_internal_issue_tracker = Use builtin lightweight issue tracker
settings.use_external_issue_tracker = Use external issue tracker settings.use_external_issue_tracker = Use external issue tracker
settings.tracker_url_format = External Issue Tracker URL Format settings.tracker_url_format = External Issue Tracker URL Format
settings.tracker_issue_style = External Issue Tracker Naming Style: settings.tracker_issue_style = External Issue Tracker Naming Style:

File diff suppressed because one or more lines are too long

View File

@ -250,6 +250,22 @@ function initRepository() {
$prompt_span.hide(); $prompt_span.hide();
} }
}); });
// Enable or select internal/external wiki system and issue tracker.
$('.enable-system').change(function () {
if (this.checked) {
$($(this).data('target')).removeClass('disabled');
} else {
$($(this).data('target')).addClass('disabled');
}
});
$('.enable-system-radio').change(function () {
if (this.value == 'false') {
$($(this).data('target')).addClass('disabled');
} else if (this.value == 'true') {
$($(this).data('target')).removeClass('disabled');
}
});
} }
// Labels // Labels
@ -410,7 +426,7 @@ function initRepository() {
if (confirm($this.data('locale'))) { if (confirm($this.data('locale'))) {
$.post($this.data('url'), { $.post($this.data('url'), {
"_csrf": csrf "_csrf": csrf
}).success(function() { }).success(function () {
$('#' + $this.data('comment-id')).remove(); $('#' + $this.data('comment-id')).remove();
}); });
} }
@ -471,11 +487,11 @@ function initRepository() {
} }
} }
function initRepositoryCollaboration(){ function initRepositoryCollaboration() {
console.log('initRepositoryCollaboration'); console.log('initRepositoryCollaboration');
// Change collaborator access mode // Change collaborator access mode
$('.access-mode.menu .item').click(function(){ $('.access-mode.menu .item').click(function () {
var $menu = $(this).parent(); var $menu = $(this).parent();
$.post($menu.data('url'), { $.post($menu.data('url'), {
"_csrf": csrf, "_csrf": csrf,
@ -971,11 +987,11 @@ $(document).ready(function () {
$('.show-modal.button').click(function () { $('.show-modal.button').click(function () {
$($(this).data('modal')).modal('show'); $($(this).data('modal')).modal('show');
}); });
$('.delete-post.button').click(function(){ $('.delete-post.button').click(function () {
var $this = $(this); var $this = $(this);
$.post($this.data('request-url'),{ $.post($this.data('request-url'), {
"_csrf": csrf "_csrf": csrf
}).done(function(){ }).done(function () {
window.location.href = $this.data('done-url'); window.location.href = $this.data('done-url');
}); });
}); });
@ -1129,7 +1145,7 @@ $(window).load(function () {
} }
}); });
$(function() { $(function () {
if ($('.user.signin').length >0) return; if ($('.user.signin').length > 0) return;
$('form').areYouSure(); $('form').areYouSure();
}); });

View File

@ -87,20 +87,28 @@
<div class="inline field"> <div class="inline field">
<label>{{.i18n.Tr "repo.wiki"}}</label> <label>{{.i18n.Tr "repo.wiki"}}</label>
<div class="ui checkbox"> <div class="ui checkbox">
<input name="enable_wiki" type="checkbox" {{if .Repository.EnableWiki}}checked{{end}}> <input class="enable-system" name="enable_wiki" type="checkbox" data-target="#wiki_box" {{if .Repository.EnableWiki}}checked{{end}}>
<label>{{.i18n.Tr "repo.settings.wiki_desc"}}</label> <label>{{.i18n.Tr "repo.settings.wiki_desc"}}</label>
</div> </div>
</div> </div>
<div class="inline field"> <div class="field {{if not .Repository.EnableWiki}}disabled{{end}}" id="wiki_box">
<div class="ui checkbox"> <div class="field">
<input name="enable_external_wiki" type="checkbox" {{if .Repository.EnableExternalWiki}}checked{{end}}> <div class="ui radio checkbox">
<label>{{.i18n.Tr "repo.settings.use_external_wiki"}}</label> <input class="hidden enable-system-radio" tabindex="0" name="enable_external_wiki" type="radio" value="false" data-target="#external_wiki_box" {{if not .Repository.EnableExternalWiki}}checked{{end}}/>
<label>{{.i18n.Tr "repo.settings.use_internal_wiki"}}</label>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input class="hidden enable-system-radio" tabindex="0" name="enable_external_wiki" type="radio" value="true" data-target="#external_wiki_box" {{if .Repository.EnableExternalWiki}}checked{{end}}/>
<label>{{.i18n.Tr "repo.settings.use_external_wiki"}}</label>
</div>
</div>
<div class="field {{if not .Repository.EnableExternalWiki}}disabled{{end}}" id="external_wiki_box">
<label for="external_wiki_url">{{.i18n.Tr "repo.settings.external_wiki_url"}}</label>
<input id="external_wiki_url" name="external_wiki_url" type="url" value="{{.Repository.ExternalWikiURL}}">
<p class="help">{{.i18n.Tr "repo.settings.external_wiki_url_desc"}}</p>
</div> </div>
</div>
<div class="field">
<label for="external_wiki_url">{{.i18n.Tr "repo.settings.external_wiki_url"}}</label>
<input id="external_wiki_url" name="external_wiki_url" type="url" value="{{.Repository.ExternalWikiURL}}">
<p class="help">{{.i18n.Tr "repo.settings.external_wiki_url_desc"}}</p>
</div> </div>
<div class="ui divider"></div> <div class="ui divider"></div>
@ -108,33 +116,43 @@
<div class="inline field"> <div class="inline field">
<label>{{.i18n.Tr "repo.issues"}}</label> <label>{{.i18n.Tr "repo.issues"}}</label>
<div class="ui checkbox"> <div class="ui checkbox">
<input name="enable_issues" type="checkbox" {{if .Repository.EnableIssues}}checked{{end}}> <input class="enable-system" name="enable_issues" type="checkbox" data-target="#issue_box" {{if .Repository.EnableIssues}}checked{{end}}>
<label>{{.i18n.Tr "repo.settings.issues_desc"}}</label> <label>{{.i18n.Tr "repo.settings.issues_desc"}}</label>
</div> </div>
</div> </div>
<div class="inline field"> <div class="field {{if not .Repository.EnableIssues}}disabled{{end}}" id="issue_box">
<div class="ui checkbox">
<input name="enable_external_tracker" type="checkbox" {{if .Repository.EnableExternalTracker}}checked{{end}}>
<label>{{.i18n.Tr "repo.settings.use_external_issue_tracker"}}</label>
</div>
</div>
<div class="field">
<label for="tracker_url_format">{{.i18n.Tr "repo.settings.tracker_url_format"}}</label>
<input id="tracker_url_format" name="tracker_url_format" type="url" value="{{.Repository.ExternalTrackerFormat}}" placeholder="e.g. https://github.com/{user}/{repo}/issues/{index}">
<p class="help">{{.i18n.Tr "repo.settings.tracker_url_format_desc" | Str2html}}</p>
</div>
<div class="inline fields">
<label for="issue_style">{{.i18n.Tr "repo.settings.tracker_issue_style"}}</label>
<div class="field"> <div class="field">
<div class="ui radio checkbox"> <div class="ui radio checkbox">
<input class="hidden" tabindex="0" name="tracker_issue_style" type="radio" value="numeric" {{if eq .Repository.ExternalTrackerStyle "numeric"}}checked=""{{end}}/> <input class="hidden enable-system-radio" tabindex="0" name="enable_external_tracker" type="radio" value="false" data-target="#external_issue_box" {{if not .Repository.EnableExternalTracker}}checked{{end}}/>
<label>{{.i18n.Tr "repo.settings.tracker_issue_style.numeric"}} <span class="ui light grey text">(#1234)</span></label> <label>{{.i18n.Tr "repo.settings.use_internal_issue_tracker"}}</label>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<div class="ui radio checkbox"> <div class="ui radio checkbox">
<input class="hidden" tabindex="0" name="tracker_issue_style" type="radio" value="alphanumeric" {{if eq .Repository.ExternalTrackerStyle "alphanumeric"}}checked=""{{end}}/> <input class="hidden enable-system-radio" tabindex="0" name="enable_external_tracker" type="radio" value="true" data-target="#external_issue_box" {{if .Repository.EnableExternalTracker}}checked{{end}}/>
<label>{{.i18n.Tr "repo.settings.tracker_issue_style.alphanumeric"}} <span class="ui light grey text">(ABC-123, DEFG-234)</span></label> <label>{{.i18n.Tr "repo.settings.use_external_issue_tracker"}}</label>
</div>
</div>
<div class="field {{if not .Repository.EnableExternalTracker}}disabled{{end}}" id="external_issue_box">
<div class="field">
<label for="tracker_url_format">{{.i18n.Tr "repo.settings.tracker_url_format"}}</label>
<input id="tracker_url_format" name="tracker_url_format" type="url" value="{{.Repository.ExternalTrackerFormat}}" placeholder="e.g. https://github.com/{user}/{repo}/issues/{index}">
<p class="help">{{.i18n.Tr "repo.settings.tracker_url_format_desc" | Str2html}}</p>
</div>
<div class="inline fields">
<label for="issue_style">{{.i18n.Tr "repo.settings.tracker_issue_style"}}</label>
<div class="field">
<div class="ui radio checkbox">
<input class="hidden" tabindex="0" name="tracker_issue_style" type="radio" value="numeric" {{if eq .Repository.ExternalTrackerStyle "numeric"}}checked=""{{end}}/>
<label>{{.i18n.Tr "repo.settings.tracker_issue_style.numeric"}} <span class="ui light grey text">(#1234)</span></label>
</div>
</div>
<div class="field">
<div class="ui radio checkbox">
<input class="hidden" tabindex="0" name="tracker_issue_style" type="radio" value="alphanumeric" {{if eq .Repository.ExternalTrackerStyle "alphanumeric"}}checked=""{{end}}/>
<label>{{.i18n.Tr "repo.settings.tracker_issue_style.alphanumeric"}} <span class="ui light grey text">(ABC-123, DEFG-234)</span></label>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>