Skip to content

Commit

Permalink
Adding helper methods for each notification type. Fixes ember-templat…
Browse files Browse the repository at this point in the history
  • Loading branch information
ynnoj committed Dec 16, 2015
1 parent 713e7b6 commit d4b093b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
30 changes: 29 additions & 1 deletion addon/services/notification-messages-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export default Ember.ArrayProxy.extend({
defaultClearDuration: 3200,

addNotification(options) {

// If no message is set, throw an error
if (!options.message) {
throw new Error("No notification message set");
Expand All @@ -29,6 +28,35 @@ export default Ember.ArrayProxy.extend({
return notification;
},

// Helper methods for each type of notification
error(message, options) {
this.addNotification(Ember.merge({
message: message,
type: 'error'
}, options));
},

success(message, options) {
this.addNotification(Ember.merge({
message: message,
type: 'success'
}, options));
},

info(message, options) {
this.addNotification(Ember.merge({
message: message,
type: 'info'
}, options));
},

warning(message, options) {
this.addNotification(Ember.merge({
message: message,
type: 'warning'
}, options));
},

removeNotification(notification) {
if (!notification) {
return;
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@
<label>Clear all</label>
</div>
</div>
<button class="button" {{action 'showNotifcation'}}>Show</button>
<button class="button" {{action "showNotifcation"}}>Show</button>
{{outlet}}

0 comments on commit d4b093b

Please sign in to comment.