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({
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";
})

View file

@ -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;

View file

@ -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,

View file

@ -181,9 +181,21 @@
</div>
</section>
<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" @click="toggleModal">Annuler</button>
</footer>
</div>
</div>
</main>
</main>
<script>
const canPublish = <%- user.mastodon.publish || false %>;
</script>