Skip to content

Commit d8f2b3f

Browse files
authored
Merge pull request #3316 from nextcloud/fix/admin-settings
fix(settings): properly handle loading state
2 parents 8a53fd3 + 3cbf8fc commit d8f2b3f

1 file changed

Lines changed: 15 additions & 19 deletions

File tree

src/FormsSettings.vue

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
<div>
88
<NcSettingsSection :name="t('forms', 'Form creation')">
99
<NcCheckboxRadioSwitch
10-
ref="switchRestrictCreation"
1110
v-model="appConfig.restrictCreation"
1211
class="forms-settings__creation__switch"
12+
:loading="loading.restrictCreation"
1313
type="switch"
1414
@update:modelValue="onRestrictCreationChange">
1515
{{ t('forms', 'Restrict form creation to selected groups') }}
@@ -26,22 +26,22 @@
2626
</NcSettingsSection>
2727
<NcSettingsSection :name="t('forms', 'Form sharing')">
2828
<NcCheckboxRadioSwitch
29-
ref="switchAllowPublicLink"
3029
v-model="appConfig.allowPublicLink"
30+
:loading="loading.allowPublicLink"
3131
type="switch"
3232
@update:modelValue="onAllowPublicLinkChange">
3333
{{ t('forms', 'Allow sharing by link') }}
3434
</NcCheckboxRadioSwitch>
3535
<NcCheckboxRadioSwitch
36-
ref="switchAllowPermitAll"
3736
v-model="appConfig.allowPermitAll"
37+
:loading="loading.allowPermitAll"
3838
type="switch"
3939
@update:modelValue="onAllowPermitAllChange">
4040
{{ t('forms', 'Allow sharing to all logged in accounts') }}
4141
</NcCheckboxRadioSwitch>
4242
<NcCheckboxRadioSwitch
43-
ref="switchAllowShowToAll"
4443
v-model="appConfig.allowShowToAll"
44+
:loading="loading.allowShowToAll"
4545
type="switch"
4646
@update:modelValue="onAllowShowToAllChange">
4747
{{
@@ -78,6 +78,7 @@ export default {
7878
return {
7979
appConfig: loadState(appName, 'appConfig'),
8080
availableGroups: loadState(appName, 'availableGroups'),
81+
loading: {},
8182
}
8283
},
8384
@@ -92,41 +93,36 @@ export default {
9293
* @param {boolean|Array} newVal The resp. new Value to store.
9394
*/
9495
async onRestrictCreationChange(newVal) {
95-
const el = this.$refs.switchRestrictCreation
96-
el.loading = true
96+
this.loading.restrictCreation = true
9797
await this.saveAppConfig('restrictCreation', newVal)
98-
el.loading = false
98+
this.loading.restrictCreation = false
9999
},
100100
101101
async onCreationAllowedGroupsChange(newVal) {
102-
const el = this.$refs.switchRestrictCreation
103-
el.loading = true
102+
this.loading.creationAllowedGroups = true
104103
await this.saveAppConfig(
105104
'creationAllowedGroups',
106105
newVal.map((group) => group.groupId),
107106
)
108-
el.loading = false
107+
this.loading.creationAllowedGroups = false
109108
},
110109
111110
async onAllowPublicLinkChange(newVal) {
112-
const el = this.$refs.switchAllowPublicLink
113-
el.loading = true
111+
this.loading.allowPublicLink = true
114112
await this.saveAppConfig('allowPublicLink', newVal)
115-
el.loading = false
113+
this.loading.allowPublicLink = false
116114
},
117115
118116
async onAllowPermitAllChange(newVal) {
119-
const el = this.$refs.switchAllowPermitAll
120-
el.loading = true
117+
this.loading.allowPermitAll = true
121118
await this.saveAppConfig('allowPermitAll', newVal)
122-
el.loading = false
119+
this.loading.allowPermitAll = false
123120
},
124121
125122
async onAllowShowToAllChange(newVal) {
126-
const el = this.$refs.switchAllowShowToAll
127-
el.loading = true
123+
this.loading.allowShowToAll = true
128124
await this.saveAppConfig('allowShowToAll', newVal)
129-
el.loading = false
125+
this.loading.allowShowToAll = false
130126
},
131127
132128
/**

0 commit comments

Comments
 (0)