Merge pull request #533 from artlepool/master
Multi-line custom field types (taiga-front #451)stable
commit
27b428827f
|
@ -128,6 +128,7 @@ CustomAttributeValueDirective = ($template, $selectedText, $compile) ->
|
||||||
link = ($scope, $el, $attrs, $ctrl) ->
|
link = ($scope, $el, $attrs, $ctrl) ->
|
||||||
render = (attributeValue, edit=false) ->
|
render = (attributeValue, edit=false) ->
|
||||||
value = attributeValue.value
|
value = attributeValue.value
|
||||||
|
innerText = attributeValue.value
|
||||||
editable = isEditable()
|
editable = isEditable()
|
||||||
ctx = {
|
ctx = {
|
||||||
id: attributeValue.id
|
id: attributeValue.id
|
||||||
|
@ -135,6 +136,7 @@ CustomAttributeValueDirective = ($template, $selectedText, $compile) ->
|
||||||
description: attributeValue.description
|
description: attributeValue.description
|
||||||
value: value
|
value: value
|
||||||
isEditable: editable
|
isEditable: editable
|
||||||
|
field_type: attributeValue.field_type
|
||||||
}
|
}
|
||||||
|
|
||||||
if editable and (edit or not value)
|
if editable and (edit or not value)
|
||||||
|
@ -152,14 +154,14 @@ CustomAttributeValueDirective = ($template, $selectedText, $compile) ->
|
||||||
return permissions.indexOf(requiredEditionPerm) > -1
|
return permissions.indexOf(requiredEditionPerm) > -1
|
||||||
|
|
||||||
saveAttributeValue = ->
|
saveAttributeValue = ->
|
||||||
attributeValue.value = $el.find("input").val()
|
attributeValue.value = $el.find("input, textarea").val()
|
||||||
|
|
||||||
$scope.$apply ->
|
$scope.$apply ->
|
||||||
$ctrl.updateAttributeValue(attributeValue).then ->
|
$ctrl.updateAttributeValue(attributeValue).then ->
|
||||||
render(attributeValue, false)
|
render(attributeValue, false)
|
||||||
|
|
||||||
$el.on "keyup", "input[name=description]", (event) ->
|
$el.on "keyup", "input[name=description], textarea[name='description']", (event) ->
|
||||||
if event.keyCode == 13
|
if event.keyCode == 13 and event.currentTarget.type != "textarea"
|
||||||
submit(event)
|
submit(event)
|
||||||
else if event.keyCode == 27
|
else if event.keyCode == 27
|
||||||
render(attributeValue, false)
|
render(attributeValue, false)
|
||||||
|
@ -169,14 +171,12 @@ CustomAttributeValueDirective = ($template, $selectedText, $compile) ->
|
||||||
return if not isEditable()
|
return if not isEditable()
|
||||||
return if $selectedText.get().length
|
return if $selectedText.get().length
|
||||||
render(attributeValue, true)
|
render(attributeValue, true)
|
||||||
$el.find("input[name='description']").focus().select()
|
$el.find("input[name='description'], textarea[name='description']").focus().select()
|
||||||
$scope.$apply()
|
|
||||||
|
|
||||||
$el.on "click", "a.icon-edit", (event) ->
|
$el.on "click", "a.icon-edit", (event) ->
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
render(attributeValue, true)
|
render(attributeValue, true)
|
||||||
$el.find("input[name='description']").focus().select()
|
$el.find("input[name='description'], textarea[name='description']").focus().select()
|
||||||
$scope.$apply()
|
|
||||||
|
|
||||||
## Actions (on edit mode)
|
## Actions (on edit mode)
|
||||||
submit = debounce 2000, (event) =>
|
submit = debounce 2000, (event) =>
|
||||||
|
|
|
@ -448,7 +448,9 @@
|
||||||
"TASK_DESCRIPTION": "Tasks custom fields",
|
"TASK_DESCRIPTION": "Tasks custom fields",
|
||||||
"TASK_ADD": "Add a custom field in tasks",
|
"TASK_ADD": "Add a custom field in tasks",
|
||||||
"ISSUE_DESCRIPTION": "Issues custom fields",
|
"ISSUE_DESCRIPTION": "Issues custom fields",
|
||||||
"ISSUE_ADD": "Add a custom field in issues"
|
"ISSUE_ADD": "Add a custom field in issues",
|
||||||
|
"FIELD_TYPE_TEXT": "Text",
|
||||||
|
"FIELD_TYPE_MULTI": "Multi-line"
|
||||||
},
|
},
|
||||||
"PROJECT_VALUES": {
|
"PROJECT_VALUES": {
|
||||||
"PAGE_TITLE": "{{sectionName}} - Project values - {{projectName}}",
|
"PAGE_TITLE": "{{sectionName}} - Project values - {{projectName}}",
|
||||||
|
|
|
@ -8,7 +8,15 @@ form.custom-field-single.editable
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
div.custom-field-value
|
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 %>")
|
input#custom-field-description(name="description", type="text", value!="<%- value %>")
|
||||||
|
<% } %>
|
||||||
|
|
||||||
div.custom-field-options
|
div.custom-field-options
|
||||||
a.icon.icon-floppy(href="", title="{{'COMMON.CUSTOM_ATTRIBUTES.SAVE' | translate}}")
|
a.icon.icon-floppy(href="", title="{{'COMMON.CUSTOM_ATTRIBUTES.SAVE' | translate}}")
|
||||||
|
|
|
@ -10,6 +10,8 @@ section.custom-fields-table.basic-table
|
||||||
span(translate="COMMON.FIELDS.NAME")
|
span(translate="COMMON.FIELDS.NAME")
|
||||||
div.custom-description
|
div.custom-description
|
||||||
span(translate="COMMON.FIELDS.DESCRIPTION")
|
span(translate="COMMON.FIELDS.DESCRIPTION")
|
||||||
|
div.custom-field-type
|
||||||
|
span(translate="COMMON.FIELDS.TYPE")
|
||||||
div.custom-options
|
div.custom-options
|
||||||
|
|
||||||
div.table-body
|
div.table-body
|
||||||
|
@ -21,6 +23,8 @@ section.custom-fields-table.basic-table
|
||||||
span {{ attr.name }}
|
span {{ attr.name }}
|
||||||
div.custom-description
|
div.custom-description
|
||||||
span {{ attr.description }}
|
span {{ attr.description }}
|
||||||
|
div.custom-field-type
|
||||||
|
span(translate="ADMIN.CUSTOM_FIELDS.FIELD_TYPE_{{ attr.field_type }}")
|
||||||
div.custom-options
|
div.custom-options
|
||||||
div.custom-options-wrapper
|
div.custom-options-wrapper
|
||||||
a.js-edit-custom-field-button.icon.icon-edit(href="", title="{{'ADMIN.CUSTOM_ATTRIBUTES.EDIT' | translate}}")
|
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
|
fieldset.custom-description
|
||||||
input(type="text", name="description", placeholder="{{'ADMIN.CUSTOM_ATTRIBUTES.SET_FIELD_DESCRIPTION' | translate}}",
|
input(type="text", name="description", placeholder="{{'ADMIN.CUSTOM_ATTRIBUTES.SET_FIELD_DESCRIPTION' | translate}}",
|
||||||
ng-model="attr.description")
|
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
|
fieldset.custom-options
|
||||||
div.custom-options-wrapper
|
div.custom-options-wrapper
|
||||||
|
@ -46,7 +53,9 @@ section.custom-fields-table.basic-table
|
||||||
fieldset.custom-description
|
fieldset.custom-description
|
||||||
input(type="text", name="description", placeholder="{{'ADMIN.CUSTOM_ATTRIBUTES.SET_FIELD_DESCRIPTION' | translate}}",
|
input(type="text", name="description", placeholder="{{'ADMIN.CUSTOM_ATTRIBUTES.SET_FIELD_DESCRIPTION' | translate}}",
|
||||||
ng-model="newAttr.description")
|
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
|
fieldset.custom-options
|
||||||
div.custom-options-wrapper
|
div.custom-options-wrapper
|
||||||
a.js-create-custom-field-button.icon.icon-floppy(href="", title="{{'ADMIN.CUSTOM_ATTRIBUTES.SAVE_TITLE' | translate}}")
|
a.js-create-custom-field-button.icon.icon-floppy(href="", title="{{'ADMIN.CUSTOM_ATTRIBUTES.SAVE_TITLE' | translate}}")
|
||||||
|
|
|
@ -70,9 +70,13 @@
|
||||||
}
|
}
|
||||||
.custom-description {
|
.custom-description {
|
||||||
@include ellipsis(100%);
|
@include ellipsis(100%);
|
||||||
flex-basis: 90%;
|
flex-basis: 50%;
|
||||||
flex-grow: 8;
|
flex-grow: 8;
|
||||||
}
|
}
|
||||||
|
.custom-field-type {
|
||||||
|
flex-basis: 25%;
|
||||||
|
flex-grow: 0;
|
||||||
|
}
|
||||||
.custom-options {
|
.custom-options {
|
||||||
flex-basis: 100px;
|
flex-basis: 100px;
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
|
|
|
@ -67,6 +67,12 @@
|
||||||
.custom-field-value {
|
.custom-field-value {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 0 1rem 0 2rem;
|
padding: 0 1rem 0 2rem;
|
||||||
|
.read-mode {
|
||||||
|
white-space: pre;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.read-mode {
|
||||||
|
white-space: pre;
|
||||||
}
|
}
|
||||||
form {
|
form {
|
||||||
label {
|
label {
|
||||||
|
|
Loading…
Reference in New Issue