Fixing issuaes when displaying custom fields on detail

stable
Alejandro Alonso 2015-02-20 08:57:11 +01:00 committed by David Barragán Merino
parent c919ae22d4
commit 74331bbbc0
2 changed files with 7 additions and 5 deletions

View File

@ -116,21 +116,22 @@ CustomAttributesValuesDirective = ($templates, $storage) ->
module.directive("tgCustomAttributesValues", ["$tgTemplate", "$tgStorage", CustomAttributesValuesDirective])
CustomAttributeValueDirective = ($template) ->
CustomAttributeValueDirective = ($template, $selectedText) ->
template = $template.get("custom-attributes/custom-attribute-value.html", true)
templateEdit = $template.get("custom-attributes/custom-attribute-value-edit.html", true)
link = ($scope, $el, $attrs, $ctrl) ->
render = (attributeValue, edit=false) ->
value = attributeValue.value
ctx = {
id: attributeValue.id
name: attributeValue.name
description: attributeValue.description
value: attributeValue.value
value: value
isEditable: isEditable()
}
if edit
if edit or not value
html = templateEdit(ctx)
else
html = template(ctx)
@ -158,6 +159,7 @@ CustomAttributeValueDirective = ($template) ->
## Actions (on view mode)
$el.on "click", ".custom-field-value.read-mode", ->
return if not isEditable()
return if $selectedText.get().length
render(attributeValue, true)
$el.find("input[name='description']").focus().select()
@ -187,4 +189,4 @@ CustomAttributeValueDirective = ($template) ->
restrict: "AE"
}
module.directive("tgCustomAttributeValue", ["$tgTemplate", CustomAttributeValueDirective])
module.directive("tgCustomAttributeValue", ["$tgTemplate", "$selectedText", CustomAttributeValueDirective])

View File

@ -8,7 +8,7 @@ form.custom-field-single
<% } %>
div.custom-field-value
input#custom-field-description(name="description", type="text", placeholder!="<%- value %>")
input#custom-field-description(name="description", type="text", value!="<%- value %>")
div.custom-field-options
a.icon.icon-floppy(href="", title="Save Custom Field")