@configuratorware/configurator-frontendgui 1.40.6 → 1.41.1
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/Shared/Components/AmountPrice/index.js +175 -46
- package/App/Shared/Components/ConfigurationOverview/index.js +114 -0
- package/App/Shared/Containers/AmountPrice/index.js +2 -1
- package/App/configuration.js +1 -1
- package/package.json +4 -4
- package/public/translations/de_DE.json +1 -0
- 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/Shared/Components/AmountPrice/__snapshots__/index.test.jsx.snap +133 -8
- package/src/App/Shared/Components/AmountPrice/index.js +109 -3
- package/src/App/Shared/Components/ConfigurationOverview/index.js +58 -0
- package/src/App/Shared/Containers/AmountPrice/index.js +2 -0
- package/src/App/configuration.js +1 -1
|
@@ -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,
|
|
@@ -86,6 +86,8 @@ import {
|
|
|
86
86
|
getVectorizeForDesignProductionMethods,
|
|
87
87
|
getImagesByDesignArea,
|
|
88
88
|
designProductionMethodHasEmbroideryVisualizationEffect,
|
|
89
|
+
getMandatoryVectorizationForDesignProductionMethods,
|
|
90
|
+
isVectorizedLogoMandatory,
|
|
89
91
|
} from '../Reducers/DesignArea/Selectors';
|
|
90
92
|
import {
|
|
91
93
|
getUserImage,
|
|
@@ -1075,6 +1077,33 @@ export default class DesignDataService {
|
|
|
1075
1077
|
}
|
|
1076
1078
|
};
|
|
1077
1079
|
|
|
1080
|
+
handleDesignProductionMethodChangeToMandatoryVectorization = async designProductionMethodIdentifier => {
|
|
1081
|
+
const state = Services.store.state;
|
|
1082
|
+
|
|
1083
|
+
const {
|
|
1084
|
+
currentVectorsMandatory,
|
|
1085
|
+
newVectorsMandatory,
|
|
1086
|
+
} = getMandatoryVectorizationForDesignProductionMethods(state, designProductionMethodIdentifier);
|
|
1087
|
+
|
|
1088
|
+
const designArea = getSelectedDesignArea(state);
|
|
1089
|
+
const nonColorizedImages = getImagesByDesignArea(state, designArea.identifier).filter(
|
|
1090
|
+
obj => !get(obj, 'imageData.gallery') && !get(obj, 'imageData.displayColorPreview')
|
|
1091
|
+
);
|
|
1092
|
+
|
|
1093
|
+
if (
|
|
1094
|
+
nonColorizedImages.length === 1 &&
|
|
1095
|
+
((!currentVectorsMandatory && newVectorsMandatory) ||
|
|
1096
|
+
!isColorPreviewCompatible(
|
|
1097
|
+
state,
|
|
1098
|
+
nonColorizedImages[0].imageData,
|
|
1099
|
+
designProductionMethodIdentifier
|
|
1100
|
+
))
|
|
1101
|
+
) {
|
|
1102
|
+
await Services.store.dispatch(showSwitchToProductionMethodWithVectorization());
|
|
1103
|
+
return true;
|
|
1104
|
+
}
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1078
1107
|
checkColorUsageForDesignProductionMethod = async designProductionMethodIdentifier => {
|
|
1079
1108
|
const state = Services.store.state;
|
|
1080
1109
|
const { maxColorAmount, designProductionMethod } = getSelectedDesignAreaProperties(state);
|
|
@@ -1086,9 +1115,9 @@ export default class DesignDataService {
|
|
|
1086
1115
|
const currentVectorsRequired = !!get(designProductionMethod, 'options.vectorsRequired');
|
|
1087
1116
|
const newVectorsRequired = !!get(newProductionMethod, 'options.vectorsRequired');
|
|
1088
1117
|
const designArea = getSelectedDesignArea(state);
|
|
1089
|
-
const colorPreviewRequired =
|
|
1090
|
-
newProductionMethod
|
|
1091
|
-
|
|
1118
|
+
const colorPreviewRequired =
|
|
1119
|
+
designProductionMethodHasEmbroideryVisualizationEffect(newProductionMethod) ||
|
|
1120
|
+
isVectorizedLogoMandatory(newProductionMethod);
|
|
1092
1121
|
|
|
1093
1122
|
if (
|
|
1094
1123
|
(newMaxColorAmount !== 0 && newMaxColorAmount < maxColorAmount) ||
|
|
@@ -1116,6 +1145,8 @@ export default class DesignDataService {
|
|
|
1116
1145
|
images.forEach(object => {
|
|
1117
1146
|
object.remove();
|
|
1118
1147
|
});
|
|
1148
|
+
|
|
1149
|
+
await this.updateCanvasData(canvas);
|
|
1119
1150
|
}
|
|
1120
1151
|
}
|
|
1121
1152
|
|
|
@@ -1194,9 +1225,9 @@ export default class DesignDataService {
|
|
|
1194
1225
|
};
|
|
1195
1226
|
|
|
1196
1227
|
async vectorizeSingleImageAndShowEditDialog(identifier) {
|
|
1197
|
-
const showImageEditDialog =
|
|
1198
|
-
identifier
|
|
1199
|
-
|
|
1228
|
+
const showImageEditDialog =
|
|
1229
|
+
(await this.handleDesignProductionMethodChangeFromNonVectorizationToVectorization(identifier)) ||
|
|
1230
|
+
(await this.handleDesignProductionMethodChangeToMandatoryVectorization(identifier));
|
|
1200
1231
|
|
|
1201
1232
|
if (showImageEditDialog) {
|
|
1202
1233
|
Services.ui.show('globalLoader');
|
|
@@ -1204,16 +1235,22 @@ export default class DesignDataService {
|
|
|
1204
1235
|
const state = Services.store.state;
|
|
1205
1236
|
const designArea = getSelectedDesignArea(state);
|
|
1206
1237
|
const canvas = this._getCanvas(designArea);
|
|
1207
|
-
|
|
1208
|
-
|
|
1238
|
+
|
|
1239
|
+
const images = getImagesByDesignArea(state, designArea.identifier);
|
|
1240
|
+
const firstNonVectorizedImage = images.find(
|
|
1241
|
+
obj =>
|
|
1242
|
+
!get(obj, 'imageData.gallery') &&
|
|
1243
|
+
(!get(obj, 'imageData.operations.vectorize') ||
|
|
1244
|
+
!get(obj, 'imageData.displayColorPreview'))
|
|
1209
1245
|
);
|
|
1210
|
-
const operations = {
|
|
1211
|
-
...firstNonVectorizedImage.imageData.operations,
|
|
1212
|
-
vectorize: true,
|
|
1213
|
-
};
|
|
1214
|
-
const imageData = firstNonVectorizedImage.imageData;
|
|
1215
1246
|
|
|
1216
1247
|
try {
|
|
1248
|
+
const operations = {
|
|
1249
|
+
...firstNonVectorizedImage.imageData.operations,
|
|
1250
|
+
vectorize: true,
|
|
1251
|
+
};
|
|
1252
|
+
const imageData = firstNonVectorizedImage.imageData;
|
|
1253
|
+
|
|
1217
1254
|
//returing if placeHolderImage, from executing edit operations
|
|
1218
1255
|
if (imageData.isPlaceHolderImage) {
|
|
1219
1256
|
return;
|
|
@@ -1855,13 +1892,16 @@ export default class DesignDataService {
|
|
|
1855
1892
|
const compatibilityInfoHash = getDesignAreaImageCompatibilityInfo(designProductionMethod);
|
|
1856
1893
|
const imageIsCompatible = areHashesCompatible(image.compatibilityInfoHash, compatibilityInfoHash);
|
|
1857
1894
|
const operationsMatching = compareOperations(image.operations, operations);
|
|
1858
|
-
const
|
|
1859
|
-
|
|
1860
|
-
|
|
1895
|
+
const vectorizedLogoMandatory = isVectorizedLogoMandatory(designProductionMethod);
|
|
1896
|
+
|
|
1897
|
+
const colorPreviewRequired =
|
|
1898
|
+
designProductionMethodHasEmbroideryVisualizationEffect(designProductionMethod) ||
|
|
1899
|
+
vectorizedLogoMandatory;
|
|
1861
1900
|
|
|
1862
1901
|
const imageDataPatch = {
|
|
1863
1902
|
compatibilityInfoHash,
|
|
1864
1903
|
colorPreviewRequired,
|
|
1904
|
+
vectorizedLogoMandatory,
|
|
1865
1905
|
...(displayColorPreview !== undefined && { displayColorPreview }),
|
|
1866
1906
|
};
|
|
1867
1907
|
|