Skip to content

Commit

Permalink
feat(hit-policy): allow to clear aggregation from dropdown
Browse files Browse the repository at this point in the history
Closes #370
Closes #389
  • Loading branch information
barmac authored and fake-join[bot] committed Nov 5, 2019
1 parent 2916654 commit 6fc458d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ const HIT_POLICIES = [
'OUTPUT ORDER'
];

const DEFAULT_AGGREGATION = 'NO LIST AGGREGATION';

const LIST_FUNCTIONS = [
DEFAULT_AGGREGATION,
'SUM',
'MIN',
'MAX',
Expand All @@ -34,12 +37,8 @@ export default class HitPolicyCellContextMenu extends Component {
this._modeling.editHitPolicy(hitPolicy, undefined);
}

onAggregationChange(value) {
let aggregation = value === ''
? undefined
: value;

this._modeling.editHitPolicy('COLLECT', aggregation);
onAggregationChange(aggregation) {
this._modeling.editHitPolicy('COLLECT', aggregation || undefined);
}

onElementsChanged() {
Expand Down Expand Up @@ -88,8 +87,8 @@ export default class HitPolicyCellContextMenu extends Component {

const aggregationOptions = LIST_FUNCTIONS.map(l => {
return {
label: l === 'NONE' ? '-' : l,
value: l
label: l,
value: l === DEFAULT_AGGREGATION ? undefined : l
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,44 @@ describe('features/hit-policy - editor', function() {
}));


it('should remove aggregation when input is empty', function() {

// given
triggerInputSelectChange(inputSelect, 'COLLECT');

const aggregationInputSelect = domQuery(
'.hit-policy-edit-operator-select',
testContainer
);

const input = domQuery('.dms-input', aggregationInputSelect);

// when
triggerInputEvent(input, '');

// then
expect(root.businessObject.aggregation).to.not.exist;
});


it('should remove aggregation when NO LIST AGGREGATION is selected', function() {

// given
triggerInputSelectChange(inputSelect, 'COLLECT');

const aggregationInputSelect = domQuery(
'.hit-policy-edit-operator-select',
testContainer
);

// when
triggerInputSelectChange(aggregationInputSelect);

// then
expect(root.businessObject.aggregation).to.not.exist;
});


it('should edit aggregation - select', inject(function(sheet) {

// given
Expand Down
5 changes: 4 additions & 1 deletion packages/dmn-js-shared/test/util/EventUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ export function triggerKeyEvent(element, event, optionsOrCode) {
export function triggerInputSelectChange(inputSelect, value, testContainer) {
triggerClick(inputSelect);

const option = domQuery(`.option[data-value="${ value }"]`, testContainer);
const optionQuery = value ?
`.option[data-value="${ value }"]` : '.option:not([data-value])';

const option = domQuery(optionQuery, testContainer);

return triggerClick(option);
}

0 comments on commit 6fc458d

Please sign in to comment.