only can click submit if video is valid, and clears after submit

This commit is contained in:
hak8or 2018-03-08 06:24:53 -05:00
parent d1ac84e5ad
commit 7fa1d0edb3
1 changed files with 14 additions and 3 deletions

View File

@ -45,7 +45,7 @@
</p>
<button type="button"
class="button input-group" style="max-height:50px; max-width:100px; float: right;"
@click="Submit">Submit</button>
v-if="Valid" @click="Submit">Submit</button>
</div>
<div class="medium-2 cell"></div>
<div class="input-group medium-2 cell">
@ -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);