Improve tgConfirm.notify method to allow a custom title and message
parent
adb756b4cd
commit
8a50d2fa58
|
@ -24,6 +24,18 @@ timeout = @.taiga.timeout
|
||||||
cancelTimeout = @.taiga.cancelTimeout
|
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
|
class ConfirmService extends taiga.Service
|
||||||
@.$inject = ["$q"]
|
@.$inject = ["$q"]
|
||||||
|
|
||||||
|
@ -100,15 +112,24 @@ class ConfirmService extends taiga.Service
|
||||||
@.el.removeClass("hidden")
|
@.el.removeClass("hidden")
|
||||||
return defered.promise
|
return defered.promise
|
||||||
|
|
||||||
notify: (type, message) ->
|
notify: (type, message, title) ->
|
||||||
# TODO: at this momment the message is ignored
|
# NOTE: Typesi are: error, success, light-error
|
||||||
# because the notification message not permits
|
# See partials/components/notification-message.jade)
|
||||||
# custom messages.
|
# Add default texts to NOTIFICATION_MSG for new notification types
|
||||||
#
|
|
||||||
# Types: error, success, light-error
|
|
||||||
selector = ".notification-message-#{type}"
|
selector = ".notification-message-#{type}"
|
||||||
@.el = angular.element(selector)
|
@.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 = angular.element("body")
|
||||||
body.find(".notification-message .notification-light").removeClass('active');
|
body.find(".notification-message .notification-light").removeClass('active');
|
||||||
body.find(selector).addClass('active');
|
body.find(selector).addClass('active');
|
||||||
|
|
|
@ -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.hidden.notification-message.notification-message-success
|
||||||
div.icon.icon-notification-success
|
div.icon.icon-notification-success
|
||||||
div.text
|
div.text
|
||||||
|
|
Loading…
Reference in New Issue