-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: adapt contract when fetching all option lists to visualise …
…error per option list
- Loading branch information
Showing
31 changed files
with
306 additions
and
257 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,11 @@ | ||
using System.Collections.Generic; | ||
using JetBrains.Annotations; | ||
|
||
namespace Altinn.Studio.Designer.Models.Dto; | ||
|
||
public class OptionListData | ||
{ | ||
public string Title; | ||
[CanBeNull] public List<Option> Data; | ||
public bool? HasError; | ||
} |
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
41 changes: 0 additions & 41 deletions
41
...nd/app-development/features/appContentLibrary/utils/convertOptionListsToCodeLists.test.ts
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
frontend/app-development/features/appContentLibrary/utils/convertOptionListsToCodeLists.ts
This file was deleted.
Oops, something went wrong.
49 changes: 49 additions & 0 deletions
49
...velopment/features/appContentLibrary/utils/convertOptionsListsDataToCodeListsData.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,49 @@ | ||
import type { CodeListData } from '@studio/content-library'; | ||
import { convertOptionsListsDataToCodeListsData } from './convertOptionsListsDataToCodeListsData'; | ||
import type { OptionsListsResponse } from 'app-shared/types/api/OptionsLists'; | ||
|
||
describe('convertOptionsListsDataToCodeListsData', () => { | ||
it('converts option lists data to code lists data correctly', () => { | ||
const optionListId: string = 'optionListId'; | ||
const optionListsData: OptionsListsResponse = [ | ||
{ | ||
title: optionListId, | ||
data: [ | ||
{ label: 'Option 1', value: '1' }, | ||
{ label: 'Option 2', value: '2' }, | ||
], | ||
hasError: false, | ||
}, | ||
]; | ||
const result: CodeListData[] = convertOptionsListsDataToCodeListsData(optionListsData); | ||
expect(result).toEqual([ | ||
{ | ||
title: optionListId, | ||
data: [ | ||
{ label: 'Option 1', value: '1' }, | ||
{ label: 'Option 2', value: '2' }, | ||
], | ||
hasError: false, | ||
}, | ||
]); | ||
}); | ||
|
||
it('sets hasError to true in result when optionListsResponse returns an option list with error', () => { | ||
const optionListId: string = 'optionListId'; | ||
const optionListsData: OptionsListsResponse = [ | ||
{ | ||
title: optionListId, | ||
data: null, | ||
hasError: true, | ||
}, | ||
]; | ||
const result: CodeListData[] = convertOptionsListsDataToCodeListsData(optionListsData); | ||
expect(result).toEqual([{ title: optionListId, data: null, hasError: true }]); | ||
}); | ||
|
||
it('returns a result with empty code list data array when the input option list data is empty', () => { | ||
const optionListsData: OptionsListsResponse = []; | ||
const result: CodeListData[] = convertOptionsListsDataToCodeListsData(optionListsData); | ||
expect(result).toEqual([]); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
...pp-development/features/appContentLibrary/utils/convertOptionsListsDataToCodeListsData.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,20 @@ | ||
import type { OptionsListData, OptionsListsResponse } from 'app-shared/types/api/OptionsLists'; | ||
import type { CodeListData } from '@studio/content-library'; | ||
|
||
export const convertOptionsListsDataToCodeListsData = (optionListsData: OptionsListsResponse) => { | ||
const codeListsData = []; | ||
optionListsData.map((optionListData) => { | ||
const codeListData = convertOptionsListDataToCodeListData(optionListData); | ||
codeListsData.push(codeListData); | ||
}); | ||
return codeListsData; | ||
}; | ||
|
||
const convertOptionsListDataToCodeListData = (optionListData: OptionsListData) => { | ||
const codeListData: CodeListData = { | ||
title: optionListData.title, | ||
data: optionListData.data, | ||
hasError: optionListData.hasError, | ||
}; | ||
return codeListData; | ||
}; |
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
14 changes: 9 additions & 5 deletions
14
frontend/libs/studio-content-library/mocks/mockPagesConfig.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
Oops, something went wrong.