Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapped KRadioButton groups in KRadioButtonGroup #12751

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 68 additions & 66 deletions kolibri/core/assets/src/views/UserTable/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,30 +84,31 @@
:key="user.id"
:style="isSelectedStyle(user.id)"
>
<td>
<KCheckbox
v-if="selectable && enableMultipleSelection"
:disabled="disabled"
:checked="userIsSelected(user.id)"
class="user-checkbox"
data-test="userCheckbox"
@change="selectUser(user.id, $event)"
>
<KLabeledIcon
:icon="isCoach ? 'coach' : 'person'"
:label="user.full_name"
data-test="fullName"
/>
<UserTypeDisplay
aria-hidden="true"
:userType="user.kind"
:omitLearner="true"
class="role-badge"
data-test="userRoleBadge"
:class="$computedClass(userRoleBadgeStyle)"
/>
</KCheckbox>
<!--
<KRadioButtonGroup>
<td>
<KCheckbox
v-if="selectable && enableMultipleSelection"
:disabled="disabled"
:checked="userIsSelected(user.id)"
class="user-checkbox"
data-test="userCheckbox"
@change="selectUser(user.id, $event)"
>
<KLabeledIcon
:icon="isCoach ? 'coach' : 'person'"
:label="user.full_name"
data-test="fullName"
/>
<UserTypeDisplay
aria-hidden="true"
:userType="user.kind"
:omitLearner="true"
class="role-badge"
data-test="userRoleBadge"
:class="$computedClass(userRoleBadgeStyle)"
/>
</KCheckbox>
<!--
@MisRob: It's possible to pass `<label>` content to `KRadioButton`
via the default slot, however it's not what this slot has been
made for so doing so is hackish, even though resulting
Expand All @@ -117,52 +118,53 @@
not providing label content. Reported related KDS issue
https://github.com/learningequality/kolibri-design-system/issues/348
-->
<KRadioButton
v-else-if="selectable && !enableMultipleSelection"
:disabled="disabled"
:buttonValue="user.id"
:currentValue="firstSelectedUser"
:label="''"
data-test="userRadioButton"
@change="selectSingleUser(user.id)"
>
<!--
<KRadioButton
v-else-if="selectable && !enableMultipleSelection"
:disabled="disabled"
:buttonValue="user.id"
:currentValue="firstSelectedUser"
:label="''"
data-test="userRadioButton"
@change="selectSingleUser(user.id)"
>
<!--
override muted color in the disabled state with
the normal text color in `style` (using `color`
prop won't work for this purpose)
-->
<KLabeledIcon
:icon="isCoach ? 'coach' : 'person'"
:label="user.full_name"
data-test="fullName"
:style="{ color: $themeTokens.text }"
/>
<UserTypeDisplay
aria-hidden="true"
:userType="user.kind"
:omitLearner="true"
class="role-badge"
data-test="userRoleBadge"
:class="$computedClass(userRoleBadgeStyle)"
/>
</KRadioButton>
<template v-else>
<KLabeledIcon
:icon="isCoach ? 'coach' : 'person'"
:label="user.full_name"
:style="{ color: $themeTokens.text }"
data-test="fullName"
/>
<UserTypeDisplay
aria-hidden="true"
:userType="user.kind"
:omitLearner="true"
class="role-badge"
data-test="userRoleBadge"
:class="$computedClass(userRoleBadgeStyle)"
/>
</template>
</td>
<KLabeledIcon
:icon="isCoach ? 'coach' : 'person'"
:label="user.full_name"
data-test="fullName"
:style="{ color: $themeTokens.text }"
/>
<UserTypeDisplay
aria-hidden="true"
:userType="user.kind"
:omitLearner="true"
class="role-badge"
data-test="userRoleBadge"
:class="$computedClass(userRoleBadgeStyle)"
/>
</KRadioButton>
<template v-else>
<KLabeledIcon
:icon="isCoach ? 'coach' : 'person'"
:label="user.full_name"
:style="{ color: $themeTokens.text }"
data-test="fullName"
/>
<UserTypeDisplay
aria-hidden="true"
:userType="user.kind"
:omitLearner="true"
class="role-badge"
data-test="userRoleBadge"
:class="$computedClass(userRoleBadgeStyle)"
/>
</template>
</td>
</KRadioButtonGroup>
<td
class="visuallyhidden"
data-test="userRoleLabel"
Expand Down
39 changes: 21 additions & 18 deletions kolibri/core/assets/src/views/sync/RadioButtonGroup.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
<template>

<div>
<KRadioButton
v-for="(item, idx) in items"
:key="idx"
:buttonValue="itemValue(item)"
:currentValue="currentValue"
:label="itemLabel(item)"
:description="description(item)"
v-bind="$attrs"
@input="$emit('update:currentValue', $event)"
>
<slot
v-if="showUnderButtonSlot(item)"
name="underbutton"
v-bind="{ selected }"
></slot>
</KRadioButton>
</div>
<KRadioButtonGroup>
<div>
<KRadioButton
v-for="(item, idx) in items"
:key="idx"
:buttonValue="itemValue(item)"
:currentValue="currentValue"
:label="itemLabel(item)"
:description="description(item)"
v-bind="$attrs"
@input="$emit('update:currentValue', $event)"
>
<slot
v-if="showUnderButtonSlot(item)"
name="underbutton"
v-bind="{ selected }"
>
</slot>
</KRadioButton>
</div>
</KRadioButtonGroup>

</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,24 @@
<!-- Static Devices -->
<template v-for="(d, idx) in savedDevices">
<div :key="`div-${idx}`">
<KRadioButton
:key="idx"
v-model="selectedDeviceId"
class="radio-button"
:buttonValue="d.id"
:label="d.nickname"
:description="d.base_url"
:disabled="formDisabled || !isDeviceAvailable(d.id)"
/>
<KButton
:key="`forget-${idx}`"
:text="coreString('removeAction')"
class="remove-device-button"
appearance="basic-link"
@click="removeSavedDevice(d.id)"
/>
<KRadioButtonGroup>
<KRadioButton
:key="idx"
v-model="selectedDeviceId"
class="radio-button"
:buttonValue="d.id"
:label="d.nickname"
:description="d.base_url"
:disabled="formDisabled || !isDeviceAvailable(d.id)"
/>
<KButton
:key="`forget-${idx}`"
:text="coreString('removeAction')"
class="remove-device-button"
appearance="basic-link"
@click="removeSavedDevice(d.id)"
/>
</KRadioButtonGroup>
</div>
</template>

Expand Down
46 changes: 24 additions & 22 deletions kolibri/core/assets/src/views/sync/SelectSyncSourceModal.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
<template>

<SelectSourceModal
:submitDisabled="formIsDisabled"
:showLoadingMessage="formIsDisabled && !initialDelay"
@submit="handleSubmit"
@cancel="handleCancel"
>
<KRadioButton
v-model="source"
:label="$tr('dataPortalLabel')"
:buttonValue="SyncSources.PORTAL"
:disabled="portalIsOffline || formIsDisabled"
:autofocus="!portalIsOffline"
:description="$tr('dataPortalDescription')"
/>
<KRadioButton
v-model="source"
:label="$tr('localNetworkLabel')"
:buttonValue="SyncSources.PEER"
:disabled="formIsDisabled"
:description="$tr('localNetworkDescription')"
/>
</SelectSourceModal>
<KRadioButtonGroup>
iamshobhraj marked this conversation as resolved.
Show resolved Hide resolved
<SelectSourceModal
:submitDisabled="formIsDisabled"
:showLoadingMessage="formIsDisabled && !initialDelay"
@submit="handleSubmit"
@cancel="handleCancel"
>
<KRadioButton
v-model="source"
:label="$tr('dataPortalLabel')"
:buttonValue="SyncSources.PORTAL"
:disabled="portalIsOffline || formIsDisabled"
:autofocus="!portalIsOffline"
:description="$tr('dataPortalDescription')"
/>
<KRadioButton
v-model="source"
:label="$tr('localNetworkLabel')"
:buttonValue="SyncSources.PEER"
:disabled="formIsDisabled"
:description="$tr('localNetworkDescription')"
/>
</SelectSourceModal>
</KRadioButtonGroup>

</template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,34 @@
{{ questionOrder$() }}
</h5>
<KGrid>
<KGridItem
:layout12="{ span: 6 }"
:layout8="{ span: 4 }"
:layout4="{ span: 2 }"
>
<KRadioButton
v-model="learners_see_fixed_order"
:label="randomizedLabel$()"
:buttonValue="false"
:description="randomizedOptionDescription$()"
/>
</KGridItem>
<KGridItem
:layout12="{ span: 6 }"
:layout8="{ span: 4 }"
:layout4="{ span: 2 }"
>
<KRadioButton
v-model="learners_see_fixed_order"
:label="fixedLabel$()"
:buttonValue="true"
:description="fixedOptionDescription$()"
/>
</KGridItem>
<KRadioButtonGroup>
<KGridItem
:layout12="{ span: 6 }"
:layout8="{ span: 4 }"
:layout4="{ span: 2 }"
>
<KRadioButton
v-model="learners_see_fixed_order"
:label="randomizedLabel$()"
:buttonValue="false"
:description="randomizedOptionDescription$()"
/>
</KGridItem>
</KRadioButtonGroup>
MisRob marked this conversation as resolved.
Show resolved Hide resolved
<KRadioButtonGroup>
<KGridItem
:layout12="{ span: 6 }"
:layout8="{ span: 4 }"
:layout4="{ span: 2 }"
>
<KRadioButton
v-model="learners_see_fixed_order"
:label="fixedLabel$()"
:buttonValue="true"
:description="fixedOptionDescription$()"
/>
</KGridItem>
</KRadioButtonGroup>
</KGrid>
</div>

Expand Down
Loading
Loading