Add wiki links spinner on creation
parent
1ca461e5e2
commit
23d272503c
|
@ -34,7 +34,7 @@ module = angular.module("taigaWiki")
|
||||||
## Wiki Main Directive
|
## Wiki Main Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls, $loading) ->
|
||||||
template = _.template("""
|
template = _.template("""
|
||||||
<header>
|
<header>
|
||||||
<h1>Links</h1>
|
<h1>Links</h1>
|
||||||
|
@ -128,13 +128,32 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
||||||
target = angular.element(event.currentTarget)
|
target = angular.element(event.currentTarget)
|
||||||
newLink = target.val()
|
newLink = target.val()
|
||||||
|
|
||||||
$el.find(".new").addClass("hidden")
|
$loading.start($el.find(".new"))
|
||||||
$el.find(".new input").val('')
|
|
||||||
|
|
||||||
$tgrepo.create("wiki-links", {project: $scope.projectId, title: newLink, href: slugify(newLink)}).then ->
|
promise = $tgrepo.create("wiki-links", {project: $scope.projectId, title: newLink, href: slugify(newLink)})
|
||||||
$ctrl.loadWikiLinks().then ->
|
promise.then ->
|
||||||
|
loadPromise = $ctrl.loadWikiLinks()
|
||||||
|
loadPromise.then ->
|
||||||
|
$loading.finish($el.find(".new"))
|
||||||
|
$el.find(".new").addClass("hidden")
|
||||||
|
$el.find(".new input").val('')
|
||||||
|
$el.find(".add-button").show()
|
||||||
render($scope.wikiLinks)
|
render($scope.wikiLinks)
|
||||||
$el.find(".add-button").show()
|
loadPromise.then null, ->
|
||||||
|
$loading.finish($el.find(".new"))
|
||||||
|
$el.find(".new").addClass("hidden")
|
||||||
|
$el.find(".new input").val('')
|
||||||
|
$el.find(".add-button").show()
|
||||||
|
$confirm.notify("error", "Error loading wiki links")
|
||||||
|
|
||||||
|
promise.then null, (error) ->
|
||||||
|
$loading.finish($el.find(".new"))
|
||||||
|
$el.find(".new input").val(newLink)
|
||||||
|
$el.find(".new input").focus().select()
|
||||||
|
if error?.__all__?[0]?
|
||||||
|
$confirm.notify("error", "The link already exists")
|
||||||
|
else
|
||||||
|
$confirm.notify("error")
|
||||||
|
|
||||||
else if event.keyCode == 27
|
else if event.keyCode == 27
|
||||||
target = angular.element(event.currentTarget)
|
target = angular.element(event.currentTarget)
|
||||||
|
@ -147,4 +166,4 @@ WikiNavDirective = ($tgrepo, $log, $location, $confirm, $navUrls) ->
|
||||||
|
|
||||||
return {link:link}
|
return {link:link}
|
||||||
|
|
||||||
module.directive("tgWikiNav", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", "$tgNavUrls", WikiNavDirective])
|
module.directive("tgWikiNav", ["$tgRepo", "$log", "$tgLocation", "$tgConfirm", "$tgNavUrls", "$tgLoading", WikiNavDirective])
|
||||||
|
|
|
@ -30,6 +30,22 @@
|
||||||
color: $gray-light;
|
color: $gray-light;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&.loading {
|
||||||
|
background: $grayer;
|
||||||
|
border: 1px solid #b8b8b8;
|
||||||
|
margin: 0;
|
||||||
|
padding: 8px;
|
||||||
|
text-align: center;
|
||||||
|
width: 100%;
|
||||||
|
.icon-spinner {
|
||||||
|
float: none;
|
||||||
|
color: $whitish;
|
||||||
|
}
|
||||||
|
span {
|
||||||
|
@include animation (loading .5s linear);
|
||||||
|
@include animation (spin 1s linear infinite);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.button {
|
.button {
|
||||||
color: $white;
|
color: $white;
|
||||||
|
|
Loading…
Reference in New Issue