Browse Source

Fixed issue #1923 - Pulldowns are not sorted currently.

Martin Edenhofer 7 years ago
parent
commit
7e91e3ca4a

+ 4 - 4
app/assets/javascripts/app/controllers/_ui_element/_application_ui_element.coffee

@@ -6,7 +6,7 @@ class App.UiElement.ApplicationUiElement
     # skip sorting if it is disabled by config
     return if attribute.sortBy == null
 
-    return if !attribute.options
+    return if _.isEmpty(attribute.options)
 
     # arrays can only get ordered
     if _.isArray(attribute.options)
@@ -43,7 +43,7 @@ class App.UiElement.ApplicationUiElement
       attribute.options[''] = '-'
 
   @getConfigOptionList: (attribute) ->
-    return if !attribute.options
+    return if _.isEmpty(attribute.options)
     selection = attribute.options
     attribute.options = []
     if _.isArray(selection)
@@ -69,7 +69,7 @@ class App.UiElement.ApplicationUiElement
   @getRelationOptionList: (attribute, params) ->
 
     # build options list based on relation
-    return if !attribute.relation
+    return if _.isEmpty(attribute.relation)
     return if !App[attribute.relation]
 
     attribute.options = []
@@ -175,7 +175,7 @@ class App.UiElement.ApplicationUiElement
   # execute filter
   @filterOption: (attribute) ->
     return if !attribute.filter
-    return if !attribute.options
+    return if _.isEmpty(attribute.options)
 
     return if typeof attribute.filter isnt 'function'
     App.Log.debug 'ControllerForm', '_filterOption:filter-function'

+ 10 - 9
public/assets/tests/form_extended.js

@@ -2,14 +2,8 @@
 // form
 test('form checks', function() {
 
+  // use unsorted order to check if the frontend is sorting correctly
   App.TicketPriority.refresh([
-    {
-      id:         1,
-      name:       '1 low',
-      note:       'some note 1',
-      active:     true,
-      created_at: '2014-06-10T11:17:34.000Z',
-    },
     {
       id:         2,
       name:       '2 normal',
@@ -38,6 +32,13 @@ test('form checks', function() {
       active:     false,
       created_at: '2014-06-10T10:17:56.000Z',
     },
+    {
+      id:         1,
+      name:       '1 low',
+      note:       'some note 1',
+      active:     true,
+      created_at: '2014-06-10T11:17:34.000Z',
+    },
   ])
 
   App.TicketState.refresh([
@@ -145,8 +146,8 @@ test('form checks', function() {
     el:        el,
     model:     {
       configure_attributes: [
-        { name: 'priority1_id', display: 'Priroity1', tag: 'select', relation: 'TicketPriority', null: true },
-        { name: 'priority2_id', display: 'Priroity2', tag: 'select', multiple: true, relation: 'TicketPriority', null: true },
+        { name: 'priority1_id', display: 'Priroity1', tag: 'select', relation: 'TicketPriority', null: true, options: {} },
+        { name: 'priority2_id', display: 'Priroity2', tag: 'select', multiple: true, relation: 'TicketPriority', null: true, options: {} },
         { name: 'priority3_id', display: 'Priroity3', tag: 'select', relation: 'TicketPriority', null: true },
         { name: 'escalation_times', display: 'Times', tag: 'sla_times', null: true },
         { name: 'working_hours',    display: 'Hours', tag: 'business_hours', null: true },