Newer
Older

robinwilliam.hundt
committed
<template>
<div class="dialog-box">
<div v-if="commentDisplayable" class="body elevation-1" :style="{borderColor: borderColor, backgroundColor}">

robinwilliam.hundt
committed
<span class="tip tip-up" :style="{borderBottomColor: borderColor}"></span>
<span v-if="ofTutor" class="of-tutor">Of tutor: {{ofTutor}}</span>

robinwilliam.hundt
committed
<span class="comment-created">{{parsedCreated}}</span>
<div class="visibility-icon" v-if="showVisibilityIcon">
<v-tooltip top v-if="visibleToStudent" size="20px">
<v-icon
slot="activator"
size="20px"
>visibility</v-icon>
<span>Will be visible to student</span>
</v-tooltip>
<v-tooltip top v-else>
<v-icon
slot="activator"
size="20px">visibility_off</v-icon>
<span>Won't be visible to student</span>
</v-tooltip>
</div>

robinwilliam.hundt
committed
<div class="message">{{text}}</div>
<v-btn

robinwilliam.hundt
committed
class="delete-button"
v-if="deletable"
@click.stop="toggleDeleteComment"
>
<v-icon
v-if="!markedForDeletion.hasOwnProperty(this.pk)"
color="grey darken-1" size="20px">delete_forever</v-icon>
<v-icon v-else size="20px">restore</v-icon>
</v-btn>

robinwilliam.hundt
committed
</div>
<v-layout v-if="showLabels" ml-2>
<v-flex sm4>
<v-flex sm12>
UNCHANGED
</v-flex>
<feedback-label
removable
v-for="label in unchangedLabels"
v-bind="label"
:key="label.pk"
@remove-clicked="deleteAction"
/>
</v-flex>
<v-flex sm4>
<v-flex sm12>
WILL BE REMOVED
</v-flex>
<feedback-label
removable
v-for="label in removedLabels"
v-bind="label"
:key="label.pk"
@remove-clicked="deleteAction"
/>
</v-flex>
<v-flex sm4>
<v-flex sm12>
WILL BE ADDED
</v-flex>
<feedback-label
removable
v-for="label in addedLabels"
v-bind="label"
:key="label.pk"
@remove-clicked="deleteAction"
/>
</v-flex>
</v-layout>

robinwilliam.hundt
committed
</div>
</template>
<script>
import { mapState } from 'vuex'
import { UI } from '@/store/modules/ui'
import { SubmissionNotes } from '@/store/modules/submission-notes'
import FeedbackLabel from "@/components/feedback_labels/FeedbackLabel.vue"
import { FeedbackLabels as Labels } from '@/store/modules/feedback-labels'
import commentLabelSelector from "@/components/mixins/commentLabelSelector"
export default {
name: 'feedback-comment',
components: {
FeedbackLabel,
},
mixins: [
commentLabelSelector,
],
props: {
pk: {
type: String,
required: false
},
text: {
type: String,
required: true
},
type: String,
required: false
},
type: String,
required: false
},
lineNo: {
type: String,
required: true
},
deletable: {
type: Boolean,
default: false
},
type: Boolean,
default: true
},
type: Boolean,
default: true
commentDisplayable () { return this.text !== "" },
showLabels () {
return this.visibleToStudent &&
(this.getUnchangedLabels().length > 0 ||
this.getAddedLabels().length > 0 ||
this.getRemovedLabels().length > 0)
},
markedForDeletion () { return SubmissionNotes.state.commentsMarkedForDeletion },
if (this.modified) {
return new Date(this.modified).toLocaleString()
} else {
return 'Just now'

robinwilliam.hundt
committed
}
},
borderColor () {
if (this.pk) {
return this.markedForDeletion.hasOwnProperty(this.pk) ? '#B5B5B5' : '#3D8FC1'
return UI.state.darkMode ? 'grey' : '#F3F3F3'
unchangedLabels() {
return this.mapPksToLabelObj(this.getUnchangedLabels())
},
addedLabels() {
return this.mapPksToLabelObj(this.getAddedLabels())
},
removedLabels() {
return this.mapPksToLabelObj(this.getRemovedLabels())
}
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
deleteAction (pk) {
let labels
const concated = this.getUnchangedLabels().concat(this.getAddedLabels())
if (this.getUnchangedLabels().includes(pk)) {
labels = concated.filter((val) => {
return val !== pk
})
} else if (this.getAddedLabels().includes(pk)) {
labels = concated.filter((val) => {
return val !== pk
})
} else if (this.getRemovedLabels().includes(pk)) {
concated.push(pk)
labels = concated
}
if (labels.length > 0 || SubmissionNotes.state.hasOrigFeedback || this.commentDisplayable) {
SubmissionNotes.UPDATE_FEEDBACK_LINE({
lineNo: Number(this.lineNo),
comment: {
text: this.text || "",
labels: labels,
}
})
} else {
SubmissionNotes.DELETE_FEEDBACK_LINE(Number(this.lineNo))
}
},
toggleDeleteComment () {
if (this.pk) {
if (!this.markedForDeletion.hasOwnProperty(this.pk)) {
SubmissionNotes.MARK_COMMENT_FOR_DELETION({ pk: this.pk })
SubmissionNotes.UN_MARK_COMMENT_FOR_DELETION({ pk: this.pk })

robinwilliam.hundt
committed
}
SubmissionNotes.DELETE_FEEDBACK_LINE(this.lineNo)

robinwilliam.hundt
committed
}
}

robinwilliam.hundt
committed
</script>
<style scoped>
.tip {
width: 0px;
height: 0px;
position: absolute;
background: transparent;
border: 10px solid;
}
.tip-up {
top: -22px; /* Same as body margin top + border */
left: 10px;
border-right-color: transparent;
border-left-color: transparent;
border-top-color: transparent;
}
.dialog-box .body {

robinwilliam.hundt
committed
position: relative;
height: auto;
margin: 20px 10px 10px 10px;
padding: 5px;
border-radius: 0px;
border: 2px solid;
}
.body .message {
min-height: 30px;
border-radius: 3px;
font-size: 14px;
line-height: 1.5;
white-space: pre-wrap;
}
.delete-button {

robinwilliam.hundt
committed
}
.comment-created {
position: absolute;
font-size: 10px;
right: 4px;
top: -20px;
}
.of-tutor {
position: absolute;
font-size: 13px;
top: -20px;
left: 50px;
}
.visibility-icon {
position: absolute;
top: -4px;
left: -34px;
}