Fix invalid limit parameter when fetching groups
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
parent
42912a0e25
commit
ba13880147
4 changed files with 11 additions and 3 deletions
|
@ -60,7 +60,8 @@
|
||||||
<multiselect v-if="isLimitedToGroups(app)" :options="groups" :value="appGroups" @select="addGroupLimitation" @remove="removeGroupLimitation" :options-limit="5"
|
<multiselect v-if="isLimitedToGroups(app)" :options="groups" :value="appGroups" @select="addGroupLimitation" @remove="removeGroupLimitation" :options-limit="5"
|
||||||
:placeholder="t('settings', 'Limit app usage to groups')"
|
:placeholder="t('settings', 'Limit app usage to groups')"
|
||||||
label="name" track-by="id" class="multiselect-vue"
|
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>
|
<span slot="noResult">{{t('settings', 'No results')}}</span>
|
||||||
</multiselect>
|
</multiselect>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -54,6 +54,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
asyncFindGroup(query) {
|
||||||
|
return this.$store.dispatch('getGroups', {search: query, limit: 5, offset: 0});
|
||||||
|
},
|
||||||
isLimitedToGroups(app) {
|
isLimitedToGroups(app) {
|
||||||
if (this.app.groups.length || this.groupCheckedAppsData) {
|
if (this.app.groups.length || this.groupCheckedAppsData) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -74,6 +74,9 @@ const mutations = {
|
||||||
},
|
},
|
||||||
addGroup(state, {gid, displayName}) {
|
addGroup(state, {gid, displayName}) {
|
||||||
try {
|
try {
|
||||||
|
if (typeof state.groups.find((group) => group.id === gid) !== 'undefined') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// extend group to default values
|
// extend group to default values
|
||||||
let group = Object.assign({}, defaults.group, {
|
let group = Object.assign({}, defaults.group, {
|
||||||
id: gid,
|
id: gid,
|
||||||
|
@ -223,7 +226,8 @@ const actions = {
|
||||||
|
|
||||||
getGroups(context, { offset, limit, search }) {
|
getGroups(context, { offset, limit, search }) {
|
||||||
search = typeof search === 'string' ? 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) => {
|
.then((response) => {
|
||||||
if (Object.keys(response.data.ocs.data.groups).length > 0) {
|
if (Object.keys(response.data.ocs.data.groups).length > 0) {
|
||||||
response.data.ocs.data.groups.forEach(function(group) {
|
response.data.ocs.data.groups.forEach(function(group) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ export default {
|
||||||
beforeMount() {
|
beforeMount() {
|
||||||
this.$store.dispatch('getCategories');
|
this.$store.dispatch('getCategories');
|
||||||
this.$store.dispatch('getAllApps');
|
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)
|
this.$store.commit('setUpdateCount', this.$store.getters.getServerData.updateCount)
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
Loading…
Reference in a new issue