diff options
author | Colin Okay <colin@cicadas.surf> | 2022-10-28 07:15:52 -0500 |
---|---|---|
committer | Colin Okay <colin@cicadas.surf> | 2022-10-28 07:15:52 -0500 |
commit | 578e2fa0790a7c749e0f597bcdc6b5e4f776dfa2 (patch) | |
tree | 1db5347263817aa19723af8a9066457fae11bdbe | |
parent | 5b0c8784305b9a2bf34816b264a8d9c6968d0bcc (diff) |
Add: collaborator/editor managment on playlists
-rw-r--r-- | home.lisp | 4 | ||||
-rw-r--r-- | model.lisp | 9 | ||||
-rw-r--r-- | playlist.lisp | 40 |
3 files changed, 50 insertions, 3 deletions
@@ -28,8 +28,8 @@ (url-to-playlist pl))) (with-clog-create parent (div () - (section (:h4) - (a (:link url :content (playlist-title pl) :bind pl-link)))) + (p () + (a (:link url :content (playlist-title pl) :bind pl-link)))) (set-on-click pl-link (thunk* @@ -110,6 +110,15 @@ (hash-string pw (user-pwsalt user))) user)))) +(defun remove-editor (playlist editor) + (with-transaction () + (setf (playlist-editors playlist) + (delete editor (playlist-editors playlist))))) + +(defun add-editor (playlist editor) + (with-transaction () + (pushnew editor (playlist-editors playlist) :test #'eq))) + (defun destroy-invite (invite) (with-transaction () (bknr.datastore:delete-object invite))) 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" |