Fixes #3909 - Wrong size for textareas in triggers and core workflow.

This commit is contained in:
Rolf Schmidt 2022-01-13 12:28:26 +01:00
parent 93fcc862e5
commit 6489fc7602
4 changed files with 38 additions and 9 deletions

View file

@ -96,6 +96,8 @@ class App.UiElement.ApplicationSelector
# ignore passwords and relations # ignore passwords and relations
if row.type isnt 'password' && row.name.substr(row.name.length-4,4) isnt '_ids' && row.searchable isnt false if row.type isnt 'password' && row.name.substr(row.name.length-4,4) isnt '_ids' && row.searchable isnt false
config = _.clone(row) config = _.clone(row)
if config.tag is 'textarea'
config.expanding = false
if config.type is 'email' || config.type is 'tel' if config.type is 'email' || config.type is 'tel'
config.type = 'text' config.type = 'text'
for operatorRegEx, operator of operators_type for operatorRegEx, operator of operators_type

View file

@ -153,6 +153,8 @@ class App.UiElement.core_workflow_condition extends App.UiElement.ApplicationSel
# ignore passwords and relations # ignore passwords and relations
if row.type isnt 'password' && row.name.substr(row.name.length-4,4) isnt '_ids' && row.searchable isnt false if row.type isnt 'password' && row.name.substr(row.name.length-4,4) isnt '_ids' && row.searchable isnt false
config = _.clone(row) config = _.clone(row)
if config.tag is 'textarea'
config.expanding = false
if config.tag is 'select' if config.tag is 'select'
config.multiple = true config.multiple = true
config.default = undefined config.default = undefined

View file

@ -4,16 +4,17 @@ class App.UiElement.textarea
fileUploaderId = 'file-uploader-' + new Date().getTime() + '-' + Math.floor( Math.random() * 99999 ) fileUploaderId = 'file-uploader-' + new Date().getTime() + '-' + Math.floor( Math.random() * 99999 )
item = $( App.view('generic/textarea')( attribute: attribute ) + '<div class="file-uploader ' + attribute.class + '" id="' + fileUploaderId + '"></div>' ) item = $( App.view('generic/textarea')( attribute: attribute ) + '<div class="file-uploader ' + attribute.class + '" id="' + fileUploaderId + '"></div>' )
a = -> if attribute.expanding isnt false
visible = $( item[0] ).is(':visible') a = ->
if visible && !$( item[0] ).expanding('active')
$( item[0] ).expanding()
$( item[0] ).on('focus', ->
visible = $( item[0] ).is(':visible') visible = $( item[0] ).is(':visible')
if visible && !$( item[0] ).expanding('active') if visible && !$( item[0] ).expanding('active')
$( item[0] ).expanding().focus() $( item[0] ).expanding()
) $( item[0] ).on('focus', ->
App.Delay.set(a, 80) visible = $( item[0] ).is(':visible')
if visible && !$( item[0] ).expanding('active')
$( item[0] ).expanding().focus()
)
App.Delay.set(a, 80)
if attribute.upload if attribute.upload

View file

@ -1607,3 +1607,27 @@ QUnit.test("form with external links", assert => {
assert.equal('https://example.com/?q=133', el.find('input[name="a"]').parents('.controls').find('a[href]').attr('href')) assert.equal('https://example.com/?q=133', el.find('input[name="a"]').parents('.controls').find('a[href]').attr('href'))
assert.equal('https://example.com/?q=abc%20d', el.find('select[name="b"]').parents('.controls').find('a[href]').attr('href')) assert.equal('https://example.com/?q=abc%20d', el.find('select[name="b"]').parents('.controls').find('a[href]').attr('href'))
}); });
QUnit.test("Fixes #3909 - Wrong size for textareas in triggers and core workflow.", assert => {
var done = assert.async(1)
$('#qunit').append('<hr><h1>Fixes #3909 - Wrong size for textareas in triggers and core workflow.</h1><form id="form21"></form>')
var el = $('#form21')
new App.ControllerForm({
el: el,
model: {
configure_attributes: [
{ name: '3909_textarea_expanding', display: 'Textarea1', tag: 'textarea', rows: 6, limit: 100, null: true },
{ name: '3909_textarea_no_expanding', display: 'Textarea2', tag: 'textarea', rows: 6, limit: 100, null: false, expanding: false },
],
},
autofocus: true
});
new Promise( (resolve, reject) => {
App.Delay.set(resolve, 200);
}).then( function() {
assert.equal(el.find('textarea[name="3909_textarea_expanding"]').parent().hasClass('expanding-wrapper'), true, '3909_textarea_expanding has correct class')
assert.equal(el.find('textarea[name="3909_textarea_no_expanding"]').parent().hasClass('expanding-wrapper'), false, '3909_textarea_no_expanding has correct class')
})
.finally(done)
});