this repo has no description
1{{ define "repo/fragments/addLabelModal" }} 2 {{ $root := .root }} 3 {{ $subject := .subject }} 4 {{ $state := .state }} 5 {{ with $root }} 6 <form 7 hx-put="/{{ .RepoInfo.FullName }}/labels/perform" 8 hx-on::after-request="if(event.detail.successful) this.reset()" 9 hx-indicator="#spinner" 10 hx-swap="none" 11 class="flex flex-col gap-4" 12 > 13 <p class="text-gray-500 dark:text-gray-400">Add, remove or update labels.</p> 14 15 <input class="hidden" name="repo" value="{{ .RepoInfo.RepoAt.String }}"> 16 <input class="hidden" name="subject" value="{{ $subject }}"> 17 18 <div class="flex flex-col gap-2 max-h-64 overflow-y-auto"> 19 {{ $id := 0 }} 20 {{ range $k, $valset := $state.Inner }} 21 {{ $d := index $root.LabelDefs $k }} 22 {{ range $v, $s := $valset }} 23 <div class="grid grid-cols-2 cursor-pointer rounded"> 24 <label class="w-full flex items-center gap-2"> 25 <input type="checkbox" name="op-{{$id}}" value="add" checked> 26 {{ template "labels/fragments/labelDef" $d }} 27 </label> 28 {{ template "valueTypeInput" (dict "valueType" $d.ValueType "value" $v "key" $k) }} 29 <input type="hidden" name="operand-key" value="{{ $k }}"> 30 {{ $id = add $id 1 }} 31 </div> 32 {{ end }} 33 {{ end }} 34 35 {{ range $k, $d := $root.LabelDefs }} 36 {{ if not ($state.ContainsLabel $k) }} 37 <div class="grid grid-cols-2 cursor-pointer rounded"> 38 <label class="w-full flex items-center gap-2"> 39 <input type="checkbox" name="op-{{$id}}" value="add"> 40 {{ template "labels/fragments/labelDef" $d }} 41 </label> 42 {{ template "valueTypeInput" (dict "valueType" $d.ValueType "value" "" "key" $k) }} 43 <input type="hidden" name="operand-key" value="{{ $k }}"> 44 {{ $id = add $id 1 }} 45 </div> 46 {{ end }} 47 {{ end }} 48 </div> 49 50 <div class="flex gap-2 pt-2"> 51 <button 52 type="button" 53 popovertarget="add-label-modal" 54 popovertargetaction="hide" 55 class="btn w-1/2 flex items-center gap-2 text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300" 56 > 57 {{ i "x" "size-4" }} cancel 58 </button> 59 <button type="submit" class="btn w-1/2 flex items-center"> 60 <span class="inline-flex gap-2 items-center">{{ i "check" "size-4" }} save</span> 61 <span id="spinner" class="group"> 62 {{ i "loader-circle" "ml-2 w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }} 63 </span> 64 </button> 65 </div> 66 <div id="add-label-error" class="text-red-500 dark:text-red-400"></div> 67 </form> 68 {{ end }} 69{{ end }} 70 71{{ define "valueTypeInput" }} 72 {{ $valueType := .valueType }} 73 {{ $value := .value }} 74 {{ $key := .key }} 75 76 {{ if $valueType.IsEnumType }} 77 {{ template "enumTypeInput" $ }} 78 {{ else if $valueType.IsBool }} 79 {{ template "boolTypeInput" $ }} 80 {{ else if $valueType.IsInt }} 81 {{ template "intTypeInput" $ }} 82 {{ else if $valueType.IsString }} 83 {{ template "stringTypeInput" $ }} 84 {{ else if $valueType.IsNull }} 85 {{ template "nullTypeInput" $ }} 86 {{ end }} 87{{ end }} 88 89{{ define "enumTypeInput" }} 90 {{ $valueType := .valueType }} 91 {{ $value := .value }} 92 <select name="operand-val" class="w-full p-1 rounded border border-gray-300 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-600"> 93 {{ range $valueType.Enum }} 94 <option value="{{.}}" {{ if eq $value . }} selected {{ end }}>{{.}}</option> 95 {{ end }} 96 </select> 97{{ end }} 98 99{{ define "boolTypeInput" }} 100 {{ $value := .value }} 101 <select name="operand-val" class="w-full p-1 rounded border border-gray-300 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-600"> 102 <option value="true" {{ if $value }} selected {{ end }}>true</option> 103 <option value="false" {{ if not $value }} selected {{ end }}>false</option> 104 </select> 105{{ end }} 106 107{{ define "intTypeInput" }} 108 {{ $value := .value }} 109 <input class="p-1 w-full" type="number" name="operand-val" value="{{$value}}" max="100"> 110{{ end }} 111 112{{ define "stringTypeInput" }} 113 {{ $value := .value }} 114 <input class="p-1 w-full" type="text" name="operand-val" value="{{$value}}"> 115{{ end }} 116 117{{ define "nullTypeInput" }} 118 <input class="p-1" type="hidden" name="operand-val" value="null"> 119{{ end }}