31
31
v-model =" item[r - 1]"
32
32
:disabled =" getLowestGranted(item) < r - 1"
33
33
color =" primary"
34
+ @update:model-value =" onCheckboxModified"
34
35
/>
35
36
<v-checkbox v-else v-model =" item[r - 1]" :disabled =" true" />
36
37
</td >
41
42
</template >
42
43
43
44
<script lang="ts">
44
- import { defineComponent , ref , Ref , watch , PropType } from " vue" ;
45
+ import { defineComponent , ref , Ref , PropType } from " vue" ;
45
46
import _ from " lodash" ;
46
47
import { granted } from " @/util/grants" ;
47
48
import { PERMISSIONS , ROLE_NAMES , Permission , Grants } from " ott-common/permissions" ;
@@ -62,10 +63,7 @@ export const PermissionsEditor = defineComponent({
62
63
emits: [" update:modelValue" ],
63
64
setup(props , { emit }) {
64
65
const permissions: Ref <Permission []> = ref ([]);
65
- const dirty = ref (false );
66
- const shouldAcceptExternalUpdate = ref (true );
67
66
const isLoading = ref (false );
68
- const updateEpoch = ref (0 );
69
67
70
68
const rolePerms = {
71
69
[Role .Moderator ]: " configure-room.set-permissions.for-moderator" ,
@@ -131,47 +129,22 @@ export const PermissionsEditor = defineComponent({
131
129
return new Grants (grants );
132
130
}
133
131
134
- watch (props , () => {
135
- if (shouldAcceptExternalUpdate .value ) {
136
- dirty .value = false ;
137
- updateEpoch .value ++ ;
138
- permissions .value = extractFromGrants (props .modelValue );
139
- } else {
140
- shouldAcceptExternalUpdate .value = true ;
141
- }
142
- });
143
-
144
- watch (
145
- permissions ,
146
- () => {
147
- if (! dirty .value ) {
148
- dirty .value = true ;
149
- shouldAcceptExternalUpdate .value = false ;
150
- permissions .value = extractFromGrants (rebuildMasks ());
151
- }
152
- },
153
- { deep: true }
154
- );
155
-
156
- watch (dirty , val => {
157
- if (val ) {
158
- emit (" update:modelValue" , rebuildMasks ());
159
- dirty .value = false ;
160
- }
161
- });
132
+ function onCheckboxModified() {
133
+ const masks = rebuildMasks ();
134
+ permissions .value = extractFromGrants (masks );
135
+ emit (" update:modelValue" , masks );
136
+ }
162
137
163
138
return {
164
139
permissions ,
165
- dirty ,
166
- shouldAcceptExternalUpdate ,
167
140
isLoading ,
168
- updateEpoch ,
169
141
granted ,
170
142
ROLE_NAMES ,
171
143
getLowestGranted ,
172
144
getHighestDenied ,
173
145
rolePerms ,
174
146
Role ,
147
+ onCheckboxModified ,
175
148
};
176
149
},
177
150
});
0 commit comments