Skip to content

Commit

Permalink
Fixes #1213 - Emit all events consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Lancha committed Oct 2, 2018
1 parent 0a14437 commit 89fae01
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 17 deletions.
28 changes: 22 additions & 6 deletions packages/clay-dataset-display/src/ClayDatasetDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ class ClayDatasetDisplay extends ClayComponent {
* @private
*/
_handleCreationButtonClicked(event) {
this.emit('creationButtonClicked', event);
return !this.emit({
name: 'creationButtonClicked',
originalEvent: event,
});
}

/**
Expand All @@ -130,7 +133,10 @@ class ClayDatasetDisplay extends ClayComponent {
* @private
*/
_handleCreationMenuMoreButtonClicked(event) {
this.emit('creationMenuMoreButtonClicked', event);
return !this.emit({
name: 'creationMenuMoreButtonClicked',
originalEvent: event,
});
}

/**
Expand All @@ -139,7 +145,10 @@ class ClayDatasetDisplay extends ClayComponent {
* @private
*/
_handleFilterDoneClicked(event) {
this.emit('filterDoneClicked', event);
return !this.emit({
name: 'filterDoneClicked',
originalEvent: event,
});
}

/**
Expand Down Expand Up @@ -237,7 +246,10 @@ class ClayDatasetDisplay extends ClayComponent {
* @private
*/
_handleSearch(event) {
this.emit('search', event);
return !this.emit({
name: 'search',
originalEvent: event
});
}

/**
Expand All @@ -246,7 +258,11 @@ class ClayDatasetDisplay extends ClayComponent {
* @private
*/
_handleSortingButtonClicked(event) {
this.emit('sortingButtonClicked', event);
return !this.emit({
data: event.data,
name: 'sortingButtonClicked',
originalEvent: event
});
}

/**
Expand All @@ -256,7 +272,7 @@ class ClayDatasetDisplay extends ClayComponent {
* @private
*/
_handleSelectPageCheckboxChanged(event) {
let checkboxStatus = event.target.checked;
let checkboxStatus = event.data.checked;

if (checkboxStatus) {
this._selectAllItems();
Expand Down
53 changes: 42 additions & 11 deletions packages/clay-management-toolbar/src/ClayManagementToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ class ClayManagementToolbar extends ClayComponent {
* @private
*/
_handleClearResultsClick(event) {
this.emit('clearButtonClicked', event);
return !this.emit({
name: 'clearButtonClicked',
originalEvent: event
});
}

/**
Expand All @@ -65,7 +68,10 @@ class ClayManagementToolbar extends ClayComponent {
* @private
*/
_handleCreationButtonClicked(event) {
this.emit('creationButtonClicked', event);
return !this.emit({
name: 'creationButtonClicked',
originalEvent: event
});
}

/**
Expand All @@ -88,7 +94,10 @@ class ClayManagementToolbar extends ClayComponent {
* @private
*/
_handleCreationMenuMoreButtonClicked(event) {
this.emit('creationMenuMoreButtonClicked', event);
return !this.emit({
name: 'creationMenuMoreButtonClicked',
originalEvent: event
});
}

/**
Expand All @@ -97,7 +106,10 @@ class ClayManagementToolbar extends ClayComponent {
* @private
*/
_handleFilterDoneButtonClick(event) {
this.emit('filterDoneClicked', event);
return !this.emit({
name: 'filterDoneClicked',
originalEvent: event
});
}

/**
Expand All @@ -120,7 +132,10 @@ class ClayManagementToolbar extends ClayComponent {
* @private
*/
_handleFilterLabelCloseClicked(event) {
this.emit('filterLabelCloseClicked', event);
return !this.emit({
name: 'filterLabelCloseClicked',
originalEvent: event
});
}

/**
Expand All @@ -129,7 +144,10 @@ class ClayManagementToolbar extends ClayComponent {
* @private
*/
_handleInfoButtonClicked(event) {
this.emit('infoButtonClicked', event);
return !this.emit({
name: 'infoButtonClicked',
originalEvent: event
});
}

/**
Expand Down Expand Up @@ -167,7 +185,10 @@ class ClayManagementToolbar extends ClayComponent {
* @return {Boolean} If the event has been prevented or not.
*/
_handleSearchSearchClick(event) {
return !this.emit('search', event);
return !this.emit({
name: 'search',
originalEvent: event
});
}

/**
Expand All @@ -176,16 +197,26 @@ class ClayManagementToolbar extends ClayComponent {
* @private
*/
_handleSelectPageCheckboxChanged(event) {
this.emit('selectPageCheckboxChanged', event);
return !this.emit({
data: {
checked: event.target.checked,
},
name: 'selectPageCheckboxChanged',
originalEvent: event
});
}

/**
* Continues the propagation of the sorting button clicked event
* @private
*/
_handleSortingButtonClicked() {
this.emit('sortingButtonClicked', {
sortingOrder: this.sortingOrder,
_handleSortingButtonClicked(event) {
return !this.emit({
data: {
sortingOrder: this.sortingOrder,
},
name: 'sortingButtonClicked',
originalEvent: event
});
}

Expand Down

0 comments on commit 89fae01

Please sign in to comment.