Reset and init new user form language

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2019-08-13 08:46:22 +02:00 committed by npmbuildbot[bot]
parent cbc82a9449
commit c6d664a817
3 changed files with 47 additions and 30 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -141,6 +141,28 @@ import { Multiselect } from 'nextcloud-vue'
import InfiniteLoading from 'vue-infinite-loading'; import InfiniteLoading from 'vue-infinite-loading';
import Vue from 'vue'; import Vue from 'vue';
const unlimitedQuota = {
id: 'none',
label: t('settings', 'Unlimited')
}
const defaultQuota = {
id: 'default',
label: t('settings', 'Default quota')
}
const newUser = {
id: '',
displayName: '',
password: '',
mailAddress: '',
groups: [],
subAdminsGroups: [],
quota: defaultQuota,
language: {
code: 'en',
name: t('settings', 'Default language')
}
}
export default { export default {
name: 'userList', name: 'userList',
props: ['users', 'showConfig', 'selectedGroup', 'externalActions'], props: ['users', 'showConfig', 'selectedGroup', 'externalActions'],
@ -150,27 +172,16 @@ export default {
InfiniteLoading InfiniteLoading
}, },
data() { data() {
let unlimitedQuota = {id:'none', label:t('settings', 'Unlimited')},
defaultQuota = {id:'default', label:t('settings', 'Default quota')};
return { return {
unlimitedQuota: unlimitedQuota, unlimitedQuota,
defaultQuota: defaultQuota, defaultQuota,
loading: { loading: {
all: false, all: false,
groups: false groups: false
}, },
scrolled: false, scrolled: false,
searchQuery: '', searchQuery: '',
newUser: { newUser: Object.assign({}, newUser)
id:'',
displayName:'',
password:'',
mailAddress:'',
groups: [],
subAdminsGroups: [],
quota: defaultQuota,
language: {code: 'en', name: t('settings', 'Default language')}
}
}; };
}, },
mounted() { mounted() {
@ -179,17 +190,9 @@ export default {
} }
/** /**
* Init default language from server data. The use of this.settings * Reset and init new user form
* requires a computed variable, which break the v-model binding of the form,
* this is a much easier solution than getter and setter on a computed var
*/ */
Vue.set(this.newUser.language, 'code', this.settings.defaultLanguage); this.resetForm()
/**
* In case the user directly loaded the user list within a group
* the watch won't be triggered. We need to initialize it.
*/
this.setNewUserDefaultGroup(this.selectedGroup);
/** /**
* Register search * Register search
@ -338,9 +341,23 @@ export default {
resetForm() { resetForm() {
// revert form to original state // revert form to original state
Object.assign(this.newUser, this.$options.data.call(this).newUser); this.newUser = Object.assign({}, newUser);
// reset group
/**
* Init default language from server data. The use of this.settings
* requires a computed variable, which break the v-model binding of the form,
* this is a much easier solution than getter and setter on a computed var
*/
if (this.settings.defaultLanguage) {
Vue.set(this.newUser.language, 'code', this.settings.defaultLanguage);
}
/**
* In case the user directly loaded the user list within a group
* the watch won't be triggered. We need to initialize it.
*/
this.setNewUserDefaultGroup(this.selectedGroup); this.setNewUserDefaultGroup(this.selectedGroup);
this.loading.all = false; this.loading.all = false;
}, },
createUser() { createUser() {