Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various improvements #1551

Merged
merged 13 commits into from
Oct 10, 2024
65 changes: 63 additions & 2 deletions src/components/lists/TaskList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
<th class="frames number-cell" ref="th-frames" v-if="isShots">
{{ $t('tasks.fields.frames') }}
</th>
<th class="difficulty number-cell" ref="th-difficulty">
{{ $t('tasks.fields.difficulty') }}
</th>
<th
ref="th-estimation"
class="estimation number-cell"
Expand Down Expand Up @@ -119,6 +122,25 @@
<td class="frames number-cell" v-if="isShots">
{{ getEntity(task.entity.id).nb_frames }}
</td>
<td class="difficulty number-cell">
<combobox
class="difficulty-combobox"
:options="difficultyOptions"
:with-margin="false"
:value="task.difficulty"
@input="updateDifficulty($event)"
v-if="isInDepartment(task) && selectionGrid[task.id]"
v-models="task.difficulty"
/>
<span
class="difficulty number-cell"
v-for="index in task.difficulty"
:key="task.id + 'difficulty' + index"
v-else
>
&bull;
</span>
</td>
<td class="estimation number-cell">
<input
class="input"
Expand Down Expand Up @@ -317,6 +339,7 @@ import {
import { formatListMixin } from '@/components/mixins/format'
import { domMixin } from '@/components/mixins/dom'

import Combobox from '@/components/widgets/Combobox.vue'
import DateField from '@/components/widgets/DateField.vue'
import EntityPreview from '@/components/widgets/EntityPreview.vue'
import EntityThumbnail from '@/components/widgets/EntityThumbnail.vue'
Expand All @@ -331,6 +354,7 @@ export default {
mixins: [domMixin, formatListMixin],

components: {
Combobox,
DateField,
EntityPreview,
EntityThumbnail,
Expand All @@ -342,6 +366,13 @@ export default {

data() {
return {
difficultyOptions: [
{ label: '•', value: 1 },
{ label: '••', value: 2 },
{ label: '•••', value: 3 },
{ label: '••••', value: 4 },
{ label: '•••••', value: 5 }
],
lastSelection: null,
page: 1,
selectionGrid: {},
Expand Down Expand Up @@ -531,7 +562,9 @@ export default {
return (
(data.start_date !== undefined && taskStart !== data.start_date) ||
(data.due_date !== undefined && taskDue !== data.due_date) ||
(data.estimation !== undefined && task.estimation !== data.estimation)
(data.estimation !== undefined &&
task.estimation !== data.estimation) ||
(data.difficulty !== undefined && task.difficulty !== data.difficulty)
)
},

Expand Down Expand Up @@ -560,7 +593,8 @@ export default {
Object.keys(this.selectionGrid).forEach(taskId => {
let data = {
start_date: null,
due_date: null
due_date: null,
difficulty: null
}
const task = this.taskMap.get(taskId)
const dueDate = task.due_date ? parseSimpleDate(task.due_date) : null
Expand All @@ -583,6 +617,9 @@ export default {
due_date: dueDate
}
}
if (task.difficulty) {
data.difficulty = task.difficulty
}
if (this.isTaskChanged(task, data)) {
this.updateTask({ taskId, data }).catch(console.error)
}
Expand Down Expand Up @@ -644,6 +681,20 @@ export default {
})
},

updateDifficulty(difficulty) {
this.updateTasksDifficulty({ difficulty })
},

updateTasksDifficulty({ difficulty }) {
Object.keys(this.selectionGrid).forEach(taskId => {
const task = this.taskMap.get(taskId)
const data = { difficulty }
if (this.isTaskChanged(task, data)) {
this.updateTask({ taskId, data }).catch(console.error)
}
})
},

formatDate(date) {
if (date) return moment(date).format('YYYY-MM-DD')
return ''
Expand Down Expand Up @@ -691,6 +742,16 @@ export default {
event.target &&
// Dirty hack needed to make date picker and inputs work properly
(['INPUT'].includes(event.target.nodeName) ||
// Combo box should not trigger selection
event.target.className.indexOf('selected-line') >= 0 ||
event.target.className.indexOf('down-icon') >= 0 ||
event.target.className.indexOf('flexrow') >= 0 ||
event.target.className.indexOf('c-mask') >= 0 ||
event.target.className.indexOf('option-line') >= 0 ||
event.target.className.indexOf('combobox') >= 0 ||
event.target.className === '' ||
(event.target.parentNode &&
['difficulty'].includes(event.target.className)) ||
(event.target.parentNode &&
['HEADER'].includes(event.target.parentNode.nodeName)) ||
['cell day selected'].includes(event.target.className))
Expand Down
58 changes: 58 additions & 0 deletions src/components/mixins/parameters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Helpers to apply and save parameters to the url and local storage.
*/
import preferences from '@/lib/preferences'

export const parametersMixin = {
methods: {
applyParametersToUrl() {
const query = Object.keys(this.parameters).reduce((acc, key) => {
if (this.parameters[key]) {
acc[key] = this.parameters[key]
if (acc[key] === 'true') {
acc[key] = true
} else if (acc[key] === 'false') {
acc[key] = false
}
}
return acc
}, {})
this.$router.replace({ query })
},

getParametersFromUrl() {
return this.$route.query
},

applyQueryParameters(params) {
const urlParams = this.getParametersFromUrl()
Object.assign(params, urlParams || {})
return params
},

saveParemetersToPreferences() {
preferences.setObjectPreference(
`parameters:{this.parameterNamespace}`,
this.parameters
)
},

getParametersFromPreferences(defaultParameters) {
return (
preferences.getObjectPreference(
`parameters:{this.parameterNamespace}`
) || defaultParameters
)
}
},

watch: {
parameters: {
deep: true,
handler() {
this.applyParametersToUrl()
this.saveParemetersToPreferences()
}
}
}
}
16 changes: 10 additions & 6 deletions src/components/mixins/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,10 @@ export const playerMixin = {
document.activeElement.blur()
this.fullScreen = false
setTimeout(() => {
window.dispatchEvent(new Event('resize'))
this.triggerResize()
}, 200)
setTimeout(() => {
window.dispatchEvent(new Event('resize'))
this.triggerResize()
}, 500)
},

Expand Down Expand Up @@ -763,10 +763,10 @@ export const playerMixin = {
if (this.fullScreen && !this.isFullScreen()) {
this.fullScreen = false
setTimeout(() => {
window.dispatchEvent(new Event('resize'))
this.triggerResize()
}, 200)
setTimeout(() => {
window.dispatchEvent(new Event('resize'))
this.triggerResize()
}, 500)
}
},
Expand Down Expand Up @@ -905,7 +905,7 @@ export const playerMixin = {

onFilmClicked() {
this.isEntitiesHidden = !this.isEntitiesHidden
window.dispatchEvent(new Event('resize'))
this.triggerResize()
this.$nextTick(() => {
this.resetHeight()
this.scrollToEntity(this.playingEntityIndex)
Expand Down Expand Up @@ -953,7 +953,7 @@ export const playerMixin = {
if (!this.isCommentsHidden) {
this.$refs['task-info'].$el.style.height = `${height}px`
}
window.dispatchEvent(new Event('resize'))
this.triggerResize()
this.$nextTick(() => {
this.$refs['task-info'].focusCommentTextarea()
this.resetHeight()
Expand Down Expand Up @@ -1422,6 +1422,10 @@ export const playerMixin = {
return resolve(file)
})
})
},

triggerResize() {
window.dispatchEvent(new Event('resize'))
}
},

Expand Down
1 change: 1 addition & 0 deletions src/components/modals/EditBackgroundModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
v-model.trim="form.name"
/>
<boolean-field
class="mb2"
:label="$t('backgrounds.fields.is_default')"
@enter="confirmClicked"
v-model="form.is_default"
Expand Down
1 change: 1 addition & 0 deletions src/components/modals/EditSearchFilterGroupModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<color-field :label="$t('main.color')" v-model="form.color" />

<boolean-field
class="mt1"
:label="$t('main.is_shared')"
v-model="form.is_shared"
v-if="isCurrentUserManager && currentProduction"
Expand Down
1 change: 1 addition & 0 deletions src/components/modals/EditSearchFilterModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
/>

<combobox
class="mt2"
:label="$t('main.filter_group')"
:options="allowedGroups"
v-model="form.search_filter_group_id"
Expand Down
7 changes: 7 additions & 0 deletions src/components/modals/EditTaskStatusModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,41 +42,48 @@
v-model="form.description"
/>
<boolean-field
class="mr05 mb05"
:label="$t('task_status.fields.is_default')"
@enter="confirmClicked"
v-model="form.is_default"
:disabled="form.for_concept === 'true'"
/>
<boolean-field
class="mr05 mb05"
:label="$t('task_status.fields.is_done')"
@enter="confirmClicked"
v-model="form.is_done"
v-if="form.is_default === 'false'"
/>
<boolean-field
class="mr05 mb05"
:label="$t('task_status.fields.is_retake')"
@enter="confirmClicked"
v-model="form.is_retake"
v-if="form.is_default === 'false'"
/>
<boolean-field
class="mr05 mb05"
:label="$t('task_status.fields.is_artist_allowed')"
@enter="confirmClicked"
v-model="form.is_artist_allowed"
/>
<boolean-field
class="mr05 mb05"
:label="$t('task_status.fields.is_client_allowed')"
@enter="confirmClicked"
v-model="form.is_client_allowed"
v-if="form.for_concept !== 'true'"
/>
<boolean-field
class="mr05 mb05"
:label="$t('task_status.fields.is_feedback_request')"
@enter="confirmClicked"
v-model="form.is_feedback_request"
v-if="form.is_default === 'false'"
/>
<color-field
class="mt2"
:label="$t('task_status.fields.color')"
:colors="colors"
v-model="form.color"
Expand Down
Loading