From 81599155e817e00bd0588df4cb201d1081104388 Mon Sep 17 00:00:00 2001 From: Otto Richter <git@otto.splvs.net> Date: Wed, 25 Dec 2024 03:58:07 +0100 Subject: [PATCH] New repo: Rework basic settings - separate template - ensure correct labelling of elements - drop additional required indicators for field that already have browser semantics (the icon has colour contrast issues anyway), especially as the first dropdown cannot be left empty --- templates/repo/create.tmpl | 52 ++------------------------------ templates/repo/create_basic.tmpl | 45 +++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 49 deletions(-) create mode 100644 templates/repo/create_basic.tmpl diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index df4288a2f2..79ed22d78e 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -16,56 +16,10 @@ <p>{{ctx.Locale.TrN .MaxCreationLimit "repo.form.reach_limit_of_creation_1" "repo.form.reach_limit_of_creation_n" .MaxCreationLimit}}</p> </div> {{end}} - <div class="inline required field {{if .Err_Owner}}error{{end}}"> - <label>{{ctx.Locale.Tr "repo.owner"}}</label> - <div class="ui selection owner dropdown"> - <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> - <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> - {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} - <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> - </span> - {{svg "octicon-triangle-down" 14 "dropdown icon"}} - <div class="menu"> - <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}" title="{{.SignedUser.Name}}"> - {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} - <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> - </div> - {{range .Orgs}} - <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> - {{ctx.AvatarUtils.Avatar . 28 "mini"}} - <span class="truncated-item-name">{{.ShortName 40}}</span> - </div> - {{end}} - </div> - </div> - <span class="help">{{ctx.Locale.Tr "repo.owner_helper"}}</span> - </div> + <fieldset> + {{template "repo/create_basic" .}} + </fieldset> - <div class="inline required field {{if .Err_RepoName}}error{{end}}"> - <label for="repo_name">{{ctx.Locale.Tr "repo.repo_name"}}</label> - <input id="repo_name" name="repo_name" value="{{.repo_name}}" autofocus required maxlength="100"> - <span class="help">{{ctx.Locale.Tr "repo.repo_name_helper"}}</span> - </div> - <div class="inline field"> - <label>{{ctx.Locale.Tr "repo.visibility"}}</label> - <div class="ui checkbox"> - <input name="private" type="checkbox" - {{if .IsForcedPrivate}} - checked disabled - {{else}} - {{if .private}}checked{{end}} - {{end}}> - <label>{{ctx.Locale.Tr "repo.visibility_helper"}}</label> - </div> - {{if .IsForcedPrivate}} - <span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span> - {{end}} - <span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span> - </div> - <div class="inline field {{if .Err_Description}}error{{end}}"> - <label for="description">{{ctx.Locale.Tr "repo.repo_desc"}}</label> - <textarea id="description" rows="2" name="description" placeholder="{{ctx.Locale.Tr "repo.repo_desc_helper"}}" maxlength="2048">{{.description}}</textarea> - </div> <div class="inline field"> <label>{{ctx.Locale.Tr "repo.template"}}</label> <div id="repo_template_search" class="ui search selection dropdown"> diff --git a/templates/repo/create_basic.tmpl b/templates/repo/create_basic.tmpl new file mode 100644 index 0000000000..78a4e8b957 --- /dev/null +++ b/templates/repo/create_basic.tmpl @@ -0,0 +1,45 @@ +<label id="repo_owner_label" {{if .Err_Owner}}class="field error"{{end}}>{{ctx.Locale.Tr "repo.owner"}} + <div class="ui selection required dropdown" aria-labelledby="repo_owner_label"> + <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required> + <span class="text truncated-item-container" title="{{.ContextUser.Name}}"> + {{ctx.AvatarUtils.Avatar .ContextUser 28 "mini"}} + <span class="truncated-item-name">{{.ContextUser.ShortName 40}}</span> + </span> + {{svg "octicon-triangle-down" 14 "dropdown icon"}} + <div class="menu"> + <div class="item truncated-item-container" data-value="{{.SignedUser.ID}}" title="{{.SignedUser.Name}}"> + {{ctx.AvatarUtils.Avatar .SignedUser 28 "mini"}} + <span class="truncated-item-name">{{.SignedUser.ShortName 40}}</span> + </div> + {{range .Orgs}} + <div class="item truncated-item-container" data-value="{{.ID}}" title="{{.Name}}"> + {{ctx.AvatarUtils.Avatar . 28 "mini"}} + <span class="truncated-item-name">{{.ShortName 40}}</span> + </div> + {{end}} + </div> + </div> + <span class="help">{{ctx.Locale.Tr "repo.owner_helper"}}</span> +</label> +<label {{if .Err_RepoName}}class="field error"{{end}}> + {{ctx.Locale.Tr "repo.repo_name"}} + <input name="repo_name" value="{{.repo_name}}" required maxlength="100"> + <span class="help">{{ctx.Locale.Tr "repo.repo_name_helper"}}</span> +</label> +<label> + <input name="private" type="checkbox" + {{if .IsForcedPrivate}} + checked disabled + {{else}} + {{if .private}}checked{{end}} + {{end}}> + {{ctx.Locale.Tr "repo.visibility_helper"}} + {{if .IsForcedPrivate}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_helper_forced"}}</span> + {{end}} + <span class="help">{{ctx.Locale.Tr "repo.visibility_description"}}</span> +</label> +<label {{if .Err_Description}}class="field error"{{end}}> + {{ctx.Locale.Tr "repo.repo_desc"}} + <textarea rows="2" name="description" placeholder="{{ctx.Locale.Tr "repo.repo_desc_helper"}}" maxlength="2048">{{.description}}</textarea> +</label>