mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
multiple choice when adding new feed
This commit is contained in:
parent
745ade6121
commit
d83dda9ebf
@ -184,7 +184,7 @@ func FeedListHandler(rw http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
writeJSON(rw, map[string]string{"status": "success"})
|
||||
}
|
||||
} else if strings.HasPrefix(contentType, "text/xml") || strings.HasPrefix(contentType, "application/xml") {
|
||||
} else if strings.HasPrefix(contentType, "text/xml") || strings.HasPrefix(contentType, "application/xml") || strings.HasPrefix(contentType, "application/rss+xml") {
|
||||
err = createFeed(db(req), feedUrl, feed.FolderID)
|
||||
if err == nil {
|
||||
writeJSON(rw, map[string]string{"status": "success"})
|
||||
|
@ -188,12 +188,25 @@
|
||||
<p class="cursor-default"><b>New Feed</b></p>
|
||||
<form action="" @submit.prevent="createFeed(event)" class="mt-4">
|
||||
<label for="feed-url">URL</label>
|
||||
<input id="feed-url" name="url" type="url" class="form-control" required autocomplete="off">
|
||||
<input id="feed-url" name="url" type="url" class="form-control" required autocomplete="off" :readonly="feedNewChoice.length > 0">
|
||||
<label for="feed-folder" class="mt-3">Folder</label>
|
||||
<select class="form-control" id="feed-folder" name="folder_id">
|
||||
<option value=""></option>
|
||||
<option :value="folder.id" v-for="folder in folders">{{ folder.title }}</option>
|
||||
</select>
|
||||
<div class="mt-4" v-if="feedNewChoice.length">
|
||||
<p class="mb-2">
|
||||
Multiple feeds found. Choose one below:
|
||||
<a href="#" class="float-right" @click.prevent="resetFeedChoice()">cancel</a>
|
||||
</p>
|
||||
<label class="selectgroup" v-for="choice in feedNewChoice">
|
||||
<input type="radio" name="feedToAdd" :value="choice.url" v-model="feedNewChoiceSelected">
|
||||
<div class="selectgroup-label">
|
||||
<div>{{ choice.title }}</div>
|
||||
<div :class="{light: choice.title}">{{ choice.url }}</div>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
<button class="btn btn-block btn-default mt-3" :class="{loading: loading.newfeed}" type="submit">Add</button>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -117,6 +117,8 @@ var vm = new Vue({
|
||||
'feeds': [],
|
||||
'feedSelected': null,
|
||||
'feedListWidth': null,
|
||||
'feedNewChoice': [],
|
||||
'feedNewChoiceSelected': '',
|
||||
'items': [],
|
||||
'itemsPage': {
|
||||
'cur': 1,
|
||||
@ -380,6 +382,9 @@ var vm = new Vue({
|
||||
url: form.querySelector('input[name=url]').value,
|
||||
folder_id: parseInt(form.querySelector('select[name=folder_id]').value) || null,
|
||||
}
|
||||
if (this.feedNewChoiceSelected) {
|
||||
data.url = this.feedNewChoiceSelected
|
||||
}
|
||||
this.loading.newfeed = true
|
||||
var vm = this
|
||||
api.feeds.create(data).then(function(result) {
|
||||
@ -388,6 +393,9 @@ var vm = new Vue({
|
||||
vm.feeds = feeds
|
||||
})
|
||||
vm.$bvModal.hide('settings-modal')
|
||||
} else if (result.status === 'multiple') {
|
||||
vm.feedNewChoice = result.choice
|
||||
vm.feedNewChoiceSelected = result.choice[0].url
|
||||
}
|
||||
vm.loading.newfeed = false
|
||||
})
|
||||
@ -444,5 +452,9 @@ var vm = new Vue({
|
||||
resizeItemList: function(width) {
|
||||
this.itemListWidth = Math.min(Math.max(200, width), 700)
|
||||
},
|
||||
resetFeedChoice: function() {
|
||||
this.feedNewChoice = []
|
||||
this.feedNewChoiceSelected = ''
|
||||
},
|
||||
}
|
||||
})
|
||||
|
@ -146,6 +146,10 @@ select.form-control:not([multiple]):not([size]) {
|
||||
opacity: .6;
|
||||
}
|
||||
|
||||
.light {
|
||||
opacity: .6;
|
||||
}
|
||||
|
||||
.selectgroup {
|
||||
position: relative;
|
||||
display: block;
|
||||
|
Loading…
x
Reference in New Issue
Block a user