-
Notifications
You must be signed in to change notification settings - Fork 70
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
Showing
51 changed files
with
1,287 additions
and
755 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
frontend/packages/shared/src/types/ComponentSpecificConfig.ts
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,85 @@ | ||
import { ComponentType } from './ComponentType'; | ||
import { KeyValuePairs } from 'app-shared/types/KeyValuePairs'; | ||
import { MapLayer } from 'app-shared/types/MapLayer'; | ||
import { FormPanelVariant } from 'app-shared/types/FormPanelVariant'; | ||
|
||
type Option<T = any> = { | ||
label: string; | ||
value: T; | ||
}; | ||
|
||
type OptionsComponentBase = { | ||
options?: Option[]; | ||
preselectedOptionIndex?: number; | ||
optionsId?: string; | ||
}; | ||
|
||
type FileUploadComponentBase = { | ||
description: string; | ||
hasCustomFileEndings: boolean; | ||
maxFileSizeInMB: number; | ||
displayMode: string; | ||
maxNumberOfAttachments: number; | ||
minNumberOfAttachments: number; | ||
validFileEndings?: string; | ||
}; | ||
|
||
export type ComponentSpecificConfig<T extends ComponentType = ComponentType> = { | ||
[ComponentType.Alert]: { severity: 'success' | 'info' | 'warning' | 'danger' }; | ||
[ComponentType.Accordion]: {}; | ||
[ComponentType.AccordionGroup]: {}; | ||
[ComponentType.ActionButton]: {}; | ||
[ComponentType.AddressComponent]: { simplified: boolean }; | ||
[ComponentType.AttachmentList]: {}; | ||
[ComponentType.Button]: { onClickAction: () => void }; | ||
[ComponentType.ButtonGroup]: {}; | ||
[ComponentType.Checkboxes]: OptionsComponentBase; | ||
[ComponentType.Custom]: { tagName: string; framework: string; [id: string]: any }; | ||
[ComponentType.Datepicker]: { timeStamp: boolean }; | ||
[ComponentType.Dropdown]: { optionsId: string }; | ||
[ComponentType.FileUpload]: FileUploadComponentBase; | ||
[ComponentType.FileUploadWithTag]: FileUploadComponentBase & { optionsId: string }; | ||
[ComponentType.Grid]: {}; | ||
[ComponentType.Group]: { | ||
maxCount?: number; | ||
edit?: { | ||
multiPage?: boolean; | ||
mode?: string; | ||
}; | ||
}; | ||
[ComponentType.Header]: { size: string }; | ||
[ComponentType.IFrame]: {}; | ||
[ComponentType.Image]: { | ||
image?: { | ||
src?: KeyValuePairs<string>; | ||
align?: string | null; | ||
width?: string; | ||
}; | ||
}; | ||
[ComponentType.Input]: { disabled?: boolean }; | ||
[ComponentType.InstanceInformation]: {}; | ||
[ComponentType.InstantiationButton]: {}; | ||
[ComponentType.Likert]: {}; | ||
[ComponentType.Link]: {}; | ||
[ComponentType.List]: {}; | ||
[ComponentType.Map]: { | ||
centerLocation: { | ||
latitude: number; | ||
longitude: number; | ||
}; | ||
zoom: number; | ||
layers?: MapLayer[]; | ||
}; | ||
[ComponentType.MultipleSelect]: {}; | ||
[ComponentType.NavigationBar]: {}; | ||
[ComponentType.NavigationButtons]: { showSaveButton?: boolean; showPrev?: boolean }; | ||
[ComponentType.Panel]: { | ||
variant: FormPanelVariant; | ||
showIcon: boolean; | ||
}; | ||
[ComponentType.Paragraph]: {}; | ||
[ComponentType.PrintButton]: {}; | ||
[ComponentType.RadioButtons]: OptionsComponentBase; | ||
[ComponentType.Summary]: {}; | ||
[ComponentType.TextArea]: {}; | ||
}[T]; |
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,5 @@ | ||
export enum FormPanelVariant { | ||
Info = 'info', | ||
Warning = 'warning', | ||
Success = 'success', | ||
} |
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,5 @@ | ||
export interface MapLayer { | ||
url: string; | ||
attribution?: string; | ||
subdomains?: 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
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
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
71 changes: 71 additions & 0 deletions
71
...d/packages/ux-editor/src/converters/formLayoutConverters/externalLayoutToInternal.test.ts
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,71 @@ | ||
import { externalLayoutToInternal } from './externalLayoutToInternal'; | ||
import { | ||
externalLayoutWithMultiPageGroup, | ||
internalLayoutWithMultiPageGroup, | ||
} from '../../testing/layoutWithMultiPageGroupMocks'; | ||
import { createEmptyLayout } from '../../utils/formLayoutUtils'; | ||
import { ExternalFormLayout } from 'app-shared/types/api'; | ||
import { IInternalLayout } from '../../types/global'; | ||
import { layoutSchemaUrl } from 'app-shared/cdn-paths'; | ||
|
||
describe('externalLayoutToInternal', () => { | ||
it('Converts an external layout to an internal layout', () => { | ||
const result = externalLayoutToInternal(externalLayoutWithMultiPageGroup); | ||
expect(result).toEqual(internalLayoutWithMultiPageGroup); | ||
}); | ||
|
||
it('Returns an empty layout if the external layout is null', () => { | ||
const result = externalLayoutToInternal(null); | ||
expect(result).toEqual(createEmptyLayout()); | ||
}); | ||
|
||
it('Returns an empty layout with custom properties when the "data" property is null', () => { | ||
const customProperty1 = 'test1'; | ||
const customProperty2 = 'test2'; | ||
const externalLayout: ExternalFormLayout = { | ||
$schema: layoutSchemaUrl(), | ||
data: null, | ||
customProperty1, | ||
customProperty2, | ||
}; | ||
const expectedResult: IInternalLayout = { | ||
...createEmptyLayout(), | ||
customRootProperties: { | ||
customProperty1, | ||
customProperty2, | ||
}, | ||
}; | ||
const result = externalLayoutToInternal(externalLayout); | ||
expect(result).toEqual(expectedResult); | ||
}); | ||
|
||
it('Returns an empty layout with custom properties when the "layout" property within the "data" property is null', () => { | ||
const rootCustomProperty1 = 'test1'; | ||
const rootCustomProperty2 = 'test2'; | ||
const dataCustomProperty1 = 'test3'; | ||
const dataCustomProperty2 = 'test4'; | ||
const externalLayout: ExternalFormLayout = { | ||
$schema: layoutSchemaUrl(), | ||
data: { | ||
layout: null, | ||
dataCustomProperty1, | ||
dataCustomProperty2, | ||
}, | ||
rootCustomProperty1, | ||
rootCustomProperty2, | ||
}; | ||
const expectedResult: IInternalLayout = { | ||
...createEmptyLayout(), | ||
customRootProperties: { | ||
rootCustomProperty1, | ||
rootCustomProperty2, | ||
}, | ||
customDataProperties: { | ||
dataCustomProperty1, | ||
dataCustomProperty2, | ||
}, | ||
}; | ||
const result = externalLayoutToInternal(externalLayout); | ||
expect(result).toEqual(expectedResult); | ||
}); | ||
}); |
Oops, something went wrong.