This repository has been archived on 2024-09-20. You can view files and clone it, but cannot push or open issues or pull requests.
musicapp/views/tracks.moon

82 lines
3.0 KiB
Plaintext
Raw Normal View History

2019-04-18 05:08:09 +00:00
import Widget from require "lapis.html"
import trim from require "lapis.util"
2019-04-18 05:08:09 +00:00
import Tracks from require "models"
class extends Widget
2019-04-18 05:17:04 +00:00
menu: =>
2019-04-18 05:08:09 +00:00
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 ">>"
2019-04-18 06:43:26 +00:00
2019-04-18 05:08:09 +00:00
content: =>
@menu!
div ->
element "table", ->
tr ->
th "Artist"
2019-06-28 03:20:52 +00:00
th "Title"
th "Album"
2019-04-18 05:08:09 +00:00
th "Genre"
th "Mood"
th "Link"
th "Status"
th "Quality"
th "✓"
2019-06-28 02:49:32 +00:00
th "Tags"
2019-04-18 05:08:09 +00:00
for track in *@tracks
2019-06-15 00:41:39 +00:00
tr class: Tracks.statuses[track.status], ->
form {
action: @url_for "tracks", order: @order, asc_desc: @asc_desc, page: @page
method: "POST"
enctype: "multipart/form-data"
}, ->
td -> input type: "text", name: "artist", value: track.artist
2019-06-28 03:20:52 +00:00
td -> input type: "text", name: "title", value: track.title
td -> input type: "text", name: "album", value: track.album
td -> input type: "text", name: "genre", value: track.genre
td -> input type: "text", name: "mood", value: track.mood
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"
2019-06-28 02:49:32 +00:00
td -> input type: "text", name: "tags", value: trim(track.tags)
2019-04-18 05:08:09 +00:00
@menu!