Browse Source

Fixes: Mobile - Fixed problems with customer and organization field in the ticket create.

Dominik Klein 2 years ago
parent
commit
c4de870e91

+ 1 - 0
app/frontend/apps/mobile/entities/user/__tests__/mocks/user-mocks.ts

@@ -52,6 +52,7 @@ export const defaultUser = (): ConfidentTake<UserQuery, 'user'> => {
       ],
       ],
       totalCount: 1,
       totalCount: 1,
     },
     },
+    hasSecondaryOrganizations: true,
     objectAttributeValues: [
     objectAttributeValues: [
       {
       {
         attribute: {
         attribute: {

+ 2 - 0
app/frontend/apps/mobile/pages/search/graphql/queries/searchOverview.api.ts

@@ -23,6 +23,7 @@ export const SearchDocument = gql`
       }
       }
       customer {
       customer {
         id
         id
+        internalId
         fullname
         fullname
       }
       }
       updatedAt
       updatedAt
@@ -39,6 +40,7 @@ export const SearchDocument = gql`
       image
       image
       organization {
       organization {
         id
         id
+        internalId
         name
         name
       }
       }
       updatedAt
       updatedAt

+ 2 - 0
app/frontend/apps/mobile/pages/search/graphql/queries/searchOverview.graphql

@@ -19,6 +19,7 @@ query search(
       }
       }
       customer {
       customer {
         id
         id
+        internalId
         fullname
         fullname
       }
       }
       updatedAt
       updatedAt
@@ -35,6 +36,7 @@ query search(
       image
       image
       organization {
       organization {
         id
         id
+        internalId
         name
         name
       }
       }
       updatedAt
       updatedAt

+ 2 - 2
app/frontend/apps/mobile/pages/ticket/views/TicketCreate.vue

@@ -12,7 +12,7 @@ import { useMultiStepForm, useForm } from '@shared/components/Form'
 import { useApplicationStore } from '@shared/stores/application'
 import { useApplicationStore } from '@shared/stores/application'
 import { useTicketCreateArticleType } from '@shared/entities/ticket/composables/useTicketCreateArticleType'
 import { useTicketCreateArticleType } from '@shared/entities/ticket/composables/useTicketCreateArticleType'
 import { ButtonVariant } from '@shared/components/Form/fields/FieldButton/types'
 import { ButtonVariant } from '@shared/components/Form/fields/FieldButton/types'
-import { useTicketFormOganizationHandling } from '@shared/entities/ticket/composables/useTicketFormOrganizationHandler'
+import { useTicketFormOganizationHandler } from '@shared/entities/ticket/composables/useTicketFormOrganizationHandler'
 import { FormData, type FormSchemaNode } from '@shared/components/Form/types'
 import { FormData, type FormSchemaNode } from '@shared/components/Form/types'
 import { i18n } from '@shared/i18n'
 import { i18n } from '@shared/i18n'
 import { MutationHandler } from '@shared/server/apollo/handler'
 import { MutationHandler } from '@shared/server/apollo/handler'
@@ -317,7 +317,7 @@ const submitButtonDisabled = computed(() => {
       ref="form"
       ref="form"
       class="text-left"
       class="text-left"
       :schema="formSchema"
       :schema="formSchema"
-      :handlers="[useTicketFormOganizationHandling()]"
+      :handlers="[useTicketFormOganizationHandler()]"
       :multi-step-form-groups="Object.keys(allSteps)"
       :multi-step-form-groups="Object.keys(allSteps)"
       :schema-data="schemaData"
       :schema-data="schemaData"
       :form-updater-id="EnumFormUpdaterId.FormUpdaterUpdaterTicketCreate"
       :form-updater-id="EnumFormUpdaterId.FormUpdaterUpdaterTicketCreate"

+ 1 - 0
app/frontend/shared/components/Form/Form.vue

@@ -518,6 +518,7 @@ const executeFormHandler = (
       formNode.value,
       formNode.value,
       currentValues,
       currentValues,
       props.changeFields,
       props.changeFields,
+      updateSchemaDataField,
       schemaData,
       schemaData,
       changedField,
       changedField,
     )
     )

+ 19 - 13
app/frontend/shared/components/Form/fields/FieldAutoComplete/FieldAutoCompleteInputDialog.vue

@@ -5,7 +5,7 @@ import type { ConcreteComponent, Ref } from 'vue'
 import { computed, nextTick, onMounted, ref, toRef, watch } from 'vue'
 import { computed, nextTick, onMounted, ref, toRef, watch } from 'vue'
 import { useRouter } from 'vue-router'
 import { useRouter } from 'vue-router'
 import { cloneDeep } from 'lodash-es'
 import { cloneDeep } from 'lodash-es'
-import { refDebounced } from '@vueuse/core'
+import { refDebounced, watchOnce } from '@vueuse/core'
 import { useLazyQuery } from '@vue/apollo-composable'
 import { useLazyQuery } from '@vue/apollo-composable'
 import gql from 'graphql-tag'
 import gql from 'graphql-tag'
 import type { NameNode, OperationDefinitionNode, SelectionNode } from 'graphql'
 import type { NameNode, OperationDefinitionNode, SelectionNode } from 'graphql'
@@ -28,7 +28,9 @@ const props = defineProps<{
   optionIconComponent: ConcreteComponent
   optionIconComponent: ConcreteComponent
 }>()
 }>()
 
 
-const { isCurrentValue } = useValue(toRef(props, 'context'))
+const contextReactive = toRef(props, 'context')
+
+const { isCurrentValue } = useValue(contextReactive)
 
 
 const emit = defineEmits<{
 const emit = defineEmits<{
   (e: 'updateOptions', options: AutoCompleteOption[]): void
   (e: 'updateOptions', options: AutoCompleteOption[]): void
@@ -37,7 +39,7 @@ const emit = defineEmits<{
 
 
 const { sortedOptions, selectOption } = useSelectOptions(
 const { sortedOptions, selectOption } = useSelectOptions(
   toRef(props, 'options'),
   toRef(props, 'options'),
-  toRef(props, 'context'),
+  contextReactive,
 )
 )
 
 
 let areLocalOptionsReplaced = false
 let areLocalOptionsReplaced = false
@@ -102,20 +104,24 @@ const AutocompleteSearchDocument = gql`
 const autocompleteQueryHandler = new QueryHandler(
 const autocompleteQueryHandler = new QueryHandler(
   useLazyQuery(AutocompleteSearchDocument, () => ({
   useLazyQuery(AutocompleteSearchDocument, () => ({
     input: {
     input: {
-      query: debouncedFilter.value,
+      query: debouncedFilter.value || props.context.defaultFilter || '',
       limit: props.context.limit,
       limit: props.context.limit,
-      ...props.context.additionalQueryParams,
+      ...(props.context.additionalQueryParams || {}),
     },
     },
   })),
   })),
 )
 )
 
 
-watch(
-  () => debouncedFilter.value,
-  (newValue) => {
-    if (!newValue.length) return
-    autocompleteQueryHandler.load()
-  },
-)
+if (props.context.defaultFilter) {
+  autocompleteQueryHandler.load()
+} else {
+  watchOnce(
+    () => debouncedFilter.value,
+    (newValue) => {
+      if (!newValue.length) return
+      autocompleteQueryHandler.load()
+    },
+  )
+}
 
 
 const autocompleteQueryResultKey = (
 const autocompleteQueryResultKey = (
   (AutocompleteSearchDocument.definitions[0] as OperationDefinitionNode)
   (AutocompleteSearchDocument.definitions[0] as OperationDefinitionNode)
@@ -266,7 +272,7 @@ useTraverseOptions(autocompleteList)
       role="listbox"
       role="listbox"
     >
     >
       <div
       <div
-        v-for="(option, index) in filter
+        v-for="(option, index) in filter || context.defaultFilter
           ? sortedAutocompleteOptions
           ? sortedAutocompleteOptions
           : sortedOptions"
           : sortedOptions"
         :key="String(option.value)"
         :key="String(option.value)"

+ 2 - 0
app/frontend/shared/components/Form/fields/FieldAutoComplete/index.ts

@@ -8,9 +8,11 @@ import FieldAutoCompleteInput from './FieldAutoCompleteInput.vue'
 export const autoCompleteProps = [
 export const autoCompleteProps = [
   'action',
   'action',
   'actionIcon',
   'actionIcon',
+  'additionalQueryParams',
   'allowUnknownValues',
   'allowUnknownValues',
   'clearable',
   'clearable',
   'debounceInterval',
   'debounceInterval',
+  'defaultFilter',
   'filterInputPlaceholder',
   'filterInputPlaceholder',
   'filterInputValidation',
   'filterInputValidation',
   'limit',
   'limit',

+ 1 - 0
app/frontend/shared/components/Form/fields/FieldAutoComplete/types.ts

@@ -26,6 +26,7 @@ export type AutoCompleteProps = FormFieldContext<{
   clearable?: boolean
   clearable?: boolean
   debounceInterval: number
   debounceInterval: number
   disabled?: boolean
   disabled?: boolean
+  defaultFilter?: string
   filterInputPlaceholder?: string
   filterInputPlaceholder?: string
   filterInputValidation?: string
   filterInputValidation?: string
   limit?: number
   limit?: number

+ 1 - 1
app/frontend/shared/components/Form/fields/FieldCustomer/FieldCustomerWrapper.vue

@@ -36,7 +36,7 @@ Object.assign(props.context, {
     value: SelectValue,
     value: SelectValue,
     context: Props['context'],
     context: Props['context'],
   ) => {
   ) => {
-    if (!context.belongsToObjectField) return null
+    if (!context.belongsToObjectField || !initialEntityObject) return null
 
 
     const belongsToObject = initialEntityObject[context.belongsToObjectField]
     const belongsToObject = initialEntityObject[context.belongsToObjectField]
 
 

+ 1 - 7
app/frontend/shared/components/Form/fields/FieldOrganization/FieldOrganizationWrapper.vue

@@ -30,13 +30,12 @@ const props = defineProps<Props>()
 
 
 Object.assign(props.context, {
 Object.assign(props.context, {
   optionIconComponent: markRaw(FieldOrganizationOptionIcon),
   optionIconComponent: markRaw(FieldOrganizationOptionIcon),
-
   initialOptionBuilder: (
   initialOptionBuilder: (
     initialEntityObject: ObjectLike,
     initialEntityObject: ObjectLike,
     value: SelectValue,
     value: SelectValue,
     context: Props['context'],
     context: Props['context'],
   ) => {
   ) => {
-    if (!context.belongsToObjectField) return null
+    if (!context.belongsToObjectField || !initialEntityObject) return null
 
 
     const belongsToObject = initialEntityObject[
     const belongsToObject = initialEntityObject[
       context.belongsToObjectField
       context.belongsToObjectField
@@ -46,11 +45,6 @@ Object.assign(props.context, {
 
 
     return getAutoCompleteOption(belongsToObject)
     return getAutoCompleteOption(belongsToObject)
   },
   },
-
-  // TODO: change the action to the actual new organization route
-  action: '/tickets',
-  actionIcon: 'mobile-new-organization',
-
   gqlQuery: AutocompleteSearchOrganizationDocument,
   gqlQuery: AutocompleteSearchOrganizationDocument,
 })
 })
 </script>
 </script>

Some files were not shown because too many files changed in this diff