-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(entities-plugins): plugin form UX phase 2
- Loading branch information
1 parent
8de453e
commit f49f23e
Showing
57 changed files
with
1,313 additions
and
872 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
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,16 @@ | ||
export type FGCollapsibleOptions = boolean | { | ||
title?: string | ||
description?: string | ||
nestedCollapsible?: { | ||
fields: any[], | ||
triggerLabel: { | ||
expand: string | ||
collapse: string | ||
} | ||
} | ||
} | ||
|
||
export interface FGSlots { | ||
beforeContent?: string | ||
emptyState?: string | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './generator/types' |
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
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
86 changes: 86 additions & 0 deletions
86
packages/entities/entities-plugins/src/components/PluginFieldRuleAlerts.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,86 @@ | ||
<template> | ||
<KAlert class="plugin-field-rule-alerts"> | ||
<ul> | ||
<li | ||
v-for="(alert, i) in formattedSimpleAlerts" | ||
:key="`simple-alert-${i}`" | ||
> | ||
{{ alert }} | ||
</li> | ||
|
||
<li v-if="props.rules.onlyOneOfMutuallyRequired && props.rules.onlyOneOfMutuallyRequired.length > 0"> | ||
<div | ||
v-for="(combinations, i) in props.rules.onlyOneOfMutuallyRequired" | ||
:key="`only-one-mutually-alert-${i}`" | ||
> | ||
<div>{{ t('plugins.form.field_rules.only_one_of_mutually_required') }}</div> | ||
<ul> | ||
<li | ||
v-for="(fields, j) in combinations" | ||
:key="`only-one-mutually-alert-${i}-combination-${j}`" | ||
> | ||
{{ formatFields(fields) }} | ||
</li> | ||
</ul> | ||
</div> | ||
</li> | ||
</ul> | ||
</KAlert> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed } from 'vue' | ||
import composables from '../composables' | ||
import type { FieldRules } from '../types' | ||
const props = defineProps<{ | ||
rules: FieldRules | ||
}>() | ||
const { formatPluginFieldLabel } = composables.usePluginHelpers() | ||
const { i18n: { t } } = composables.useI18n() | ||
const formatFields = (fields: string[]) => | ||
fields.map((field) => | ||
field.replace(/^[cC]onfig\./, '').split('.').map((s) => formatPluginFieldLabel(s)).join('.'), | ||
).join(', ') | ||
const formatAlert = (translateKey: Parameters<typeof t>[0], fields: string[]) => | ||
t(translateKey, { parameters: formatFields(fields) }) | ||
const formattedSimpleAlerts = computed<string[]>(() => { | ||
const alerts = [] | ||
if (props.rules.atLeastOneOf) { | ||
for (const fields of props.rules.atLeastOneOf) { | ||
alerts.push(formatAlert('plugins.form.field_rules.at_least_one_of', fields)) | ||
} | ||
} | ||
if (props.rules.onlyOneOf) { | ||
for (const fields of props.rules.onlyOneOf) { | ||
alerts.push(formatAlert('plugins.form.field_rules.only_one_of', fields)) | ||
} | ||
} | ||
if (props.rules.mutuallyRequired) { | ||
for (const fields of props.rules.mutuallyRequired) { | ||
alerts.push(formatAlert('plugins.form.field_rules.mutually_required', fields)) | ||
} | ||
} | ||
return alerts | ||
}) | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.plugin-field-rule-alerts { | ||
ul { | ||
margin: 0; | ||
padding-inline-start: $kui-space-80; | ||
} | ||
margin-bottom: $kui-space-60; | ||
margin-top: $kui-space-40; | ||
} | ||
</style> |
Oops, something went wrong.