From 01f7cf44d47ac1fa48068cfb7d7e5f8acc94c59c Mon Sep 17 00:00:00 2001 From: Michael Foiani Date: Mon, 30 Jul 2018 11:57:23 -0400 Subject: Now clears fields on sumbit buttons and fixed some formatting isuues with two cards. --- src/components/mao-tutoring.js | 99 +++++++++++++----------------------------- 1 file changed, 31 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/components/mao-tutoring.js b/src/components/mao-tutoring.js index 85aac99..04b7b1d 100644 --- a/src/components/mao-tutoring.js +++ b/src/components/mao-tutoring.js @@ -47,17 +47,6 @@ class MaoTutoring extends connect(store)(PageViewElement) { ${ButtonSharedStyles}
-

Tutoring

- - -
-
- - -
`; } static get properties() { return { // This is the data from the store. - signedIn: Boolean, - authMessage: String, - hours: Number, - requestedHours: Number, + signedIn: Boolean, + authMessage: String, + hours: Number, + requestedHours: Number, submitFieldsOpened: Boolean }} @@ -265,23 +230,6 @@ class MaoTutoring extends connect(store)(PageViewElement) { this.authMessage = state.firebase.authMessage; this.sumbitFieldsOpened = false; - - if(this.signedIn) { - this.toggleShowingCard(); - } - } - - logIn() { - const email = this.shadowRoot.getElementById('emailField') .value + - '@communityschoolnaples.org'; - const password = this.shadowRoot.getElementById('passwordField') .value; - - store.dispatch(signIn(email,password)); - } - - toggleShowingCard() { - - this.shadowRoot.getElementById('tutoring-grid').style = 'grid-template-areas: "title" "card2";'; } toggleSubmitFields() { @@ -289,14 +237,29 @@ class MaoTutoring extends connect(store)(PageViewElement) { } requestHours() { - - if(confirm('Are you sure that you want to send this request for hours?')) { - const timeHours = (this.shadowRoot.getElementById('timeField') .value) - /60; - const traineeName = this.shadowRoot.getElementById('traineeField').value; - const date = this.shadowRoot.getElementById('dateField') .value; - - store.dispatch(requestHours(timeHours, traineeName, date)); + if(this.shadowRoot) { + var timeElement = this.shadowRoot.getElementById('timeField'); + var traineeElement = this.shadowRoot.getElementById('traineeField'); + var dateElement = this.shadowRoot.getElementById('dateField') + + if( timeElement .value.trim() === "" || + traineeElement .value.trim() === "" || + dateElement .value === "") { + alert("Please fill out all fields when making hours request."); + } else { + if(confirm('Are you sure that you want to send this request for hours?')) { + const timeHours = (timeElement .value) + /60; + const traineeName = traineeElement.value; + const date = dateElement .value; + + store.dispatch(requestHours(timeHours, traineeName, date)); + + timeElement .value = ""; + traineeElement .value = ""; + dateElement .value = ""; + } + } } } -- cgit v1.2.3-70-g09d2