From 3b3a4cf779938a1e30b365148c9ba7bd6c51b7d6 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Sat, 7 Oct 2023 18:52:52 +0200 Subject: [PATCH] =?UTF-8?q?Possibilit=C3=A9=20de=20ne=20pas=20partager=20u?= =?UTF-8?q?n=20album=20sur=20le=20fediverse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- javascripts/ajouter-un-album.js | 7 ++++++- sass/modal.scss | 11 +++++++++++ src/middleware/Albums.js | 5 +++-- views/pages/ajouter-un-album.ejs | 14 +++++++++++++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/javascripts/ajouter-un-album.js b/javascripts/ajouter-un-album.js index ef5cd90..02f50d4 100644 --- a/javascripts/ajouter-un-album.js +++ b/javascripts/ajouter-un-album.js @@ -1,6 +1,8 @@ Vue.createApp({ data() { return { + // eslint-disable-next-line no-undef + share: canPublish, q: "", year: "", country: "", @@ -169,7 +171,10 @@ Vue.createApp({ this.submitting = true; return axios - .post("/api/v1/albums", this.details) + .post("/api/v1/albums", { + album: this.details, + share: this.share, + }) .then(() => { window.location.href = "/ma-collection"; }) diff --git a/sass/modal.scss b/sass/modal.scss index e44de67..e76be5e 100644 --- a/sass/modal.scss +++ b/sass/modal.scss @@ -116,6 +116,17 @@ border-bottom-left-radius: 6px; border-bottom-right-radius: 6px; border-top: 1px solid var(--border-color); + justify-content: end; + align-items: baseline; + + .field { + flex-direction: row; + + padding: 6px; + span { + padding-left: 6px; + } + } .button:not(:last-child) { margin-right: .5em; diff --git a/src/middleware/Albums.js b/src/middleware/Albums.js index 97058bc..c5ba642 100644 --- a/src/middleware/Albums.js +++ b/src/middleware/Albums.js @@ -25,8 +25,9 @@ class Albums extends Pages { */ static async postAddOne(req) { const { body, user } = req; + const { album: albumDetails, share } = body; const data = { - ...body, + ...albumDetails, discogsId: body.id, User: user._id, }; @@ -54,7 +55,7 @@ class Albums extends Pages { const { publish, token, url, message } = mastodonConfig; - if (publish && url && token) { + if (share && publish && url && token) { const M = new Mastodon({ access_token: token, api_url: url, diff --git a/views/pages/ajouter-un-album.ejs b/views/pages/ajouter-un-album.ejs index d48aa4c..2574670 100644 --- a/views/pages/ajouter-un-album.ejs +++ b/views/pages/ajouter-un-album.ejs @@ -181,9 +181,21 @@ - \ No newline at end of file + + + \ No newline at end of file