@admin-layout/client 10.0.9-alpha.59 → 10.0.9-alpha.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config/defaultSettings.d.ts.map +1 -1
- package/lib/config/defaultSettings.js +82 -99
- package/lib/config/defaultSettings.js.map +1 -1
- package/lib/hooks/useLayoutSettings.d.ts.map +1 -1
- package/lib/hooks/useLayoutSettings.js +23 -18
- package/lib/hooks/useLayoutSettings.js.map +1 -1
- package/lib/utils/settingsDiff.test.d.ts +2 -0
- package/lib/utils/settingsDiff.test.d.ts.map +1 -0
- package/lib/utils/settingsDifference.d.ts +5 -0
- package/lib/utils/settingsDifference.d.ts.map +1 -0
- package/lib/utils/settingsDifference.js +206 -0
- package/lib/utils/settingsDifference.js.map +1 -0
- package/lib/utils/settingsDifference.test.d.ts +2 -0
- package/lib/utils/settingsDifference.test.d.ts.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultSettings.d.ts","sourceRoot":"","sources":["../../src/config/defaultSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"defaultSettings.d.ts","sourceRoot":"","sources":["../../src/config/defaultSettings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAuE3D,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG;IAClC,IAAI,EAAE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ACvB,iBAAiB,EAAE,OAAO,CAAC;oBAC3B,QAAQ,EAAE,MAAM,CAAC;oBACjB,MAAM,EAAE,MAAM,CAAC;oBACf,eAAe,EAAE,MAAM,CAAC;oBACxB,SAAS,EAAE,MAAM,CAAC;oBAClB,UAAU,EAAE,OAAO,CAAC;oBACpB,QAAQ,EAAE,OAAO,CAAC;oBAClB,gBAAgB,EAAE,OAAO,CAAC;oBAC1B,eAAe,EAAE,OAAO,CAAC;oBACzB,iBAAiB,EAAE,iBAAiB,CAAC;oBACrC,gBAAgB,EAAE,OAAO,CAAC;oBAC1B,eAAe,EAAE,MAAM,CAAC;iBAC3B,CAAC;gBACF,MAAM,EAAE;oBACJ,UAAU,EAAE,OAAO,CAAC;iBACvB,CAAC;aACL,CAAC;SACL,CAAC;KACL,CACJ,CAAC;IACF,UAAU,EAAE,GAAG,EAAE,CAAC;IAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,SA6G7B,CAAC"}
|
|
@@ -1,4 +1,68 @@
|
|
|
1
|
-
import {SearchBarBehavior}from'../interfaces/settings.js'
|
|
1
|
+
import {SearchBarBehavior}from'../interfaces/settings.js';// import { ContentWidth, SearchBarBehavior, NavigationMode, SideMenuType } from '@admin-layout/tailwind-design-pro/src/machines/types';
|
|
2
|
+
// Constants for common values
|
|
3
|
+
const DEFAULT_LAYOUT = {
|
|
4
|
+
contentWidth: 'Fluid',
|
|
5
|
+
fixedHeader: true,
|
|
6
|
+
fixedSidebar: true,
|
|
7
|
+
splitMenus: false,
|
|
8
|
+
};
|
|
9
|
+
const DEFAULT_HEADER = {
|
|
10
|
+
showLogo: true,
|
|
11
|
+
showRightContent: true,
|
|
12
|
+
showMenuToggle: true,
|
|
13
|
+
showBackButton: true,
|
|
14
|
+
showPageTitle: true,
|
|
15
|
+
showActionButtons: true,
|
|
16
|
+
position: 'fixed',
|
|
17
|
+
backgroundColor: 'inherit',
|
|
18
|
+
elevation: 2,
|
|
19
|
+
showHeader: true,
|
|
20
|
+
showMenu: true,
|
|
21
|
+
menuHeaderRender: true,
|
|
22
|
+
searchBarRender: true,
|
|
23
|
+
searchBarBehavior: SearchBarBehavior.PERMANENT,
|
|
24
|
+
searchBarOverlay: true,
|
|
25
|
+
scrollThreshold: 50,
|
|
26
|
+
};
|
|
27
|
+
const SEARCH_TYPES = {
|
|
28
|
+
HOTELS: 'HOTELS',
|
|
29
|
+
FLIGHTS: 'FLIGHTS',
|
|
30
|
+
CARS: 'CARS',
|
|
31
|
+
};
|
|
32
|
+
const AMENITIES = [
|
|
33
|
+
'WiFi',
|
|
34
|
+
'Pool',
|
|
35
|
+
'Parking',
|
|
36
|
+
'Air Conditioning',
|
|
37
|
+
'Kitchen',
|
|
38
|
+
'Washer',
|
|
39
|
+
'Dryer',
|
|
40
|
+
'TV',
|
|
41
|
+
'Gym',
|
|
42
|
+
'Elevator',
|
|
43
|
+
'Hot Tub',
|
|
44
|
+
'Breakfast',
|
|
45
|
+
];
|
|
46
|
+
// Shared view configuration
|
|
47
|
+
const SHARED_VIEW_CONFIG = {
|
|
48
|
+
layout: {
|
|
49
|
+
...DEFAULT_LAYOUT,
|
|
50
|
+
navigationMode: 'mixed',
|
|
51
|
+
sideMenuType: 'expanded',
|
|
52
|
+
upperMenuDividerName: 'Navigation',
|
|
53
|
+
middleMenuDividerName: 'Dashboard',
|
|
54
|
+
lowerMenuDividerName: 'Admin',
|
|
55
|
+
},
|
|
56
|
+
regions: {
|
|
57
|
+
header: {
|
|
58
|
+
...DEFAULT_HEADER,
|
|
59
|
+
showSearchSlot: true,
|
|
60
|
+
height: '64px',
|
|
61
|
+
},
|
|
62
|
+
footer: { showFooter: true },
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
const defaultSettings = {
|
|
2
66
|
logo: 'https://cdmbase.s3.ca-central-1.amazonaws.com/favicon-new-128.svg',
|
|
3
67
|
themeType: 'light',
|
|
4
68
|
theme: 'default',
|
|
@@ -6,9 +70,9 @@ import {SearchBarBehavior}from'../interfaces/settings.js';const defaultSettings
|
|
|
6
70
|
colorPrimary: '#1677FF',
|
|
7
71
|
secondaryColor: '#4A5568',
|
|
8
72
|
layout: 'mix',
|
|
9
|
-
contentWidth:
|
|
10
|
-
fixedHeader:
|
|
11
|
-
fixSiderbar:
|
|
73
|
+
contentWidth: DEFAULT_LAYOUT.contentWidth,
|
|
74
|
+
fixedHeader: DEFAULT_LAYOUT.fixedHeader,
|
|
75
|
+
fixSiderbar: DEFAULT_LAYOUT.fixedSidebar,
|
|
12
76
|
colorWeak: false,
|
|
13
77
|
title: 'CDMBase LLC',
|
|
14
78
|
iconfontUrl: '',
|
|
@@ -34,80 +98,12 @@ import {SearchBarBehavior}from'../interfaces/settings.js';const defaultSettings
|
|
|
34
98
|
routeSettings: {
|
|
35
99
|
'/': {
|
|
36
100
|
layout: {
|
|
37
|
-
desktop:
|
|
38
|
-
|
|
39
|
-
sideMenuType: 'expanded',
|
|
40
|
-
contentWidth: 'Fluid',
|
|
41
|
-
fixedHeader: true,
|
|
42
|
-
fixedSidebar: true,
|
|
43
|
-
splitMenus: false,
|
|
44
|
-
upperMenuDividerName: 'Navigation',
|
|
45
|
-
middleMenuDividerName: 'Dashboard',
|
|
46
|
-
lowerMenuDividerName: 'Admin',
|
|
47
|
-
},
|
|
48
|
-
mobile: {
|
|
49
|
-
navigationMode: 'sidebar',
|
|
50
|
-
sideMenuType: 'collapsed',
|
|
51
|
-
contentWidth: 'Fluid',
|
|
52
|
-
fixedHeader: false,
|
|
53
|
-
fixedSidebar: false,
|
|
54
|
-
splitMenus: false,
|
|
55
|
-
upperMenuDividerName: 'Mobile Navigation',
|
|
56
|
-
middleMenuDividerName: 'Mobile Dashboard',
|
|
57
|
-
lowerMenuDividerName: 'Mobile Admin',
|
|
58
|
-
},
|
|
101
|
+
desktop: SHARED_VIEW_CONFIG.layout,
|
|
102
|
+
mobile: SHARED_VIEW_CONFIG.layout,
|
|
59
103
|
},
|
|
60
104
|
regions: {
|
|
61
|
-
desktop:
|
|
62
|
-
|
|
63
|
-
showLogo: true,
|
|
64
|
-
showSearchSlot: true,
|
|
65
|
-
showRightContent: true,
|
|
66
|
-
showMenuToggle: true,
|
|
67
|
-
showBackButton: true,
|
|
68
|
-
showPageTitle: true,
|
|
69
|
-
showActionButtons: true,
|
|
70
|
-
position: 'fixed',
|
|
71
|
-
height: '64px',
|
|
72
|
-
backgroundColor: 'inherit',
|
|
73
|
-
elevation: 2,
|
|
74
|
-
showHeader: true,
|
|
75
|
-
showMenu: true,
|
|
76
|
-
menuHeaderRender: true,
|
|
77
|
-
searchBarRender: true,
|
|
78
|
-
searchBarBehavior: SearchBarBehavior.PERMANENT,
|
|
79
|
-
searchBarOverlay: true,
|
|
80
|
-
scrollThreshold: 50,
|
|
81
|
-
},
|
|
82
|
-
footer: {
|
|
83
|
-
showFooter: true,
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
mobile: {
|
|
87
|
-
header: {
|
|
88
|
-
showLogo: true,
|
|
89
|
-
showSearchSlot: false,
|
|
90
|
-
showRightContent: true,
|
|
91
|
-
showMenuToggle: true,
|
|
92
|
-
showBackButton: true,
|
|
93
|
-
showPageTitle: true,
|
|
94
|
-
showActionButtons: true,
|
|
95
|
-
position: 'fixed',
|
|
96
|
-
height: '56px',
|
|
97
|
-
backgroundColor: 'inherit',
|
|
98
|
-
elevation: 2,
|
|
99
|
-
showHeader: true,
|
|
100
|
-
showMenu: true,
|
|
101
|
-
menuHeaderRender: true,
|
|
102
|
-
searchBarRender: true,
|
|
103
|
-
searchBarBehavior: SearchBarBehavior.PERMANENT,
|
|
104
|
-
searchBarOverlay: true,
|
|
105
|
-
scrollThreshold: 50,
|
|
106
|
-
},
|
|
107
|
-
footer: {
|
|
108
|
-
showFooter: true,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
105
|
+
desktop: SHARED_VIEW_CONFIG.regions,
|
|
106
|
+
mobile: SHARED_VIEW_CONFIG.regions,
|
|
111
107
|
},
|
|
112
108
|
},
|
|
113
109
|
},
|
|
@@ -115,40 +111,40 @@ import {SearchBarBehavior}from'../interfaces/settings.js';const defaultSettings
|
|
|
115
111
|
activeComponent: null,
|
|
116
112
|
searchbarSettings: {
|
|
117
113
|
enabledSearchBars: {
|
|
118
|
-
HOTELS: true,
|
|
119
|
-
FLIGHTS: true,
|
|
120
|
-
CARS: true,
|
|
114
|
+
[SEARCH_TYPES.HOTELS]: true,
|
|
115
|
+
[SEARCH_TYPES.FLIGHTS]: true,
|
|
116
|
+
[SEARCH_TYPES.CARS]: true,
|
|
121
117
|
},
|
|
122
118
|
fieldsConfig: {
|
|
123
|
-
HOTELS: {
|
|
119
|
+
[SEARCH_TYPES.HOTELS]: {
|
|
124
120
|
location: true,
|
|
125
121
|
dates: true,
|
|
126
122
|
guests: true,
|
|
127
123
|
},
|
|
128
|
-
FLIGHTS: {
|
|
124
|
+
[SEARCH_TYPES.FLIGHTS]: {
|
|
129
125
|
fromLocation: true,
|
|
130
126
|
toLocation: true,
|
|
131
127
|
dates: true,
|
|
132
128
|
returnFlight: true,
|
|
133
129
|
},
|
|
134
|
-
CARS: {
|
|
130
|
+
[SEARCH_TYPES.CARS]: {
|
|
135
131
|
pickupLocation: true,
|
|
136
132
|
dropoffLocation: true,
|
|
137
133
|
dates: true,
|
|
138
134
|
},
|
|
139
135
|
},
|
|
140
136
|
datePickerConfig: {
|
|
141
|
-
HOTELS: {
|
|
137
|
+
[SEARCH_TYPES.HOTELS]: {
|
|
142
138
|
enableSingleDayMode: true,
|
|
143
139
|
enableTimeSelection: true,
|
|
144
140
|
defaultToSingleDay: false,
|
|
145
141
|
},
|
|
146
|
-
FLIGHTS: {
|
|
142
|
+
[SEARCH_TYPES.FLIGHTS]: {
|
|
147
143
|
enableSingleDayMode: false,
|
|
148
144
|
enableTimeSelection: false,
|
|
149
145
|
defaultToSingleDay: false,
|
|
150
146
|
},
|
|
151
|
-
CARS: {
|
|
147
|
+
[SEARCH_TYPES.CARS]: {
|
|
152
148
|
enableSingleDayMode: false,
|
|
153
149
|
enableTimeSelection: true,
|
|
154
150
|
defaultToSingleDay: false,
|
|
@@ -164,20 +160,7 @@ import {SearchBarBehavior}from'../interfaces/settings.js';const defaultSettings
|
|
|
164
160
|
amenities: true,
|
|
165
161
|
datasources: true,
|
|
166
162
|
},
|
|
167
|
-
amenitiesList:
|
|
168
|
-
{ name: 'WiFi' },
|
|
169
|
-
{ name: 'Pool' },
|
|
170
|
-
{ name: 'Parking' },
|
|
171
|
-
{ name: 'Air Conditioning' },
|
|
172
|
-
{ name: 'Kitchen' },
|
|
173
|
-
{ name: 'Washer' },
|
|
174
|
-
{ name: 'Dryer' },
|
|
175
|
-
{ name: 'TV' },
|
|
176
|
-
{ name: 'Gym' },
|
|
177
|
-
{ name: 'Elevator' },
|
|
178
|
-
{ name: 'Hot Tub' },
|
|
179
|
-
{ name: 'Breakfast' },
|
|
180
|
-
],
|
|
163
|
+
amenitiesList: AMENITIES.map((name) => ({ name })),
|
|
181
164
|
},
|
|
182
165
|
showTypeSelector: true,
|
|
183
166
|
isSettingsPanelOpen: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultSettings.js","sources":["../../src/config/defaultSettings.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"defaultSettings.js","sources":["../../src/config/defaultSettings.ts"],"sourcesContent":[null],"names":[],"mappings":"0DACA;AACA;AAuEA,MAAM,cAAM,GAAY;IACpB,YAAY,EAAC,OAAA;IACb,WAAgB,EAAA,IAAA;IAChB,YAAc,EAAA;IACd,UAAU,EAAE;;MAEF,iBAAS;IACnB,QAAe,EAAA,IAAA;IACf,sBAAoB;IACpB,cAAa;IACb,cAAc,EAAE;IAChB,aAAY;IACZ,uBAAsB;IACtB,QAAS,EAAA,OAAQ;IACjB,eAAc,EAAA,SAAA;IACd,SAAS,EAAE;IACX,UAAe,EAAA,IAAA;IACf,QAAiB,EAAA,IA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayoutSettings.d.ts","sourceRoot":"","sources":["../../src/hooks/useLayoutSettings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLayoutSettings.d.ts","sourceRoot":"","sources":["../../src/hooks/useLayoutSettings.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,iBAAiB;;0BA2DP,GAAG;CA+CzB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useEffect,useCallback}from'react';import {useDispatch,useSelector}from'react-redux';import {merge
|
|
1
|
+
import {useEffect,useCallback}from'react';import {useDispatch,useSelector}from'react-redux';import {merge}from'lodash-es';import {defaultSettings}from'../config/defaultSettings.js';import {CHANGE_SETTINGS_ACTION}from'../constants/constants.js';import {compareAndSaveSettingsDifferences}from'../utils/settingsDifference.js';const updateColorWeak = (colorWeak) => {
|
|
2
2
|
// @sri to avoid breaking during SSR, split into to checks
|
|
3
3
|
if (typeof window !== 'undefined') {
|
|
4
4
|
const root = document.getElementById('root');
|
|
@@ -7,13 +7,6 @@ import {useEffect,useCallback}from'react';import {useDispatch,useSelector}from'r
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
const getDifference = (obj1, obj2) => {
|
|
11
|
-
return transform(obj1, (result, value, key) => {
|
|
12
|
-
if (!isEqual(value, obj2[key])) {
|
|
13
|
-
result[key] = isObject(value) && isObject(obj2[key]) ? getDifference(value, obj2[key]) : value;
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
10
|
const useLayoutSettings = () => {
|
|
18
11
|
const dispatch = useDispatch();
|
|
19
12
|
const settings = useSelector((state) => state.settings);
|
|
@@ -41,8 +34,19 @@ const useLayoutSettings = () => {
|
|
|
41
34
|
throw new Error('Failed to fetch settings');
|
|
42
35
|
}
|
|
43
36
|
const diffSettings = await response.json();
|
|
44
|
-
//
|
|
37
|
+
// Deep merge the differences with default settings
|
|
45
38
|
const mergedSettings = merge({}, defaultSettings, diffSettings);
|
|
39
|
+
// Ensure route settings are properly merged
|
|
40
|
+
if (diffSettings.routeSettings) {
|
|
41
|
+
Object.keys(diffSettings.routeSettings).forEach((route) => {
|
|
42
|
+
if (defaultSettings.routeSettings[route]) {
|
|
43
|
+
mergedSettings.routeSettings[route] = merge({}, defaultSettings.routeSettings[route], diffSettings.routeSettings[route]);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
mergedSettings.routeSettings[route] = diffSettings.routeSettings[route];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
46
50
|
return mergedSettings;
|
|
47
51
|
}
|
|
48
52
|
catch (error) {
|
|
@@ -54,33 +58,34 @@ const useLayoutSettings = () => {
|
|
|
54
58
|
const setSettings = useCallback(async (config) => {
|
|
55
59
|
const { colorWeak, contentWidth } = config;
|
|
56
60
|
try {
|
|
61
|
+
// Handle UI updates for special settings
|
|
57
62
|
if (settings.contentWidth !== contentWidth) {
|
|
58
63
|
if (typeof window !== 'undefined') {
|
|
59
64
|
window.dispatchEvent(new Event('resize'));
|
|
60
65
|
}
|
|
61
66
|
}
|
|
62
67
|
updateColorWeak(!!colorWeak);
|
|
63
|
-
//
|
|
64
|
-
const
|
|
68
|
+
// Use the improved difference comparison and saving function
|
|
69
|
+
const cleanDiffSettings = compareAndSaveSettingsDifferences(config, defaultSettings);
|
|
70
|
+
console.log('cleanDiffSettings >>>>>>>>>>>>>>', cleanDiffSettings);
|
|
65
71
|
const response = await fetch('/resources/settings', {
|
|
66
72
|
method: 'POST',
|
|
67
73
|
headers: {
|
|
68
74
|
'Content-Type': 'application/json',
|
|
69
75
|
},
|
|
70
|
-
body: JSON.stringify({ config:
|
|
76
|
+
body: JSON.stringify({ config: cleanDiffSettings }),
|
|
71
77
|
});
|
|
72
78
|
if (!response.ok) {
|
|
73
79
|
throw new Error('Failed to update settings');
|
|
74
80
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
};
|
|
81
|
+
const result = await response.json();
|
|
82
|
+
console.log('result >>>>>>>>>>>>>>', result);
|
|
83
|
+
// Merge the full config with default settings before updating the store
|
|
84
|
+
const mergedSettings = merge({}, defaultSettings, config);
|
|
79
85
|
dispatch({
|
|
80
86
|
type: CHANGE_SETTINGS_ACTION,
|
|
81
|
-
payload:
|
|
87
|
+
payload: mergedSettings,
|
|
82
88
|
});
|
|
83
|
-
return await response.json();
|
|
84
89
|
}
|
|
85
90
|
catch (error) {
|
|
86
91
|
console.error(error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayoutSettings.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLayoutSettings.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settingsDiff.test.d.ts","sourceRoot":"","sources":["../../src/utils/settingsDiff.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settingsDifference.d.ts","sourceRoot":"","sources":["../../src/utils/settingsDifference.ts"],"names":[],"mappings":"AAoKA;;GAEG;AACH,eAAO,MAAM,iCAAiC,oBAAqB,GAAG,mBAAmB,GAAG,QAoD3F,CAAC"}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import {cloneDeep,isObject,isEqual,transform,get}from'lodash-es';/**
|
|
2
|
+
* Gets the deep differences between two objects
|
|
3
|
+
* Returns only the values that differ from obj2
|
|
4
|
+
*/
|
|
5
|
+
const getDifference = (obj1, obj2) => {
|
|
6
|
+
// Create copies to avoid modifying the original objects
|
|
7
|
+
const source = cloneDeep(obj1);
|
|
8
|
+
const target = cloneDeep(obj2);
|
|
9
|
+
// If obj1 is undefined or null, return undefined to avoid adding to result
|
|
10
|
+
if (source === undefined || source === null) {
|
|
11
|
+
// Only include null/undefined if they differ from obj2
|
|
12
|
+
return source !== target ? source : undefined;
|
|
13
|
+
}
|
|
14
|
+
// If we're comparing different types, or if obj2 is null/undefined, return obj1
|
|
15
|
+
if (typeof source !== typeof target || target === undefined || target === null) {
|
|
16
|
+
return source;
|
|
17
|
+
}
|
|
18
|
+
// Handle non-object comparisons (primitives, functions, etc.)
|
|
19
|
+
if (!isObject(source) || !isObject(target)) {
|
|
20
|
+
// Case-insensitive string comparison
|
|
21
|
+
if (typeof source === 'string' && typeof target === 'string') {
|
|
22
|
+
return source.toLowerCase() !== target.toLowerCase() ? source : undefined;
|
|
23
|
+
}
|
|
24
|
+
return !isEqual(source, target) ? source : undefined;
|
|
25
|
+
}
|
|
26
|
+
// For arrays, do a simple equality check and return the full array if different
|
|
27
|
+
if (Array.isArray(source) && Array.isArray(target)) {
|
|
28
|
+
return !isEqual(source, target) ? source : undefined;
|
|
29
|
+
}
|
|
30
|
+
// For objects, do deep comparison
|
|
31
|
+
const result = transform(source, (result, value, key) => {
|
|
32
|
+
// Skip keys that are in source but have the exact same value in target
|
|
33
|
+
if (key in target && isEqual(value, target[key])) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
// If the key doesn't exist in target, add it to the result
|
|
37
|
+
if (!(key in target)) {
|
|
38
|
+
result[key] = value;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
// For nested objects, recursively get differences
|
|
42
|
+
if (isObject(value) && isObject(target[key])) {
|
|
43
|
+
const nestedDiff = getDifference(value, target[key]);
|
|
44
|
+
if (nestedDiff !== undefined && (Array.isArray(nestedDiff) || Object.keys(nestedDiff).length > 0)) {
|
|
45
|
+
result[key] = nestedDiff;
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
// For non-objects (primitives, etc.), only add if different
|
|
50
|
+
if (!isEqual(value, target[key])) {
|
|
51
|
+
result[key] = value;
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
// Return undefined if the resulting object is empty
|
|
55
|
+
return Object.keys(result).length > 0 ? result : undefined;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Special handler for route settings differences with improved nested comparison
|
|
59
|
+
*/
|
|
60
|
+
const getRouteSettingsDifferences = (currentRouteSettings, defaultRouteSettings) => {
|
|
61
|
+
const differences = {};
|
|
62
|
+
// Get the default route template (typically from '/')
|
|
63
|
+
const defaultRouteTemplate = defaultRouteSettings['/'] || Object.values(defaultRouteSettings)[0];
|
|
64
|
+
if (!defaultRouteTemplate) {
|
|
65
|
+
console.warn('No default route template found for comparison');
|
|
66
|
+
return currentRouteSettings;
|
|
67
|
+
}
|
|
68
|
+
// Compare each route's settings
|
|
69
|
+
Object.keys(currentRouteSettings).forEach((route) => {
|
|
70
|
+
const currentRouteConfig = currentRouteSettings[route];
|
|
71
|
+
// Use the specific route config if it exists, otherwise use the default template
|
|
72
|
+
const defaultRouteConfig = defaultRouteSettings[route] || defaultRouteTemplate;
|
|
73
|
+
// Compare each section separately (layout, regions, etc)
|
|
74
|
+
const routeDiff = {};
|
|
75
|
+
Object.keys(currentRouteConfig).forEach((section) => {
|
|
76
|
+
if (section === 'layout' || section === 'regions') {
|
|
77
|
+
const sectionDiff = {};
|
|
78
|
+
// Compare desktop and mobile separately
|
|
79
|
+
['desktop', 'mobile'].forEach((device) => {
|
|
80
|
+
if (!currentRouteConfig[section][device]) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// For regions section with header/footer
|
|
84
|
+
if (section === 'regions') {
|
|
85
|
+
const regionsDiff = {};
|
|
86
|
+
['header', 'footer'].forEach((region) => {
|
|
87
|
+
if (!currentRouteConfig[section][device][region]) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// Get default path for comparison
|
|
91
|
+
const defaultRegionPath = `${section}.${device}.${region}`;
|
|
92
|
+
const defaultRegion = get(defaultRouteConfig, defaultRegionPath);
|
|
93
|
+
if (defaultRegion) {
|
|
94
|
+
const regionDiff = getDifference(currentRouteConfig[section][device][region], defaultRegion);
|
|
95
|
+
if (regionDiff !== undefined && Object.keys(regionDiff).length > 0) {
|
|
96
|
+
regionsDiff[region] = regionDiff;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
if (Object.keys(regionsDiff).length > 0) {
|
|
101
|
+
sectionDiff[device] = regionsDiff;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
// For other sections (like layout)
|
|
106
|
+
const defaultDevicePath = `${section}.${device}`;
|
|
107
|
+
const defaultDevice = get(defaultRouteConfig, defaultDevicePath);
|
|
108
|
+
if (defaultDevice) {
|
|
109
|
+
const deviceDiff = getDifference(currentRouteConfig[section][device], defaultDevice);
|
|
110
|
+
if (deviceDiff !== undefined && Object.keys(deviceDiff).length > 0) {
|
|
111
|
+
sectionDiff[device] = deviceDiff;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
if (Object.keys(sectionDiff).length > 0) {
|
|
117
|
+
routeDiff[section] = sectionDiff;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
const sectionDiff = getDifference(currentRouteConfig[section], defaultRouteConfig[section]);
|
|
122
|
+
if (sectionDiff !== undefined && Object.keys(sectionDiff).length > 0) {
|
|
123
|
+
routeDiff[section] = sectionDiff;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
// Only include the route if there are actual differences
|
|
128
|
+
if (Object.keys(routeDiff).length > 0) {
|
|
129
|
+
differences[route] = routeDiff;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
return Object.keys(differences).length > 0 ? differences : undefined;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Compares settings objects and saves only the differences
|
|
136
|
+
*/
|
|
137
|
+
const compareAndSaveSettingsDifferences = (currentSettings, defaultSettings) => {
|
|
138
|
+
try {
|
|
139
|
+
if (!currentSettings || !defaultSettings) {
|
|
140
|
+
console.warn('Missing settings objects for comparison');
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
// Make deep clones to avoid modifying the original objects
|
|
144
|
+
const current = cloneDeep(currentSettings);
|
|
145
|
+
const defaults = cloneDeep(defaultSettings);
|
|
146
|
+
// Handle route settings separately
|
|
147
|
+
const routeSettingsDiff = current.routeSettings
|
|
148
|
+
? getRouteSettingsDifferences(current.routeSettings, defaults?.routeSettings || {})
|
|
149
|
+
: undefined;
|
|
150
|
+
// Make a copy of settings without routeSettings to compare separately
|
|
151
|
+
const currentWithoutRoutes = { ...current };
|
|
152
|
+
const defaultWithoutRoutes = { ...defaults };
|
|
153
|
+
delete currentWithoutRoutes.routeSettings;
|
|
154
|
+
delete defaultWithoutRoutes.routeSettings;
|
|
155
|
+
// Get differences for all other settings
|
|
156
|
+
const otherSettingsDiff = getDifference(currentWithoutRoutes, defaultWithoutRoutes);
|
|
157
|
+
// Combine the differences
|
|
158
|
+
const diffSettings = {};
|
|
159
|
+
// Add other settings differences if any exist and are not empty objects
|
|
160
|
+
if (otherSettingsDiff && Object.keys(otherSettingsDiff).length > 0) {
|
|
161
|
+
Object.assign(diffSettings, otherSettingsDiff);
|
|
162
|
+
}
|
|
163
|
+
// Add route settings differences if any exist
|
|
164
|
+
if (routeSettingsDiff && Object.keys(routeSettingsDiff).length > 0) {
|
|
165
|
+
diffSettings.routeSettings = routeSettingsDiff;
|
|
166
|
+
}
|
|
167
|
+
// If there are no differences at all, return early
|
|
168
|
+
if (Object.keys(diffSettings).length === 0) {
|
|
169
|
+
return { success: true, message: 'No changes to save' };
|
|
170
|
+
}
|
|
171
|
+
// Remove empty objects from the diff
|
|
172
|
+
// This helps prevent unnecessary properties in the payload
|
|
173
|
+
const cleanDiffSettings = removeEmptyObjects(diffSettings);
|
|
174
|
+
return cleanDiffSettings;
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
console.error('Error comparing settings differences:', error);
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Recursively removes empty objects from an object
|
|
183
|
+
* This helps clean up the diff payload
|
|
184
|
+
*/
|
|
185
|
+
function removeEmptyObjects(obj) {
|
|
186
|
+
if (!isObject(obj) || Array.isArray(obj)) {
|
|
187
|
+
return obj;
|
|
188
|
+
}
|
|
189
|
+
const result = {};
|
|
190
|
+
let hasKeys = false;
|
|
191
|
+
Object.keys(obj).forEach((key) => {
|
|
192
|
+
const value = obj[key];
|
|
193
|
+
if (isObject(value) && !Array.isArray(value)) {
|
|
194
|
+
const cleanValue = removeEmptyObjects(value);
|
|
195
|
+
if (Object.keys(cleanValue).length > 0) {
|
|
196
|
+
result[key] = cleanValue;
|
|
197
|
+
hasKeys = true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else if (value !== undefined) {
|
|
201
|
+
result[key] = value;
|
|
202
|
+
hasKeys = true;
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
return hasKeys ? result : {};
|
|
206
|
+
}export{compareAndSaveSettingsDifferences};//# sourceMappingURL=settingsDifference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settingsDifference.js","sources":["../../src/utils/settingsDifference.ts"],"sourcesContent":[null],"names":[],"mappings":";AAsKG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settingsDifference.test.d.ts","sourceRoot":"","sources":["../../src/utils/settingsDifference.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@admin-layout/client",
|
|
3
|
-
"version": "10.0.9-alpha.
|
|
3
|
+
"version": "10.0.9-alpha.62",
|
|
4
4
|
"description": "Sample client for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "b7a9006c1f96081cb2b3906adef7d8556203f85f",
|
|
41
41
|
"typescript": {
|
|
42
42
|
"definition": "lib/index.d.ts"
|
|
43
43
|
}
|