{{template "repo/settings/layout_head" (dict "pageClass" "repository settings metadata")}}
	<div class="user-main-content twelve wide column">
		<h4 class="ui top attached header">
			{{svg "octicon-list-unordered" 16}} {{ctx.Locale.Tr "repo.settings.metadata"}}
		</h4>
		<div class="ui attached segment">
			{{if .CustomFieldDefs}}
			<form class="ui form" method="post" action="{{.RepoLink}}/settings/metadata">
				{{.CsrfTokenHtml}}
				{{$values := .CustomFieldValues}}
				{{$options := .CustomFieldOptions}}
				{{range .CustomFieldDefs}}
					{{$currentVal := index $values .ID}}
					<div class="field">
						<label>{{.Name}}{{if .Description}} <small class="text grey">({{.Description}})</small>{{end}}</label>
						{{if .Options}}
							{{$opts := index $options .ID}}
							<select name="field_{{.ID}}" class="ui dropdown">
								<option value="">—</option>
								{{range $opts}}
									<option value="{{.}}" {{if eq . $currentVal}}selected{{end}}>{{.}}</option>
								{{end}}
							</select>
						{{else if eq (printf "%s" .FieldType) "checkbox"}}
							<div class="ui checkbox">
								<input type="checkbox" name="field_{{.ID}}" value="true" {{if eq $currentVal "true"}}checked{{end}}>
								<label></label>
							</div>
						{{else if eq (printf "%s" .FieldType) "number"}}
							<input type="number" name="field_{{.ID}}" value="{{$currentVal}}">
						{{else if eq (printf "%s" .FieldType) "url"}}
							<input type="url" name="field_{{.ID}}" value="{{$currentVal}}" placeholder="https://...">
						{{else if eq (printf "%s" .FieldType) "date"}}
							<input type="date" name="field_{{.ID}}" value="{{$currentVal}}">
						{{else}}
							<input type="text" name="field_{{.ID}}" value="{{$currentVal}}">
						{{end}}
					</div>
				{{end}}
				<div class="field tw-mt-4">
					<button class="ui primary button" type="submit">{{ctx.Locale.Tr "save"}}</button>
				</div>
			</form>
			{{else}}
			<p class="text grey">{{ctx.Locale.Tr "repo.settings.metadata_empty"}}</p>
			{{end}}
		</div>
	</div>
{{template "repo/settings/layout_footer" .}}
