Fix invalid limit parameter when fetching groups

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2018-07-04 12:05:30 +02:00
parent 42912a0e25
commit ba13880147
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
4 changed files with 11 additions and 3 deletions

View File

@ -60,7 +60,8 @@
<multiselect v-if="isLimitedToGroups(app)" :options="groups" :value="appGroups" @select="addGroupLimitation" @remove="removeGroupLimitation" :options-limit="5"
:placeholder="t('settings', 'Limit app usage to groups')"
label="name" track-by="id" class="multiselect-vue"
:multiple="true" :close-on-select="false">
:multiple="true" :close-on-select="false"
@search-change="asyncFindGroup">
<span slot="noResult">{{t('settings', 'No results')}}</span>
</multiselect>
</div>

View File

@ -54,6 +54,9 @@
}
},
methods: {
asyncFindGroup(query) {
return this.$store.dispatch('getGroups', {search: query, limit: 5, offset: 0});
},
isLimitedToGroups(app) {
if (this.app.groups.length || this.groupCheckedAppsData) {
return true;

View File

@ -74,6 +74,9 @@ const mutations = {
},
addGroup(state, {gid, displayName}) {
try {
if (typeof state.groups.find((group) => group.id === gid) !== 'undefined') {
return;
}
// extend group to default values
let group = Object.assign({}, defaults.group, {
id: gid,
@ -223,7 +226,8 @@ const actions = {
getGroups(context, { offset, limit, search }) {
search = typeof search === 'string' ? search : '';
return api.get(OC.linkToOCS(`cloud/groups?offset=${offset}&limit=${limit}&search=${search}`, 2))
let limitParam = limit === -1 ? '' : `&limit=${limit}`;
return api.get(OC.linkToOCS(`cloud/groups?offset=${offset}&search=${search}${limitParam}`, 2))
.then((response) => {
if (Object.keys(response.data.ocs.data.groups).length > 0) {
response.data.ocs.data.groups.forEach(function(group) {

View File

@ -73,7 +73,7 @@ export default {
beforeMount() {
this.$store.dispatch('getCategories');
this.$store.dispatch('getAllApps');
this.$store.dispatch('getGroups', {offset: 0, limit: -1});
this.$store.dispatch('getGroups', {offset: 0, limit: 5});
this.$store.commit('setUpdateCount', this.$store.getters.getServerData.updateCount)
},
mounted() {