0
0
Fork 0

Populate with some more elements and methods

This commit is contained in:
Tyler-A 2020-07-30 22:11:46 -06:00
parent 6595e3ebef
commit 85b94fbd79

View file

@ -1,6 +1,11 @@
<template> <template>
<div id="control"> <div id="control">
<div id="user_data"></div> <div
v-if="user.name || dev || preview"
id="user_data"
>
{{ user.name }}
</div>
<div id="type"> <div id="type">
<select v-model="type"> <select v-model="type">
<option value="" disabled>Select a Type</option> <option value="" disabled>Select a Type</option>
@ -18,15 +23,16 @@
</div> </div>
<div id="amount"> <div id="amount">
<input <input
v-model="amount"
type="number" type="number"
min="1" min="1"
max="50" max="50"
placeholder="How many?" placeholder="How many?"
v-model="amount" @input="verify_request_amount()"
> >
</div> </div>
<div <div
v-if="type && duration" v-if="type && duration && !error"
id="data_button" id="data_button"
> >
<button @click.self="data_request()"> <button @click.self="data_request()">
@ -82,34 +88,51 @@ export default {
methods: { methods: {
event(name) { this.$emit(name); }, event(name) { this.$emit(name); },
get_user() {}, get_user() {},
data_request() { verify_request_amount() {
let amount = parseInt(this.amount); let amount;
try {
amount = parseInt(this.amount)
} catch (err) {
this.error = err
return;
};
if (amount > 50) { if (amount > 50) {
this.error = `Cannot request more than 50 ${this.type.toLowerCase()}`; this.error = `Cannot request more than 50 ${this.type.toLowerCase()}`;
return;
} else if (amount < 1) { } else if (amount < 1) {
this.error = `Cannot get 0 or fewer ${this.type.toLowerCase()}`; this.error = `Cannot get 0 or fewer ${this.type.toLowerCase()}`;
return;
} else { } else {
this.error = ``;
return amount;
}
},
data_request() {
let amount = parseInt(this.amount);
if (amount) {
this.event(`data_request`, { this.event(`data_request`, {
type: this.type, type: this.type,
amount: amount, amount: amount,
duration: this.duration, duration: this.duration,
}); });
} };
}, },
} }
} }
</script> </script>
<style scoped> <style>
#control { #control {
border-radius: var(--corner-rounding); border-radius: var(--corner-rounding);
background-color: var(--card-colour); background-color: var(--card-colour);
justify-content: space-evenly; justify-content: space-evenly;
padding: 15px 15px 5px;
flex-direction: column;
align-items: center; align-items: center;
margin: 15px auto; margin: 15px auto;
flex-wrap: wrap; flex-wrap: wrap;
display: flex; display: flex;
padding: 15px 15px 5px;
width: 90%; width: 90%;
} }