Browse Source

Maintenance: Mobile - Move app-specific code into shared context when it makes sense

Vladimir Sheremet 1 year ago
parent
commit
8d3abcae21

+ 2 - 2
app/frontend/apps/mobile/components/CommonStepper/CommonStepper.story.vue

@@ -2,11 +2,11 @@
 
 
 <script setup lang="ts">
 <script setup lang="ts">
 import { ref } from 'vue'
 import { ref } from 'vue'
+import type { FormStep } from '#shared/components/Form/types.ts'
 import CommonStepper from './CommonStepper.vue'
 import CommonStepper from './CommonStepper.vue'
-import type { CommonStepperStep } from './types.ts'
 
 
 const modelValue = ref('step1')
 const modelValue = ref('step1')
-const steps: Record<string, CommonStepperStep> = {
+const steps: Record<string, FormStep> = {
   step1: {
   step1: {
     label: '1',
     label: '1',
     order: 1,
     order: 1,

+ 2 - 2
app/frontend/apps/mobile/components/CommonStepper/CommonStepper.vue

@@ -2,12 +2,12 @@
 
 
 <script setup lang="ts">
 <script setup lang="ts">
 import { computed } from 'vue'
 import { computed } from 'vue'
-import type { CommonStepperStep as Step } from './types.ts'
+import type { FormStep } from '#shared/components/Form/types.ts'
 import CommonStepperStep from './CommonStepperStep.vue'
 import CommonStepperStep from './CommonStepperStep.vue'
 
 
 interface Props {
 interface Props {
   modelValue: string
   modelValue: string
-  steps: Record<string, Step>
+  steps: Record<string, FormStep>
 }
 }
 
 
 const props = defineProps<Props>()
 const props = defineProps<Props>()

+ 2 - 2
app/frontend/apps/mobile/components/CommonStepper/__tests__/CommonStepper.spec.ts

@@ -1,14 +1,14 @@
 // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
 
 
 import { renderComponent } from '#tests/support/components/index.ts'
 import { renderComponent } from '#tests/support/components/index.ts'
+import type { FormStep } from '#shared/components/Form/types.ts'
 import { ref } from 'vue'
 import { ref } from 'vue'
 import CommonStepper from '../CommonStepper.vue'
 import CommonStepper from '../CommonStepper.vue'
-import type { CommonStepperStep } from '../types.ts'
 
 
 describe('stepper component', () => {
 describe('stepper component', () => {
   test('renders valid steps', async () => {
   test('renders valid steps', async () => {
     const modelValue = ref('step1')
     const modelValue = ref('step1')
-    const steps: Record<string, CommonStepperStep> = {
+    const steps: Record<string, FormStep> = {
       step1: {
       step1: {
         label: '1',
         label: '1',
         order: 1,
         order: 1,

+ 0 - 3
app/frontend/apps/mobile/components/CommonStepper/index.ts

@@ -1,3 +0,0 @@
-// Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
-
-export type { CommonStepperStep } from './types.ts'

+ 0 - 10
app/frontend/apps/mobile/components/CommonStepper/types.ts

@@ -1,10 +0,0 @@
-// Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
-
-export interface CommonStepperStep {
-  label: string
-  order: number
-  errorCount: number
-  valid: boolean
-  disabled: boolean
-  completed: boolean
-}

+ 1 - 1
app/frontend/apps/mobile/pages/error/views/Error.vue

@@ -3,7 +3,7 @@
 <script setup lang="ts">
 <script setup lang="ts">
 import { computed } from 'vue'
 import { computed } from 'vue'
 import CommonBackButton from '#mobile/components/CommonBackButton/CommonBackButton.vue'
 import CommonBackButton from '#mobile/components/CommonBackButton/CommonBackButton.vue'
-import { errorOptions } from '#mobile/router/error.ts'
+import { errorOptions } from '#shared/router/error.ts'
 import { ErrorStatusCodes } from '#shared/types/error.ts'
 import { ErrorStatusCodes } from '#shared/types/error.ts'
 
 
 const errorImage = computed(() => {
 const errorImage = computed(() => {

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

@@ -35,7 +35,7 @@ import { populateEditorNewLines } from '#shared/components/Form/fields/FieldEdit
 import CommonStepper from '#mobile/components/CommonStepper/CommonStepper.vue'
 import CommonStepper from '#mobile/components/CommonStepper/CommonStepper.vue'
 import CommonButton from '#mobile/components/CommonButton/CommonButton.vue'
 import CommonButton from '#mobile/components/CommonButton/CommonButton.vue'
 import CommonBackButton from '#mobile/components/CommonBackButton/CommonBackButton.vue'
 import CommonBackButton from '#mobile/components/CommonBackButton/CommonBackButton.vue'
-import { errorOptions } from '#mobile/router/error.ts'
+import { errorOptions } from '#shared/router/error.ts'
 import { useConfirmationDialog } from '#mobile/components/CommonConfirmation/useConfirmationDialog.ts'
 import { useConfirmationDialog } from '#mobile/components/CommonConfirmation/useConfirmationDialog.ts'
 import {
 import {
   useTicketDuplicateDetectionHandler,
   useTicketDuplicateDetectionHandler,

+ 1 - 1
app/frontend/apps/mobile/router/index.ts

@@ -4,8 +4,8 @@ import type { App } from 'vue'
 import type { RouteRecordRaw } from 'vue-router'
 import type { RouteRecordRaw } from 'vue-router'
 import mainInitializeRouter from '#shared/router/index.ts'
 import mainInitializeRouter from '#shared/router/index.ts'
 import type { InitializeAppRouter, RoutesModule } from '#shared/types/router.ts'
 import type { InitializeAppRouter, RoutesModule } from '#shared/types/router.ts'
+import { errorAfterGuard } from '#shared/router/error.ts'
 import transitionViewGuard from './guards/before/viewTransition.ts'
 import transitionViewGuard from './guards/before/viewTransition.ts'
-import { errorAfterGuard } from './error.ts'
 
 
 const routeModules: Record<string, RoutesModule> = import.meta.glob(
 const routeModules: Record<string, RoutesModule> = import.meta.glob(
   ['../pages/*/routes.ts', '../pages/*/routes/*.ts'],
   ['../pages/*/routes.ts', '../pages/*/routes/*.ts'],

+ 9 - 0
app/frontend/shared/components/Form/types.ts

@@ -234,3 +234,12 @@ export interface FormRef {
     groupNode?: FormKitNode,
     groupNode?: FormKitNode,
   ): void
   ): void
 }
 }
+
+export interface FormStep {
+  label: string
+  order: number
+  errorCount: number
+  valid: boolean
+  disabled: boolean
+  completed: boolean
+}

+ 3 - 3
app/frontend/shared/components/Form/useMultiStepForm.ts

@@ -4,7 +4,7 @@ import { createMessage, getNode } from '@formkit/core'
 import type { FormKitNode } from '@formkit/core'
 import type { FormKitNode } from '@formkit/core'
 import { computed, toRef, ref, reactive, watch } from 'vue'
 import { computed, toRef, ref, reactive, watch } from 'vue'
 import type { ComputedRef, Ref } from 'vue'
 import type { ComputedRef, Ref } from 'vue'
-import type { CommonStepperStep } from '#mobile/components/CommonStepper/index.ts'
+import type { FormStep } from './types.ts'
 
 
 interface InternalMultiFormSteps {
 interface InternalMultiFormSteps {
   label: string
   label: string
@@ -95,8 +95,8 @@ export const useMultiStepForm = (
     return false
     return false
   }
   }
 
 
-  const allSteps = computed<Record<string, CommonStepperStep>>(() => {
-    const mappedSteps: Record<string, CommonStepperStep> = {}
+  const allSteps = computed<Record<string, FormStep>>(() => {
+    const mappedSteps: Record<string, FormStep> = {}
 
 
     stepNames.value.forEach((stepName) => {
     stepNames.value.forEach((stepName) => {
       const alreadyVisisted = visitedSteps.value.includes(stepName)
       const alreadyVisisted = visitedSteps.value.includes(stepName)

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