Settings users list new user language

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-04-10 13:24:40 +02:00
parent 82e1f182c8
commit 8bca1558c3
No known key found for this signature in database
GPG key ID: 60C25B8C072916CF
5 changed files with 44 additions and 30 deletions

File diff suppressed because one or more lines are too long

View file

@ -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());
}
}

View file

@ -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);

View file

@ -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 }));
},

View file

@ -144,6 +144,7 @@ $serverData['sortGroups'] = $sortGroupsBy;
$serverData['quotaPreset'] = $quotaPreset;
$serverData['userCount'] = $userCount-$disabledUsers;
$serverData['languages'] = $languages;
$serverData['defaultLanguage'] = $config->getSystemValue('default_language', 'en');
// Settings
$serverData['defaultQuota'] = $defaultQuota;
$serverData['canChangePassword'] = $canChangePassword;