Skip to content

Commit

Permalink
Merge pull request #1493 from NicoPennec/fix/settings-form
Browse files Browse the repository at this point in the history
Fix Settings form
  • Loading branch information
EvanBldy authored Jul 16, 2024
2 parents 710065b + f8e791c commit e9b0abb
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 48 deletions.
3 changes: 1 addition & 2 deletions src/components/lists/TimesheetList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ export default {
'px'
this.disabledDates = {
to:
this.isCurrentUserArtist &&
this.organisation.timesheets_locked === 'true'
this.isCurrentUserArtist && this.organisation.timesheets_locked
? moment().subtract(1, 'weeks').toDate() // Disable dates older than one week
: undefined,
from: moment().toDate() // Disable dates after today
Expand Down
4 changes: 1 addition & 3 deletions src/components/pages/Edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,7 @@ export default {
this.$on('annotation-changed', this.onAnnotationChanged)
this.$options.scrubbing = false
this.isHd = this.organisation
? this.organisation.hd_by_default === 'true'
: false
this.isHd = Boolean(this.organisation.hd_by_default)
if (this.picturePlayer) {
this.picturePlayer.addEventListener('load', async () => {
const wasPlaying = this.isPlaying
Expand Down
8 changes: 7 additions & 1 deletion src/components/pages/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,13 @@ export default {
if (this.checkWebhook()) {
this.loading.save = true
this.errors.save = false
this.saveOrganisation(this.form)
const organisation = {
...this.form,
hd_by_default: this.form.hd_by_default === 'true',
timesheets_locked: this.form.timesheets_locked === 'true',
use_original_file_name: this.form.use_original_file_name === 'true'
}
this.saveOrganisation(organisation)
.catch(err => {
console.error(err)
this.errors.save = true
Expand Down
4 changes: 1 addition & 3 deletions src/components/pages/playlists/PlaylistPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1064,9 +1064,7 @@ export default {
mounted() {
this.$options.scrubbing = false
this.isHd = this.organisation
? this.organisation.hd_by_default === 'true'
: false
this.isHd = Boolean(this.organisation.hd_by_default)
if (this.entities) {
this.entityList = Object.values(this.entities)
} else {
Expand Down
4 changes: 1 addition & 3 deletions src/components/previews/PreviewPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1058,9 +1058,7 @@ export default {
const isMuted = localPreferences.getBoolPreference('player:muted')
this.isRepeating = isRepeating
this.isMuted = isMuted
this.isHd = this.organisation
? this.organisation.hd_by_default === 'true'
: false
this.isHd = Boolean(this.organisation.hd_by_default)
},
focus() {
Expand Down
8 changes: 0 additions & 8 deletions src/lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ const auth = {
} else {
const user = res.body.user
const organisation = res.body.organisation || {}
organisation.use_original_file_name =
organisation.use_original_file_name ? 'true' : 'false'
organisation.timesheets_locked = organisation.timesheets_locked
? 'true'
: 'false'
organisation.hd_by_default = organisation.hd_by_default
? 'true'
: 'false'
store.commit(SET_ORGANISATION, organisation)
store.commit(USER_LOGIN, user)
callback(null)
Expand Down
29 changes: 5 additions & 24 deletions src/store/api/people.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,17 @@ import client from '@/store/api/client'
import { buildQueryString } from '@/lib/query'

export default {
getOrganisation() {
return client.pget('/api/data/organisations').then(organisations => {
let organisation = {
name: 'Kitsu',
hours_by_day: 8,
has_avatar: false,
use_original_file_name: false,
timesheets_locked: false,
chat_token_slack: '',
chat_webhook_mattermost: '',
chat_token_discord: ''
}
if (organisations.length > 0) organisation = organisations[0]
organisation.use_original_file_name = organisation.use_original_file_name
? 'true'
: 'false'
organisation.timesheets_locked = organisation.timesheets_locked
? 'true'
: 'false'
Promise.resolve(organisation)
})
getOrganisations() {
return client.pget('/api/data/organisations')
},

updateOrganisation(organisation) {
const data = {
name: organisation.name,
hours_by_day: organisation.hours_by_day,
timesheets_locked: organisation.timesheets_locked === 'true',
use_original_file_name: organisation.use_original_file_name === 'true',
hd_by_default: organisation.hd_by_default === 'true',
timesheets_locked: organisation.timesheets_locked,
use_original_file_name: organisation.use_original_file_name,
hd_by_default: organisation.hd_by_default,
chat_token_slack: organisation.chat_token_slack,
chat_webhook_mattermost: organisation.chat_webhook_mattermost,
chat_token_discord: organisation.chat_token_discord,
Expand Down
9 changes: 5 additions & 4 deletions src/store/modules/people.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ const initialState = {
name: 'Kitsu',
hours_by_day: 8,
has_avatar: false,
use_original_file_name: 'false',
timesheets_locked: 'false'
hd_by_default: false,
timesheets_locked: false,
use_original_file_name: false
},

people: [],
Expand Down Expand Up @@ -218,8 +219,8 @@ const getters = {

const actions = {
async getOrganisation({ commit }) {
const organisation = await peopleApi.getOrganisation()
commit(SET_ORGANISATION, organisation)
const organisations = await peopleApi.getOrganisations()
commit(SET_ORGANISATION, organisations[0])
},

async saveOrganisation({ commit }, form) {
Expand Down

0 comments on commit e9b0abb

Please sign in to comment.