@configuratorware/configurator-frontendgui 1.40.2 → 1.40.4
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/App/Modules/Designer/Containers/ImageEditDialog.js +28 -10
- package/App/Reducers/DesignArea/Selectors.js +44 -11
- package/App/Reducers/DesignData/Modifiers.js +3 -1
- package/App/Reducers/ImageGallery/Actions.js +25 -18
- package/App/Reducers/ImageGallery/Reducer.js +5 -0
- package/App/Reducers/ImageGallery/Selectors.js +1 -1
- package/App/Screens/DesignerProductPreview/DesignerProductPreviewManager.js +10 -9
- package/App/Services/DesignDataService.js +494 -435
- package/App/configuration.js +1 -1
- package/package.json +4 -4
- package/src/App/Modules/Designer/Containers/ImageEditDialog.js +33 -6
- package/src/App/Reducers/DesignArea/Selectors.js +39 -9
- package/src/App/Reducers/DesignArea/__tests__/Selectors.test.js +19 -0
- package/src/App/Reducers/DesignData/Modifiers.js +3 -0
- package/src/App/Reducers/ImageGallery/Actions.js +20 -5
- package/src/App/Reducers/ImageGallery/Reducer.js +5 -0
- package/src/App/Reducers/ImageGallery/Selectors.js +4 -3
- package/src/App/Reducers/ImageGallery/__tests__/Actions.test.js +81 -7
- package/src/App/Screens/DesignerProductPreview/DesignerProductPreviewManager.js +4 -1
- package/src/App/Services/DesignDataService.js +56 -16
- package/src/App/configuration.js +1 -1
package/App/configuration.js
CHANGED
|
@@ -31,7 +31,7 @@ var DEVELOPMENT_HOST_INT = 'http://int.configuratorware.local'; // eslint-disabl
|
|
|
31
31
|
var DEVELOPMENT_HOST_LOCAL = 'http://localhost:10030';
|
|
32
32
|
var hostsByNodeEnv = {
|
|
33
33
|
production: '',
|
|
34
|
-
development:
|
|
34
|
+
development: DEVELOPMENT_HOST_LOCAL,
|
|
35
35
|
test: ''
|
|
36
36
|
};
|
|
37
37
|
var resourceUrlsByNodeEnv = {
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configuratorware/configurator-frontendgui",
|
|
3
|
-
"version": "1.40.
|
|
3
|
+
"version": "1.40.4",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@babel/polyfill": "^7.12.1",
|
|
9
|
-
"@configuratorware/scripts": "1.40.
|
|
9
|
+
"@configuratorware/scripts": "1.40.4",
|
|
10
10
|
"@hot-loader/react-dom": "^17.0.1",
|
|
11
11
|
"@material-ui/core": "^4.12.2",
|
|
12
12
|
"@material-ui/icons": "^4.11.2",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"react-router-dom": "^5.2.0",
|
|
40
40
|
"react-swipeable": "^5.5.1",
|
|
41
41
|
"react-zoom-pan-pinch": "^2.1.3",
|
|
42
|
-
"redhotmagma-graphics-editor": "1.40.
|
|
43
|
-
"redhotmagma-visualization": "1.40.
|
|
42
|
+
"redhotmagma-graphics-editor": "1.40.4",
|
|
43
|
+
"redhotmagma-visualization": "1.40.4",
|
|
44
44
|
"redux": "^4.1.0",
|
|
45
45
|
"redux-logger": "^3.0.6",
|
|
46
46
|
"redux-persist": "^5.10.0",
|
|
@@ -97,6 +97,7 @@ export class ImageEditDialogContainer extends React.Component {
|
|
|
97
97
|
open: PropTypes.bool,
|
|
98
98
|
editMode: PropTypes.bool,
|
|
99
99
|
vectorsRequired: PropTypes.bool,
|
|
100
|
+
vectorizedLogoMandatory: PropTypes.bool,
|
|
100
101
|
colorDisabled: PropTypes.bool,
|
|
101
102
|
loading: PropTypes.bool,
|
|
102
103
|
errorCode: PropTypes.string,
|
|
@@ -180,6 +181,7 @@ export class ImageEditDialogContainer extends React.Component {
|
|
|
180
181
|
isImageCompatible,
|
|
181
182
|
isColorMappingCompatible,
|
|
182
183
|
vectorsRequired,
|
|
184
|
+
vectorizedLogoMandatory,
|
|
183
185
|
} = this.props;
|
|
184
186
|
|
|
185
187
|
const { vectorize, vectorizeColorsMap, activeTabIndex, originalImagePreview } = this.state;
|
|
@@ -256,13 +258,32 @@ export class ImageEditDialogContainer extends React.Component {
|
|
|
256
258
|
Object.assign(newState, { vectorizeColorsMap });
|
|
257
259
|
}
|
|
258
260
|
|
|
259
|
-
if (
|
|
261
|
+
if (
|
|
262
|
+
activeTabIndex === 2 &&
|
|
263
|
+
(vectorsRequired || vectorizedLogoMandatory) &&
|
|
264
|
+
!vectorize &&
|
|
265
|
+
!image.gallery
|
|
266
|
+
) {
|
|
260
267
|
Object.assign(newState, {
|
|
261
268
|
vectorize: true,
|
|
262
269
|
});
|
|
263
270
|
}
|
|
264
271
|
|
|
265
|
-
|
|
272
|
+
let options;
|
|
273
|
+
if (
|
|
274
|
+
activeTabIndex === 2 &&
|
|
275
|
+
!image.gallery &&
|
|
276
|
+
vectorizedLogoMandatory &&
|
|
277
|
+
!image.displayColorPreview &&
|
|
278
|
+
!this.state.displayColorPreview
|
|
279
|
+
) {
|
|
280
|
+
options = { displayColorPreview: true };
|
|
281
|
+
Object.assign(newState, {
|
|
282
|
+
displayColorPreview: true,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
(!isMatch(this.state, newState) || options) && this.handleStateChange(newState, options);
|
|
266
287
|
|
|
267
288
|
if ((justOpened || imageChanged) && !image.incomplete) {
|
|
268
289
|
this.updatePreview(null, { forceFetch: operationsChanged });
|
|
@@ -514,10 +535,12 @@ export class ImageEditDialogContainer extends React.Component {
|
|
|
514
535
|
if (forceUpdate) {
|
|
515
536
|
this.previewVersion = Math.random();
|
|
516
537
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
538
|
+
if (previewUrl) {
|
|
539
|
+
preview =
|
|
540
|
+
getPreviewUrlFromImageData(previewUrl) +
|
|
541
|
+
(this.previewVersion ? `?${this.previewVersion}` : '');
|
|
542
|
+
originalImagePreview = preview;
|
|
543
|
+
}
|
|
521
544
|
}
|
|
522
545
|
}
|
|
523
546
|
|
|
@@ -641,6 +664,7 @@ export class ImageEditDialogContainer extends React.Component {
|
|
|
641
664
|
maxColorAmount,
|
|
642
665
|
colorDisabled,
|
|
643
666
|
vectorsRequired,
|
|
667
|
+
vectorizedLogoMandatory,
|
|
644
668
|
image,
|
|
645
669
|
usedColors,
|
|
646
670
|
imageColorsWereEdited,
|
|
@@ -680,6 +704,7 @@ export class ImageEditDialogContainer extends React.Component {
|
|
|
680
704
|
activeTabIndex === 2 &&
|
|
681
705
|
colorCount > 0 &&
|
|
682
706
|
!isGalleryImage &&
|
|
707
|
+
!vectorizedLogoMandatory &&
|
|
683
708
|
(colorPreviewEnabled || !colorPreviewRequirementFulfilled);
|
|
684
709
|
|
|
685
710
|
return (
|
|
@@ -779,6 +804,7 @@ const mapStateToProps = state => {
|
|
|
779
804
|
const colorPalettes = getColorPalettes(state);
|
|
780
805
|
const designProductionMethod = getSelectedDesignProductionMethod(state);
|
|
781
806
|
const vectorsRequired = !!get(designProductionMethod, 'options.vectorsRequired');
|
|
807
|
+
const vectorizedLogoMandatory = !!get(designProductionMethod, 'options.vectorizedLogoMandatory');
|
|
782
808
|
const colorDisabled = isColoringDisabled(state);
|
|
783
809
|
const userImages = getUserImages(imageGallery);
|
|
784
810
|
const hasPlaceHolderImage = hasPlaceHolderImagesForActiveDesignArea(state);
|
|
@@ -818,6 +844,7 @@ const mapStateToProps = state => {
|
|
|
818
844
|
userImages,
|
|
819
845
|
colorPalettes,
|
|
820
846
|
vectorsRequired,
|
|
847
|
+
vectorizedLogoMandatory,
|
|
821
848
|
colorDisabled,
|
|
822
849
|
uploadSize,
|
|
823
850
|
galleryHasImages,
|
|
@@ -13,6 +13,7 @@ import intersectionBy from 'lodash/intersectionBy';
|
|
|
13
13
|
import isEqual from 'lodash/isEqual';
|
|
14
14
|
import values from 'lodash/values';
|
|
15
15
|
import createSelector from 'Utils/Function/createSelector';
|
|
16
|
+
import memoize from 'Utils/Function/memoize';
|
|
16
17
|
import { getConf } from '../../configuration';
|
|
17
18
|
import { getMissingColorPalettesColors } from '../../Services/DesignDataService';
|
|
18
19
|
import { getConfigurator, getSelectedVariantIdentifier } from '../Configurator/Selectors';
|
|
@@ -368,17 +369,19 @@ export function getCurrentCanvasSize(state, defaultSize = zeroSize) {
|
|
|
368
369
|
return getCanvasSizeFromDesignProductionMethod(designProductionMethod);
|
|
369
370
|
}
|
|
370
371
|
|
|
372
|
+
const memoizedCanvasSize = memoize((width, height, isMetric, dpi) => ({
|
|
373
|
+
width,
|
|
374
|
+
height,
|
|
375
|
+
isMetric,
|
|
376
|
+
dpi,
|
|
377
|
+
}));
|
|
378
|
+
|
|
371
379
|
export function getCanvasSizeFromDesignProductionMethod(designProductionMethod, defaultSize = zeroSize) {
|
|
372
380
|
const { width, height, dpi } = designProductionMethod;
|
|
373
381
|
if (!width || !height) {
|
|
374
382
|
return defaultSize;
|
|
375
383
|
}
|
|
376
|
-
return
|
|
377
|
-
width,
|
|
378
|
-
height,
|
|
379
|
-
isMetric: true,
|
|
380
|
-
dpi: dpi || getConf('designer.dpi', 300),
|
|
381
|
-
};
|
|
384
|
+
return memoizedCanvasSize(width, height, true, dpi || getConf('designer.dpi', 300));
|
|
382
385
|
}
|
|
383
386
|
|
|
384
387
|
export function getCanvasSizeFromDesignArea(state, designArea, defaultSize = zeroSize) {
|
|
@@ -800,7 +803,8 @@ export const getDesignAreaImageCompatibilityInfo = designProductionMethod => {
|
|
|
800
803
|
.sort();
|
|
801
804
|
const vectorsRequired = !!get(designProductionMethod, 'options.vectorsRequired');
|
|
802
805
|
const maxColorAmount = get(designProductionMethod, 'options.maxColorAmount', 0);
|
|
803
|
-
|
|
806
|
+
const vectorizedLogoMandatory = get(designProductionMethod, 'options.vectorizedLogoMandatory', false);
|
|
807
|
+
return { colorPalettes, vectorsRequired, maxColorAmount, vectorizedLogoMandatory };
|
|
804
808
|
};
|
|
805
809
|
|
|
806
810
|
export const getCurrentCompatibilityInfoHash = state =>
|
|
@@ -812,6 +816,7 @@ export const areHashesCompatible = (storedHash, targetHash) => {
|
|
|
812
816
|
(storedHash &&
|
|
813
817
|
isEqual(storedHash.colorPalettes, targetHash.colorPalettes) &&
|
|
814
818
|
(!targetHash.vectorsRequired || storedHash.vectorsRequired) &&
|
|
819
|
+
(!targetHash.vectorizedLogoMandatory || storedHash.vectorizedLogoMandatory) &&
|
|
815
820
|
(!targetHash.maxColorAmount || storedHash.maxColorAmount <= targetHash.maxColorAmount))
|
|
816
821
|
);
|
|
817
822
|
};
|
|
@@ -895,14 +900,21 @@ export const getDesignAreaColorAmount = (maxColorAmount, preSelectionColorAmount
|
|
|
895
900
|
return amount;
|
|
896
901
|
};
|
|
897
902
|
|
|
903
|
+
export const isVectorizedLogoMandatory = designProductionMethod =>
|
|
904
|
+
!!designProductionMethod?.options?.vectorizedLogoMandatory;
|
|
905
|
+
|
|
898
906
|
export const getVectorizeForDesignProductionMethods = (state, designProductionMethodIdentifier) => {
|
|
899
907
|
const { designProductionMethod } = getSelectedDesignAreaProperties(state);
|
|
900
908
|
const newProductionMethod = getDesignProductionMethodByIdentifier(
|
|
901
909
|
state,
|
|
902
910
|
designProductionMethodIdentifier
|
|
903
911
|
);
|
|
904
|
-
const currentVectorsRequired =
|
|
905
|
-
|
|
912
|
+
const currentVectorsRequired =
|
|
913
|
+
!!get(designProductionMethod, 'options.vectorsRequired') &&
|
|
914
|
+
isVectorizedLogoMandatory(designProductionMethod);
|
|
915
|
+
const newVectorsRequired =
|
|
916
|
+
!!get(newProductionMethod, 'options.vectorsRequired') &&
|
|
917
|
+
isVectorizedLogoMandatory(newProductionMethod);
|
|
906
918
|
|
|
907
919
|
return {
|
|
908
920
|
currentVectorsRequired,
|
|
@@ -910,6 +922,24 @@ export const getVectorizeForDesignProductionMethods = (state, designProductionMe
|
|
|
910
922
|
};
|
|
911
923
|
};
|
|
912
924
|
|
|
925
|
+
export const getMandatoryVectorizationForDesignProductionMethods = (
|
|
926
|
+
state,
|
|
927
|
+
designProductionMethodIdentifier
|
|
928
|
+
) => {
|
|
929
|
+
const { designProductionMethod } = getSelectedDesignAreaProperties(state);
|
|
930
|
+
const newProductionMethod = getDesignProductionMethodByIdentifier(
|
|
931
|
+
state,
|
|
932
|
+
designProductionMethodIdentifier
|
|
933
|
+
);
|
|
934
|
+
const currentVectorsMandatory = isVectorizedLogoMandatory(designProductionMethod);
|
|
935
|
+
const newVectorsMandatory = isVectorizedLogoMandatory(newProductionMethod);
|
|
936
|
+
|
|
937
|
+
return {
|
|
938
|
+
currentVectorsMandatory,
|
|
939
|
+
newVectorsMandatory,
|
|
940
|
+
};
|
|
941
|
+
};
|
|
942
|
+
|
|
913
943
|
export const getImagesByDesignArea = (state, designAreaIdentifier) => {
|
|
914
944
|
if (!designAreaIdentifier) {
|
|
915
945
|
designAreaIdentifier = getSelectedDesignArea(state).identifier;
|
|
@@ -1588,6 +1588,7 @@ describe('Reducers/DesignArea/Selectors', () => {
|
|
|
1588
1588
|
expect(compatibilityInfo).toEqual({
|
|
1589
1589
|
colorPalettes: ['default'],
|
|
1590
1590
|
vectorsRequired: true,
|
|
1591
|
+
vectorizedLogoMandatory: false,
|
|
1591
1592
|
maxColorAmount: 4,
|
|
1592
1593
|
});
|
|
1593
1594
|
});
|
|
@@ -1602,6 +1603,7 @@ describe('Reducers/DesignArea/Selectors', () => {
|
|
|
1602
1603
|
options: {
|
|
1603
1604
|
maxColorAmount: 4,
|
|
1604
1605
|
vectorsRequired: true,
|
|
1606
|
+
vectorizedLogoMandatory: true,
|
|
1605
1607
|
},
|
|
1606
1608
|
colorPalettes: [
|
|
1607
1609
|
{
|
|
@@ -1631,6 +1633,7 @@ describe('Reducers/DesignArea/Selectors', () => {
|
|
|
1631
1633
|
expect(compatibilityInfo).toEqual({
|
|
1632
1634
|
colorPalettes: ['default'],
|
|
1633
1635
|
vectorsRequired: true,
|
|
1636
|
+
vectorizedLogoMandatory: true,
|
|
1634
1637
|
maxColorAmount: 4,
|
|
1635
1638
|
});
|
|
1636
1639
|
});
|
|
@@ -1664,6 +1667,22 @@ describe('Reducers/DesignArea/Selectors', () => {
|
|
|
1664
1667
|
}
|
|
1665
1668
|
)
|
|
1666
1669
|
).toBe(false);
|
|
1670
|
+
expect(
|
|
1671
|
+
areHashesCompatible(
|
|
1672
|
+
{
|
|
1673
|
+
colorPalettes: ['palette_1'],
|
|
1674
|
+
vectorsRequired: true,
|
|
1675
|
+
maxColorAmount: 4,
|
|
1676
|
+
vectorizedLogoMandatory: false,
|
|
1677
|
+
},
|
|
1678
|
+
{
|
|
1679
|
+
colorPalettes: ['palette_1'],
|
|
1680
|
+
vectorsRequired: true,
|
|
1681
|
+
maxColorAmount: 4,
|
|
1682
|
+
vectorizedLogoMandatory: true,
|
|
1683
|
+
}
|
|
1684
|
+
)
|
|
1685
|
+
).toBe(false);
|
|
1667
1686
|
});
|
|
1668
1687
|
|
|
1669
1688
|
test('areHashesCompatible returns the correct result compatible hashes', () => {
|
|
@@ -46,11 +46,14 @@ export const getEditDataFromOperations = (imageFileName, operations, designProdu
|
|
|
46
46
|
} = operations;
|
|
47
47
|
|
|
48
48
|
const maxColorAmount = +get(designProductionMethod, 'options.maxColorAmount', 0);
|
|
49
|
+
|
|
50
|
+
const vectorizedLogoMandatory = get(designProductionMethod, 'options.vectorizedLogoMandatory', false);
|
|
49
51
|
const vectorizeMonochrome = maxColorAmount === 1 && vectorizeThreshold === 1;
|
|
50
52
|
|
|
51
53
|
const result = {
|
|
52
54
|
fileName: imageFileName,
|
|
53
55
|
operations: [],
|
|
56
|
+
vectorizedLogoMandatory,
|
|
54
57
|
};
|
|
55
58
|
|
|
56
59
|
if (clipping && clippingColor) {
|
|
@@ -3,7 +3,11 @@ import { createAsyncTask } from '../UI/Actions';
|
|
|
3
3
|
import { getUserImagesByDesignArea } from './Selectors';
|
|
4
4
|
import { calculateImageBrightness } from '../../Services/DesignDataService';
|
|
5
5
|
import { getImageUsageInfo } from './Selectors';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getCurrentCompatibilityInfoHash,
|
|
8
|
+
getSelectedDesignProductionMethod,
|
|
9
|
+
isVectorizedLogoMandatory,
|
|
10
|
+
} from '../DesignArea/Selectors';
|
|
7
11
|
|
|
8
12
|
export const RECEIVE_GALLERY = 'imageGallery/RECEIVE_GALLERY';
|
|
9
13
|
export const RECEIVE_GALLERY_TAGS = 'imageGallery/RECEIVE_GALLERY_TAGS';
|
|
@@ -94,7 +98,9 @@ export const updateImage = (identifier, imageDataPatch, immediateCommit = false)
|
|
|
94
98
|
};
|
|
95
99
|
|
|
96
100
|
export const uploadImage = file =>
|
|
97
|
-
createAsyncTask(WN_UPLOAD_IMAGE, async dispatch => {
|
|
101
|
+
createAsyncTask(WN_UPLOAD_IMAGE, async (dispatch, getState) => {
|
|
102
|
+
const designProductionMethod = getSelectedDesignProductionMethod(getState());
|
|
103
|
+
const vectorizedLogoMandatory = isVectorizedLogoMandatory(designProductionMethod);
|
|
98
104
|
const data = new FormData();
|
|
99
105
|
data.append('userImage', file);
|
|
100
106
|
data.append('userImageEditData', JSON.stringify({}));
|
|
@@ -103,7 +109,9 @@ export const uploadImage = file =>
|
|
|
103
109
|
postDataAsync(
|
|
104
110
|
URL_UPLOAD,
|
|
105
111
|
data,
|
|
106
|
-
createDefaultReceiver(RECEIVE_IMAGE_UPLOAD_DATA
|
|
112
|
+
createDefaultReceiver(RECEIVE_IMAGE_UPLOAD_DATA, {
|
|
113
|
+
vectorizedLogoMandatory,
|
|
114
|
+
}),
|
|
107
115
|
{},
|
|
108
116
|
{},
|
|
109
117
|
{
|
|
@@ -142,7 +150,9 @@ export const dismissError = () => (dispatch, getState) => {
|
|
|
142
150
|
* @param actionOptions
|
|
143
151
|
*/
|
|
144
152
|
export const editImage = (editData, imageData, actionOptions = {}) =>
|
|
145
|
-
createAsyncTask(WN_UPLOAD_IMAGE, async dispatch => {
|
|
153
|
+
createAsyncTask(WN_UPLOAD_IMAGE, async (dispatch, getState) => {
|
|
154
|
+
const designProductionMethod = getSelectedDesignProductionMethod(getState());
|
|
155
|
+
const vectorizedLogoMandatory = isVectorizedLogoMandatory(designProductionMethod);
|
|
146
156
|
const data = new FormData();
|
|
147
157
|
const { createCopy } = editData;
|
|
148
158
|
data.append('userImageEditData', JSON.stringify(editData));
|
|
@@ -151,7 +161,12 @@ export const editImage = (editData, imageData, actionOptions = {}) =>
|
|
|
151
161
|
postDataAsync(
|
|
152
162
|
URL_UPLOAD,
|
|
153
163
|
data,
|
|
154
|
-
createDefaultReceiver(RECEIVE_IMAGE_UPLOAD_DATA, {
|
|
164
|
+
createDefaultReceiver(RECEIVE_IMAGE_UPLOAD_DATA, {
|
|
165
|
+
imageData,
|
|
166
|
+
createCopy,
|
|
167
|
+
vectorizedLogoMandatory,
|
|
168
|
+
...actionOptions,
|
|
169
|
+
})
|
|
155
170
|
)
|
|
156
171
|
);
|
|
157
172
|
return await calculateImageBrightness(uploadResponse);
|
|
@@ -30,6 +30,11 @@ const updateDerivedImageDataProps = imageData => {
|
|
|
30
30
|
imageData.displayColorPreview = getConf('autoPreviewVectorization', true);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
if (imageData.vectorizedLogoMandatory) {
|
|
34
|
+
imageData.colorPreviewEnabled = false;
|
|
35
|
+
imageData.displayColorPreview = true;
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
return imageData;
|
|
34
39
|
};
|
|
35
40
|
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
getCurrentCompatibilityInfoHash,
|
|
13
13
|
getDesignProductionMethodByIdentifier,
|
|
14
14
|
getSelectedDesignProductionMethod,
|
|
15
|
+
isVectorizedLogoMandatory,
|
|
15
16
|
} from '../DesignArea/Selectors';
|
|
16
17
|
import isEqual from 'lodash/isEqual';
|
|
17
18
|
|
|
@@ -141,9 +142,9 @@ export const isColorPreviewCompatible = (state, image, designProductionMethodIde
|
|
|
141
142
|
const designProductionMethod = designProductionMethodIdentifier
|
|
142
143
|
? getDesignProductionMethodByIdentifier(state, designProductionMethodIdentifier)
|
|
143
144
|
: getSelectedDesignProductionMethod(state);
|
|
144
|
-
const colorPreviewRequired =
|
|
145
|
-
designProductionMethod
|
|
146
|
-
|
|
145
|
+
const colorPreviewRequired =
|
|
146
|
+
designProductionMethodHasEmbroideryVisualizationEffect(designProductionMethod) ||
|
|
147
|
+
isVectorizedLogoMandatory(designProductionMethod);
|
|
147
148
|
|
|
148
149
|
const displayColorPreview = image && (!!image.gallery || !!image.displayColorPreview);
|
|
149
150
|
// do not let the user to add a raster image if the production method is embroidery
|
|
@@ -35,6 +35,10 @@ jest.mock('../../../Services/DesignDataService');
|
|
|
35
35
|
|
|
36
36
|
/*skipped Tests should be updated , the tests run properly in test file but fail globally in 'npm run test'*/
|
|
37
37
|
describe('Reducers/ImageGallery/Actions', () => {
|
|
38
|
+
afterEach(() => {
|
|
39
|
+
jest.clearAllMocks();
|
|
40
|
+
});
|
|
41
|
+
|
|
38
42
|
it('getGalleryUrlForTags encodes tags as comma separated query params', () => {
|
|
39
43
|
const tags = [
|
|
40
44
|
{ title: 'tag1', checked: true },
|
|
@@ -51,7 +55,7 @@ describe('Reducers/ImageGallery/Actions', () => {
|
|
|
51
55
|
expect(fetchDataAsync.mock.calls[0][0]).toBe(URL_TAGS);
|
|
52
56
|
expect(fetchDataAsync.mock.calls[0][1]).toBe(receiveGalleryTags);
|
|
53
57
|
});
|
|
54
|
-
it
|
|
58
|
+
it('selectTags calls dispatch with the correct action and calls dispatch with the fetchGalleryAction too', () => {
|
|
55
59
|
const tags = [{ title: 'Cars', checked: true }];
|
|
56
60
|
const dispatch = jest.fn();
|
|
57
61
|
selectTags(tags)(dispatch);
|
|
@@ -61,7 +65,7 @@ describe('Reducers/ImageGallery/Actions', () => {
|
|
|
61
65
|
});
|
|
62
66
|
expect(fetchDataAsync.mock.calls[0][0]).toBe(getGalleryUrlForTags(tags));
|
|
63
67
|
});
|
|
64
|
-
it
|
|
68
|
+
it('fetchGallery calls fetchDataAsync with the correct url and receive action creator', () => {
|
|
65
69
|
const mockResult = jest.fn(() => ({}));
|
|
66
70
|
const fetchDataAsyncSpy = jest.fn(() => mockResult);
|
|
67
71
|
fetchDataAsync.mockImplementationOnce(fetchDataAsyncSpy);
|
|
@@ -80,12 +84,46 @@ describe('Reducers/ImageGallery/Actions', () => {
|
|
|
80
84
|
fileName,
|
|
81
85
|
});
|
|
82
86
|
const dispatch = jest.fn();
|
|
83
|
-
|
|
87
|
+
const getState = () => ({
|
|
88
|
+
configurator: {
|
|
89
|
+
configuration: {
|
|
90
|
+
designdata: {
|
|
91
|
+
designArea1: {
|
|
92
|
+
designProductionMethodIdentifier: 'customPrinting',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
designArea: {
|
|
98
|
+
selectedDesignArea: {
|
|
99
|
+
identifier: 'designArea1',
|
|
100
|
+
mask: null,
|
|
101
|
+
designProductionMethods: [
|
|
102
|
+
{
|
|
103
|
+
identifier: 'customPrinting',
|
|
104
|
+
mask: null,
|
|
105
|
+
options: {
|
|
106
|
+
maxColorAmount: 4,
|
|
107
|
+
vectorsRequired: true,
|
|
108
|
+
vectorizedLogoMandatory: true,
|
|
109
|
+
},
|
|
110
|
+
colorPalettes: [
|
|
111
|
+
{
|
|
112
|
+
identifier: 'default',
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
await uploadImage(fileName)(dispatch, getState);
|
|
84
121
|
expect(postDataAsync.mock.calls[0][0]).toEqual(URL_UPLOAD);
|
|
85
122
|
expect(formDataToJSON(postDataAsync.mock.calls[0][1]).userImage).toEqual(fileName);
|
|
86
|
-
expect(createDefaultReceiver).
|
|
123
|
+
expect(createDefaultReceiver.mock.calls[0][0]).toBe(RECEIVE_IMAGE_UPLOAD_DATA);
|
|
124
|
+
expect(createDefaultReceiver.mock.calls[0][1]).toMatchObject({ vectorizedLogoMandatory: true });
|
|
87
125
|
});
|
|
88
|
-
it
|
|
126
|
+
it('editImage calls postDataAsync with the correct params', async () => {
|
|
89
127
|
const fileName = 'test.png';
|
|
90
128
|
createAsyncTask.mockImplementationOnce((name, action) => action);
|
|
91
129
|
postDataAsync.mockResolvedValueOnce({
|
|
@@ -101,12 +139,46 @@ describe('Reducers/ImageGallery/Actions', () => {
|
|
|
101
139
|
},
|
|
102
140
|
],
|
|
103
141
|
};
|
|
104
|
-
|
|
142
|
+
const getState = () => ({
|
|
143
|
+
configurator: {
|
|
144
|
+
configuration: {
|
|
145
|
+
designdata: {
|
|
146
|
+
designArea1: {
|
|
147
|
+
designProductionMethodIdentifier: 'customPrinting',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
designArea: {
|
|
153
|
+
selectedDesignArea: {
|
|
154
|
+
identifier: 'designArea1',
|
|
155
|
+
mask: null,
|
|
156
|
+
designProductionMethods: [
|
|
157
|
+
{
|
|
158
|
+
identifier: 'customPrinting',
|
|
159
|
+
mask: null,
|
|
160
|
+
options: {
|
|
161
|
+
maxColorAmount: 4,
|
|
162
|
+
vectorsRequired: true,
|
|
163
|
+
vectorizedLogoMandatory: true,
|
|
164
|
+
},
|
|
165
|
+
colorPalettes: [
|
|
166
|
+
{
|
|
167
|
+
identifier: 'default',
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
},
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
await editImage(editData)(dispatch, getState);
|
|
105
176
|
expect(postDataAsync.mock.calls[0][0]).toEqual(URL_UPLOAD);
|
|
106
177
|
expect(formDataToJSON(postDataAsync.mock.calls[0][1]).userImageEditData).toEqual(
|
|
107
178
|
JSON.stringify(editData)
|
|
108
179
|
);
|
|
109
|
-
expect(createDefaultReceiver).
|
|
180
|
+
expect(createDefaultReceiver.mock.calls[0][0]).toBe(RECEIVE_IMAGE_UPLOAD_DATA);
|
|
181
|
+
expect(createDefaultReceiver.mock.calls[0][1]).toMatchObject({ vectorizedLogoMandatory: true });
|
|
110
182
|
});
|
|
111
183
|
it('dismissError creates the correct action', () => {
|
|
112
184
|
const dispatch = jest.fn();
|
|
@@ -195,6 +267,7 @@ describe('Reducers/ImageGallery/Actions', () => {
|
|
|
195
267
|
options: {
|
|
196
268
|
maxColorAmount: 4,
|
|
197
269
|
vectorsRequired: true,
|
|
270
|
+
vectorizedLogoMandatory: true,
|
|
198
271
|
},
|
|
199
272
|
colorPalettes: [
|
|
200
273
|
{
|
|
@@ -222,6 +295,7 @@ describe('Reducers/ImageGallery/Actions', () => {
|
|
|
222
295
|
vectorizeColorsMap,
|
|
223
296
|
compatibilityInfoHash: {
|
|
224
297
|
maxColorAmount: 4,
|
|
298
|
+
vectorizedLogoMandatory: true,
|
|
225
299
|
vectorsRequired: true,
|
|
226
300
|
colorPalettes: ['default'],
|
|
227
301
|
},
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
getCameraViewListForDesignAreaList,
|
|
8
8
|
getDefaultDesignAreaIdentifierFromProductionMethod,
|
|
9
9
|
getSelectedDesignProductionMethodForDesignArea,
|
|
10
|
+
isVectorizedLogoMandatory,
|
|
10
11
|
} from '../../Reducers/DesignArea/Selectors';
|
|
11
12
|
import { getSelectedVariantIdentifier } from '../../Reducers/Configurator/Selectors';
|
|
12
13
|
import { setSelectedImageData } from '../../Reducers/ImageGallery/Actions';
|
|
@@ -50,6 +51,8 @@ const prepareImageData = (function createImageDataPreProcessor() {
|
|
|
50
51
|
const colorPreviewRequired = designProductionMethodHasEmbroideryVisualizationEffect(
|
|
51
52
|
designProductionMethod
|
|
52
53
|
);
|
|
54
|
+
const vectorizedLogoMandatory = isVectorizedLogoMandatory(designProductionMethod);
|
|
55
|
+
|
|
53
56
|
if (colorPreviewRequired) {
|
|
54
57
|
// creating the color map, as it was added from the image edit dialog
|
|
55
58
|
const svgContent = await getSvgContent(imageData.preview.url, false, true);
|
|
@@ -59,7 +62,7 @@ const prepareImageData = (function createImageDataPreProcessor() {
|
|
|
59
62
|
...imageData,
|
|
60
63
|
colorPreviewRequired: true,
|
|
61
64
|
displayColorPreview: true,
|
|
62
|
-
colorPreviewEnabled:
|
|
65
|
+
colorPreviewEnabled: !vectorizedLogoMandatory,
|
|
63
66
|
operations: {
|
|
64
67
|
...imageData.operations,
|
|
65
68
|
vectorizeColorsMap,
|