mirror of
https://github.com/pinry/pinry.git
synced 2025-11-17 18:30:39 +01:00
Feature: Add pin delete function
This commit is contained in:
committed by
Isaac Bythewood
parent
459486932d
commit
58f778f4b4
@@ -8,7 +8,7 @@
|
|||||||
custom-size="mdi-24px">
|
custom-size="mdi-24px">
|
||||||
</b-icon>
|
</b-icon>
|
||||||
</span>
|
</span>
|
||||||
<span class="icon-container">
|
<span class="icon-container" @click="deletePin">
|
||||||
<b-icon
|
<b-icon
|
||||||
type="is-light"
|
type="is-light"
|
||||||
icon="delete"
|
icon="delete"
|
||||||
@@ -27,12 +27,34 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import API from './api';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Editor',
|
name: 'Editor',
|
||||||
props: {
|
props: {
|
||||||
show: {
|
pin: {
|
||||||
default: false,
|
default() {
|
||||||
type: Boolean,
|
return {};
|
||||||
|
},
|
||||||
|
type: Object,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
deletePin() {
|
||||||
|
this.$buefy.dialog.confirm({
|
||||||
|
message: 'Delete this Pin?',
|
||||||
|
onConfirm: () => {
|
||||||
|
API.Pin.deleteById(this.pin.id).then(
|
||||||
|
() => {
|
||||||
|
this.$buefy.toast.open('Pin deleted');
|
||||||
|
this.$emit('pin-delete-succeed', this.pin.id);
|
||||||
|
},
|
||||||
|
() => {
|
||||||
|
this.$buefy.toast.open('Failed to delete Pin');
|
||||||
|
},
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -17,11 +17,15 @@
|
|||||||
<div class="grid-sizer"></div>
|
<div class="grid-sizer"></div>
|
||||||
<div class="gutter-sizer"></div>
|
<div class="gutter-sizer"></div>
|
||||||
<div class="pin-card grid-item">
|
<div class="pin-card grid-item">
|
||||||
<div>
|
<div @mouseenter="showEditButtons(item.id)"
|
||||||
<EditorUI v-show="shouldShowEdit(item.id)"></EditorUI>
|
|
||||||
<img :src="item.url"
|
|
||||||
@mouseenter="showEditButtons(item.id)"
|
|
||||||
@mouseleave="hideEditButtons(item.id)"
|
@mouseleave="hideEditButtons(item.id)"
|
||||||
|
>
|
||||||
|
<EditorUI
|
||||||
|
v-show="shouldShowEdit(item.id)"
|
||||||
|
:pin="item"
|
||||||
|
v-on:pin-delete-succeed="reset"
|
||||||
|
></EditorUI>
|
||||||
|
<img :src="item.url"
|
||||||
@load="onPinImageLoaded(item.id)"
|
@load="onPinImageLoaded(item.id)"
|
||||||
@click="openPreview(item)"
|
@click="openPreview(item)"
|
||||||
alt="item.description"
|
alt="item.description"
|
||||||
@@ -76,7 +80,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 bus from './utils/bus';
|
import bus from './utils/bus';
|
||||||
import EditorUI from './EditorUI.vue';
|
import EditorUI from './PinEditorUI.vue';
|
||||||
|
|
||||||
function createImageItem(pin) {
|
function createImageItem(pin) {
|
||||||
const image = {};
|
const image = {};
|
||||||
|
|||||||
@@ -64,6 +64,12 @@ const Pin = {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
deleteById(pinId) {
|
||||||
|
const url = `${API_PREFIX}pins/${pinId}/`;
|
||||||
|
return axios.delete(
|
||||||
|
url,
|
||||||
|
);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user