changeset 6416:99d344aa825d

- issue2550648 - keyword boolean search multiple issues Fix issue where saving the keyword boolean search would remove the link to open the editor. Note that re-opening the editor starts with a blank operation. It does not inherit the existing expression.
author John Rouillard <rouilj@ieee.org>
date Wed, 19 May 2021 20:41:58 -0400
parents dbacf6bf2a2f
children 586865e08f42
files CHANGES.txt roundup/cgi/KeywordsExpr.py
diffstat 2 files changed, 31 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGES.txt	Tue May 18 08:50:46 2021 +0200
+++ b/CHANGES.txt	Wed May 19 20:41:58 2021 -0400
@@ -103,6 +103,9 @@
   if the given property is unset for an element of the list. Crash
   fixed. New feature NoneFirst added to method to make unset values
   sort at start or end of sorted list. (John Rouillard)
+- issue2550648 - keyword boolean search. Issue has multiple problems.
+  Fix issue where saving the keyword boolean search would remove the
+  link to open the editor.
 
 Features:
 - issue2550522 - Add 'filter' command to command-line
--- a/roundup/cgi/KeywordsExpr.py	Tue May 18 08:50:46 2021 +0200
+++ b/roundup/cgi/KeywordsExpr.py	Wed May 19 20:41:58 2021 -0400
@@ -1,7 +1,7 @@
 # This module is free software, you may redistribute it
 # and/or modify under the same terms as Python.
 
-WINDOW_CONTENT = r'''\
+WINDOW_CONTENT = r'''
 <h3>Keyword Expression Editor:</h3>
 <hr/>
 <div id="content"></div>
@@ -220,16 +220,39 @@
     return out;
 }
 
-function main_content() {
+function main_display() {
+    var out = '';
+    out += '<span id="display_%(prop)s">' + parse(current).infix() + '<\/span>';
+    return out;
+}
+
+function main_input() {
     var out = '';
     out += '<input type="hidden" name="%(prop)s" value="' + current + '"\/>';
-    out += parse(current).infix();
     return out;
 }
 
 function modify_main() {
-    main = window.opener.document.getElementById("keywords_%(prop)s");
-    main.innerHTML = main_content();
+    /* if display form of expression exists, overwrite */
+    display = window.opener.document.getElementById('display_%(prop)s');
+    if ( display ) {
+      display.outerHTML = main_display();
+    }
+
+    /* overwrite select if present, otherwise overwrite the hidden input */
+    input = window.opener.document.querySelector('select[name="%(prop)s"]');
+    if (! input) {
+       input = window.opener.document.querySelector('input[name="%(prop)s"]');
+    }
+
+    /* if display exists, only update hidden input. If display doesn't
+       exist, inject both hidden input and display. */
+    if ( display ) {
+       content = main_input();
+    } else {
+       content = main_input() + main_display();
+    }
+    input.outerHTML = content;
 }
 
 function set_content() {

Roundup Issue Tracker: http://roundup-tracker.org/