mirror of
https://github.com/pinry/pinry.git
synced 2025-11-17 10:20:39 +01:00
Feature: Add Board delete function
This commit is contained in:
committed by
Isaac Bythewood
parent
54487787f5
commit
e455821ac6
@@ -16,24 +16,32 @@
|
|||||||
<div class="grid-sizer"></div>
|
<div class="grid-sizer"></div>
|
||||||
<div class="gutter-sizer"></div>
|
<div class="gutter-sizer"></div>
|
||||||
<div class="board-card grid-item">
|
<div class="board-card grid-item">
|
||||||
<router-link :to="{ name: 'board', params: { boardId: item.id } }">
|
<div @mouseenter="currentEditBoard = item.id"
|
||||||
|
@mouseleave="currentEditBoard = null"
|
||||||
|
>
|
||||||
<div class="card-image">
|
<div class="card-image">
|
||||||
<img :src="item.preview_image_url"
|
<BoardEditorUI
|
||||||
@load="onPinImageLoaded(item.id)"
|
v-show="shouldShowEdit(item.id)"
|
||||||
:style="item.style"
|
:board="item"
|
||||||
v-show="item.preview_image_url"
|
v-on:board-delete-succeed="reset"
|
||||||
class="preview-image">
|
></BoardEditorUI>
|
||||||
|
<router-link :to="{ name: 'board', params: { boardId: item.id } }">
|
||||||
|
<img :src="item.preview_image_url"
|
||||||
|
@load="onPinImageLoaded(item.id)"
|
||||||
|
:style="item.style"
|
||||||
|
v-show="item.preview_image_url"
|
||||||
|
class="preview-image">
|
||||||
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<div class="board-footer">
|
<div class="board-footer">
|
||||||
<p class="sub-title board-info">{{ item.name }}</p>
|
<p class="sub-title board-info">{{ item.name }}</p>
|
||||||
|
|
||||||
<p class="description">
|
<p class="description">
|
||||||
<small>
|
<small>
|
||||||
Pins in board: <span class="num-pins">{{ item.total_pins }}</span>
|
Pins in board: <span class="num-pins">{{ item.total_pins }}</span>
|
||||||
</small>
|
</small>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</router-link>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -52,6 +60,7 @@ import loadingSpinner from './loadingSpinner.vue';
|
|||||||
import noMore from './noMore.vue';
|
import noMore from './noMore.vue';
|
||||||
import scroll from './utils/scroll';
|
import scroll from './utils/scroll';
|
||||||
import placeholder from '../assets/pinry-placeholder.jpg';
|
import placeholder from '../assets/pinry-placeholder.jpg';
|
||||||
|
import BoardEditorUI from './editors/BoardEditUI.vue';
|
||||||
|
|
||||||
function createBoardItem(board) {
|
function createBoardItem(board) {
|
||||||
const defaultPreviewImage = placeholder;
|
const defaultPreviewImage = placeholder;
|
||||||
@@ -81,25 +90,45 @@ function createBoardItem(board) {
|
|||||||
return boardItem;
|
return boardItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initialData() {
|
||||||
|
return {
|
||||||
|
currentEditBoard: null,
|
||||||
|
blocks: [],
|
||||||
|
blocksMap: {},
|
||||||
|
status: {
|
||||||
|
loading: false,
|
||||||
|
hasNext: true,
|
||||||
|
offset: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'boards',
|
name: 'boards',
|
||||||
components: {
|
components: {
|
||||||
loadingSpinner,
|
loadingSpinner,
|
||||||
noMore,
|
noMore,
|
||||||
|
BoardEditorUI,
|
||||||
},
|
},
|
||||||
data() {
|
data: initialData,
|
||||||
return {
|
|
||||||
blocks: [],
|
|
||||||
blocksMap: {},
|
|
||||||
status: {
|
|
||||||
loading: false,
|
|
||||||
hasNext: true,
|
|
||||||
offset: 0,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
},
|
|
||||||
props: ['boardUsername'],
|
props: ['boardUsername'],
|
||||||
methods: {
|
methods: {
|
||||||
|
initialize() {
|
||||||
|
this.fetchMore(true);
|
||||||
|
},
|
||||||
|
reset() {
|
||||||
|
const data = initialData();
|
||||||
|
Object.entries(data).forEach(
|
||||||
|
(kv) => {
|
||||||
|
const [key, value] = kv;
|
||||||
|
this[key] = value;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
this.initialize();
|
||||||
|
},
|
||||||
|
shouldShowEdit(boardId) {
|
||||||
|
return this.currentEditBoard === boardId;
|
||||||
|
},
|
||||||
onPinImageLoaded(itemId) {
|
onPinImageLoaded(itemId) {
|
||||||
this.blocksMap[itemId].class = {
|
this.blocksMap[itemId].class = {
|
||||||
'image-loaded': true,
|
'image-loaded': true,
|
||||||
@@ -165,7 +194,7 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.registerScrollEvent();
|
this.registerScrollEvent();
|
||||||
this.fetchMore(true);
|
this.initialize();
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -34,6 +34,10 @@ const Board = {
|
|||||||
{ pins_to_add: pinIds },
|
{ pins_to_add: pinIds },
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
delete(boardId) {
|
||||||
|
const url = `${API_PREFIX}boards/${boardId}/`;
|
||||||
|
return axios.delete(url);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const Pin = {
|
const Pin = {
|
||||||
|
|||||||
58
pinry-spa/src/components/editors/BoardEditUI.vue
Normal file
58
pinry-spa/src/components/editors/BoardEditUI.vue
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<template>
|
||||||
|
<div class="editor">
|
||||||
|
<div class="editor-buttons">
|
||||||
|
<span class="icon-container" @click="deleteBoard">
|
||||||
|
<b-icon
|
||||||
|
type="is-light"
|
||||||
|
icon="delete"
|
||||||
|
custom-size="mdi-24px">
|
||||||
|
</b-icon>
|
||||||
|
</span>
|
||||||
|
<span class="icon-container">
|
||||||
|
<b-icon
|
||||||
|
type="is-light"
|
||||||
|
icon="pencil"
|
||||||
|
custom-size="mdi-24px">
|
||||||
|
</b-icon>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import API from '../api';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'BoardEditor',
|
||||||
|
props: {
|
||||||
|
board: {
|
||||||
|
default() {
|
||||||
|
return {};
|
||||||
|
},
|
||||||
|
type: Object,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
deleteBoard() {
|
||||||
|
this.$buefy.dialog.confirm({
|
||||||
|
message: 'Delete this Board?',
|
||||||
|
onConfirm: () => {
|
||||||
|
API.Board.delete(this.board.id).then(
|
||||||
|
() => {
|
||||||
|
this.$buefy.toast.open('Board deleted');
|
||||||
|
this.$emit('board-delete-succeed', this.board.id);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.$buefy.toast.open('Failed to delete Board');
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
@import './editor';
|
||||||
|
</style>
|
||||||
@@ -61,28 +61,5 @@ export default {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@mixin border-radius {
|
@import './editor';
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.editor-buttons {
|
|
||||||
padding: 3px 1px 3px 3px;
|
|
||||||
background-color: rgba(225, 225, 225, 0.6);
|
|
||||||
position: absolute;
|
|
||||||
top: 5px;
|
|
||||||
right: 5px;
|
|
||||||
float: right;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
@include border-radius;
|
|
||||||
.icon-container {
|
|
||||||
@include border-radius;
|
|
||||||
padding: 5px 2px 2px 2px;
|
|
||||||
background-color: rgba(0, 0, 0, 0.8);
|
|
||||||
margin-right: 2px;
|
|
||||||
span {
|
|
||||||
opacity: 0.9;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
24
pinry-spa/src/components/editors/editor.scss
Normal file
24
pinry-spa/src/components/editors/editor.scss
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
@mixin border-radius {
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor-buttons {
|
||||||
|
padding: 3px 1px 3px 3px;
|
||||||
|
background-color: rgba(225, 225, 225, 0.6);
|
||||||
|
position: absolute;
|
||||||
|
top: 5px;
|
||||||
|
right: 5px;
|
||||||
|
float: right;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
@include border-radius;
|
||||||
|
.icon-container {
|
||||||
|
@include border-radius;
|
||||||
|
padding: 5px 2px 2px 2px;
|
||||||
|
background-color: rgba(0, 0, 0, 0.8);
|
||||||
|
margin-right: 2px;
|
||||||
|
span {
|
||||||
|
opacity: 0.9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user