Stackedit/src/components/modals/GistPublishModal.vue

74 lines
2.5 KiB
Vue
Raw Normal View History

2017-09-23 19:01:50 +00:00
<template>
2017-09-26 22:54:26 +00:00
<div class="modal__inner-1">
2017-09-23 19:01:50 +00:00
<div class="modal__inner-2">
<div class="modal__image">
<icon-provider provider-id="gist"></icon-provider>
</div>
<p>This will publish <b>{{currentFileName}}</b> to a <b>Gist</b>.</p>
2017-09-26 22:54:26 +00:00
<form-entry label="Filename">
<input slot="field" class="textfield" type="text" v-model.trim="filename" @keyup.enter="resolve()">
</form-entry>
2017-09-23 19:01:50 +00:00
<div class="form-entry">
<div class="form-entry__checkbox">
<label>
<input type="checkbox" v-model="isPublic"> Public
</label>
</div>
</div>
2017-09-26 22:54:26 +00:00
<form-entry label="Existing Gist ID (optional)">
<input slot="field" class="textfield" type="text" v-model.trim="gistId" @keyup.enter="resolve()">
2017-09-23 19:01:50 +00:00
<div class="form-entry__info">
2017-09-26 22:54:26 +00:00
If the file exists in the Gist, it will be replaced.
2017-09-23 19:01:50 +00:00
</div>
2017-09-26 22:54:26 +00:00
</form-entry>
<form-entry label="Template">
<select slot="field" class="textfield" v-model="selectedTemplate" @keyup.enter="resolve()">
<option v-for="(template, id) in allTemplates" :key="id" :value="id">
{{ template.name }}
</option>
</select>
2017-09-23 19:01:50 +00:00
<div class="form-entry__actions">
<a href="javascript:void(0)" @click="configureTemplates">Configure templates</a>
</div>
2017-09-26 22:54:26 +00:00
</form-entry>
2017-09-23 19:01:50 +00:00
<div class="modal__tip">
2017-09-26 22:54:26 +00:00
<b>ProTip:</b> You can provide a value for <code>title</code> in the <a href="javascript:void(0)" @click="openFileProperties">file properties</a>.
2017-09-23 19:01:50 +00:00
</div>
<div class="modal__button-bar">
<button class="button" @click="config.reject()">Cancel</button>
<button class="button" @click="resolve()">Ok</button>
</div>
</div>
</div>
</template>
<script>
import gistProvider from '../../services/providers/gistProvider';
2017-09-26 22:54:26 +00:00
import modalTemplate from './modalTemplate';
2017-09-23 19:01:50 +00:00
2017-09-26 22:54:26 +00:00
export default modalTemplate({
2017-09-23 19:01:50 +00:00
data: () => ({
filename: '',
gistId: '',
}),
2017-09-26 22:54:26 +00:00
computedLocalSettings: {
isPublic: 'gistIsPublic',
selectedTemplate: 'gistPublishTemplate',
2017-09-23 19:01:50 +00:00
},
created() {
this.filename = `${this.currentFileName}.md`;
},
methods: {
resolve() {
if (this.filename) {
// Return new location
const location = gistProvider.makeLocation(
this.config.token, this.filename, this.isPublic, this.gistId);
location.templateId = this.selectedTemplate;
this.config.resolve(location);
}
},
},
2017-09-26 22:54:26 +00:00
});
2017-09-23 19:01:50 +00:00
</script>