Skip to content

Commit

Permalink
Displaying posts from an analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
JmScherer committed Nov 27, 2023
1 parent 28d41d3 commit b34f5a2
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 7 deletions.
64 changes: 61 additions & 3 deletions frontend/src/components/AnalysisView/DiscussionPost.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,69 @@
<template>
<div>
Post
<div class="discussion-post">
<div class="discussion-header">
<b>{{ author_name }}</b>
{{ timestamp }}
</div>
<div class="discussion-content">
{{ content }}
</div>
</div>
</template>

<script>
export default {
name: "discussion-post",

Check failure on line 15 in frontend/src/components/AnalysisView/DiscussionPost.vue

View workflow job for this annotation

GitHub Actions / nodejs-ci (20.8)

Expected indentation of 2 spaces but found 4

Check failure on line 15 in frontend/src/components/AnalysisView/DiscussionPost.vue

View workflow job for this annotation

GitHub Actions / nodejs-ci (20.8)

Strings must use singlequote
props: {

Check failure on line 16 in frontend/src/components/AnalysisView/DiscussionPost.vue

View workflow job for this annotation

GitHub Actions / nodejs-ci (20.8)

Expected indentation of 2 spaces but found 4
id: {

Check failure on line 17 in frontend/src/components/AnalysisView/DiscussionPost.vue

View workflow job for this annotation

GitHub Actions / nodejs-ci (20.8)

Expected indentation of 4 spaces but found 8
type: String

Check failure on line 18 in frontend/src/components/AnalysisView/DiscussionPost.vue

View workflow job for this annotation

GitHub Actions / nodejs-ci (20.8)

Expected indentation of 6 spaces but found 12

Check failure on line 18 in frontend/src/components/AnalysisView/DiscussionPost.vue

View workflow job for this annotation

GitHub Actions / nodejs-ci (20.8)

Missing trailing comma
},

Check failure on line 19 in frontend/src/components/AnalysisView/DiscussionPost.vue

View workflow job for this annotation

GitHub Actions / nodejs-ci (20.8)

Expected indentation of 4 spaces but found 8
author_id: {

Check failure on line 20 in frontend/src/components/AnalysisView/DiscussionPost.vue

View workflow job for this annotation

GitHub Actions / nodejs-ci (20.8)

Expected indentation of 4 spaces but found 8
type: String

Check failure on line 21 in frontend/src/components/AnalysisView/DiscussionPost.vue

View workflow job for this annotation

GitHub Actions / nodejs-ci (20.8)

Expected indentation of 6 spaces but found 12

Check failure on line 21 in frontend/src/components/AnalysisView/DiscussionPost.vue

View workflow job for this annotation

GitHub Actions / nodejs-ci (20.8)

Missing trailing comma
},
author_name: {
type: String
},
publish_timestamp: {
type: String
},
content: {
type: String
},
attachments: {
type: Array,
default: () => {
return [];
},
},
thread: {
type: Array,
default: () => {
return [];
},
},
},
computed: {
timestamp: function() {
return new Date(this.publish_timestamp).toUTCString()
}
}
}
</script>
</script>

<style scoped>
.discussion-post {
display: flex;
flex-wrap: wrap;
}
.discussion-header {
margin-top: var(--p-10);
margin-bottom: var(--p-10);
}
.discussion-content {
margin-bottom: var(--p-10);
}
</style>
37 changes: 33 additions & 4 deletions frontend/src/components/AnalysisView/DiscussionSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
<div class="rosalution-section-seperator"></div>
<div class="section-content">
<div class="discussion-new-post">
<div contenteditable="plaintext-only" class="discussion-new-post-text-area">
</div>
<textarea
contenteditable="plaintext-only"
class="discussion-new-post-text-area"
v-model="newPostContent"
/>
<div class="discussion-actions">
<button class="secondary-button" @click="cancelNewDiscussionPost">
Cancel
Expand All @@ -23,25 +26,51 @@
</button>
</div>
</div>
<DiscussionPost v-for="discussion in discussions"
:id="discussion.post_id"
:author_id="discussion.author_id"
:author_name="discussion.author_fullname"
:publish_timestamp="discussion.publish_timestamp"
:content="discussion.content"
:attachments="discussion.attachments"
:thread="discussion.thread"
/>
</div>
</div>
</template>

<script>
import DiscussionPost from './DiscussionPost.vue';
export default {
name: 'discussion-section',
emits: ['discussion:new-post'],
components: {
DiscussionPost
},
props: {
header: {
type: String,
},
discussions: {
type: Array,
default: () => {
return [];
},
},
},
data: function() {
return {
newPostContent: '',
}
},
methods: {
newDiscussionPost() {
console.log("Publishing Post!")
this.$emit('discussion:new-post', this.newPostContent)
},
cancelNewDiscussionPost() {
console.log("Cancelled post");
}
},
}
};
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/stores/authStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const authStore = {
getUsername() {
return this.state.username;
},
getClientId() {
return this.state.clientId;
},
hasWritePermissions() {
return this.hasRole('write');
},
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/views/AnalysisView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
/>
<DiscussionSection
id="Discussion"
:discussions="this.discussions"
@discussion:new-post="this.addDiscussionPost"
/>
<SupplementalFormList
id="Supporting_Evidence"
Expand Down Expand Up @@ -205,6 +207,9 @@ export default {
attachments() {
return this.analysis.supporting_evidence_files;
},
discussions() {
return this.analysis.discussions;
},
genomicUnitsList() {
return this.analysis.genomic_units;
},
Expand Down Expand Up @@ -605,7 +610,16 @@ export default {
await notificationDialog.title('Failure').confirmText('Ok').alert(error);
}
},
addDiscussionPost(newPostContent) {
const newPostObject = {
author_id: this.auth.getClientId(),
author_name: this.auth.getUsername(),
publish_timestamp: new Date().toISOString(),
content: newPostContent,
}
console.log(newPostObject)
},
copyToClipboard(copiedText) {
toast.success(`Copied ${copiedText} to clipboard!`);
},
Expand Down

0 comments on commit b34f5a2

Please sign in to comment.