chore: add prettier frontent linter

This commit is contained in:
Oleg Lobanov
2021-03-21 12:51:58 +01:00
parent a721dc1f31
commit c44b37c50c
73 changed files with 18898 additions and 4499 deletions

View File

@@ -3,18 +3,31 @@
<div class="column">
<form class="card" @submit="updateSettings">
<div class="card-title">
<h2>{{ $t('settings.profileSettings') }}</h2>
<h2>{{ $t("settings.profileSettings") }}</h2>
</div>
<div class="card-content">
<p><input type="checkbox" v-model="hideDotfiles"> {{ $t('settings.hideDotfiles') }}</p>
<p><input type="checkbox" v-model="singleClick"> {{ $t('settings.singleClick') }}</p>
<h3>{{ $t('settings.language') }}</h3>
<languages class="input input--block" :locale.sync="locale"></languages>
<p>
<input type="checkbox" v-model="hideDotfiles" />
{{ $t("settings.hideDotfiles") }}
</p>
<p>
<input type="checkbox" v-model="singleClick" />
{{ $t("settings.singleClick") }}
</p>
<h3>{{ $t("settings.language") }}</h3>
<languages
class="input input--block"
:locale.sync="locale"
></languages>
</div>
<div class="card-action">
<input class="button button--flat" type="submit" :value="$t('buttons.update')">
<input
class="button button--flat"
type="submit"
:value="$t('buttons.update')"
/>
</div>
</form>
</div>
@@ -22,16 +35,32 @@
<div class="column">
<form class="card" v-if="!user.lockPassword" @submit="updatePassword">
<div class="card-title">
<h2>{{ $t('settings.changePassword') }}</h2>
<h2>{{ $t("settings.changePassword") }}</h2>
</div>
<div class="card-content">
<input :class="passwordClass" type="password" :placeholder="$t('settings.newPassword')" v-model="password" name="password">
<input :class="passwordClass" type="password" :placeholder="$t('settings.newPasswordConfirm')" v-model="passwordConf" name="password">
<input
:class="passwordClass"
type="password"
:placeholder="$t('settings.newPassword')"
v-model="password"
name="password"
/>
<input
:class="passwordClass"
type="password"
:placeholder="$t('settings.newPasswordConfirm')"
v-model="passwordConf"
name="password"
/>
</div>
<div class="card-action">
<input class="button button--flat" type="submit" :value="$t('buttons.update')">
<input
class="button button--flat"
type="submit"
:value="$t('buttons.update')"
/>
</div>
</form>
</div>
@@ -39,75 +68,80 @@
</template>
<script>
import { mapState, mapMutations } from 'vuex'
import { users as api } from '@/api'
import Languages from '@/components/settings/Languages'
import { mapState, mapMutations } from "vuex";
import { users as api } from "@/api";
import Languages from "@/components/settings/Languages";
export default {
name: 'settings',
name: "settings",
components: {
Languages
Languages,
},
data: function () {
return {
password: '',
passwordConf: '',
password: "",
passwordConf: "",
hideDotfiles: false,
singleClick: false,
locale: ''
}
locale: "",
};
},
computed: {
...mapState([ 'user' ]),
passwordClass () {
const baseClass = 'input input--block'
...mapState(["user"]),
passwordClass() {
const baseClass = "input input--block";
if (this.password === '' && this.passwordConf === '') {
return baseClass
if (this.password === "" && this.passwordConf === "") {
return baseClass;
}
if (this.password === this.passwordConf) {
return `${baseClass} input--green`
return `${baseClass} input--green`;
}
return `${baseClass} input--red`
}
return `${baseClass} input--red`;
},
},
created () {
this.locale = this.user.locale
this.hideDotfiles = this.user.hideDotfiles
this.singleClick = this.user.singleClick
created() {
this.locale = this.user.locale;
this.hideDotfiles = this.user.hideDotfiles;
this.singleClick = this.user.singleClick;
},
methods: {
...mapMutations([ 'updateUser' ]),
async updatePassword (event) {
event.preventDefault()
...mapMutations(["updateUser"]),
async updatePassword(event) {
event.preventDefault();
if (this.password !== this.passwordConf || this.password === '') {
return
if (this.password !== this.passwordConf || this.password === "") {
return;
}
try {
const data = { id: this.user.id, password: this.password }
await api.update(data, ['password'])
this.updateUser(data)
this.$showSuccess(this.$t('settings.passwordUpdated'))
const data = { id: this.user.id, password: this.password };
await api.update(data, ["password"]);
this.updateUser(data);
this.$showSuccess(this.$t("settings.passwordUpdated"));
} catch (e) {
this.$showError(e)
this.$showError(e);
}
},
async updateSettings (event) {
event.preventDefault()
async updateSettings(event) {
event.preventDefault();
try {
const data = { id: this.user.id, locale: this.locale, hideDotfiles: this.hideDotfiles, singleClick: this.singleClick }
await api.update(data, ['locale', 'hideDotfiles', 'singleClick'])
this.updateUser(data)
this.$showSuccess(this.$t('settings.settingsUpdated'))
const data = {
id: this.user.id,
locale: this.locale,
hideDotfiles: this.hideDotfiles,
singleClick: this.singleClick,
};
await api.update(data, ["locale", "hideDotfiles", "singleClick"]);
this.updateUser(data);
this.$showSuccess(this.$t("settings.settingsUpdated"));
} catch (e) {
this.$showError(e)
this.$showError(e);
}
}
}
}
},
},
};
</script>