]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix displaying of rewrite subject in WebUI
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 19 Jul 2016 17:48:25 +0000 (18:48 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 19 Jul 2016 17:48:25 +0000 (18:48 +0100)
interface/js/rspamd.js

index 6d6a7c5c5460c7fa1d7873bf8372d18f5e1f454a..1aa96e6fab09c6d7c2bc89baf52afe9546a7a305 100644 (file)
                     // Order of sliders greylist -> probable spam -> spam
                     $('#actionsBody').empty();
                     $('#actionsForm').empty();
-                    items = [];
+                    var items = [];
                     var min = 0;
                     var max = Number.MIN_VALUE;
                     $.each(data, function (i, item) {
                             label = 'Greylist';
                             idx = 0;
                         }
+                        else if (item.action === 'rewrite subject') {
+                            label = 'Rewrite subject';
+                            idx = 2;
+                        }
                         else if (item.action === 'reject') {
                             label = 'Spam';
-                            idx = 2;
+                            idx = 3;
                         }
                         if (idx >= 0) {
-                            items[idx] =
-                                '<div class="form-group">' +
+                            items.push({idx: idx,
+                                html: '<div class="form-group">' +
                                     '<label class="control-label col-sm-2">' + label + '</label>' +
                                     '<div class="controls slider-controls col-sm-10">' +
                                     '<input class="slider" type="slider" value="' + item.value + '">' +
                                     '</div>' +
-                                    '</div>';
+                                    '</div>'
+                            });
                         }
                         if (item.value > max) {
                             max = item.value * 2;
                         }
                     });
 
-                    $('#actionsBody').html('<form id="actionsForm">' + items.join('') +
+                    items.sort(function(a, b) { return a.idx - b.idx; });
+
+                    $('#actionsBody').html('<form id="actionsForm">' +
+                        items.map(function(e) { return e.html; }).join('') +
                         '<br><div class="form-group">' +
                         '<button class="btn btn-primary" ' +
                         'type="submit">Save actions</button></div></form>');