File tree Expand file tree Collapse file tree 5 files changed +22
-21
lines changed
MainPage/pages/VizPage/slice Expand file tree Collapse file tree 5 files changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ import { ChartDTO } from 'app/types/ChartDTO';
2525import { View } from 'app/types/View' ;
2626import {
2727 buildUpdateChartRequest ,
28- convertToChartDTO2 ,
28+ convertToChartDto ,
2929} from 'app/utils/ChartDtoHelper' ;
3030import { filterSqlOperatorName } from 'app/utils/internalChartHelper' ;
3131import { request2 } from 'utils/request' ;
@@ -220,7 +220,7 @@ export const fetchChartAction = createAsyncThunk<
220220 method : 'GET' ,
221221 url : `viz/datacharts/${ arg . chartId } ` ,
222222 } ) ;
223- return convertToChartDTO2 ( response ?. data ) ;
223+ return convertToChartDto ( response ?. data ) ;
224224 }
225225 return arg . backendChart as any ;
226226} ) ;
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ import { getLoggedInUserPermissions } from 'app/pages/MainPage/slice/thunks';
2727import { StoryBoard } from 'app/pages/StoryBoardPage/slice/types' ;
2828import { IChartDrillOption } from 'app/types/ChartDrillOption' ;
2929import { ChartDTO } from 'app/types/ChartDTO' ;
30- import { convertToChartDTO } from 'app/utils/ChartDtoHelper' ;
30+ import { convertToChartDto } from 'app/utils/ChartDtoHelper' ;
3131import { filterSqlOperatorName } from 'app/utils/internalChartHelper' ;
3232import { RootState } from 'types' ;
3333import { request2 } from 'utils/request' ;
@@ -263,7 +263,7 @@ export const fetchVizChartAction = createAsyncThunk(
263263 url : `viz/datacharts/${ arg . backendChartId } ` ,
264264 } ) ;
265265 return {
266- data : convertToChartDTO ( response ?. data ) ,
266+ data : convertToChartDto ( response ?. data ) ,
267267 filterSearchParams : arg . filterSearchParams ,
268268 } ;
269269 } ,
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ import {
2929import { handleServerStoryAction } from 'app/pages/StoryBoardPage/slice/actions' ;
3030import { ServerStoryBoard } from 'app/pages/StoryBoardPage/slice/types' ;
3131import { IChartDrillOption } from 'app/types/ChartDrillOption' ;
32- import { convertToChartDTO } from 'app/utils/ChartDtoHelper' ;
32+ import { convertToChartDto } from 'app/utils/ChartDtoHelper' ;
3333import { RootState } from 'types' ;
3434import persistence from 'utils/persistence' ;
3535import { request2 } from 'utils/request' ;
@@ -99,7 +99,7 @@ export const fetchShareVizInfo = createAsyncThunk(
9999 case 'DATACHART' :
100100 const shareVizInfo = {
101101 ...data ,
102- vizDetail : convertToChartDTO ( data . vizDetail ) ,
102+ vizDetail : convertToChartDto ( data . vizDetail ) ,
103103 } ;
104104 thunkAPI . dispatch (
105105 shareActions . setDataChart ( { data : shareVizInfo , filterSearchParams } ) ,
Original file line number Diff line number Diff line change 1616 * limitations under the License.
1717 */
1818
19+ import beginViewModelMigration from 'app/migration/ViewConfig/migrationViewModelConfig' ;
1920import { ChartConfig , ChartStyleConfig } from 'app/types/ChartConfig' ;
2021import { ChartConfigDTO , ChartDetailConfigDTO } from 'app/types/ChartConfigDTO' ;
2122import { ChartDTO } from 'app/types/ChartDTO' ;
2223import {
2324 mergeChartDataConfigs ,
2425 mergeChartStyleConfigs ,
2526 transformHierarchyMeta ,
26- transformMeta ,
2727} from 'app/utils/internalChartHelper' ;
2828import { Omit } from 'utils/object' ;
2929
30- export function convertToChartDTO ( data ) : ChartDTO {
31- return Object . assign ( { } , data , {
32- config : JSON . parse ( data ?. config ) ,
33- view : {
34- ...Omit ( data ?. view , [ 'model' ] ) ,
35- meta : transformMeta ( data ?. view ?. model ) ,
36- } ,
37- } ) ;
38- }
39-
40- export function convertToChartDTO2 ( data ) : ChartDTO {
30+ export function convertToChartDto ( data ) : ChartDTO {
31+ if ( data ?. view ?. model ) {
32+ data . view . model = beginViewModelMigration ( data . view . model ) ;
33+ }
4134 return Object . assign ( { } , data , {
4235 config : JSON . parse ( data ?. config ) ,
4336 view : {
Original file line number Diff line number Diff line change 1919import {
2020 buildUpdateChartRequest ,
2121 convertToChartConfigDTO ,
22- convertToChartDTO ,
22+ convertToChartDto ,
2323 mergeToChartConfig ,
2424} from '../ChartDtoHelper' ;
2525
@@ -31,11 +31,19 @@ describe('chartDtoHelper Test', () => {
3131 model : JSON . stringify ( { name : 2 } ) ,
3232 } ,
3333 } ;
34- const dto = convertToChartDTO ( data ) ;
34+ const dto = convertToChartDto ( data ) ;
3535 expect ( dto ) . toEqual ( {
3636 config : { id : 1 } ,
3737 view : {
38- meta : [ { id : 'name' , category : 'field' } ] ,
38+ meta : [
39+ {
40+ name : 'name' ,
41+ id : 'name' ,
42+ subType : undefined ,
43+ category : 'field' ,
44+ children : undefined ,
45+ } ,
46+ ] ,
3947 } ,
4048 } ) ;
4149 } ) ;
You can’t perform that action at this time.
0 commit comments