event listener

This commit is contained in:
Tim Zieger 2020-05-27 15:30:18 +02:00
parent 8e2a8208f3
commit 95aaac09c8
5 changed files with 86 additions and 36 deletions

View File

@ -1,5 +1,5 @@
<template >
<v-container>
<v-container id = "createAccountListen">
<v-card align-center>
<h3 class="text-center display-2 logowhite--text">Details</h3>
@ -79,5 +79,15 @@ export default {
}
},
},
mounted() {
var listen = document.getElementById('createAccountListen');
listen.addEventListener("keyup", e => {
if (e.keyCode === 13) {
e.preventDefault();
this.addAccount();
}
});
}
};
</script>

View File

@ -1,5 +1,5 @@
<template >
<v-container>
<v-container id = "createRecordListen">
<v-card align-center>
<h3 class="text-center display-2 logowhite--text">Details</h3>
@ -45,7 +45,7 @@
</v-container>
</template>
<script>
import { baseUri} from "../variables";
import { baseUri } from "../variables";
export default {
name: "CreateTimeTrackAccount",
data: () => ({
@ -58,38 +58,46 @@ export default {
methods: {
addRecord() {
var account ="";
var accountxhttp = new XMLHttpRequest();
var account = "";
var accountxhttp = new XMLHttpRequest();
accountxhttp.onreadystatechange = function() {
if ((this.status == 200) & (this.readyState == 4)) {
//account =
account =JSON.parse(accountxhttp.responseText)
account = account._links.self.href;
}
};
accountxhttp.open("GET", baseUri + "/accounts/search/findByUsernameAndName?username=" + sessionStorage.getItem("username")+ "&account=" +this.accountname, false);
accountxhttp.setRequestHeader("Content-Type", "application/json");
accountxhttp.onreadystatechange = function() {
if ((this.status == 200) & (this.readyState == 4)) {
//account =
accountxhttp.setRequestHeader("Authorization", sessionStorage.getItem("jwt"));
accountxhttp.send( null );
if (this.newstartdate != "" && this.newenddate != "" && this.newdate != "" && account != "" ) {
account = JSON.parse(accountxhttp.responseText);
account = account._links.self.href;
}
};
accountxhttp.open(
"GET",
baseUri +
"/accounts/search/findByUsernameAndName?username=" +
sessionStorage.getItem("username") +
"&account=" +
this.accountname,
false
);
accountxhttp.setRequestHeader("Content-Type", "application/json");
accountxhttp.setRequestHeader(
"Authorization",
sessionStorage.getItem("jwt")
);
accountxhttp.send(null);
if (
this.newstartdate != "" &&
this.newenddate != "" &&
this.newdate != "" &&
account != ""
) {
var xhttp = new XMLHttpRequest();
var suc;
xhttp.onreadystatechange = function() {
if ((this.status == 201) & (this.readyState == 4)) {
suc = true;
suc = true;
}
};
xhttp.open("POST", baseUri + "/records", false);
@ -108,11 +116,22 @@ export default {
account +
'"}'
);
if(suc == true){
this.$router.push( "/timerecords");
if (suc == true) {
this.$router.push("/timerecords");
}
}
},
}
},
mounted() {
var listen = document.getElementById('createRecordListen');
listen.addEventListener("keyup", e => {
if (e.keyCode === 13) {
e.preventDefault();
this.addRecord();
}
});
}
};
</script>

View File

@ -1,5 +1,5 @@
<template >
<v-container>
<v-container id = "editAccountListen">
<v-card align-center>
<div class="text-center ma-3">
<h2 class="text-center display-2 logowhite--text">Account to edit:</h2>
@ -115,6 +115,16 @@ export default {
this.newrevenue = account.revenue;
this.newdescription = account.description;
},
mounted() {
var listen = document.getElementById('editAccountListen');
listen.addEventListener("keyup", e => {
if (e.keyCode === 13) {
e.preventDefault();
this.editAccount();
}
});
}
};
</script>

View File

@ -1,5 +1,5 @@
<template >
<v-container>
<v-container id="editRecordListen">
<v-card align-center>
@ -111,6 +111,16 @@ export default {
this.newstartdate = record.startdate;
this.newenddate = record.enddate;
},
mounted() {
var listen = document.getElementById('editRecordListen');
listen.addEventListener("keyup", e => {
if (e.keyCode === 13) {
e.preventDefault();
this.editRecord();
}
});
}
};
</script>

View File

@ -1,5 +1,5 @@
<template >
<v-container class="fill-height">
<v-container class="fill-height" id="signInListen">
<v-row align="center" justify="center">
<v-col cols="12">
<v-card elevation="0">
@ -171,7 +171,8 @@ export default {
}
},
mounted(){
window.addEventListener('keyup', (e) => {
var listen = document.getElementById('signInListen');
listen.addEventListener('keyup', (e) => {
if (e.keyCode === 13) {
e.preventDefault();
if(this.step==1){