aboutsummaryrefslogtreecommitdiffhomepage
path: root/playlist.lisp
diff options
context:
space:
mode:
authorColin Okay <colin@cicadas.surf>2022-10-28 07:15:52 -0500
committerColin Okay <colin@cicadas.surf>2022-10-28 07:15:52 -0500
commit578e2fa0790a7c749e0f597bcdc6b5e4f776dfa2 (patch)
tree1db5347263817aa19723af8a9066457fae11bdbe /playlist.lisp
parent5b0c8784305b9a2bf34816b264a8d9c6968d0bcc (diff)
Add: collaborator/editor managment on playlists
Diffstat (limited to 'playlist.lisp')
-rw-r--r--playlist.lisp40
1 files changed, 39 insertions, 1 deletions
diff --git a/playlist.lisp b/playlist.lisp
index 938972c..dbe982f 100644
--- a/playlist.lisp
+++ b/playlist.lisp
@@ -301,6 +301,43 @@
(format nil "Error while fetching track at: ~a~%"
url)))))))))))
+(defun create-editor-managment (parent playlist)
+ (when (eq (session-user parent) (playlist-user playlist))
+ (with-clog-create parent
+ (div ()
+ (section (:h3 :content "Collaborators"))
+ (unordered-list (:bind editor-list))
+ (button (:content "Add Contributor" :bind addbtn))
+ (form-element (:text :bind userinput))
+ (span (:bind username-status)))
+ (setf (place-holder userinput) "who?"
+ (width userinput ) 140)
+ (flet ((create-editor-item (editor)
+ (with-clog-create editor-list
+ (p (:content (user-name editor) :bind editor-elem)
+ (button (:content "remove" :bind delbtn)))
+ (set-on-click
+ delbtn
+ (thunk*
+ (remove-editor playlist editor)
+ (destroy editor-elem))))))
+ (set-on-key-press
+ userinput
+ (thunk*
+ (setf (text username-status)
+ (if (user-with-name (value userinput))
+ "✔" "No user with that name"))))
+ (set-on-click
+ addbtn
+ (thunk*
+ (when-let (user (user-with-name (value userinput)))
+ (add-editor playlist user)
+ (setf (value userinput) ""
+ (text username-status) "")
+ (create-editor-item user))))
+ (dolist (editor (playlist-editors playlist))
+ (create-editor-item editor))))))
+
(defun playlist-key-from-url (url)
(first (last (ppcre:split "/" (nth 4 (multiple-value-list (quri:parse-uri url)))))))
@@ -322,7 +359,8 @@
(now-playing-display (ctl))
(track-listing (pl))
- (new-track-form (pl)))
+ (new-track-form (pl))
+ (editor-managment (pl)))
(setf (pl-title ctl) title-elem
(pl-dur ctl) dur-elem
(display input) "none"