mirror of
https://github.com/pinry/pinry.git
synced 2026-01-29 02:29:25 +01:00
Feature: Add support for bookmarklet url
This commit is contained in:
committed by
Isaac Bythewood
parent
a7670892f0
commit
e09e25a31a
@@ -5,13 +5,20 @@ import BoardEdit from './BoardEdit.vue';
|
||||
import Add2Board from './pin_edit/Add2Board.vue';
|
||||
|
||||
|
||||
function openPinEdit(vm, props = null) {
|
||||
function openPinEdit(vm, props = null, onCreated = null) {
|
||||
vm.$buefy.modal.open(
|
||||
{
|
||||
parent: vm,
|
||||
component: PinCreateModal,
|
||||
props,
|
||||
hasModalCard: true,
|
||||
events: {
|
||||
pinCreated() {
|
||||
if (onCreated !== null) {
|
||||
onCreated();
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ import bus from '../utils/bus';
|
||||
import ModelForm from '../utils/ModelForm';
|
||||
|
||||
function isURLBlank(url) {
|
||||
return url !== null && url !== '';
|
||||
return url !== null && url === '';
|
||||
}
|
||||
|
||||
const fields = ['url', 'referer', 'description', 'tags'];
|
||||
@@ -100,6 +100,10 @@ const fields = ['url', 'referer', 'description', 'tags'];
|
||||
export default {
|
||||
name: 'PinCreateModal',
|
||||
props: {
|
||||
fromUrl: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
username: {
|
||||
type: String,
|
||||
default: null,
|
||||
@@ -142,6 +146,11 @@ export default {
|
||||
this.pinModel.form.description.value = this.existedPin.description;
|
||||
this.pinModel.form.tags.value = this.existedPin.tags;
|
||||
}
|
||||
if (this.fromUrl) {
|
||||
this.pinModel.form.url.value = this.fromUrl.url;
|
||||
this.pinModel.form.referer.value = this.fromUrl.referer;
|
||||
this.pinModel.form.description.value = this.fromUrl.description;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
fetchBoardList() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import Pins4User from '../views/Pins4User.vue';
|
||||
import Pins4Board from '../views/Pins4Board.vue';
|
||||
import Pins4Id from '../views/Pins4Id.vue';
|
||||
import Boards4User from '../views/Boards4User.vue';
|
||||
import PinCreate from '../views/PinCreate.vue';
|
||||
|
||||
Vue.use(VueRouter);
|
||||
|
||||
@@ -40,6 +41,11 @@ const routes = [
|
||||
name: 'boards4user',
|
||||
component: Boards4User,
|
||||
},
|
||||
{
|
||||
path: '/pin-creation/from-url',
|
||||
name: 'pin-creation-from-url',
|
||||
component: PinCreate,
|
||||
},
|
||||
];
|
||||
|
||||
const router = new VueRouter({
|
||||
|
||||
@@ -5,10 +5,58 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import PinCreateModal from './PinCreateModal.vue';
|
||||
import modals from '../components/modals';
|
||||
import API from '../components/api';
|
||||
|
||||
export default {
|
||||
name: 'PinCreate',
|
||||
name: 'PinCreateFromURL',
|
||||
data() {
|
||||
return {
|
||||
meta: {
|
||||
url: null,
|
||||
referer: null,
|
||||
description: null,
|
||||
},
|
||||
user: {
|
||||
loggedIn: false,
|
||||
meta: null,
|
||||
},
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
initialize(force = false) {
|
||||
const self = this;
|
||||
API.User.fetchUserInfo(force).then(
|
||||
(user) => {
|
||||
if (user === null) {
|
||||
self.user.loggedIn = false;
|
||||
self.user.meta = {};
|
||||
} else {
|
||||
self.user.meta = user;
|
||||
self.user.loggedIn = true;
|
||||
self.createPin();
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
onCreated() {
|
||||
this.$buefy.dialog.alert(
|
||||
'Please turn off this page by hand since '
|
||||
+ 'Javascript has no permission to do this',
|
||||
);
|
||||
},
|
||||
createPin() {
|
||||
modals.openPinEdit(
|
||||
this,
|
||||
{ username: this.user.meta.username, fromUrl: this.meta },
|
||||
this.onCreated,
|
||||
);
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.meta = this.$route.query;
|
||||
this.initialize();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user