From 7fa1d0edb392a1ef9c7d258da5c076f53a1d4b2f Mon Sep 17 00:00:00 2001 From: hak8or Date: Thu, 8 Mar 2018 06:24:53 -0500 Subject: [PATCH] only can click submit if video is valid, and clears after submit --- src/components/Channel_Add.vue | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/Channel_Add.vue b/src/components/Channel_Add.vue index e80ac8e..7feddce 100644 --- a/src/components/Channel_Add.vue +++ b/src/components/Channel_Add.vue @@ -45,7 +45,7 @@

+ v-if="Valid" @click="Submit">Submit
@@ -154,6 +154,11 @@ export default Vue.extend({ // Hide the bars and erase internal state. this.Expanded = false; + this.clear(); + }, + + // Clears the contents of the add channel field + clear() : void { this.Title = ""; this.Description = ""; this.ID = ""; @@ -203,8 +208,13 @@ export default Vue.extend({ this.ID = this.ID.replace(ytchurl, ""); // Check if what remains looks like a youtube channel ID. - if (this.ID.length != "UCyS4xQE6DK4_p3qXQwJQAyA".length) - return; + if (this.ID.length != "UCyS4xQE6DK4_p3qXQwJQAyA".length){ + this.Title = ""; + this.Description = ""; + this.ID = ""; + this.Thumbnail = ""; + this.Valid = false; + } // Get channel metadata. const API = 'https://www.googleapis.com/youtube/v3/channels?'; @@ -215,6 +225,7 @@ export default Vue.extend({ this.Description = _.truncate(resp.data.items[0].snippet.description, {length: 70}); this.Title = resp.data.items[0].snippet.title; this.Thumbnail = resp.data.items[0].snippet.thumbnails.high.url; + this.Valid = true; }) .catch(function (error) { console.log(error);