Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow for clearing and removing individual toasts #11

Merged
merged 1 commit into from
Jan 10, 2017
Merged

allow for clearing and removing individual toasts #11

merged 1 commit into from
Jan 10, 2017

Conversation

baseballlover723
Copy link
Contributor

toastr allows you to individually clear and remove toasts, this change lets you do that. This shouldn't break anything since you can safely ignore the arguments for clear and remove. Manually tested on one of my ember apps.

@knownasilya knownasilya merged commit 39fddc5 into knownasilya:master Jan 10, 2017
@knownasilya
Copy link
Owner

I'll release a new version tomorrow. Thanks for the PR.

knownasilya pushed a commit that referenced this pull request Jan 10, 2017
Enhancements
------------

- Allow removing individual toasts
  ```js
  let item = this.toast.info('hello');
  this.toast.remove(item);
  ```
- Allow clearing individual toasts
  ```js
  let item = this.toast.info('hello');
  this.toast.clear(item);
  ```
- Save toasts to the `toasts` property and auto remove when hidden

Thanks to @baseballlover723 for PR #11
@knownasilya
Copy link
Owner

Published v1.5.0. I also added a toasts property to manage toasts.

@knownasilya
Copy link
Owner

Clear and remove doesn't really work for individual toasts, because Toastr.js checks if they are visible and does nothing.. see https://github.com/CodeSeven/toastr/blob/master/toastr.js#L458

@baseballlover723
Copy link
Contributor Author

let me take a look, because I was definitely able to clear an individual toast on one of my own ember apps.

@baseballlover723
Copy link
Contributor Author

so I checked on my app, and it looks like removing an individual toast doesn't work, however, clearing an individual toast does work. One way to could be to call clear with a 1 ms hide duration when you try and remove an individual toast

@baseballlover723
Copy link
Contributor Author

so, removing an individual toast doesn't work on the toastr library. I'm going to submit a bug report to them as well, but for now, this should have the correct behavior

remove(toastElement) {  
  if (toastElement) {
    toastElement.remove();
    this.get('toasts').removeObject(toastElement);
  } else {
    this.set('toasts', Ember.A([]));
  }
  window.toastr.remove(toastElement);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants