Skip to content

Commit

Permalink
fix(admin): fix toggle and tristate input elements not working correctly
Browse files Browse the repository at this point in the history
- Fixes "disable delivery options" in product settings not being saved

Needs myparcelnl/js-pdk#223
  • Loading branch information
EdieLemoine committed Oct 24, 2024
1 parent acb9d94 commit 0fb9af7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
22 changes: 14 additions & 8 deletions views/js/backend/admin/src/components/pdk/PsToggleInput.vue
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

0 comments on commit 0fb9af7

Please sign in to comment.