import Widget from require "lapis.html" import trim from require "lapis.util" import Tracks from require "models" class extends Widget menu: => div -> element "table", -> tr -> if @page != 1 td -> a href: @url_for("tracks", order: @order, asc_desc: @asc_desc, page: 1), "<<" td -> a href: @url_for("tracks", order: @order, asc_desc: @asc_desc, page: @page - 1), "<" else td "<<" td "<" if @page != @last_page td -> a href: @url_for("tracks", order: @order, asc_desc: @asc_desc, page: @page + 1), ">" td -> a href: @url_for("tracks", order: @order, asc_desc: @asc_desc, page: @last_page), ">>" else td ">" td ">>" content: => @menu! div -> element "table", -> tr -> th "Title" th "Artist" th "Genre" th "Mood" th "Album" th "Link" th "Status" th "Quality" th "✓" for track in *@tracks tr -> form { action: @url_for "tracks", order: @order, asc_desc: @asc_desc, page: @page method: "POST" enctype: "multipart/form-data" }, -> td -> input type: "text", name: "title", value: track.title td -> input type: "text", name: "artist", value: track.artist td -> input type: "text", name: "genre", value: track.genre td -> input type: "text", name: "mood", value: track.mood td -> input type: "text", name: "album", value: track.album td -> if track.link and #track.link > 0 a href: track.link, "*" else text "+" text " " input type: "text", name: "link", value: track.link td -> element "select", name: "status", -> for status_name in *Tracks.statuses if status_name == Tracks.statuses[track.status] option value: Tracks.statuses[status_name], selected: true, status_name else option value: Tracks.statuses[status_name], status_name td -> element "select", name: "quality", -> for quality_name in *Tracks.qualities if quality_name == Tracks.qualities[track.quality] option value: Tracks.qualities[quality_name], selected: true, quality_name else option value: Tracks.qualities[quality_name], quality_name td -> input type: "hidden", name: "id", value: track.id input type: "submit", value: "Update" @menu!