Fixes issue #1980 - ObjectManager: New select attributes with empty selection will lead block UI.

This commit is contained in:
Martin Edenhofer 2018-04-26 23:18:37 +02:00
parent 43c38dcd97
commit f023a5ad59
6 changed files with 51 additions and 43 deletions

View file

@ -54,6 +54,7 @@ class App.UiElement.ApplicationUiElement
else
order = _.sortBy(
_.keys(selection), (item) ->
return '' if !selection[item] || !selection[item].toString
selection[item].toString().toLowerCase()
)
for key in order
@ -218,10 +219,16 @@ class App.UiElement.ApplicationUiElement
value = valueOrigin
if value is null || value is undefined
value = ''
recordValue = record.value
if recordValue is null || recordValue is undefined
recordValue = ''
recordName = record.name
if recordName is null || recordName is undefined
recordName = ''
if typeof value is 'string' || typeof value is 'number' || typeof value is 'boolean'
if record.value.toString() is value.toString() || record.name.toString() is value.toString()
if recordValue.toString() is value.toString() || recordName.toString() is value.toString()
return true
else if ( value && record.value && _.include(value, record.value) ) || ( value && record.name && _.include(value, record.name) )
else if ( value && recordValue && _.include(value, recordValue) ) || ( value && recordName && _.include(value, recordName) )
return true
false

View file

@ -1,5 +1,6 @@
<div class="js-data">
<div class="js-dataType"></div>
<div class="js-dataMap" style="padding: 30px 0 0 30px;"></div>
<div class="js-dataScreens" style="padding: 30px 0 0 30px;"></div>
<div class="" style="padding-bottom: 10px"><%- @T('Here you define which authorization has access to the attribute.') %></div>
<div class="js-dataScreens"></div>
</div>

View file

@ -1,32 +0,0 @@
<div>
<div class="js-top"></div>
<div class="js-middle" style="padding-left: 70px;">
<div class="js-input">input settings</div>
<div class="js-textarea">textarea settings</div>
<div class="js-datetime">date time settings</div>
<div class="js-date">date settings</div>
<div class="js-select">select settings</div>
<div class="js-tree_selection">tree selection settings</div>
<div class="js-checkbox">checkbox settings</div>
<div class="js-boolean">boolean settings</div>
<div class="js-richtext">richtext settings</div>
</div>
<div class="boolean form-group">
<div class="horizontal">
<label for=""><%- @T('Screens') %> <span>*</span></label>
</div>
<div class="controls">
1
2
3
</diV
</div>
<div class="js-bottom"></div>
</div>

View file

@ -2,7 +2,7 @@
<table class="settings-list" style="width: 100%;">
<thead>
<tr>
<th><%- @T('Role') %>
<th><%- @T('Permissions') %>
<th><%- @T('Screen') %>
<th style="width: 50%;"><%- @T('Options') %>
</thead>
@ -24,7 +24,6 @@
<% end %>
<% end %>
<% end %>
</tbody>
</table>
</div>

View file

@ -1265,3 +1265,36 @@ test("object manager form 3", function() {
deepEqual(params, test_params, 'form param check')
});
test("form select with empty option list", function() {
$('#forms').append('<hr><h1>form select with empty option list</h1><form id="form14"></form>')
var el = $('#form14')
var defaults = {}
new App.ControllerForm({
el: el,
model: {
configure_attributes: [
{ name: 'select1', display: 'Select1', tag: 'select', null: true, default: '', options: {}, relation: '', maxlength: 255 },
{ name: 'select2', display: 'Select2', tag: 'select', null: true, default: '', options: {}, relation: '', maxlength: 255, nulloption: true },
{ name: 'select3', display: 'Select3', tag: 'select', null: true, default: '', options: { undefined: 'A', null: 'B'} },
{ name: 'select4', display: 'Select4', tag: 'select', null: true, default: '', options: { 'A': undefined, 'B': null} },
{ name: 'select5', display: 'Select5', tag: 'select', null: true, default: 'A', options: { 'A': undefined, 'B': null} },
{ name: 'select6', display: 'Select6', tag: 'select', null: true, default: undefined, options: { 'A': undefined, 'B': null} },
],
},
params: defaults,
autofocus: true
});
params = App.ControllerForm.params(el)
test_params = {
select2: '',
select3: 'undefined',
select4: 'B',
select5: 'A',
select6: 'B',
}
deepEqual(params, test_params)
});

View file

@ -53,22 +53,22 @@ if [ "$RDB" == 'postgresql' ]; then
echo " pool: 50" >> $DBFILE
echo " timeout: 5000" >> $DBFILE
echo " encoding: utf8" >> $DBFILE
echo " username: root" >> $DBFILE
echo " password: pass" >> $DBFILE
echo " username: gitlab-runner" >> $DBFILE
echo " password:" >> $DBFILE
echo "test:" >> $DBFILE
echo " adapter: postgresql" >> $DBFILE
echo " database: $DB_TEST" >> $DBFILE
echo " pool: 50" >> $DBFILE
echo " timeout: 5000" >> $DBFILE
echo " encoding: utf8" >> $DBFILE
echo " username: root" >> $DBFILE
echo " password: pass" >> $DBFILE
echo " username: gitlab-runner" >> $DBFILE
echo " password:" >> $DBFILE
echo "development:" >> $DBFILE
echo " adapter: postgresql" >> $DBFILE
echo " database: $DB_DEVELOPMENT" >> $DBFILE
echo " pool: 50" >> $DBFILE
echo " timeout: 5000" >> $DBFILE
echo " encoding: utf8" >> $DBFILE
echo " username: root" >> $DBFILE
echo " password: pass" >> $DBFILE
echo " username: gitlab-runner" >> $DBFILE
echo " password:" >> $DBFILE
fi