Make InfoDialog more flexible (can show information as well as errors)

This commit is contained in:
Rob Harrington
2018-02-22 10:47:57 +11:00
parent 5cb0a1c371
commit 7332e21013
3 changed files with 20 additions and 3 deletions

View File

@@ -1,13 +1,22 @@
angular.module("admin.utils").factory 'InfoDialog', ($rootScope, $compile, $injector, $templateCache, DialogDefaults) ->
angular.module("admin.utils").factory 'InfoDialog', ($rootScope, $q, $compile, $templateCache, DialogDefaults) ->
new class InfoDialog
icon_classes: {
error: 'icon-exclamation-sign'
info: 'icon-info-sign'
}
open: (type, message, templateUrl='admin/info_dialog.html', options={}) ->
deferred = $q.defer()
scope = $rootScope.$new()
scope.message = message
scope.dialog_class = type
scope.icon_class = @icon_classes[type]
scope.options = options
template = $compile($templateCache.get(templateUrl))(scope)
template.dialog(DialogDefaults)
template.dialog('open')
scope.close = ->
deferred.resolve()
template.dialog('close')
null
deferred.promise

View File

@@ -1,7 +1,7 @@
#info-dialog{ ng: { class: "dialog_class" } }
.message.clearfix.margin-bottom-30
.icon.text-center
%i.icon-exclamation-sign
%i{ ng: { class: "icon_class" } }
.text
{{ message }}
.action-buttons.text-center

View File

@@ -14,7 +14,7 @@
.icon {
width: 20%;
font-size: 2rem;
font-size: 4rem;
}
}
@@ -25,4 +25,12 @@
}
}
}
&.info {
.message {
.icon {
color: #5498da;
}
}
}
}