Merge branch '94-action-listener-for-butttons' into 'master'

Resolve "Action listener for Butttons"

Closes #94

See merge request marcel.schwarz/2020ss-qbc-geofence-timetracking!74
This commit is contained in:
Tim Zieger 2020-05-27 13:53:33 +00:00
commit 08b996308f
5 changed files with 86 additions and 36 deletions

View File

@ -1,5 +1,5 @@
<template > <template >
<v-container> <v-container id = "createAccountListen">
<v-card align-center> <v-card align-center>
<h3 class="text-center display-2 logowhite--text">Details</h3> <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> </script>

View File

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

View File

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

View File

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

View File

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