@lingk/sync 0.2.13 → 0.2.14

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/build/main.js CHANGED
@@ -521,9 +521,11 @@ module.exports =
521
521
  var _this = _possibleConstructorReturn(this, (SelectWrapper.__proto__ || Object.getPrototypeOf(SelectWrapper)).call(this));
522
522
 
523
523
  _this.state = {
524
- expanded: {}
524
+ expanded: {},
525
+ searchTerms: {} // {sectionname: searchterm}
525
526
  };
526
527
  _this.expand = _this.expand.bind(_this);
528
+ _this.changeSearchTerm = _this.changeSearchTerm.bind(_this);
527
529
  return _this;
528
530
  }
529
531
 
@@ -532,6 +534,13 @@ module.exports =
532
534
  value: function expand(v, parents) {
533
535
  this.setState({ expanded: _nestExpand2.default.expand(v, parents, this.state.expanded) });
534
536
  }
537
+ }, {
538
+ key: 'changeSearchTerm',
539
+ value: function changeSearchTerm(v, section) {
540
+ var searchTerms = Object.assign({}, this.state.searchTerms);
541
+ searchTerms[section] = v;
542
+ this.setState({ searchTerms: searchTerms });
543
+ }
535
544
  }, {
536
545
  key: 'render',
537
546
  value: function render() {
@@ -541,6 +550,7 @@ module.exports =
541
550
  selectedValues = _props.selectedValues,
542
551
  sectionLabels = _props.sectionLabels,
543
552
  fieldPropLabel = _props.fieldPropLabel;
553
+ var searchTerms = this.state.searchTerms;
544
554
 
545
555
  var iterator = function (sectionValues, entity, sectionLabel, iteration, parents, newParent) {
546
556
  if (newParent) {
@@ -578,6 +588,7 @@ module.exports =
578
588
  }.bind(this);
579
589
 
580
590
  var vals = values && [].concat(_toConsumableArray(values));
591
+
581
592
  if (sectionLabels) {
582
593
  var v = [];
583
594
  sectionLabels.forEach(function (s, i) {
@@ -588,6 +599,37 @@ module.exports =
588
599
  values[i].forEach(function (entity) {
589
600
  iterator(sectionValues, entity, sectionLabels[i], 0, []);
590
601
  });
602
+ //search
603
+ sectionValues.forEach(function (sv, ii) {
604
+ var satisfiesSearch = searchTerms && searchTerms[sectionLabels[i]] ? sv[fieldPropLabel].toLowerCase().indexOf(searchTerms[sectionLabels[i]].toLowerCase()) > -1 : true;
605
+ sv.satisfiesSearch = satisfiesSearch;
606
+ //satisfy parents
607
+ if (searchTerms && satisfiesSearch) {
608
+ // for nested resources (parentRef)
609
+ if (sv.parentRef) {
610
+ sv.parentRef.forEach(function (pr) {
611
+ var parentString = pr.ref.split('/')[2];
612
+ var parent = sectionValues.find(function (p) {
613
+ return parentString === p[fieldPropLabel];
614
+ });
615
+ if (parent) {
616
+ parent.satisfiesSearch = true;
617
+ }
618
+ });
619
+ }
620
+ // for nested props (parents array)
621
+ if (sv.parents) {
622
+ sv.parents.forEach(function (pr) {
623
+ var parent = sectionValues.find(function (p) {
624
+ return pr === p[fieldPropLabel];
625
+ });
626
+ if (parent) {
627
+ parent.satisfiesSearch = true;
628
+ }
629
+ });
630
+ }
631
+ }
632
+ });
591
633
  v = v.concat(sectionValues);
592
634
  })();
593
635
  }
@@ -599,6 +641,9 @@ module.exports =
599
641
  values && values.forEach(function (entity) {
600
642
  iterator(sectionValues, entity, '', 0, []);
601
643
  });
644
+ sectionValues.forEach(function (sv) {
645
+ sv.satisfiesSearch = true; // no sections = no search
646
+ });
602
647
  vals = sectionValues;
603
648
  })();
604
649
  }
@@ -606,7 +651,8 @@ module.exports =
606
651
  return _react2.default.createElement(
607
652
  'div',
608
653
  null,
609
- _react2.default.createElement(inputs.Select, Object.assign({}, this.props, { vals: vals, expand: this.expand }))
654
+ _react2.default.createElement(inputs.Select, Object.assign({}, this.props, { vals: vals, expand: this.expand,
655
+ changeSearchTerm: this.changeSearchTerm }))
610
656
  );
611
657
  }
612
658
  }]);
@@ -3033,7 +3079,8 @@ module.exports =
3033
3079
  lingkSourceKeyParents: sourceKeysParents[0] }, {
3034
3080
  provider: bundle.provider,
3035
3081
  //...bundle.recordTypeId && {recordTypeId: bundle.recordTypeId},
3036
- deleteEnabled: bundle.deleteEnabled || false
3082
+ deleteEnabled: bundle.deleteEnabled || false,
3083
+ writeMode: bundle.writeMode || (bundle.deleteEnabled ? 'delete' : 'default')
3037
3084
  })); // end push each bundle (contains resources AND mappings)
3038
3085
  })();
3039
3086
  } // end if bundleResource
@@ -19983,31 +20030,45 @@ module.exports =
19983
20030
  { className: 'bundle-mode-options-content' },
19984
20031
  _react2.default.createElement(Radio, { label: 'Add/Update',
19985
20032
  onChange: function onChange() {
19986
- return _this3.props.change('resourceGroups.' + resourceGroupIndex + '.deleteEnabled', false);
20033
+ _this3.props.change('resourceGroups.' + resourceGroupIndex + '.writeMode', 'default');
19987
20034
  },
19988
- checked: group && !group.deleteEnabled, style: { cursor: 'pointer' }
20035
+ checked: group && group.writeMode === 'default',
20036
+ style: { cursor: 'pointer' }
19989
20037
  }),
19990
20038
  _react2.default.createElement('br', null),
19991
20039
  _react2.default.createElement(
19992
- 'span',
19993
- { className: 'labelz' },
20040
+ 'div',
20041
+ { className: 'labelz', style: { fontSize: '13px' } },
19994
20042
  'If record exists in destination, update it. Otherwise, add it.'
19995
20043
  ),
19996
20044
  _react2.default.createElement('br', null),
19997
- _react2.default.createElement('br', null),
19998
20045
  _react2.default.createElement(Radio, { label: 'Add/Update/Delete',
19999
20046
  onChange: function onChange() {
20000
- return _this3.props.change('resourceGroups.' + resourceGroupIndex + '.deleteEnabled', true);
20047
+ _this3.props.change('resourceGroups.' + resourceGroupIndex + '.writeMode', 'delete');
20001
20048
  },
20002
- checked: group && group.deleteEnabled, style: { cursor: 'pointer' }
20049
+ checked: group && group.writeMode === 'delete',
20050
+ style: { cursor: 'pointer' }
20003
20051
  }),
20004
20052
  _react2.default.createElement('br', null),
20005
20053
  _react2.default.createElement(
20006
- 'span',
20007
- { className: 'labelz' },
20008
- 'Delete records that exist in the destination but not the source.'
20054
+ 'div',
20055
+ { className: 'labelz', style: { fontSize: '13px' } },
20056
+ 'Delete records that exist in the target but not the source.'
20009
20057
  ),
20010
20058
  _react2.default.createElement('br', null),
20059
+ _react2.default.createElement(Radio, { label: 'Update Only',
20060
+ onChange: function onChange() {
20061
+ _this3.props.change('resourceGroups.' + resourceGroupIndex + '.writeMode', 'updateonly');
20062
+ },
20063
+ checked: group && group.writeMode === 'updateonly',
20064
+ style: { cursor: 'pointer' }
20065
+ }),
20066
+ _react2.default.createElement('br', null),
20067
+ _react2.default.createElement(
20068
+ 'div',
20069
+ { className: 'labelz', style: { fontSize: '13px' } },
20070
+ 'Only update existing records, do not insert new ones.'
20071
+ ),
20011
20072
  _react2.default.createElement('br', null)
20012
20073
  )
20013
20074
  ) : null
@@ -23301,6 +23362,7 @@ module.exports =
23301
23362
  resources: null,
23302
23363
  recordTypeId: newGroup.recordTypeId,
23303
23364
  provider: newGroup.section,
23365
+ writeMode: 'default',
23304
23366
  // only Salesforce has ability to add "Lingk External Id"
23305
23367
  customExternalKeys: newGroup.section !== 'Salesforce'
23306
23368
  });