Fixing issuaes when displaying custom fields on detail
parent
c919ae22d4
commit
74331bbbc0
|
@ -116,21 +116,22 @@ CustomAttributesValuesDirective = ($templates, $storage) ->
|
||||||
module.directive("tgCustomAttributesValues", ["$tgTemplate", "$tgStorage", CustomAttributesValuesDirective])
|
module.directive("tgCustomAttributesValues", ["$tgTemplate", "$tgStorage", CustomAttributesValuesDirective])
|
||||||
|
|
||||||
|
|
||||||
CustomAttributeValueDirective = ($template) ->
|
CustomAttributeValueDirective = ($template, $selectedText) ->
|
||||||
template = $template.get("custom-attributes/custom-attribute-value.html", true)
|
template = $template.get("custom-attributes/custom-attribute-value.html", true)
|
||||||
templateEdit = $template.get("custom-attributes/custom-attribute-value-edit.html", true)
|
templateEdit = $template.get("custom-attributes/custom-attribute-value-edit.html", true)
|
||||||
|
|
||||||
link = ($scope, $el, $attrs, $ctrl) ->
|
link = ($scope, $el, $attrs, $ctrl) ->
|
||||||
render = (attributeValue, edit=false) ->
|
render = (attributeValue, edit=false) ->
|
||||||
|
value = attributeValue.value
|
||||||
ctx = {
|
ctx = {
|
||||||
id: attributeValue.id
|
id: attributeValue.id
|
||||||
name: attributeValue.name
|
name: attributeValue.name
|
||||||
description: attributeValue.description
|
description: attributeValue.description
|
||||||
value: attributeValue.value
|
value: value
|
||||||
isEditable: isEditable()
|
isEditable: isEditable()
|
||||||
}
|
}
|
||||||
|
|
||||||
if edit
|
if edit or not value
|
||||||
html = templateEdit(ctx)
|
html = templateEdit(ctx)
|
||||||
else
|
else
|
||||||
html = template(ctx)
|
html = template(ctx)
|
||||||
|
@ -158,6 +159,7 @@ CustomAttributeValueDirective = ($template) ->
|
||||||
## Actions (on view mode)
|
## Actions (on view mode)
|
||||||
$el.on "click", ".custom-field-value.read-mode", ->
|
$el.on "click", ".custom-field-value.read-mode", ->
|
||||||
return if not isEditable()
|
return if not isEditable()
|
||||||
|
return if $selectedText.get().length
|
||||||
render(attributeValue, true)
|
render(attributeValue, true)
|
||||||
$el.find("input[name='description']").focus().select()
|
$el.find("input[name='description']").focus().select()
|
||||||
|
|
||||||
|
@ -187,4 +189,4 @@ CustomAttributeValueDirective = ($template) ->
|
||||||
restrict: "AE"
|
restrict: "AE"
|
||||||
}
|
}
|
||||||
|
|
||||||
module.directive("tgCustomAttributeValue", ["$tgTemplate", CustomAttributeValueDirective])
|
module.directive("tgCustomAttributeValue", ["$tgTemplate", "$selectedText", CustomAttributeValueDirective])
|
||||||
|
|
|
@ -8,7 +8,7 @@ form.custom-field-single
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
div.custom-field-value
|
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
|
div.custom-field-options
|
||||||
a.icon.icon-floppy(href="", title="Save Custom Field")
|
a.icon.icon-floppy(href="", title="Save Custom Field")
|
||||||
|
|
Loading…
Reference in New Issue