diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-04-10 13:24:40 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-05-16 09:50:21 +0200 |
commit | 8bca1558c3d4056c1bfcb746516f9394fc93f09f (patch) | |
tree | c36aa5ab51c514159c2b5a4efc4b05f4281f0ea2 /settings/src | |
parent | 82e1f182c826b3a586cef59e9a4e90e1a4b9eb1f (diff) | |
download | nextcloud-server-8bca1558c3d4056c1bfcb746516f9394fc93f09f.tar.gz nextcloud-server-8bca1558c3d4056c1bfcb746516f9394fc93f09f.zip |
Settings users list new user language
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'settings/src')
-rw-r--r-- | settings/src/components/userList.vue | 39 | ||||
-rw-r--r-- | settings/src/components/userList/userRow.vue | 16 | ||||
-rw-r--r-- | settings/src/store/users.js | 10 |
3 files changed, 39 insertions, 26 deletions
diff --git a/settings/src/components/userList.vue b/settings/src/components/userList.vue index ed5be1f6adf..62040b1c33f 100644 --- a/settings/src/components/userList.vue +++ b/settings/src/components/userList.vue @@ -73,7 +73,13 @@ @tag="validateQuota" > </multiselect> </div> - <div class="languages" v-if="showConfig.showLanguages"></div> + <div class="languages" v-if="showConfig.showLanguages"> + <multiselect :options="languages" v-model="newUser.language" + :placeholder="t('settings', 'Default language')" + label="name" track-by="code" class="multiselect-vue" + :allowEmpty="false" group-values="languages" group-label="label"> + </multiselect> + </div> <div class="storageLocation" v-if="showConfig.showStoragePath"></div> <div class="userBackend" v-if="showConfig.showUserBackend"></div> <div class="lastLogin" v-if="showConfig.showLastLogin"></div> @@ -86,7 +92,7 @@ </form> <user-row v-for="(user, key) in filteredUsers" :user="user" :key="key" :settings="settings" :showConfig="showConfig" - :groups="groups" :subAdminsGroups="subAdminsGroups" :quotaOptions="quotaOptions" /> + :groups="groups" :subAdminsGroups="subAdminsGroups" :quotaOptions="quotaOptions" :languages="languages" /> <infinite-loading @infinite="infiniteHandler" ref="infiniteLoading"> <div slot="spinner"><div class="users-icon-loading icon-loading"></div></div> <div slot="no-more"><div class="users-list-end">— {{t('settings', 'no more results')}} —</div></div> @@ -104,6 +110,7 @@ import userRow from './userList/userRow'; import Multiselect from 'vue-multiselect'; import InfiniteLoading from 'vue-infinite-loading'; +import Vue from 'vue'; export default { name: 'userList', @@ -128,14 +135,21 @@ export default { mailAddress:'', groups: [], subAdminsGroups: [], - quota: defaultQuota + quota: defaultQuota, + language: {code: 'en', name: t('settings', 'Default language')} } }; }, mounted() { if (!this.settings.canChangePassword) { - OC.Notification.showTemporary(t('settings','Password change is disabled because the master key is disabled')); + OC.Notification.showTemporary(t('settings', 'Password change is disabled because the master key is disabled')); } + /** + * Init default language from server data. The use of this.settings + * requires a computed variable,vwhich break the v-model binding of the form, + * this is a much easier solution than getter and setter + */ + Vue.set(this.newUser.language, 'code', this.settings.defaultLanguage); }, computed: { settings() { @@ -190,6 +204,20 @@ export default { } } return ''; + }, + + /* LANGUAGES */ + languages() { + return Array( + { + label: t('settings', 'Common languages'), + languages: this.settings.languages.commonlanguages + }, + { + label: t('settings', 'All languages'), + languages: this.settings.languages.languages + } + ); } }, watch: { @@ -240,7 +268,8 @@ export default { email: this.newUser.mailAddress, groups: this.newUser.groups.map(group => group.id), subadmin: this.newUser.subAdminsGroups.map(group => group.id), - quota: this.newUser.quota.id + quota: this.newUser.quota.id, + language: this.newUser.language.code, }).then(() => this.resetForm()); } } diff --git a/settings/src/components/userList/userRow.vue b/settings/src/components/userList/userRow.vue index 9aa4fb3b852..e4915bd5b23 100644 --- a/settings/src/components/userList/userRow.vue +++ b/settings/src/components/userList/userRow.vue @@ -89,7 +89,7 @@ import Multiselect from 'vue-multiselect'; export default { name: 'userRow', - props: ['user', 'settings', 'groups', 'subAdminsGroups', 'quotaOptions', 'showConfig'], + props: ['user', 'settings', 'groups', 'subAdminsGroups', 'quotaOptions', 'showConfig', 'languages'], components: { popoverMenu, Multiselect @@ -175,19 +175,7 @@ export default { return this.$store.getters.getPasswordPolicyMinLength; }, - /* LANGUAGES */ - languages() { - return Array( - { - label: t('settings', 'Common languages'), - languages: this.settings.languages.commonlanguages - }, - { - label: t('settings', 'All languages'), - languages: this.settings.languages.languages - } - ); - }, + /* LANGUAGE */ userLanguage() { let availableLanguages = this.languages[0].languages.concat(this.languages[1].languages); let userLang = availableLanguages.find(lang => lang.code === this.user.language); diff --git a/settings/src/store/users.js b/settings/src/store/users.js index 61bda9c0603..cf418f81ca3 100644 --- a/settings/src/store/users.js +++ b/settings/src/store/users.js @@ -342,14 +342,10 @@ const actions = { * @param {string} options.quota User email * @returns {Promise} */ - addUser({context, dispatch}, { userid, password, email, groups, subadmin, quota }) { - console.log(subadmin, quota); + addUser({context, dispatch}, { userid, password, email, groups, subadmin, quota, language }) { return api.requireAdmin().then((response) => { - return api.post(OC.linkToOCS(`cloud/users`, 2), { userid, password, email, groups, subadmin, quota }) - .then((response) => { - //let quotaDis = dispatch('setUserData', { userid, key: 'quota', value:quota }); - //let subadminDis = dispatch('addUserSubAdmin', userid); - }) + return api.post(OC.linkToOCS(`cloud/users`, 2), { userid, password, email, groups, subadmin, quota, language }) + .then((response) => dispatch('addUserData', userid)) .catch((error) => {throw error;}); }).catch((error) => context.commit('API_FAILURE', { userid, error })); }, |