From d83dda9ebfc69773c3795443c920736bb7fcb8ee Mon Sep 17 00:00:00 2001 From: Nazar Kanaev Date: Tue, 28 Jul 2020 15:58:57 +0100 Subject: [PATCH] multiple choice when adding new feed --- server/handlers.go | 2 +- template/index.html | 15 ++++++++++++++- template/static/javascripts/app.js | 12 ++++++++++++ template/static/stylesheets/app.css | 4 ++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/server/handlers.go b/server/handlers.go index 2f650f6..ba576eb 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -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"}) diff --git a/template/index.html b/template/index.html index fbb42ef..d8f20bc 100644 --- a/template/index.html +++ b/template/index.html @@ -188,12 +188,25 @@

New Feed

- + +
+

+ Multiple feeds found. Choose one below: + cancel +

+ +
diff --git a/template/static/javascripts/app.js b/template/static/javascripts/app.js index e0864c7..3fa44b4 100644 --- a/template/static/javascripts/app.js +++ b/template/static/javascripts/app.js @@ -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 = '' + }, } }) diff --git a/template/static/stylesheets/app.css b/template/static/stylesheets/app.css index a16a2c0..9ae4352 100644 --- a/template/static/stylesheets/app.css +++ b/template/static/stylesheets/app.css @@ -146,6 +146,10 @@ select.form-control:not([multiple]):not([size]) { opacity: .6; } +.light { + opacity: .6; +} + .selectgroup { position: relative; display: block;