-
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.
- Loading branch information
1 parent
db7bf31
commit 8e73009
Showing
14 changed files
with
240 additions
and
119 deletions.
There are no files selected for viewing
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
119 changes: 83 additions & 36 deletions
119
views/js/backend/admin/src/components/pdk/PsFormGroup.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 |
---|---|---|
@@ -1,48 +1,95 @@ | ||
<template> | ||
<div class="form-group row"> | ||
<label | ||
:for="id" | ||
class="col-sm-4 form-control-label"> | ||
<span | ||
v-if="!element.isOptional && undefined !== element.props.description" | ||
class="text-danger" | ||
>* | ||
</span> | ||
<slot name="label"> | ||
{{ element.label }} | ||
</slot> | ||
</label> | ||
|
||
<div class="col-sm-8"> | ||
<slot /> | ||
<div | ||
v-show="element.isVisible" | ||
v-test="[AdminComponent.FormGroup, element]" | ||
:class="wrapperClass" | ||
class="form-group row"> | ||
<template v-if="isInteractive"> | ||
<label | ||
:class="{required: !isOptional}" | ||
:for="id" | ||
class="form-control-label"> | ||
<span | ||
v-if="isOptional" | ||
class="text-danger" | ||
>* | ||
</span> | ||
<slot name="label"> | ||
{{ element.label }} | ||
</slot> | ||
</label> | ||
|
||
<div class="col-sm input-container"> | ||
<slot /> | ||
|
||
<small | ||
v-if="element.props?.description" | ||
class="form-text text-muted"> | ||
{{ translate(element.props.description) }} | ||
</small> | ||
<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> | ||
<small | ||
v-if="element.props?.description && has(element.props.description)" | ||
class="form-text text-muted"> | ||
{{ translate(element.props.description) }} | ||
</small> | ||
<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> | ||
</template> | ||
<div | ||
v-else | ||
class="col-12"> | ||
<slot /> | ||
</div> | ||
</div> | ||
</template> | ||
<script lang="ts" setup> | ||
import {type ElementInstance, generateFieldId, useLanguage} from '@myparcel-pdk/admin'; | ||
import {toRefs, computed} from 'vue'; | ||
import {prefixComponent} from '@myparcel-pdk/admin-common'; | ||
import {generateFieldId, useLanguage, type FormGroupProps, AdminComponent, useAdminConfig} 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); | ||
// This is wrapped because isOptional is not present on all elements | ||
const isOptional = computed<boolean>(() => { | ||
return Boolean(props.element.isOptional); | ||
}); | ||
const isInteractive = computed<boolean>(() => { | ||
return props.element.hasOwnProperty('ref'); | ||
}); | ||
const config = useAdminConfig(); | ||
const wrapperClass = computed(() => { | ||
const resolvedComponent = Object.keys(config.components).find((key) => { | ||
return config.components[key] === props.element.component; | ||
}); | ||
const props = defineProps<{element: ElementInstance<{description: string}>}>(); | ||
switch (resolvedComponent) { | ||
case prefixComponent(AdminComponent.ToggleInput): | ||
return ['switch-widget']; | ||
const {translate} = useLanguage(); | ||
case prefixComponent(AdminComponent.SelectInput): | ||
case prefixComponent(AdminComponent.MultiSelectInput): | ||
return ['select-widget']; | ||
const id = generateFieldId(props.element); | ||
default: | ||
return []; | ||
} | ||
}); | ||
</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
24 changes: 24 additions & 0 deletions
24
views/js/backend/admin/src/components/pdk/PsMultiSelectInput.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,24 @@ | ||
<template> | ||
<PdkSelectInput | ||
:id="id" | ||
v-model="model" | ||
v-test="[AdminComponent.MultiSelectInput, element]" | ||
:element="element" | ||
multiple="true" /> | ||
</template> | ||
|
||
<script generic="T extends MultiSelectInputModelValue" lang="ts" setup> | ||
import { | ||
type MultiSelectInputProps, | ||
type MultiSelectInputEmits, | ||
type MultiSelectInputModelValue, | ||
AdminComponent, | ||
useElementContext, | ||
} from '@myparcel-pdk/admin'; | ||
// eslint-disable-next-line vue/no-unused-properties | ||
const props = defineProps<MultiSelectInputProps<T>>(); | ||
const emit = defineEmits<MultiSelectInputEmits<T>>(); | ||
const {id, model} = useElementContext(props, emit); | ||
</script> |
15 changes: 5 additions & 10 deletions
15
views/js/backend/admin/src/components/pdk/PsPluginSettingsWrapper.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 |
---|---|---|
@@ -1,18 +1,13 @@ | ||
<template> | ||
<div class="card row"> | ||
<div | ||
v-test="AdminComponent.PluginSettingsWrapper" | ||
class="card row"> | ||
<div class="card-body col-sm-12 pdk-plugin-settings-wrapper"> | ||
<slot /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import {defineComponent} from 'vue'; | ||
/** | ||
* A table component that can be used to render data via slots. | ||
*/ | ||
export default defineComponent({ | ||
name: 'PsPluginSettingsWrapper', | ||
}); | ||
<script lang="ts" setup> | ||
import {AdminComponent} from '@myparcel-pdk/admin'; | ||
</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
31 changes: 31 additions & 0 deletions
31
views/js/backend/admin/src/components/pdk/PsSelectInput.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,31 @@ | ||
<template> | ||
<select | ||
:id="id" | ||
v-model="model" | ||
v-test="[AdminComponent.SelectInput, element]" | ||
:name="id" | ||
class="custom-select form-control"> | ||
<option | ||
v-for="option in options" | ||
:key="option.value" | ||
:value="option.value"> | ||
{{ option.label }} | ||
</option> | ||
</select> | ||
</template> | ||
|
||
<script generic="T extends SelectInputModelValue" lang="ts" setup> | ||
import { | ||
type SelectInputProps, | ||
type SelectInputEmits, | ||
type SelectInputModelValue, | ||
AdminComponent, | ||
useSelectInputContext, | ||
} from '@myparcel-pdk/admin'; | ||
// eslint-disable-next-line vue/no-unused-properties | ||
const props = defineProps<SelectInputProps<T>>(); | ||
const emit = defineEmits<SelectInputEmits<T>>(); | ||
const {id, model, options} = useSelectInputContext(props, emit); | ||
</script> |
24 changes: 24 additions & 0 deletions
24
views/js/backend/admin/src/components/pdk/PsSettingsDivider.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,24 @@ | ||
<template> | ||
<div v-test="AdminComponent.SettingsDivider"> | ||
<PdkHeading | ||
v-if="element.props.heading" | ||
:level="element.props.level" | ||
class="bg-transparent card-header mt-3 mx-0"> | ||
{{ translate(element.props.heading) }} | ||
</PdkHeading> | ||
|
||
<p | ||
v-if="element.props.content && has(element.props.content)" | ||
class="card-text" | ||
v-text="translate(element.props.content)" /> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import {AdminComponent, useLanguage, type SettingsDividerProps} from '@myparcel-pdk/admin'; | ||
// eslint-disable-next-line vue/no-unused-properties | ||
defineProps<SettingsDividerProps>(); | ||
const {translate, has} = useLanguage(); | ||
</script> |
8 changes: 6 additions & 2 deletions
8
views/js/backend/admin/src/components/pdk/PsTabNavButtonWrapper.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 |
---|---|---|
@@ -1,7 +1,11 @@ | ||
<template> | ||
<ul class="nav nav-pills"> | ||
<ul | ||
v-test="AdminComponent.TabNavButtonWrapper" | ||
class="nav nav-pills"> | ||
<slot /> | ||
</ul> | ||
</template> | ||
|
||
<script lang="ts" setup /> | ||
<script lang="ts" setup> | ||
import {AdminComponent} from '@myparcel-pdk/admin'; | ||
</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
Oops, something went wrong.