-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(admin): improve product settings form
- Loading branch information
1 parent
713f566
commit 84714ce
Showing
4 changed files
with
140 additions
and
2 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
views/js/backend/admin/src/components/pdk/PsProductSettingsFormGroup.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<template> | ||
<div | ||
v-show="element.isVisible" | ||
v-test="[AdminComponent.FormGroup, element]" | ||
class="row"> | ||
<template v-if="isInteractive"> | ||
<div class="col-md-6"> | ||
<div class="form-group"> | ||
<label | ||
:for="id" | ||
class="form-control-label"> | ||
<slot name="label"> | ||
{{ element.label }} | ||
</slot> | ||
</label> | ||
|
||
<div> | ||
<slot /> | ||
</div> | ||
|
||
<p | ||
v-if="element.props?.description && has(element.props.description)" | ||
class="italic subtitle"> | ||
{{ translate(element.props.description) }} | ||
</p> | ||
|
||
<div | ||
v-if="!element.isValid" | ||
class="invalid-feedback"> | ||
<ul class="list-unstyled"> | ||
<li | ||
v-for="(error, index) in element.errors" | ||
:key="`error_${index}`"> | ||
{{ error }} | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<div | ||
v-else | ||
class="col-12 mb-4"> | ||
<slot /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import {toRefs, computed} from 'vue'; | ||
import {generateFieldId, useLanguage, type FormGroupProps, AdminComponent} from '@myparcel-pdk/admin'; | ||
// eslint-disable-next-line vue/no-unused-properties | ||
const props = defineProps<FormGroupProps>(); | ||
const propRefs = toRefs(props); | ||
const {translate, has} = useLanguage(); | ||
const id = generateFieldId(propRefs.element.value); | ||
const isInteractive = computed<boolean>(() => { | ||
return props.element.hasOwnProperty('ref'); | ||
}); | ||
</script> |
64 changes: 64 additions & 0 deletions
64
views/js/backend/admin/src/components/pdk/PsTriStateInput.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<template> | ||
<div | ||
v-test="[AdminComponent.TriStateInput, element]" | ||
:class="config?.cssUtilities?.displayFlex" | ||
class="row"> | ||
<div class="col-md-6"> | ||
<div class="row"> | ||
<div class="col-4"> | ||
<input | ||
v-model="model" | ||
:name="id" | ||
type="hidden" /> | ||
|
||
<PdkToggleInput | ||
v-model="toggleModel" | ||
:class="config?.cssUtilities?.marginYAuto" | ||
:element="toggleElement" /> | ||
</div> | ||
|
||
<div class="col-2"> | ||
<PdkButton | ||
:class="config?.cssUtilities?.displayFlex" | ||
:size="Size.ExtraSmall" | ||
:title="inheritElement?.label" | ||
class="!mypa-float-none !mypa-ml-1" | ||
@click="inheritModel = !inheritModel"> | ||
<div> | ||
<i | ||
:class="config?.cssUtilities?.marginYAuto" | ||
class="material-icons" | ||
role="none" | ||
v-text="inheritModel ? 'lock' : 'lock_open'" /> | ||
</div> | ||
|
||
<PdkCheckboxInput | ||
v-model="inheritModel" | ||
:element="{...inheritElement, label: undefined}" | ||
class="mypa-sr-only" | ||
tabindex="-1" /> | ||
</PdkButton> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { | ||
useTriStateInputContext, | ||
AdminComponent, | ||
useAdminConfig, | ||
Size, | ||
type TriStateInputProps, | ||
type TriStateInputEmits, | ||
} from '@myparcel-pdk/admin'; | ||
// eslint-disable-next-line vue/no-unused-properties | ||
const props = defineProps<TriStateInputProps>(); | ||
const emit = defineEmits<TriStateInputEmits>(); | ||
const config = useAdminConfig(); | ||
const {inheritElement, toggleElement, inheritModel, toggleModel, model, id} = useTriStateInputContext(props, emit); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters