123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504 |
- <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
- <script setup lang="ts">
- /* eslint-disable zammad/zammad-detect-translatable-string */
- import { computed, reactive, ref } from 'vue'
- import { EnumSecurityStateType } from '#shared/components/Form/fields/FieldSecurity/types.ts'
- import Form from '#shared/components/Form/Form.vue'
- import { defineFormSchema } from '#shared/form/defineFormSchema.ts'
- import CommonButton from '#mobile/components/CommonButton/CommonButton.vue'
- import CommonButtonGroup from '#mobile/components/CommonButtonGroup/CommonButtonGroup.vue'
- import CommonStepper from '#mobile/components/CommonStepper/CommonStepper.vue'
- import LayoutHeader from '#mobile/components/layout/LayoutHeader.vue'
- import { useDialog } from '#mobile/composables/useDialog.ts'
- import { useUserCreate } from '#mobile/entities/user/composables/useUserCreate.ts'
- const linkSchemaRaw = [
- {
- type: 'externalDataSource',
- name: 'external_data_source',
- label: 'External Data Source',
- object: 'Ticket',
- required: true,
- },
- {
- type: 'security',
- name: 'security',
- label:
- 'Security Long Name Very long Not Truncated Oh no Please Its Too Long',
- required: true,
- props: {
- securityAllowed: {
- [EnumSecurityStateType.Smime]: ['sign', 'encryption'],
- [EnumSecurityStateType.Pgp]: ['encryption'],
- },
- },
- },
- {
- type: 'editor',
- name: 'editor',
- label: 'Editor',
- required: true,
- // props: editorProps,
- },
- {
- type: 'textarea',
- name: 'textarea',
- id: 'textarea',
- label: 'Textarea',
- },
- {
- type: 'toggle',
- name: 'toggle',
- label: 'Toggle',
- required: true,
- // disabled: true,
- props: {
- value: false,
- variants: {
- true: 'Yes',
- false: 'No',
- },
- },
- },
- {
- type: 'text',
- name: 'some_input',
- label: 'Input',
- disabled: true,
- required: true,
- },
- {
- type: 'textarea',
- name: 'select',
- label: 'Textarea',
- required: true,
- },
- {
- type: 'text',
- name: 'some_input_link',
- label: 'Linked',
- props: {
- link: '/',
- },
- },
- {
- type: 'datetime',
- name: 'some_input_date',
- label: 'Date',
- props: {
- link: '/',
- clearable: true,
- },
- required: true,
- },
- {
- type: 'tags',
- name: 'tags',
- label: 'Tags',
- props: {
- link: '/',
- options: [
- { label: 'test', value: 'test' },
- { label: 'support', value: 'support' },
- { label: 'paid', value: 'paid' },
- { label: 'paid2', value: 'paid2' },
- { label: 'paid3', value: 'paid3' },
- { label: 'paid4', value: 'paid4' },
- { label: 'paid5', value: 'paid5' },
- { label: 'paid6', value: 'paid6' },
- { label: 'paid7', value: 'paid7' },
- { label: 'paid8', value: 'paid8' },
- { label: 'paid9', value: 'paid9' },
- { label: 'paid10', value: 'paid10' },
- { label: 'paid11', value: 'paid11' },
- ],
- canCreate: true,
- },
- },
- {
- type: 'treeselect',
- name: 'treeselect',
- label: 'TreeSelect',
- value: [0, 3, 5, 6, 1, 2, 8, 7],
- props: {
- clearable: true,
- multiple: true,
- options: [
- {
- value: 0,
- label: 'Item A',
- children: [
- {
- value: 1,
- label: 'Item 1',
- children: [
- {
- value: 2,
- label: 'Item I',
- },
- {
- value: 3,
- label: 'Item II',
- },
- {
- value: 4,
- label: 'Item III',
- },
- ],
- },
- {
- value: 5,
- label: 'Item 2',
- children: [
- {
- value: 6,
- label: 'Item IV',
- },
- ],
- },
- {
- value: 7,
- label: 'Item 3',
- },
- ],
- },
- {
- value: 8,
- label: 'Item B',
- },
- {
- value: 9,
- label: 'Ítem C',
- },
- ],
- link: '/tickets',
- },
- },
- {
- type: 'treeselect',
- name: 'treeselect_2',
- label: 'TreeSelect 2',
- props: {
- link: '/',
- options: [
- {
- value: 0,
- label: 'Item A',
- },
- ],
- },
- },
- {
- type: 'select',
- name: 'select_1',
- label: 'Select 1',
- disabled: true,
- props: {
- link: '/',
- options: [
- {
- value: 0,
- label: 'Item A',
- },
- ],
- },
- },
- {
- type: 'select',
- name: 'select_2',
- label: 'Select 2',
- props: {
- link: '/',
- multiple: true,
- options: [
- {
- value: 0,
- label: 'Item A',
- },
- {
- value: 1,
- label: 'Item B',
- },
- {
- value: 2,
- label: 'Item C',
- },
- ],
- },
- },
- {
- type: 'autocomplete',
- name: 'autocomplete',
- label: 'AutoComplete',
- props: {
- sorting: 'label',
- link: '/tickets',
- action: '/tickets',
- actionIcon: 'new-customer',
- gqlQuery: `
- query autocompleteSearchUser($input: AutocompleteSearchInput!) {
- autocompleteSearchUser(input: $input) {
- value
- label
- labelPlaceholder
- heading
- headingPlaceholder
- disabled
- icon
- }
- }
- `,
- },
- },
- {
- type: 'recipient',
- name: 'recipient_email',
- label: 'Recipient Email',
- },
- {
- type: 'recipient',
- name: 'recipient_phone',
- label: 'Recipient Phone',
- props: {
- contact: 'phone',
- },
- },
- {
- type: 'organization',
- name: 'organization',
- label: 'Organization',
- props: {
- gqlQuery: `
- query autocompleteSearchUser($input: AutocompleteSearchInput!) {
- autocompleteSearchUser(input: $input) {
- value
- label
- labelPlaceholder
- heading
- headingPlaceholder
- disabled
- icon
- }
- }
- `,
- },
- },
- {
- type: 'customer',
- name: 'customer',
- label: 'Customer',
- props: {
- gqlQuery: `
- query autocompleteSearchUser($input: AutocompleteSearchInput!) {
- autocompleteSearchUser(input: $input) {
- value
- label
- labelPlaceholder
- heading
- headingPlaceholder
- disabled
- icon
- }
- }
- `,
- },
- },
- ]
- const linkSchemas = defineFormSchema(linkSchemaRaw, { showDirtyMark: true })
- const schema = defineFormSchema([
- {
- isLayout: true,
- component: 'FormGroup',
- children: [
- {
- type: 'file',
- name: 'file',
- // label: 'File',
- props: {
- multiple: true,
- },
- },
- ],
- },
- ])
- const dialog = useDialog({
- name: 'dialog',
- component: () => import('#mobile/components/CommonDialog/CommonDialog.vue'),
- })
- const { openCreateUserDialog } = useUserCreate()
- const currentStep = ref('step2')
- const steps = {
- step1: {
- label: '1',
- order: 1,
- errorCount: 0,
- valid: true,
- disabled: false,
- completed: true,
- },
- step2: {
- label: '2',
- order: 2,
- errorCount: 0,
- valid: true,
- disabled: true,
- completed: false,
- },
- step3: {
- label: '3',
- order: 3,
- errorCount: 0,
- valid: true,
- completed: true,
- disabled: true,
- },
- step4: {
- label: '4',
- order: 4,
- errorCount: 3,
- valid: false,
- completed: false,
- disabled: true,
- },
- }
- const editorProps = reactive({
- contentType: 'text/plain',
- meta: {
- footer: {
- text: '/AB',
- maxlength: 276,
- warningLength: 30,
- },
- },
- })
- const updateEditorProps = () => {
- editorProps.contentType =
- editorProps.contentType === 'text/plain' ? 'text/html' : 'text/plain'
- }
- const editorSchema = defineFormSchema([
- {
- type: 'editor',
- name: 'editor',
- label: 'Editor',
- required: true,
- props: Object.keys(editorProps).reduce(
- (acc, key) => {
- acc[key] = computed(() => editorProps[key as keyof typeof editorProps])
- return acc
- },
- {} as Record<string, unknown>,
- ),
- },
- ])
- const logSubmit = console.log
- </script>
- <template>
- <div class="p-4">
- <LayoutHeader title="Playground">
- <template #before>1 / 3</template>
- <template #after>
- <CommonButton class="flex-1 px-4 py-2" variant="secondary"
- >Click
- </CommonButton>
- </template>
- </LayoutHeader>
- <h2 class="text-xl font-bold">Buttons</h2>
- <div class="mt-2 flex gap-3">
- <CommonButton class="flex-1 py-2" variant="primary" />
- <CommonButton class="flex-1 py-2" variant="secondary" />
- </div>
- <div class="my-4 flex gap-3">
- <CommonButton class="flex-1 py-2" variant="submit" />
- <CommonButton class="flex-1 py-2" variant="danger" />
- </div>
- <h3 class="text-gray mb-2 mt-2 text-lg font-semibold">
- With transparent background
- </h3>
- <div class="flex gap-3">
- <CommonButton
- class="flex-1 py-2"
- variant="primary"
- transparent-background
- />
- <CommonButton
- class="flex-1 py-2"
- variant="secondary"
- transparent-background
- />
- </div>
- <div class="my-4 flex gap-3">
- <CommonButton
- class="flex-1 py-2"
- variant="submit"
- transparent-background
- />
- <CommonButton
- class="flex-1 py-2"
- variant="danger"
- transparent-background
- />
- </div>
- <button @click="dialog.toggle({ name: 'dialog', label: 'Hello World' })">
- Dialog
- </button>
- <button type="button" @click="updateEditorProps">
- CHANGE EDITOR PROPS
- </button>
- <button form="form">Submit</button>
- <CommonStepper v-model="currentStep" class="mx-20" :steps="steps" />
- <button @click="openCreateUserDialog()">Create user</button>
- <Form :schema="editorSchema" @submit="logSubmit" />
- <CommonButtonGroup
- class="py-4"
- mode="full"
- model-value="subscribe"
- :options="[
- { label: 'Merge tickets', icon: 'home' },
- { label: 'Subscribe', icon: 'home', value: 'subscribe' },
- { label: 'Ticket info', icon: 'home' },
- ]"
- />
- <Form id="form" :schema="linkSchemas" />
- <Form :schema="schema" />
- <FormKit
- type="radio"
- :buttons="true"
- :options="[
- { label: 'Incoming Phone', value: 1, icon: 'phone-in' },
- { label: 'Outgoing Phone', value: 2, icon: 'phone-out' },
- { label: 'Send Email', value: 3, icon: 'mail-out' },
- ]"
- />
- <FormKit
- wrapper-class="mt-6 flex grow justify-center items-center"
- input-class="py-2 px-4 w-full h-14 text-xl rounded-xl select-none"
- variant="submit"
- type="submit"
- prefix-icon="arrow-right"
- suffix-icon="arrow-left"
- >
- {{ $t('Sign in') }}
- </FormKit>
- </div>
- </template>
|