Kaynağa Gözat

Feature: Add support for bookmarklet url

pull/169/head
winkidney 5 yıl önce
committed by Isaac Bythewood
ebeveyn
işleme
e09e25a31a
4 değiştirilmiş dosya ile 74 ekleme ve 4 silme
  1. +8
    -1
      pinry-spa/src/components/modals.js
  2. +10
    -1
      pinry-spa/src/components/pin_edit/PinCreateModal.vue
  3. +6
    -0
      pinry-spa/src/router/index.js
  4. +50
    -2
      pinry-spa/src/views/PinCreate.vue

+ 8
- 1
pinry-spa/src/components/modals.js Dosyayı Görüntüle

@@ -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();
}
},
},
},
);
}


+ 10
- 1
pinry-spa/src/components/pin_edit/PinCreateModal.vue Dosyayı Görüntüle

@@ -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
- 0
pinry-spa/src/router/index.js Dosyayı Görüntüle

@@ -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({


+ 50
- 2
pinry-spa/src/views/PinCreate.vue Dosyayı Görüntüle

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



Yükleniyor…
İptal
Kaydet