client: fix token-generate-window component

This commit is contained in:
Johann150 2022-12-18 20:42:05 +01:00
parent 639fa74d43
commit c411669133
Signed by untrusted user: Johann150
GPG key ID: 9EE6577A2A06F8F1

View file

@ -23,7 +23,7 @@
<div style="margin-bottom: 16px;"><b>{{ i18n.ts.permission }}</b></div> <div style="margin-bottom: 16px;"><b>{{ i18n.ts.permission }}</b></div>
<MkButton inline @click="disableAll">{{ i18n.ts.disableAll }}</MkButton> <MkButton inline @click="disableAll">{{ i18n.ts.disableAll }}</MkButton>
<MkButton inline @click="enableAll">{{ i18n.ts.enableAll }}</MkButton> <MkButton inline @click="enableAll">{{ i18n.ts.enableAll }}</MkButton>
<FormSwitch v-for="kind in (initialPermissions || kinds)" :key="kind" v-model="permissions[kind]">{{ i18n.t(`_permissions.${kind}`) }}</FormSwitch> <FormSwitch v-for="kind in kinds" :key="kind" v-model="permissions[kind]">{{ i18n.t(`_permissions.${kind}`) }}</FormSwitch>
</div> </div>
</XModalWindow> </XModalWindow>
</template> </template>
@ -57,16 +57,15 @@ const emit = defineEmits<{
let dialog: InstanceType<typeof XModalWindow> | null = $ref(null); let dialog: InstanceType<typeof XModalWindow> | null = $ref(null);
let name = $ref(props.initialName); let name = $ref(props.initialName);
let perms: Record<string, boolean> = $ref({}); let perms: Record<string, boolean> = $ref({});
const kinds = $ref(permissions); let kinds = props.initialPermissions.length > 0
? props.initialPermissions
: permissions;
if (props.initialPermissions.length > 0) { // If there is a particular set of permissions given, enable all of them.
for (const kind of props.initialPermissions) { // Otherwise, by default disable all permissions.
perms[kind] = true; const enable = props.initialPermissions.length > 0;
} for (const kind of kinds) {
} else { perms[kind] = enable;
for (const kind of kinds) {
perms[kind] = false;
}
} }
function ok(): void { function ok(): void {