Skip to content

Commit

Permalink
Merge pull request #1216 from NicoPennec/fix/comment
Browse files Browse the repository at this point in the history
Improve task comments
  • Loading branch information
NicoPennec authored Oct 11, 2023
2 parents 48764fd + a793c42 commit efbbaae
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 106 deletions.
105 changes: 93 additions & 12 deletions src/components/modals/EditCommentModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,40 @@
<label class="label">
{{ $t('comments.text') }}
</label>
<at-ta :members="team" name-key="full_name" limit="2">
<at-ta
:members="atOptions"
name-key="full_name"
limit="2"
@input="onAtTextChanged"
>
<template slot="item" slot-scope="team">
<div class="flexrow">
<people-avatar
class="flexrow-item"
:person="team.item"
:size="20"
/>
<span class="flexrow-item">
{{ team.item.full_name }}
<template v-if="team.item.isTime"> ⏱️ frame </template>
<template v-else-if="team.item.isDepartment">
<span
class="mr05"
:style="{
background: team.item.color,
width: '10px',
height: '10px',
'border-radius': '50%'
}"
>
&nbsp;
</span>
</div>
{{ team.item.full_name }}
</template>
<template v-else>
<div class="flexrow">
<people-avatar
class="flexrow-item"
:person="team.item"
:size="20"
/>
<span class="flexrow-item">
{{ team.item.full_name }}
</span>
</div>
</template>
</template>

<textarea
Expand Down Expand Up @@ -126,8 +148,10 @@
<script>
import { mapGetters } from 'vuex'
import { modalMixin } from '@/components/modals/base_modal'
import { remove } from '@/lib/models'
import files from '@/lib/files'
import { remove } from '@/lib/models'
import { replaceTimeWithTimecode } from '@/lib/render'
import { XIcon } from 'vue-feather-icons'
Expand Down Expand Up @@ -171,6 +195,18 @@ export default {
team: {
type: Array,
default: () => []
},
fps: {
type: Number,
default: 25
},
revision: {
type: Number,
default: 1
},
time: {
type: Number,
default: 0
}
},
Expand All @@ -187,7 +223,12 @@ export default {
},
computed: {
...mapGetters(['taskStatusForCurrentUser'])
...mapGetters([
'departmentMap',
'isCurrentUserClient',
'productionDepartmentIds',
'taskStatusForCurrentUser'
])
},
methods: {
Expand Down Expand Up @@ -257,6 +298,17 @@ export default {
for (let i = 0; i < this.form.checklist.length; i++) {
this.form.checklist[i].index = i
}
},
onAtTextChanged(input) {
if (input.includes('@frame')) {
this.form.text = replaceTimeWithTimecode(
input,
this.revision,
this.time,
this.fps
)
}
}
},
Expand All @@ -272,6 +324,35 @@ export default {
this.$refs.textField.focus()
}, 100)
}
},
team: {
deep: true,
immediate: true,
handler() {
if (this.isCurrentUserClient) {
this.atOptions = this.team.filter(person =>
['admin', 'manager', 'supervisor', 'client'].includes(person.role)
)
} else {
this.atOptions = [...this.team]
}
this.atOptions = this.atOptions.concat(
this.productionDepartmentIds.map(departmentId => {
const department = this.departmentMap.get(departmentId)
return {
isDepartment: true,
full_name: department.name,
color: department.color,
id: departmentId
}
})
)
this.atOptions.push({
isTime: true,
full_name: 'frame'
})
}
}
}
}
Expand Down
40 changes: 22 additions & 18 deletions src/components/pages/Task.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@
:revision="currentRevision"
@add-comment="addComment"
@add-preview="onAddPreviewClicked"
@duplicate-comment="onDuplicateComment"
@file-drop="selectFile"
@clear-files="clearPreviewFiles"
@annotation-snapshots-requested="extractAnnotationSnapshots"
Expand All @@ -214,10 +213,14 @@
(comment.person && user.id === comment.person.id) ||
isCurrentUserAdmin
"
:fps="parseInt(currentFps)"
:time="currentTime"
:revision="currentRevision"
:is-first="index === 0"
:is-last="index === pinnedCount"
:is-change="isStatusChange(index)"
@ack-comment="ackComment"
@duplicate-comment="onDuplicateComment"
@pin-comment="onPinComment"
@edit-comment="onEditComment"
@delete-comment="onDeleteComment"
Expand Down Expand Up @@ -277,6 +280,9 @@
:is-error="errors.editComment"
:comment-to-edit="commentToEdit"
:team="currentTeam"
:fps="parseInt(currentFps)"
:time="currentTime"
:revision="currentRevision"
@confirm="confirmEditTaskComment"
@cancel="onCancelEditComment"
/>
Expand Down Expand Up @@ -412,17 +418,6 @@ export default {
})
},
beforeDestroy() {
if (this.$refs['add-comment']) {
const task = this.getTask()
const lastComment = `${this.$refs['add-comment'].text}`
const previousDraft = drafts.getTaskDraft(task.id)
if (lastComment !== previousDraft && !this.$options.drafted) {
drafts.setTaskDraft(task.id, lastComment)
}
}
},
computed: {
...mapGetters([
'currentEpisode',
Expand Down Expand Up @@ -519,11 +514,11 @@ export default {
},
currentFps() {
return this.productionMap.get(this.task.project_id).fps || '25'
return this.productionMap.get(this.task?.project_id)?.fps || '25'
},
currentRevision() {
return this.currentPreview ? this.currentPreview.revision : 0
return this.currentPreview?.revision || 0
},
isCommentingAllowed() {
Expand Down Expand Up @@ -755,6 +750,7 @@ export default {
'deleteTaskPreview',
'deleteTaskComment',
'editTaskComment',
'loadComment',
'loadEpisodes',
'loadTask',
'loadShots',
Expand Down Expand Up @@ -792,7 +788,7 @@ export default {
.catch(callback)
}
}
loadingFunction(() => {
return loadingFunction(() => {
this.task = task
return this.loadTaskComments({
taskId: task.id,
Expand All @@ -801,7 +797,6 @@ export default {
.then(() => {
this.reset()
this.taskLoading = { isLoading: false, isError: false }
return Promise.resolve()
})
.catch(err => {
console.error(err)
Expand All @@ -822,12 +817,14 @@ export default {
})
.then(() => {
this.reset()
return Promise.resolve()
})
.catch(err => {
console.error(err)
this.taskLoading.isError = true
})
.finally(() => {
this.taskLoading.isLoading = false
})
}
},
Expand Down Expand Up @@ -1324,6 +1321,14 @@ export default {
}, 1000)
},
'comment:update'(eventData) {
const commentId = eventData.comment_id
if (!this.taskComments.some(({ id }) => id === commentId)) {
return
}
this.loadComment({ commentId }).catch(console.error)
},
'comment:reply'(eventData) {
if (this.task) {
const comment = this.taskComments.find(
Expand All @@ -1336,7 +1341,6 @@ export default {
)
if (!hasReply) {
this.refreshComment({
taskId: this.task.id,
commentId: eventData.comment_id
})
.then(remoteComment => {
Expand Down
45 changes: 19 additions & 26 deletions src/components/sides/TaskInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@
(comment.person && user.id === comment.person.id) ||
isCurrentUserAdmin
"
:fps="parseInt(currentFps)"
:time="isPreview ? currentTime : currentTimeRaw"
:revision="currentRevision"
@duplicate-comment="onDuplicateComment"
@pin-comment="onPinComment"
@edit-comment="onEditComment"
Expand Down Expand Up @@ -221,6 +224,9 @@
:is-error="errors.editComment"
:comment-to-edit="commentToEdit"
:team="currentTeam"
:fps="parseInt(currentFps)"
:time="isPreview ? currentTime : currentTimeRaw"
:revision="currentRevision"
@confirm="confirmEditTaskComment"
@cancel="onCancelEditComment"
/>
Expand Down Expand Up @@ -404,13 +410,6 @@ export default {
},
mounted() {
if (this.$refs['add-comment']) {
const draft = drafts.getTaskDraft(this.task.id)
if (draft) {
this.$refs['add-comment'].text = draft
}
}
if (this.sideColumnParent) {
const panelWidth =
preferences.getIntPreference('task:panel-width') || DEFAULT_PANEL_WIDTH
Expand Down Expand Up @@ -703,6 +702,7 @@ export default {
'deleteTaskComment',
'deleteTaskPreview',
'editTaskComment',
'loadComment',
'loadPreviewFileFormData',
'loadTask',
'loadTaskComments',
Expand Down Expand Up @@ -795,7 +795,7 @@ export default {
this.currentPreviewDlPath = this.getOriginalDlPath()
this.resetDraft()
this.$nextTick(() => {
if (this.$refs['add-comment']) this.$refs['add-comment'].focus()
this.focusCommentTextarea()
})
}
},
Expand Down Expand Up @@ -1255,23 +1255,6 @@ export default {
task() {
this.previewForms = []
this.currentPreviewIndex = 0
if (this.previousTaskId && this.$refs['add-comment']) {
const lastComment = `${this.$refs['add-comment'].text}`
const previousDraft = drafts.getTaskDraft(this.previousTaskId)
if (
(this.$refs['add-comment'].text.length > 0 || previousDraft) &&
this.$refs['add-comment'].text !== previousDraft
) {
drafts.setTaskDraft(this.previousTaskId, lastComment)
}
}
this.$nextTick(() => {
if (this.task) this.previousTaskId = this.task.id
if (this.task && this.$refs['add-comment']) {
const draft = drafts.getTaskDraft(this.task.id)
if (draft) this.$refs['add-comment'].text = draft
}
})
if (!this.silent) {
this.loadTaskData()
}
Expand Down Expand Up @@ -1341,6 +1324,17 @@ export default {
}, 1000)
},
'comment:update'(eventData) {
const commentId = eventData.comment_id
if (
!this.task &&
!this.taskComments.some(({ id }) => id === commentId)
) {
return
}
this.loadComment({ commentId }).catch(console.error)
},
'comment:acknowledge'(eventData) {
this.onRemoteAcknowledge(eventData, 'ack')
},
Expand All @@ -1359,7 +1353,6 @@ export default {
const reply = comment.replies.find(r => r.id === eventData.reply_id)
if (!reply) {
this.refreshComment({
taskId: this.task.id,
commentId: eventData.comment_id
})
.then(remoteComment => {
Expand Down
Loading

0 comments on commit efbbaae

Please sign in to comment.