From 52ef147c0c9894f285656d4f67bf8d7052d9660b Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Wed, 26 Oct 2022 16:57:20 -0500 Subject: Add: edit playlist title --- playlist.lisp | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'playlist.lisp') diff --git a/playlist.lisp b/playlist.lisp index 82f6f49..b71e4d7 100644 --- a/playlist.lisp +++ b/playlist.lisp @@ -70,6 +70,10 @@ (with-transaction () (make-instance 'playlist :title title :user user))) +(defun update-playlist-title (playlist title) + (with-transaction () + (setf (playlist-title playlist) title))) + ;;; CLIENT STATE (defclass/std playlist-ctl () @@ -372,9 +376,32 @@ (install-new-playlist-ctl pl body))) (with-clog-create body (div () - (section (:h2 :content (playlist-title-content pl) :bind title-elem)) + (section (:h2 :content (playlist-title pl) :bind title-elem)) + (form () + (form-element (:text :bind input))) (now-playing-display (ctl)) (track-listing (pl)) (new-track-form (pl))) - (setf (pl-title ctl) title-elem) + (setf (pl-title ctl) title-elem + (display input) "none") + + (set-on-blur + input + (alambda + (when (plusp (length (value input))) + (update-playlist-title pl (value input)) + (setf (text title-elem) (value input))) + (setf (display input) "none" + (display title-elem) "block"))) + + (set-on-click + title-elem + (alambda + (setf (value input) (text title-elem) + (display input) "inline" + (display title-elem) "none") + (focus input))) + (initialize-now-playing body))))) + +(create-form-element ) -- cgit v1.2.3