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

fix(admin): fix toggle and tristate input elements not working correctly #278

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
22 changes: 14 additions & 8 deletions views/js/backend/admin/src/components/pdk/PsToggleInput.vue
FlorianSDV marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<template>
<div class="input-container">
<input
:id="id"
v-model="model"
:name="id"
type="hidden" />

Check warning on line 8 in views/js/backend/admin/src/components/pdk/PsToggleInput.vue

View check run for this annotation

Codecov / codecov/patch

views/js/backend/admin/src/components/pdk/PsToggleInput.vue#L3-L8

Added lines #L3 - L8 were not covered by tests
<div class="input-group">
<span class="ps-switch">
<input
:id="id"
v-model="model"
:id="toggleId"
v-model="toggleModel"

Check warning on line 13 in views/js/backend/admin/src/components/pdk/PsToggleInput.vue

View check run for this annotation

Codecov / codecov/patch

views/js/backend/admin/src/components/pdk/PsToggleInput.vue#L12-L13

Added lines #L12 - L13 were not covered by tests
:disabled="element.isDisabled || element.isSuspended || element.isReadOnly"
:readonly="element.isReadOnly"
:value="true"
tabindex="-1"
type="checkbox" />

<label
:for="id"
:for="toggleId"

Check warning on line 21 in views/js/backend/admin/src/components/pdk/PsToggleInput.vue

View check run for this annotation

Codecov / codecov/patch

views/js/backend/admin/src/components/pdk/PsToggleInput.vue#L21

Added line #L21 was not covered by tests
class="!mypa-opacity-100"
role="label">
{{ translate(`toggle_${model ? 'yes' : 'no'}`) }}
{{ translate(`toggle_${toggleModel ? 'yes' : 'no'}`) }}

Check warning on line 24 in views/js/backend/admin/src/components/pdk/PsToggleInput.vue

View check run for this annotation

Codecov / codecov/patch

views/js/backend/admin/src/components/pdk/PsToggleInput.vue#L24

Added line #L24 was not covered by tests
</label>

<span class="slide-button" />
Expand All @@ -25,13 +31,13 @@
</template>

<script lang="ts" setup>
import {useLanguage, type PdkElementProps, type PdkElementEmits, useElementContext} from '@myparcel-pdk/admin';
import {useLanguage, type ToggleInputProps, type ToggleInputEmits, useToggleInputContext} from '@myparcel-pdk/admin';

Check warning on line 34 in views/js/backend/admin/src/components/pdk/PsToggleInput.vue

View check run for this annotation

Codecov / codecov/patch

views/js/backend/admin/src/components/pdk/PsToggleInput.vue#L34

Added line #L34 was not covered by tests

// eslint-disable-next-line vue/no-unused-properties
const props = defineProps<PdkElementProps<boolean>>();
const emit = defineEmits<PdkElementEmits<boolean>>();
const props = defineProps<ToggleInputProps>();
const emit = defineEmits<ToggleInputEmits>();

Check warning on line 38 in views/js/backend/admin/src/components/pdk/PsToggleInput.vue

View check run for this annotation

Codecov / codecov/patch

views/js/backend/admin/src/components/pdk/PsToggleInput.vue#L37-L38

Added lines #L37 - L38 were not covered by tests

const {id, model} = useElementContext(props, emit);
const {id, model, toggleId, toggleModel} = useToggleInputContext(props, emit);

Check warning on line 40 in views/js/backend/admin/src/components/pdk/PsToggleInput.vue

View check run for this annotation

Codecov / codecov/patch

views/js/backend/admin/src/components/pdk/PsToggleInput.vue#L40

Added line #L40 was not covered by tests

const {translate} = useLanguage();
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class="row">
<div class="col-4">
<input
:id="id"

Check warning on line 7 in views/js/backend/admin/src/components/pdk/PsTriStateInput.vue

View check run for this annotation

Codecov / codecov/patch

views/js/backend/admin/src/components/pdk/PsTriStateInput.vue#L7

Added line #L7 was not covered by tests
v-model="model"
:name="id"
type="hidden" />
Expand Down