Possibilité de ne pas partager un album sur le fediverse

This commit is contained in:
Damien Broqua 2023-10-07 18:52:52 +02:00
parent 1931bd9eda
commit 3b3a4cf779
4 changed files with 33 additions and 4 deletions

View file

@ -1,6 +1,8 @@
Vue.createApp({ Vue.createApp({
data() { data() {
return { return {
// eslint-disable-next-line no-undef
share: canPublish,
q: "", q: "",
year: "", year: "",
country: "", country: "",
@ -169,7 +171,10 @@ Vue.createApp({
this.submitting = true; this.submitting = true;
return axios return axios
.post("/api/v1/albums", this.details) .post("/api/v1/albums", {
album: this.details,
share: this.share,
})
.then(() => { .then(() => {
window.location.href = "/ma-collection"; window.location.href = "/ma-collection";
}) })

View file

@ -116,6 +116,17 @@
border-bottom-left-radius: 6px; border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px; border-bottom-right-radius: 6px;
border-top: 1px solid var(--border-color); 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) { .button:not(:last-child) {
margin-right: .5em; margin-right: .5em;

View file

@ -25,8 +25,9 @@ class Albums extends Pages {
*/ */
static async postAddOne(req) { static async postAddOne(req) {
const { body, user } = req; const { body, user } = req;
const { album: albumDetails, share } = body;
const data = { const data = {
...body, ...albumDetails,
discogsId: body.id, discogsId: body.id,
User: user._id, User: user._id,
}; };
@ -54,7 +55,7 @@ class Albums extends Pages {
const { publish, token, url, message } = mastodonConfig; const { publish, token, url, message } = mastodonConfig;
if (publish && url && token) { if (share && publish && url && token) {
const M = new Mastodon({ const M = new Mastodon({
access_token: token, access_token: token,
api_url: url, api_url: url,

View file

@ -181,9 +181,21 @@
</div> </div>
</section> </section>
<footer> <footer>
<% if ( user.mastodon.publish ) { %>
<div class="field">
<label for="share">Partager sur le fédiverse</label>
<span>
<input type="checkbox" id="share" name="share" v-model="share">
</span>
</div>
<% } %>
<button :class="['button is-primary', submitting ? 'is-disabled' : '']" @click="add">Ajouter</button> <button :class="['button is-primary', submitting ? 'is-disabled' : '']" @click="add">Ajouter</button>
<button class="button" @click="toggleModal">Annuler</button> <button class="button" @click="toggleModal">Annuler</button>
</footer> </footer>
</div> </div>
</div> </div>
</main> </main>
<script>
const canPublish = <%- user.mastodon.publish || false %>;
</script>