Minor fixes and improvements
parent
140055c0f0
commit
b1b33f76b2
|
@ -61,10 +61,10 @@ AttachmentsDirective = ($repo) ->
|
||||||
_.sorBy($scope.attachments, 'order')
|
_.sorBy($scope.attachments, 'order')
|
||||||
|
|
||||||
## Total attachments counter
|
## Total attachments counter
|
||||||
$scope.$watch "attachmentsCount", (attachmentsCount) ->
|
$scope.$watch "attachmentsCount", (count) ->
|
||||||
$el.find("span.attachments-num").html(attachmentsCount)
|
$el.find("span.attachments-num").html(count)
|
||||||
|
|
||||||
## See deprecated attachments
|
## Show/Hide deprecated attachments
|
||||||
$scope.showDeprecatedAttachments = false
|
$scope.showDeprecatedAttachments = false
|
||||||
|
|
||||||
$scope.$watch "deprecatedAttachmentsCount", (deprecatedAttachmentsCount) ->
|
$scope.$watch "deprecatedAttachmentsCount", (deprecatedAttachmentsCount) ->
|
||||||
|
@ -83,9 +83,11 @@ AttachmentsDirective = ($repo) ->
|
||||||
|
|
||||||
if $scope.showDeprecatedAttachments
|
if $scope.showDeprecatedAttachments
|
||||||
target.find("span.text").html("- hide deprecated attachments") # TODO: i18n
|
target.find("span.text").html("- hide deprecated attachments") # TODO: i18n
|
||||||
|
.prop("title", "hide deprecated attachments") # TODO: i18n
|
||||||
$el.find("div.single-attachment.deprecated").removeClass("hidden")
|
$el.find("div.single-attachment.deprecated").removeClass("hidden")
|
||||||
else
|
else
|
||||||
target.find("span.text").html("+ show deprecated attachments") # TODO: i18n
|
target.find("span.text").html("+ show deprecated attachments") # TODO: i18n
|
||||||
|
.prop("title", "show deprecated attachments") # TODO: i18n
|
||||||
$el.find("div.single-attachment.deprecated").addClass("hidden")
|
$el.find("div.single-attachment.deprecated").addClass("hidden")
|
||||||
|
|
||||||
## On destroy
|
## On destroy
|
||||||
|
@ -104,7 +106,7 @@ module.directive("tgAttachments", ["$tgRepo", AttachmentsDirective])
|
||||||
## Attachment Directive
|
## Attachment Directive
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
AttachmentDirective = ($log, $repo, $rs, $confirm) ->
|
AttachmentDirective = ($log, $repo, $confirm) ->
|
||||||
singleAttachment = _.template("""
|
singleAttachment = _.template("""
|
||||||
<div class="attachment-name">
|
<div class="attachment-name">
|
||||||
<span class="icon.icon-document"></span>
|
<span class="icon.icon-document"></span>
|
||||||
|
@ -139,7 +141,7 @@ AttachmentDirective = ($log, $repo, $rs, $confirm) ->
|
||||||
<a class="editable icon icon-delete" href="" title="Cancel"></a>
|
<a class="editable icon icon-delete" href="" title="Cancel"></a>
|
||||||
""") # TODO: i18n
|
""") # TODO: i18n
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $model) ->
|
link = ($scope, $el, $attrs) ->
|
||||||
$ctrl = $el.controller()
|
$ctrl = $el.controller()
|
||||||
|
|
||||||
render = (attachment, isEditable=false) ->
|
render = (attachment, isEditable=false) ->
|
||||||
|
@ -205,9 +207,9 @@ AttachmentDirective = ($log, $repo, $rs, $confirm) ->
|
||||||
newIsDeprecated = $el.find("input[name='is-deprecated']").prop("checked")
|
newIsDeprecated = $el.find("input[name='is-deprecated']").prop("checked")
|
||||||
|
|
||||||
if newDescription != attachment.description
|
if newDescription != attachment.description
|
||||||
attachment.setAttr("description", newDescription)
|
attachment.description = newDescription
|
||||||
if newIsDeprecated != attachment.is_deprecated
|
if newIsDeprecated != attachment.is_deprecated
|
||||||
attachment.setAttr("is_deprecated", newIsDeprecated)
|
attachment.is_deprecated = newIsDeprecated
|
||||||
|
|
||||||
onSuccess = ->
|
onSuccess = ->
|
||||||
$ctrl.loadAttachments(attachment.object_id)
|
$ctrl.loadAttachments(attachment.object_id)
|
||||||
|
@ -216,17 +218,13 @@ AttachmentDirective = ($log, $repo, $rs, $confirm) ->
|
||||||
onError = ->
|
onError = ->
|
||||||
$confirm.notify("error")
|
$confirm.notify("error")
|
||||||
|
|
||||||
if attachment.isModified()
|
$repo.save(attachment).then(onSuccess, onError)
|
||||||
$repo.save(attachment).then(onSuccess, onError)
|
|
||||||
|
|
||||||
## On destroy
|
## On destroy
|
||||||
$scope.$on "$destroy", ->
|
$scope.$on "$destroy", ->
|
||||||
$el.off()
|
$el.off()
|
||||||
|
|
||||||
return {
|
return {link: link}
|
||||||
link: link,
|
|
||||||
require: "ngModel"
|
|
||||||
}
|
|
||||||
|
|
||||||
module.directive("tgAttachment", ["$log", "$tgRepo", "$tgResources", "$tgConfirm",
|
module.directive("tgAttachment", ["$log", "$tgRepo", "$tgConfirm",
|
||||||
AttachmentDirective])
|
AttachmentDirective])
|
||||||
|
|
Loading…
Reference in New Issue