diff --git a/app/coffee/modules/base/confirm.coffee b/app/coffee/modules/base/confirm.coffee index 27a6eede..074b611d 100644 --- a/app/coffee/modules/base/confirm.coffee +++ b/app/coffee/modules/base/confirm.coffee @@ -24,6 +24,18 @@ timeout = @.taiga.timeout cancelTimeout = @.taiga.cancelTimeout +NOTIFICATION_MSG = { + "success": + title: "Everything is ok" + message: "Our oompa Loompas saved all your changes!" + "error": + title: "Oops, something happened..." + message: "Our oompa Loompas are sad, your changes were not saved!" + "light-error": + title: "Oops, something happened..." + message: "Our oompa Loompas are sad, your changes were not saved!" +} + class ConfirmService extends taiga.Service @.$inject = ["$q"] @@ -100,15 +112,24 @@ class ConfirmService extends taiga.Service @.el.removeClass("hidden") return defered.promise - notify: (type, message) -> - # TODO: at this momment the message is ignored - # because the notification message not permits - # custom messages. - # - # Types: error, success, light-error + notify: (type, message, title) -> + # NOTE: Typesi are: error, success, light-error + # See partials/components/notification-message.jade) + # Add default texts to NOTIFICATION_MSG for new notification types + selector = ".notification-message-#{type}" @.el = angular.element(selector) + if title + @.el.find("h4").html(title) + else + @.el.find("h4").html(NOTIFICATION_MSG[type].title) + + if message + @.el.find("p").html(message) + else + @.el.find("p").html(NOTIFICATION_MSG[type].message) + body = angular.element("body") body.find(".notification-message .notification-light").removeClass('active'); body.find(selector).addClass('active'); diff --git a/app/partials/views/components/notification-message.jade b/app/partials/views/components/notification-message.jade index c7cf3522..79032b72 100644 --- a/app/partials/views/components/notification-message.jade +++ b/app/partials/views/components/notification-message.jade @@ -1,3 +1,14 @@ +//- To Aadd a new notification type: +//- +//- div.hidden.notification-message.notification-message-< type > +//- (...) +//- h4 < title > +//- (...) +//- p < message > +//- (...) +//- +//-See coffe/modules/base/confirm.coffee + div.hidden.notification-message.notification-message-success div.icon.icon-notification-success div.text