lyrics

web application to manage song lyrics
git clone git://brookjeynes.dev/bjeynes/lyrics.git
Log | Files | Refs

artist-search-picker.templ (1307B)


      1 package artistsearchpicker
      2 
      3 import "fmt"
      4 
      5 templ ArtistSearchPicker(params ArtistSearchPickerParams) {
      6 	if len(params.Artists) == 0 {
      7 		<fieldset class="pickeroptions" role="radiogroup">
      8 			<p>
      9 				no artist found. 
     10 				<a target="_blank" rel="noopener noreferrer" href="/artist/new">
     11 					create a new one? (opens in new tab)
     12 				</a>
     13 			</p>
     14 		</fieldset>
     15 	} else {
     16 		<fieldset class="pickeroptions" role="radiogroup">
     17 			<legend>select artist</legend>
     18 			<ul>
     19 				for _, artist := range params.Artists {
     20 					{{
     21 						label := artist.Name
     22 						if artist.LatinName != nil && artist.Disambiguation != nil {
     23 							label = fmt.Sprintf("%s (%s, %s)", artist.Name, *artist.LatinName, *artist.Disambiguation)
     24 						} else if artist.LatinName != nil {
     25 							label = fmt.Sprintf("%s (%s)", artist.Name, *artist.LatinName)
     26 						} else if artist.Disambiguation != nil {
     27 							label = fmt.Sprintf("%s (%s)", artist.Name, *artist.Disambiguation)
     28 						}
     29 					}}
     30 					<li>
     31 						<label>
     32 							<input
     33 								type="radio"
     34 								value={ fmt.Sprintf("%d", artist.ID) }
     35 								data-name={ artist.Name }
     36 								required
     37 								@change="selected = true; artistId = $event.target.value; artistName = $event.target.dataset.name"
     38 							/>
     39 							{ label }
     40 						</label>
     41 					</li>
     42 				}
     43 			</ul>
     44 		</fieldset>
     45 	}
     46 }