summaryrefslogtreecommitdiff
path: root/playlist.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'playlist.lisp')
-rw-r--r--playlist.lisp29
1 files changed, 26 insertions, 3 deletions
diff --git a/playlist.lisp b/playlist.lisp
index 3fad639..88da89e 100644
--- a/playlist.lisp
+++ b/playlist.lisp
@@ -17,10 +17,9 @@
(:documentation "Holds the complete state for this session's viewing of a particular playlist."))
(defclass/std track-ctl ()
- ((track audio container :std nil))
+ ((track audio container info-edit-ctl edit-save-btn editing? :std nil))
(:documentation "The state of a particular track in this session's viewing of a playlist."))
-
(defun audio-for-track (ctl track)
"Return the audio element associated with the track"
(when-let (trctl (find track (tracks ctl) :test #'eq :key #'track))
@@ -228,6 +227,24 @@
;; swap list items in the dom
(place-after (container cur) (container next)))))))
+(defun toggle-track-editor (track-ctl)
+ (setf (editing? track-ctl) (not (editing? track-ctl)))
+ (if (editing? track-ctl)
+ (progn
+ (setf (text (edit-save-btn track-ctl)) "save ")
+ (with-clog-create (info-edit-ctl track-ctl)
+ (div (:class "track-edit-inputs")
+ (form-element (:text :bind artist-input))
+ (form-element (:text :bind album-input))
+ (form-element (:text :bind title-input)))
+ (set-on-click
+ (edit-save-btn track-ctl)
+ (thunk* (update-track-info
+ (track track-ctl) (value artist-input) (value album-input) (value title-input))
+ (toggle-track-editor track-ctl)))))
+ (setf (display (info-edit-ctl track-ctl)) "none"
+ (text (print (edit-save-btn track-ctl))) "edit ")))
+
(defun add-zipped-playlist-link (pl-ctl playlist)
"Adds the link to a zipped playlist to the DOM."
(for-playlist-viewers (pl-download pl-ctl) ctl
@@ -292,7 +309,9 @@
(div (:bind item :class "track-list-item")
(section (:pre :content (track-listing-line track))))
+ (div (:bind info-edit-ctl :class "track-list-edit"))
(div (:bind edit-controls)
+ (button (:content "edit " :bind edit-save-btn))
(button (:content "delete " :bind delbtn))
(button (:content "↓" :bind downbtn))
(button (:content "↑" :bind upbtn)))
@@ -301,13 +320,17 @@
(make-instance 'track-ctl
:container container
:audio audio
- :track track)))
+ :track track
+ :info-edit-ctl info-edit-ctl
+ :edit-save-btn edit-save-btn
+ :editing? nil)))
(setf (tracks ctl)
(insert-nth track-ctl -1 (tracks ctl) t))
(cond
((editorp ctl)
(setf (attribute downbtn "title") "move track down"
(attribute upbtn "title") "move track up")
+ (set-on-click edit-save-btn (thunk* (toggle-track-editor track-ctl)))
(set-on-click delbtn (thunk* (remove-track track-ctl)))
(set-on-click downbtn (thunk* (move-track-down track-ctl)))
(set-on-click upbtn (thunk* (move-track-up track-ctl))))