Initial commit of multi-line text fields

stable
Chris Wilson 2015-06-17 21:16:50 +01:00
parent dbb636db97
commit 5a92810008
5 changed files with 35 additions and 8 deletions

View File

@ -128,6 +128,7 @@ CustomAttributeValueDirective = ($template, $selectedText, $compile) ->
link = ($scope, $el, $attrs, $ctrl) ->
render = (attributeValue, edit=false) ->
value = attributeValue.value
innerText = attributeValue.value
editable = isEditable()
ctx = {
id: attributeValue.id
@ -135,6 +136,7 @@ CustomAttributeValueDirective = ($template, $selectedText, $compile) ->
description: attributeValue.description
value: value
isEditable: editable
field_type: attributeValue.field_type
}
if editable and (edit or not value)
@ -152,14 +154,14 @@ CustomAttributeValueDirective = ($template, $selectedText, $compile) ->
return permissions.indexOf(requiredEditionPerm) > -1
saveAttributeValue = ->
attributeValue.value = $el.find("input").val()
attributeValue.value = $el.find("input, textarea").val()
$scope.$apply ->
$ctrl.updateAttributeValue(attributeValue).then ->
render(attributeValue, false)
$el.on "keyup", "input[name=description]", (event) ->
if event.keyCode == 13
$el.on "keyup", "input[name=description], textarea[name='description']", (event) ->
if event.keyCode == 13 and event.currentTarget.type != "textarea"
submit(event)
else if event.keyCode == 27
render(attributeValue, false)
@ -169,14 +171,12 @@ CustomAttributeValueDirective = ($template, $selectedText, $compile) ->
return if not isEditable()
return if $selectedText.get().length
render(attributeValue, true)
$el.find("input[name='description']").focus().select()
$scope.$apply()
$el.find("input[name='description'], textarea[name='description']").focus().select()
$el.on "click", "a.icon-edit", (event) ->
event.preventDefault()
render(attributeValue, true)
$el.find("input[name='description']").focus().select()
$scope.$apply()
$el.find("input[name='description'], textarea[name='description']").focus().select()
## Actions (on edit mode)
submit = debounce 2000, (event) =>

View File

@ -8,7 +8,15 @@ form.custom-field-single.editable
<% } %>
div.custom-field-value
<% if (field_type=="MULTI") { %>
textarea#custom-field-description(name="description")
<%- value %>
<% } %>
<% if (field_type=="TEXT") { %>
input#custom-field-description(name="description", type="text", value!="<%- value %>")
<% } %>
div.custom-field-options
a.icon.icon-floppy(href="", title="{{'COMMON.CUSTOM_ATTRIBUTES.SAVE' | translate}}")

View File

@ -10,6 +10,8 @@ section.custom-fields-table.basic-table
span(translate="COMMON.FIELDS.NAME")
div.custom-description
span(translate="COMMON.FIELDS.DESCRIPTION")
div.custom-field-type
span(translate="COMMON.FIELDS.FIELD_TYPE")
div.custom-options
div.table-body
@ -21,6 +23,8 @@ section.custom-fields-table.basic-table
span {{ attr.name }}
div.custom-description
span {{ attr.description }}
div.custom-field-type
span(translate="ADMIN.CUSTOM_FIELDS.FIELD_TYPE_{{ attr.field_type }}")
div.custom-options
div.custom-options-wrapper
a.js-edit-custom-field-button.icon.icon-edit(href="", title="{{'ADMIN.CUSTOM_ATTRIBUTES.EDIT' | translate}}")
@ -33,6 +37,9 @@ section.custom-fields-table.basic-table
fieldset.custom-description
input(type="text", name="description", placeholder="{{'ADMIN.CUSTOM_ATTRIBUTES.SET_FIELD_DESCRIPTION' | translate}}",
ng-model="attr.description")
fieldset.custom-field-type
select(ng-model="attr.field_type",
ng-options="e.id as e.name | translate for e in [{'id':'TEXT', 'name': 'ADMIN.CUSTOM_FIELDS.FIELD_TYPE_TEXT'},{'id':'MULTI', 'name': 'ADMIN.CUSTOM_FIELDS.FIELD_TYPE_MULTI'}]")
fieldset.custom-options
div.custom-options-wrapper
@ -46,7 +53,9 @@ section.custom-fields-table.basic-table
fieldset.custom-description
input(type="text", name="description", placeholder="{{'ADMIN.CUSTOM_ATTRIBUTES.SET_FIELD_DESCRIPTION' | translate}}",
ng-model="newAttr.description")
fieldset.custom-field-type
select(ng-model="newAttr.field_type",
ng-options="e.id as translate(e.name) for e in [{'id':'TEXT', 'name': 'ADMIN.CUSTOM_FIELDS.FIELD_TYPE_TEXT'},{'id':'MULTI', 'name': 'ADMIN.CUSTOM_FIELDS.FIELD_TYPE_MULTI'}]")
fieldset.custom-options
div.custom-options-wrapper
a.js-create-custom-field-button.icon.icon-floppy(href="", title="{{'ADMIN.CUSTOM_ATTRIBUTES.SAVE_TITLE' | translate}}")

View File

@ -73,6 +73,10 @@
flex-basis: 90%;
flex-grow: 8;
}
.custom-field-type {
flex-basis: 25%;
flex-grow: 0;
}
.custom-options {
flex-basis: 100px;
flex-grow: 0;

View File

@ -67,6 +67,12 @@
.custom-field-value {
flex: 1;
padding: 0 1rem 0 2rem;
.read-mode {
white-space: pre
}
}
.read-mode {
white-space: pre
}
form {
label {