From 578e2fa0790a7c749e0f597bcdc6b5e4f776dfa2 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Fri, 28 Oct 2022 07:15:52 -0500 Subject: Add: collaborator/editor managment on playlists --- playlist.lisp | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'playlist.lisp') 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" -- cgit v1.2.3