kitchen-simulator 2.0.4 → 2.0.5-flip-handle-open-door

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.
@@ -5,20 +5,21 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.handleExternalEvent = handleExternalEvent;
8
- exports.parseTempPlaceholdersFromCabinetPayload = parseTempPlaceholdersFromCabinetPayload;
9
- exports.updateCabinetPayload = updateCabinetPayload;
10
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
12
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
12
  var _immutable = require("immutable");
14
13
  var _constants = require("../constants");
15
14
  var _helper = require("./helper");
16
15
  var _exporter = _interopRequireDefault(require("../catalog/utils/exporter"));
17
16
  var _itemLoader = require("../catalog/utils/item-loader");
18
- var _catalog = _interopRequireDefault(require("../catalog/catalog"));
19
- var _models = require("../models");
17
+ var _convertUnitsLite = require("./convert-units-lite");
18
+ var _export = require("./export");
19
+ var _utils = require("../components/viewer2d/utils");
20
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
+ var PRECISION = 2;
22
23
  var loadSVGsByItem = /*#__PURE__*/function () {
23
24
  var _ref = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(item) {
24
25
  var _parsed$xml$viewBox, _parsed$xml$viewBox2, response, svgText, loader, parsed, _t;
@@ -74,12 +75,12 @@ var loadSVGsByItem = /*#__PURE__*/function () {
74
75
  var compareSVGRect = function compareSVGRect(value) {
75
76
  return value.e <= 10 && value.e + value.a * value.SVGWidth + 10 >= value.viewerWidth && value.f <= 80 && value.f + value.d * value.SVGHeight + 10 >= value.viewerHeight ? true : false;
76
77
  };
77
- function loadJSON(_x2, _x3, _x4) {
78
+ function loadJSON(_x2) {
78
79
  return _loadJSON.apply(this, arguments);
79
80
  }
80
81
  /********Parse TempPlaceholder from cabinetPayloadData **************/
81
82
  function _loadJSON() {
82
- _loadJSON = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(path, success, error) {
83
+ _loadJSON = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(path) {
83
84
  return _regenerator["default"].wrap(function (_context2) {
84
85
  while (1) switch (_context2.prev = _context2.next) {
85
86
  case 0:
@@ -105,7 +106,7 @@ function _loadJSON() {
105
106
  }));
106
107
  return _loadJSON.apply(this, arguments);
107
108
  }
108
- function parseTempPlaceholdersFromCabinetPayload(_x5) {
109
+ function parseTempPlaceholdersFromCabinetPayload(_x3) {
109
110
  return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
110
111
  }
111
112
  /***** Update cabinetPayloadData with updatedTempPlaceholders *****/
@@ -449,7 +450,7 @@ function _parseTempPlaceholdersFromCabinetPayload() {
449
450
  }));
450
451
  return _parseTempPlaceholdersFromCabinetPayload.apply(this, arguments);
451
452
  }
452
- function updateCabinetPayload(_x6) {
453
+ function updateCabinetPayload(_x4) {
453
454
  return _updateCabinetPayload.apply(this, arguments);
454
455
  }
455
456
  function _updateCabinetPayload() {
@@ -479,9 +480,9 @@ function _updateCabinetPayload() {
479
480
  }));
480
481
  return _updateCabinetPayload.apply(this, arguments);
481
482
  }
482
- function addItemToCatalog(_x7, _x8, _x9, _x0) {
483
+ function addItemToCatalog(_x5, _x6, _x7, _x8) {
483
484
  return _addItemToCatalog.apply(this, arguments);
484
- }
485
+ } // Get attributs of current selected element
485
486
  function _addItemToCatalog() {
486
487
  _addItemToCatalog = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee5(element, state, catalogInstance, projectActions) {
487
488
  var elementJs, catalog, updatedStructureJson, outlineSVGData;
@@ -527,20 +528,368 @@ function _addItemToCatalog() {
527
528
  }));
528
529
  return _addItemToCatalog.apply(this, arguments);
529
530
  }
531
+ function initAttrData(element, layer, state) {
532
+ element = (0, _typeof2["default"])(element.misc) === 'object' ? element.set('misc', new _immutable.Map(element.misc)) : element;
533
+ switch (element.prototype) {
534
+ case 'items':
535
+ {
536
+ return new _immutable.Map(element);
537
+ }
538
+ case 'lines':
539
+ {
540
+ var v_a = layer.vertices.get(element.vertices.get(0));
541
+ var v_b = layer.vertices.get(element.vertices.get(1));
542
+ var distance = _export.GeometryUtils.pointsDistance(v_a.x, v_a.y, v_b.x, v_b.y);
543
+ var _unit = element.misc.get('_unitLength') || _constants.UNIT_INCH;
544
+ var _length = (0, _convertUnitsLite.convert)(distance).from(_constants.UNIT_CENTIMETER).to(_unit);
545
+ if (state.mode == _constants.MODE_DRAWING_LINE) {
546
+ return new _immutable.Map({
547
+ vertexOne: v_a,
548
+ vertexTwo: v_b,
549
+ lineLength: new _immutable.Map({
550
+ length: distance,
551
+ _length: _length,
552
+ _unit: _unit
553
+ }),
554
+ focus: element.focus
555
+ });
556
+ } else {
557
+ var allLines = layer.lines.toArray();
558
+ var relatedLine = allLines.filter(function (line) {
559
+ return line.vertices.toArray().includes(v_b.id) && line.id != element.id;
560
+ })[0];
561
+ var relatedVertexID = relatedLine && (relatedLine.vertices.toArray()[0] == v_b.id ? relatedLine.vertices.toArray()[1] : relatedLine.vertices.toArray()[0]);
562
+ var v_d = relatedVertexID && layer.getIn(['vertices', relatedVertexID]);
563
+ var lineToExtend = relatedVertexID && allLines.filter(function (line) {
564
+ return line.vertices.toArray().includes(relatedVertexID) && line.id != relatedLine.id;
565
+ })[0];
566
+ var v_c = lineToExtend && layer.getIn(['vertices', lineToExtend.vertices.toArray()[0] == v_d.id ? lineToExtend.vertices.toArray()[1] : lineToExtend.vertices.toArray()[0]]);
567
+ return new _immutable.Map({
568
+ vertexOne: v_a,
569
+ vertexTwo: v_b,
570
+ vertexThree: v_c,
571
+ vertexFour: v_d,
572
+ lineToExtend: lineToExtend,
573
+ lineLength: new _immutable.Map({
574
+ length: distance,
575
+ _length: _length,
576
+ _unit: _unit
577
+ }),
578
+ focus: element.focus
579
+ });
580
+ }
581
+ }
582
+ case 'holes':
583
+ {
584
+ var line = layer.lines.get(element.line);
585
+ var _layer$vertices$get = layer.vertices.get(line.vertices.get(0)),
586
+ x0 = _layer$vertices$get.x,
587
+ y0 = _layer$vertices$get.y;
588
+ var _layer$vertices$get2 = layer.vertices.get(line.vertices.get(1)),
589
+ x1 = _layer$vertices$get2.x,
590
+ y1 = _layer$vertices$get2.y;
591
+ var lineLength = _export.GeometryUtils.pointsDistance(x0, y0, x1, y1);
592
+ var startAt = lineLength * element.offset - element.properties.get('width').get('length') / 2;
593
+ var endAt = lineLength - lineLength * element.offset - element.properties.get('width').get('length') / 2;
594
+ var _unitA = element.misc.get('_unitA') || _constants.UNIT_INCH;
595
+ var _lengthA = (0, _convertUnitsLite.convert)(x0 > x1 ? endAt : startAt).from(_constants.UNIT_CENTIMETER).to(_unitA);
596
+ var _unitB = element.misc.get('_unitB') || _constants.UNIT_INCH;
597
+ var _lengthB = (0, _convertUnitsLite.convert)(x0 > x1 ? startAt : endAt).from(_constants.UNIT_CENTIMETER).to(_unitB);
598
+ return new _immutable.Map({
599
+ offset: element.offset,
600
+ offsetA: new _immutable.Map({
601
+ length: MathUtils.toFixedFloat(x0 > x1 ? endAt : startAt, PRECISION),
602
+ _length: MathUtils.toFixedFloat(_lengthA, PRECISION),
603
+ _unit: _unitA
604
+ }),
605
+ offsetB: new _immutable.Map({
606
+ length: MathUtils.toFixedFloat(x0 > x1 ? startAt : endAt, PRECISION),
607
+ _length: MathUtils.toFixedFloat(_lengthB, PRECISION),
608
+ _unit: _unitB
609
+ })
610
+ });
611
+ }
612
+ case 'areas':
613
+ {
614
+ return new _immutable.Map({});
615
+ }
616
+ default:
617
+ return null;
618
+ }
619
+ }
620
+ // Get properties of current selected element
621
+ function initPropData(element, catalog) {
622
+ var mapped = {};
623
+ if (!catalog.elements.hasOwnProperty(element.type) && !(!catalog.elements[element.type] && !!catalog.elements[(0, _utils.returnReplaceableDeepSearchType)(element.type)])) {
624
+ console.log("Last Selected ".concat(element.type, " Element does not exist in catalog."));
625
+ return new _immutable.Map(mapped);
626
+ }
627
+ var catalogElement = catalog.getElement(element.type);
628
+ var isFiller = catalogElement.long_name ? catalogElement.long_name.toUpperCase().includes('FILLER') : false;
629
+ if (isFiller) {
630
+ var height = {
631
+ defaultValue: element.properties.get('height').toJS(),
632
+ label: 'Height',
633
+ type: 'length-measure'
634
+ };
635
+ var depth = {
636
+ defaultValue: element.properties.get('depth').toJS(),
637
+ label: 'Depth',
638
+ type: 'length-measure'
639
+ };
640
+ catalogElement.properties = {
641
+ altitude: catalogElement.properties.altitude,
642
+ width: catalogElement.properties.width,
643
+ height: height,
644
+ depth: depth,
645
+ flip_doorhandle: catalogElement.properties.flip_doorhandle,
646
+ resize_and_scaling: catalogElement.properties.resize_and_scaling
647
+ };
648
+ }
649
+ for (var name in catalogElement.properties) {
650
+ mapped[name] = new _immutable.Map({
651
+ currentValue: element.properties.has(name) ? element.properties.get(name) : fromJS(catalogElement.properties[name].defaultValue),
652
+ configs: catalogElement.properties[name]
653
+ });
654
+ }
655
+ return new _immutable.Map(mapped);
656
+ }
657
+ function updateAttributeOfSelectedElement(element, attrPayload, state, layer, projectActions) {
658
+ var attributesFormData = initAttrData(element, layer, state);
659
+ var value = attrPayload.value;
660
+ var attributeName = attrPayload.attributeName;
661
+ // pre process
662
+ if (attributeName === _constants.ATT_ITEM_POS) {
663
+ // calculate the new position of movement
664
+ var rotRad = (value.directionAng + element.rotation) / 180 * Math.PI;
665
+ var newX = element.x + (0, _convertUnitsLite.convert)((value.oldDistance - value.newDistance) * Math.cos(rotRad)).from('in').to('cm');
666
+ var newY = element.y + (0, _convertUnitsLite.convert)((value.oldDistance - value.newDistance) * Math.sin(rotRad)).from('in').to('cm');
667
+ // const reversedDirection =
668
+ // value.directionAng === LEFT_DIST_ANG
669
+ // ? RIGHT_DIST_ANG
670
+ // : value.directionAng === RIGHT_DIST_ANG
671
+ // ? LEFT_DIST_ANG
672
+ // : value.directionAng === BACK_DIST_ANG
673
+ // ? FRONT_DIST_ANG
674
+ // : BACK_DIST_ANG;
675
+ // let dist = convert(
676
+ // element.distArray?.find(v => v[1] === reversedDirection)
677
+ // ? element.distArray?.find(v => v[1] === reversedDirection)[0]
678
+ // : 0
679
+ // )
680
+ // .from('cm')
681
+ // .to('in');
682
+ // if (dist + (value.oldDistance - value.newDistance) <= 0 || value.newDistance < 0) {
683
+ // // confirm "The item will be placed outside the floor plan. Are you sure?"
684
+ // setPopupOpen(true);
685
+ // return;
686
+ // }
687
+ value = {
688
+ x: newX,
689
+ y: newY
690
+ };
691
+ } else if (attributeName === _constants.ATT_LINE_LENGTH || attributeName === _constants.ATT_HOLE_OFFSET_A || attributeName === _constants.ATT_HOLE_OFFSET_B) {
692
+ var att = attributesFormData.has(attributeName) ? attributesFormData.get(attributeName) : element[attributeName];
693
+ if (att) value = att.merge({
694
+ _length: value,
695
+ _unit: _constants.UNIT_INCH,
696
+ length: (0, _convertUnitsLite.convert)(value).from(_constants.UNIT_INCH).to(_constants.UNIT_CENTIMETER)
697
+ });
698
+ }
699
+ // make the new attrivutes
700
+ switch (element.prototype) {
701
+ case 'items':
702
+ {
703
+ if (attributeName == _constants.ATT_ITEM_POS) {
704
+ var xVal = value.x;
705
+ var yVal = value.y;
706
+ attributesFormData = attributesFormData.set('x', xVal);
707
+ attributesFormData = attributesFormData.set('y', yVal);
708
+ } else {
709
+ attributesFormData = attributesFormData.set(attributeName, value);
710
+ }
711
+ break;
712
+ }
713
+ case 'lines':
714
+ {
715
+ switch (attributeName) {
716
+ case _constants.ATT_LINE_LENGTH:
717
+ {
718
+ var v_0 = attributesFormData.get('vertexOne');
719
+ var v_1 = attributesFormData.get('vertexTwo');
720
+ var v_b_new = _export.GeometryUtils.extendLine(v_0.x, v_0.y, v_1.x, v_1.y, value.get('length'), PRECISION);
721
+ attributesFormData = attributesFormData.withMutations(function (attr) {
722
+ attr.set('vertexTwo', v_1.merge(v_b_new));
723
+ attr.set('lineLength', value);
724
+ });
725
+ break;
726
+ }
727
+ case _constants.ATT_VERTEXT_ONE:
728
+ case _constants.ATT_VERTEXT_TWO:
729
+ {
730
+ attributesFormData = attributesFormData.withMutations(function (attr) {
731
+ attr.set(attributeName, attr.get(attributeName).merge(value));
732
+ var newDistance = _export.GeometryUtils.verticesDistance(attr.get('vertexOne'), attr.get('vertexTwo'));
733
+ attr.mergeIn(['lineLength'], attr.get('lineLength').merge({
734
+ length: newDistance,
735
+ _length: (0, _convertUnitsLite.convert)(newDistance).from(_constants.UNIT_CENTIMETER).to(attr.get('lineLength').get('_unit'))
736
+ }));
737
+ });
738
+ break;
739
+ }
740
+ default:
741
+ {
742
+ attributesFormData = attributesFormData.set(attributeName, value);
743
+ break;
744
+ }
745
+ }
746
+ break;
747
+ }
748
+ case 'holes':
749
+ {
750
+ switch (attributeName) {
751
+ case _constants.ATT_HOLE_OFFSET_A:
752
+ {
753
+ var line = layer.lines.get(element.line);
754
+ var _layer$vertices$get3 = layer.vertices.get(line.vertices.get(0)),
755
+ x0 = _layer$vertices$get3.x,
756
+ y0 = _layer$vertices$get3.y;
757
+ var _layer$vertices$get4 = layer.vertices.get(line.vertices.get(1)),
758
+ x1 = _layer$vertices$get4.x,
759
+ y1 = _layer$vertices$get4.y;
760
+ var alpha = _export.GeometryUtils.angleBetweenTwoPoints(x0, y0, x1, y1);
761
+ var lineLength = _export.GeometryUtils.pointsDistance(x0, y0, x1, y1);
762
+ var widthLength = element.properties.get('width').get('length');
763
+ var halfWidthLength = widthLength / 2;
764
+ var lengthValue = value.get('length');
765
+ lengthValue = Math.max(lengthValue, 0);
766
+ lengthValue = Math.min(lengthValue, lineLength - widthLength);
767
+ var xp = (lengthValue + halfWidthLength) * Math.cos(alpha) + x0;
768
+ var yp = (lengthValue + halfWidthLength) * Math.sin(alpha) + y0;
769
+ var offset = _export.GeometryUtils.pointPositionOnLineSegment(x0, y0, x1, y1, xp, yp);
770
+ /*
771
+ if (x0 > x1) offset = 1 - offset;
772
+ */
773
+ var endAt = MathUtils.toFixedFloat(lineLength - lineLength * offset - halfWidthLength, PRECISION);
774
+ var offsetUnit = attributesFormData.getIn(['offsetB', '_unit']);
775
+ var offsetB = new _immutable.Map({
776
+ length: endAt,
777
+ _length: (0, _convertUnitsLite.convert)(endAt).from(_constants.UNIT_CENTIMETER).to(offsetUnit),
778
+ _unit: offsetUnit
779
+ });
780
+ attributesFormData = attributesFormData.set('offsetB', offsetB).set('offset', offset);
781
+ var offsetAttribute = new _immutable.Map({
782
+ length: MathUtils.toFixedFloat(lengthValue, PRECISION),
783
+ _unit: value.get('_unit'),
784
+ _length: MathUtils.toFixedFloat((0, _convertUnitsLite.convert)(lengthValue).from(_constants.UNIT_CENTIMETER).to(value.get('_unit')), PRECISION)
785
+ });
786
+ attributesFormData = attributesFormData.set(attributeName, offsetAttribute);
787
+ break;
788
+ }
789
+ case _constants.ATT_HOLE_OFFSET_B:
790
+ {
791
+ var _line = layer.lines.get(element.line);
792
+ var _layer$vertices$get5 = layer.vertices.get(_line.vertices.get(0)),
793
+ _x9 = _layer$vertices$get5.x,
794
+ _y = _layer$vertices$get5.y;
795
+ var _layer$vertices$get6 = layer.vertices.get(_line.vertices.get(1)),
796
+ _x0 = _layer$vertices$get6.x,
797
+ _y2 = _layer$vertices$get6.y;
798
+ var _alpha = _export.GeometryUtils.angleBetweenTwoPoints(_x9, _y, _x0, _y2);
799
+ var _lineLength = _export.GeometryUtils.pointsDistance(_x9, _y, _x0, _y2);
800
+ var _widthLength = element.properties.get('width').get('length');
801
+ var _halfWidthLength = _widthLength / 2;
802
+ var _lengthValue = value.get('length');
803
+ _lengthValue = Math.max(_lengthValue, 0);
804
+ _lengthValue = Math.min(_lengthValue, _lineLength - _widthLength);
805
+ var _xp = _x0 - (_lengthValue + _halfWidthLength) * Math.cos(_alpha);
806
+ var _yp = _y2 - (_lengthValue + _halfWidthLength) * Math.sin(_alpha);
807
+ var _offset = _export.GeometryUtils.pointPositionOnLineSegment(_x9, _y, _x0, _y2, _xp, _yp);
808
+ /*
809
+ if (x0 > x1) offset = 1 - offset;
810
+ */
811
+ var startAt = MathUtils.toFixedFloat(_lineLength * _offset - _halfWidthLength, PRECISION);
812
+ var _offsetUnit = attributesFormData.getIn(['offsetA', '_unit']);
813
+ var offsetA = new _immutable.Map({
814
+ length: startAt,
815
+ _length: (0, _convertUnitsLite.convert)(startAt).from(_constants.UNIT_CENTIMETER).to(_offsetUnit),
816
+ _unit: _offsetUnit
817
+ });
818
+ attributesFormData = attributesFormData.set('offsetA', offsetA).set('offset', _offset);
819
+ var _offsetAttribute = new _immutable.Map({
820
+ length: MathUtils.toFixedFloat(_lengthValue, PRECISION),
821
+ _unit: value.get('_unit'),
822
+ _length: MathUtils.toFixedFloat((0, _convertUnitsLite.convert)(_lengthValue).from(_constants.UNIT_CENTIMETER).to(value.get('_unit')), PRECISION)
823
+ });
824
+ attributesFormData = attributesFormData.set(attributeName, _offsetAttribute);
825
+ break;
826
+ }
827
+ default:
828
+ {
829
+ attributesFormData = attributesFormData.set(attributeName, value);
830
+ break;
831
+ }
832
+ }
833
+ break;
834
+ }
835
+ default:
836
+ break;
837
+ }
838
+
839
+ // update attribute action
840
+ switch (element.prototype) {
841
+ case 'items':
842
+ {
843
+ projectActions.setItemsAttributes(attributesFormData);
844
+ break;
845
+ }
846
+ case 'lines':
847
+ {
848
+ projectActions.setLinesAttributes(attributesFormData);
849
+ break;
850
+ }
851
+ case 'holes':
852
+ {
853
+ projectActions.setHolesAttributes(attributesFormData);
854
+ break;
855
+ }
856
+ }
857
+ }
858
+ function updatePropertyOfSelectedElement(element, propertyPayload, catalog,
859
+ // class instance of Catalog, get from props
860
+ projectActions) {
861
+ var propertiesFormData = initPropData(element, catalog);
862
+ var value = propertyPayload.value;
863
+ var propertyName = propertyPayload.propertyName;
864
+ // make new properties
865
+ if (propertyName === _constants.PROP_FLIP_DOOR_HANDLE && element.properties.get(_constants.PROP_OPEN_DOORS)) {
866
+ alert('Doors are already open.');
867
+ return;
868
+ }
869
+ propertiesFormData = propertiesFormData.setIn([propertyName, 'currentValue'], value);
870
+
871
+ // update property action
872
+ if (propertiesFormData) {
873
+ var properties = propertiesFormData.map(function (data) {
874
+ return data.get('currentValue');
875
+ });
876
+ projectActions.setProperties(properties);
877
+ }
878
+ }
530
879
  function handleExternalEvent(_x1) {
531
880
  return _handleExternalEvent.apply(this, arguments);
532
881
  }
533
882
  function _handleExternalEvent() {
534
883
  _handleExternalEvent = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee7(props) {
535
- var evt, state, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _evt$payload3, moveType, moveValue, value, defaulTitle, _evt$payload4, doorStyle, itemCDS, isAll, _doorStyle, _value, _zoomValue, _value2, _zoomValue2, _evt$payload5, moldingInfo, isGlobal, _evt$payload6, option, _value3, distancePayload, _props$onInternalEven2, _t5, _t6;
884
+ var evt, state, _evt$payload, cdsItems, itemKeys, _loop3, i, _props$onInternalEven, sLineCnt, element, _state$viewer2D, _evt$payload$initialP, mouseX, mouseY, v2d, vPosX, vPosY, layerID, _evt$payload3, moveType, moveValue, value, defaulTitle, _evt$payload4, doorStyle, itemCDS, isAll, _doorStyle, _value, _zoomValue, _value2, _zoomValue2, _evt$payload5, moldingInfo, isGlobal, _evt$payload6, option, _value3, layerId, layer, _layer$getIn, selectedLines, selectedHoles, selectedItems, _i2, _i3, _i4, _props$onInternalEven2, _t5, _t6;
536
885
  return _regenerator["default"].wrap(function (_context8) {
537
886
  while (1) switch (_context8.prev = _context8.next) {
538
887
  case 0:
539
- console.log('***external event****', props.externalEvent);
888
+ // console.log('***external event****', props);
540
889
  evt = props.externalEvent;
541
890
  state = props.state.get('KitchenConfigurator');
542
891
  _t5 = evt === null || evt === void 0 ? void 0 : evt.type;
543
- _context8.next = _t5 === _constants.EXTERNAL_EVENT_LOAD_PROJECT ? 1 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_3D ? 5 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_2D ? 6 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 7 : _t5 === _constants.EXTERNAL_EVENT_ADD_WALL ? 8 : _t5 === _constants.EXTERNAL_EVENT_ADD_ITEM ? 9 : _t5 === _constants.EXTERNAL_EVENT_MOVE_PAN ? 12 : _t5 === _constants.EXTERNAL_EVENT_NEW_PROJECT ? 18 : _t5 === _constants.EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 19 : _t5 === _constants.EXTERNAL_EVENT_SET_INITIAL_DATA ? 20 : _t5 === _constants.EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 21 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_IN ? 22 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_OUT ? 25 : _t5 === _constants.EXTERNAL_EVENT_UNDO ? 28 : _t5 === _constants.EXTERNAL_EVENT_REDO ? 29 : _t5 === _constants.EXTERNAL_EVENT_SET_MOLDING ? 30 : _t5 === _constants.EXTERNAL_EVENT_PROJECT_SETTING ? 31 : _t5 === _constants.EXTERNAL_EVENT_CHANGE_DISTANCE ? 32 : _t5 === _constants.EXTERNAL_EVENT_SYNC_SCENE ? 33 : 34;
892
+ _context8.next = _t5 === _constants.EXTERNAL_EVENT_LOAD_PROJECT ? 1 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_3D ? 5 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_2D ? 6 : _t5 === _constants.EXTERNAL_EVENT_TOGGLE_TO_ELEVATION ? 7 : _t5 === _constants.EXTERNAL_EVENT_ADD_WALL ? 8 : _t5 === _constants.EXTERNAL_EVENT_ADD_ITEM ? 9 : _t5 === _constants.EXTERNAL_EVENT_MOVE_PAN ? 12 : _t5 === _constants.EXTERNAL_EVENT_NEW_PROJECT ? 18 : _t5 === _constants.EXTERNAL_EVENT_CHANGE_DOORSTYLE ? 19 : _t5 === _constants.EXTERNAL_EVENT_SET_INITIAL_DATA ? 20 : _t5 === _constants.EXTERNAL_EVENT_ADD_ROOM_SHAPE ? 21 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_IN ? 22 : _t5 === _constants.EXTERNAL_EVENT_ZOOM_OUT ? 25 : _t5 === _constants.EXTERNAL_EVENT_UNDO ? 28 : _t5 === _constants.EXTERNAL_EVENT_REDO ? 29 : _t5 === _constants.EXTERNAL_EVENT_SET_MOLDING ? 30 : _t5 === _constants.EXTERNAL_EVENT_PROJECT_SETTING ? 31 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? 32 : _t5 === _constants.EXTERNAL_EVENT_UPDATE_PROPERTY ? 32 : _t5 === _constants.EXTERNAL_EVENT_SYNC_SCENE ? 33 : 34;
544
893
  break;
545
894
  case 1:
546
895
  // prepare item data request
@@ -643,7 +992,23 @@ function _handleExternalEvent() {
643
992
  return addItemToCatalog(element, state, props.catalog, props.projectActions);
644
993
  case 10:
645
994
  // start drawing item
646
- _constants.ARRAY_3D_MODES.includes(state.mode) ? props.itemsActions.selectToolDrawingItem3D(element.name) : props.itemsActions.selectToolDrawingItem(element.name);
995
+ if (_constants.ARRAY_3D_MODES.includes(state.mode)) {
996
+ // in 3d view
997
+ props.itemsActions.selectToolDrawingItem3D(element.name);
998
+ } else {
999
+ // in 2d view
1000
+ // create cabinet
1001
+ props.itemsActions.selectToolDrawingItem(element.name);
1002
+ // mapping the initial position of client coord to viewer2D coord
1003
+ _evt$payload$initialP = evt.payload.initialPosition, mouseX = _evt$payload$initialP.mouseX, mouseY = _evt$payload$initialP.mouseY;
1004
+ v2d = (_state$viewer2D = state.viewer2D) === null || _state$viewer2D === void 0 ? void 0 : _state$viewer2D.toJS();
1005
+ if (mouseX && mouseY && v2d) {
1006
+ vPosX = (mouseX - v2d.e) / v2d.a;
1007
+ vPosY = (mouseY - v2d.f) / v2d.d;
1008
+ layerID = state.scene.selectedLayer; // move cabinet to initial position
1009
+ props.itemsActions.updateDrawingItem(layerID, vPosX, -vPosY + state.scene.height);
1010
+ }
1011
+ }
647
1012
  props.projectActions.pushLastSelectedCatalogElementToHistory(element);
648
1013
  props.projectActions.setIsCabinetDrawing(true);
649
1014
  case 11:
@@ -765,8 +1130,13 @@ function _handleExternalEvent() {
765
1130
  }
766
1131
  return _context8.abrupt("continue", 34);
767
1132
  case 32:
768
- distancePayload = evt.payload;
769
- props.itemsActions.changeDistance(distancePayload);
1133
+ layerId = state.getIn(['scene', 'selectedLayer']);
1134
+ layer = state.getIn(['scene', 'layers', layerId]);
1135
+ _layer$getIn = layer.getIn(['selected']), selectedLines = _layer$getIn.lines, selectedHoles = _layer$getIn.holes, selectedItems = _layer$getIn.items;
1136
+ for (_i2 = 0; _i2 < selectedLines.size; _i2++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i2)]), evt.payload, state, layer, props.projectActions) : updatePropertyOfSelectedElement(layer.getIn(['lines', selectedLines.get(_i2)]), evt.payload, props.catalog, props.projectActions);
1137
+ for (_i3 = 0; _i3 < selectedHoles.size; _i3++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i3)]), evt.payload, state, layer, props.projectActions) : updatePropertyOfSelectedElement(layer.getIn(['holes', selectedHoles.get(_i3)]), evt.payload, props.catalog, props.projectActions);
1138
+ for (_i4 = 0; _i4 < selectedItems.size; _i4++) (evt === null || evt === void 0 ? void 0 : evt.type) === _constants.EXTERNAL_EVENT_UPDATE_ATTRIBUTE ? updateAttributeOfSelectedElement(layer.getIn(['items', selectedItems.get(_i4)]), evt.payload, state, layer, props.projectActions) : updatePropertyOfSelectedElement(layer.getIn(['items', selectedItems.get(_i4)]), evt.payload, props.catalog, props.projectActions);
1139
+ return _context8.abrupt("continue", 34);
770
1140
  case 33:
771
1141
  // send scene object from 3DTool to HostApp using internalEvent
772
1142
  (_props$onInternalEven2 = props.onInternalEvent) === null || _props$onInternalEven2 === void 0 || _props$onInternalEven2.call(props, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitchen-simulator",
3
- "version": "2.0.4",
3
+ "version": "2.0.5-flip-handle-open-door",
4
4
  "description": "It is a kitchen simulator (self-contained micro-frontend).",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",