@configuratorware/configurator-admingui 1.34.2 → 1.34.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.
@@ -42,6 +42,13 @@ exports.START_UPLOAD = START_UPLOAD;
42
42
  var FINISH_UPLOAD = 'DESIGNVIEW_FINISH_IMAGE_UPLOAD';
43
43
  exports.FINISH_UPLOAD = FINISH_UPLOAD;
44
44
 
45
+ var renameFile = function renameFile(originalFile, newName) {
46
+ return new File([originalFile], newName, {
47
+ type: originalFile.type,
48
+ lastModified: originalFile.lastModified
49
+ });
50
+ };
51
+
45
52
  var beforeApiStateHandler = function beforeApiStateHandler(apiAction) {
46
53
  return function (dispatch, getState) {
47
54
  return new Promise(function (resolve) {
@@ -55,21 +62,22 @@ var beforeApiStateHandler = function beforeApiStateHandler(apiAction) {
55
62
  });
56
63
  return Promise.all(keys.map( /*#__PURE__*/function () {
57
64
  var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(key) {
58
- var _viewImages$key, file, type, id, files, url, result;
65
+ var _viewImages$key, file, type, id, renamedFile, files, url, result;
59
66
 
60
67
  return regeneratorRuntime.wrap(function _callee$(_context) {
61
68
  while (1) {
62
69
  switch (_context.prev = _context.next) {
63
70
  case 0:
64
71
  _viewImages$key = viewImages[key], file = _viewImages$key.file, type = _viewImages$key.type, id = _viewImages$key.id;
72
+ renamedFile = renameFile(file, file.name.replace(/\s/g, ''));
65
73
  files = new FormData();
66
- files.append('file', file); //const itemId = get(state, 'source.item.id');
74
+ files.append('file', renamedFile); //const itemId = get(state, 'source.item.id');
67
75
 
68
76
  url = "/designviews/".concat(apiAction.data.id, "/").concat(type, "/upload/detail_image/").concat(id);
69
- _context.next = 6;
77
+ _context.next = 7;
70
78
  return (0, _Helpers.dispatchPostData)(dispatch)("designview/images/".concat(key), url, files);
71
79
 
72
- case 6:
80
+ case 7:
73
81
  result = _context.sent;
74
82
  dispatch({
75
83
  type: FINISH_UPLOAD,
@@ -77,7 +85,7 @@ var beforeApiStateHandler = function beforeApiStateHandler(apiAction) {
77
85
  });
78
86
  return _context.abrupt("return", result);
79
87
 
80
- case 9:
88
+ case 10:
81
89
  case "end":
82
90
  return _context.stop();
83
91
  }
@@ -66,12 +66,18 @@ actions.postData = function () {
66
66
  for (var fontType in fontTypeMap) {
67
67
  var fontFile = state.data[fontType].value;
68
68
 
69
- if (fontFile && !(0, _lodash.isString)(fontFile)) {
70
- fontsToUpload.push({
71
- name: fontType,
72
- value: fontFile,
73
- filename: fontName + '-' + fontTypeMap[fontType] + '.ttf'
74
- });
69
+ if (fontFile) {
70
+ var filename = fontName + '-' + fontTypeMap[fontType] + '.ttf';
71
+
72
+ if (!(0, _lodash.isString)(fontFile)) {
73
+ fontsToUpload.push({
74
+ name: fontType,
75
+ value: fontFile,
76
+ filename: filename
77
+ });
78
+ } else {
79
+ dispatch(setFilenameField(fontType, filename));
80
+ }
75
81
  }
76
82
  }
77
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configuratorware/configurator-admingui",
3
- "version": "1.34.2",
3
+ "version": "1.34.4",
4
4
  "license": "UNLICENSED",
5
5
  "private": false,
6
6
  "dependencies": {
@@ -29,7 +29,7 @@
29
29
  "react-redux-i18n": "^1.9.3",
30
30
  "react-router": "^3.2.6",
31
31
  "react-sortable-hoc": "^1.11.0",
32
- "redhotmagma-visualization": "1.34.2",
32
+ "redhotmagma-visualization": "1.34.4",
33
33
  "redux": "^4.1.0",
34
34
  "redux-logger": "^3.0.6",
35
35
  "redux-persist": "^5.10.0",
@@ -19,6 +19,13 @@ import {
19
19
  } from '../../../../../App/Reducers/Entity/Actions';
20
20
  import { dispatchPostData } from '../../../../../App/Reducers/Api/Helpers';
21
21
 
22
+ const renameFile = (originalFile, newName) => {
23
+ return new File([originalFile], newName, {
24
+ type: originalFile.type,
25
+ lastModified: originalFile.lastModified,
26
+ });
27
+ };
28
+
22
29
  const beforeApiStateHandler = apiAction => (dispatch, getState) => {
23
30
  return new Promise(resolve => {
24
31
  const state = getState()[REDUCER_NAME];
@@ -31,8 +38,9 @@ const beforeApiStateHandler = apiAction => (dispatch, getState) => {
31
38
  return Promise.all(
32
39
  keys.map(async key => {
33
40
  const { file, type, id } = viewImages[key];
41
+ const renamedFile = renameFile(file, file.name.replace(/\s/g, ''));
34
42
  const files = new FormData();
35
- files.append('file', file);
43
+ files.append('file', renamedFile);
36
44
  //const itemId = get(state, 'source.item.id');
37
45
  const url = `/designviews/${apiAction.data.id}/${type}/upload/detail_image/${id}`;
38
46
  const result = await dispatchPostData(dispatch)(`designview/images/${key}`, url, files);
@@ -53,16 +53,21 @@ actions.postData = () => (dispatch, getState) => {
53
53
  fileNameItalic: 'italic',
54
54
  fileNameBoldItalic: 'bolditalic',
55
55
  };
56
-
56
+
57
57
  for (const fontType in fontTypeMap) {
58
58
  const fontFile = state.data[fontType].value;
59
-
60
- if (fontFile && !isString(fontFile)) {
61
- fontsToUpload.push({
62
- name: fontType,
63
- value: fontFile,
64
- filename: fontName + '-' + fontTypeMap[fontType] + '.ttf',
65
- });
59
+ if (fontFile) {
60
+ const filename = fontName + '-' + fontTypeMap[fontType] + '.ttf';
61
+ if (!isString(fontFile)) {
62
+ fontsToUpload.push({
63
+ name: fontType,
64
+ value: fontFile,
65
+ filename
66
+ });
67
+ }
68
+ else {
69
+ dispatch(setFilenameField(fontType, filename));
70
+ }
66
71
  }
67
72
  }
68
73
  }