aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/forum-element.js37
-rw-r--r--src/components/mao-forums.js2
2 files changed, 33 insertions, 6 deletions
diff --git a/src/components/forum-element.js b/src/components/forum-element.js
index 138cc6a..1c2585b 100644
--- a/src/components/forum-element.js
+++ b/src/components/forum-element.js
@@ -15,7 +15,7 @@ import { connect } from 'pwa-helpers/connect-mixin.js';
import { store } from '../store.js';
//These are the actions needed by this element.
-import { adminApproveHours, adminRejectHours } from '../actions/firebaseAdmin.js';
+import { createComment } from '../actions/firebaseFirestore';
// Import button styles
import { ButtonSharedStyles } from './button-shared-styles.js';
@@ -82,21 +82,21 @@ class ForumElement extends connect(store)(LitElement) {
</div>
<div class="card-actions">
<div class="button-grid">
- <paper-button class="info" raised onclick="${() => this.showComments = !this.showComments}">Show Comments</paper-button>
- <paper-button raised onclick="${() => this.postComment = !this.postComment}">${this.postComment? "Hide Draft" : "Post Comment"}</paper-button>
+ <paper-button class="info" onclick="${() => this.showComments = !this.showComments}">Show Comments</paper-button>
+ <paper-button class="alert" onclick="${() => this.postComment = !this.postComment}">${this.postComment? "Hide Draft" : "Post Comment"}</paper-button>
</div>
<div hidden="${!props.postComment}">
<hr>
<paper-input label="Comment Subject" id="comment-subject-field"></paper-input>
<paper-textarea label="Comment Content" id="comment-content-field"></paper-textarea>
- <paper-button class="success">Submit Comment</paper-comment>
+ <paper-button raised class="success" onclick="${() => this.submitComment()}">Submit Comment</paper-comment>
</div>
<div hidden="${!props.showComments}">
<hr hidden="${!props.showComments && !props.postComment}">
<h4>Comments</h4>
-
+
</div>
</div>
</div>
@@ -110,6 +110,9 @@ class ForumElement extends connect(store)(LitElement) {
author: String,
subject: String,
content: String,
+ postId: String,
+
+ comments: Array,
showComments: Boolean,
postComment: Boolean
@@ -127,11 +130,33 @@ class ForumElement extends connect(store)(LitElement) {
this.author = "";
this.subject = "";
this.content = "";
+ this.postId = "";
+
+ this.comments = [];
this.showComments = false;
this.postComment = false;
}
-
+
+ submitComment() {
+ var commentSubject = this.shadowRoot.getElementById('comment-subject-field');
+ var commentContent = this.shadowRoot.getElementById('comment-content-field');
+ //commentContent.value.replace('\n','<br>')
+ if( commentSubject &&
+ commentSubject.value.trim().length > 0 &&
+ commentContent.value.trim().length > 0) {
+ if(confirm('Are you sure you want to submit this comment on ' + this.author + "'s post about " + this.subject + '?')) {
+ store.dispatch(createComment(this.postId, commentSubject.value, commentContent.value));
+
+ commentSubject.value = "";
+ commentContent.value = "";
+ }
+ } else {
+ console.log(this.comments);
+ alert('Please fill out comment subject and content fields.');
+ }
+
+ }
}
window.customElements.define('forum-element', ForumElement);
diff --git a/src/components/mao-forums.js b/src/components/mao-forums.js
index b85fa26..1d1b5f6 100644
--- a/src/components/mao-forums.js
+++ b/src/components/mao-forums.js
@@ -153,6 +153,8 @@ class MaoForums extends connect(store)(PageViewElement) {
forumElement.author = this.forumPosts[i].email .replace('@communityschoolnaples.org', '');
forumElement.subject = this.forumPosts[i].subject;
forumElement.content = this.forumPosts[i].content;
+ forumElement.postId = this.forumPosts[i].postId;
+ forumElement.comments = this.forumPosts[i].comments;
postsGrid.appendChild(forumElement);
}