gnucash master: "Sorting" tab overhaul to improve UI

Geert Janssens gjanssens at code.gnucash.org
Sat Sep 16 04:19:38 EDT 2017


Updated	 via  https://github.com/Gnucash/gnucash/commit/53fbc6f6 (commit)
	from  https://github.com/Gnucash/gnucash/commit/75b5a41e (commit)



commit 53fbc6f62fe1037da31e512e915bba15249ab6fc
Author: christopherlam <christopher.lck at gmail.com>
Date:   Mon Sep 11 23:27:04 2017 +0800

    "Sorting" tab overhaul to improve UI
    
    This change will ensure the Sorting tab only presents *valid* options. e.g.
    Changing Primary Sortkey to 'none will disable its descendant options.
    Changing to 'Date will enable Date-interval choice.
    Changing to 'Account-name will enable relevant account-name options.
    Usability fix. This should help newcomers.

diff --git a/gnucash/report/standard-reports/transaction.scm b/gnucash/report/standard-reports/transaction.scm
index 80fd782..4fbab7d 100644
--- a/gnucash/report/standard-reports/transaction.scm
+++ b/gnucash/report/standard-reports/transaction.scm
@@ -51,9 +51,13 @@
 (define pagename-sorting (N_ "Sorting"))
 (define optname-prime-sortkey (N_ "Primary Key"))
 (define optname-prime-subtotal (N_ "Primary Subtotal"))
+(define optname-prime-sortorder (N_ "Primary Sort Order"))
 (define optname-prime-date-subtotal (N_ "Primary Subtotal for Date Key"))
+(define optname-full-account-name (N_ "Show Full Account Name"))
+(define optname-show-account-code (N_ "Show Account Code"))
 (define optname-sec-sortkey (N_ "Secondary Key"))
 (define optname-sec-subtotal (N_ "Secondary Subtotal"))
+(define optname-sec-sortorder  (N_ "Secondary Sort Order"))
 (define optname-sec-date-subtotal (N_ "Secondary Subtotal for Date Key"))
 (define optname-void-transactions (N_ "Void Transactions"))
 (define optname-table-export (N_ "Table for Exporting"))
@@ -839,54 +843,100 @@ disable the substring filter. This filter is case-sensitive.")
           (vector 'weekly (N_ "Weekly") (N_ "Weekly."))
           (vector 'monthly (N_ "Monthly") (N_ "Monthly."))
           (vector 'quarterly (N_ "Quarterly") (N_ "Quarterly."))
-          (vector 'yearly (N_ "Yearly") (N_ "Yearly.")))))
-    
+          (vector 'yearly (N_ "Yearly") (N_ "Yearly."))))
+
+        (prime-sortkey 'account-name)
+        (prime-sortkey-subtotal-true #t)
+        (sec-sortkey 'register-order)
+        (sec-sortkey-subtotal-true #f))
+
+    (define (apply-selectable-by-name-sorting-options)
+      (let* ((prime-sortkey-enabled (not (eq? prime-sortkey 'none)))
+             (prime-sortkey-subtotal-enabled (member prime-sortkey subtotal-enabled))
+             (prime-date-sortingtype-enabled (member prime-sortkey date-sorting-types))
+             (sec-sortkey-enabled (not (eq? sec-sortkey 'none)))
+             (sec-sortkey-subtotal-enabled (member sec-sortkey subtotal-enabled))
+             (sec-date-sortingtype-enabled (member sec-sortkey date-sorting-types)))
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-prime-subtotal
+         prime-sortkey-subtotal-enabled)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-prime-sortorder
+         prime-sortkey-enabled)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-sec-subtotal
+         sec-sortkey-subtotal-enabled)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-sec-sortorder
+         sec-sortkey-enabled)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-full-account-name
+         (or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
+             (and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)))
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-show-account-code
+         (or (and prime-sortkey-subtotal-enabled prime-sortkey-subtotal-true)
+             (and sec-sortkey-subtotal-enabled sec-sortkey-subtotal-true)))
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-prime-date-subtotal
+         prime-date-sortingtype-enabled)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options pagename-sorting optname-sec-date-subtotal
+         sec-date-sortingtype-enabled)))
+
     ;; primary sorting criterion
     (gnc:register-trep-option
      (gnc:make-multichoice-callback-option
       pagename-sorting optname-prime-sortkey
       "a" (N_ "Sort by this criterion first.")
-      'account-name
+      prime-sortkey
       key-choice-list #f
       (lambda (x)
-        (gnc-option-db-set-option-selectable-by-name
-         options pagename-sorting optname-prime-subtotal
-         (and (member x subtotal-enabled) #t))
-        (gnc-option-db-set-option-selectable-by-name
-         options pagename-sorting optname-prime-date-subtotal
-         (if (member x date-sorting-types) #t #f)))))
+        (set! prime-sortkey x)
+        (apply-selectable-by-name-sorting-options))))
     
     (gnc:register-trep-option
      (gnc:make-simple-boolean-option
-      pagename-sorting (N_ "Show Full Account Name")
-      "a1" 
+      pagename-sorting optname-full-account-name
+      "j1"
       (N_ "Show the full account name for subtotals and subtitles?")
       #f))
     
     (gnc:register-trep-option
      (gnc:make-simple-boolean-option
-      pagename-sorting (N_ "Show Account Code")
-      "a2" 
+      pagename-sorting optname-show-account-code
+      "j2"
       (N_ "Show the account code for subtotals and subtitles?")
       #f))
     
     (gnc:register-trep-option
-     (gnc:make-simple-boolean-option
+     (gnc:make-complex-boolean-option
       pagename-sorting optname-prime-subtotal
-      "c" 
+      "e5"
       (N_ "Subtotal according to the primary key?")
-      #t))
-    
+      prime-sortkey-subtotal-true #f
+      (lambda (x)
+        (set! prime-sortkey-subtotal-true x)
+        (apply-selectable-by-name-sorting-options))))
+
     (gnc:register-trep-option
      (gnc:make-multichoice-option
       pagename-sorting optname-prime-date-subtotal
-      "d" (N_ "Do a date subtotal.")
+      "e2" (N_ "Do a date subtotal.")
       'monthly
       subtotal-choice-list))
     
     (gnc:register-trep-option
      (gnc:make-multichoice-option
-      pagename-sorting (N_ "Primary Sort Order")
+      pagename-sorting optname-prime-sortorder
       "e" (N_ "Order of primary sorting.")
       'ascend
       ascending-choice-list))
@@ -897,39 +947,65 @@ disable the substring filter. This filter is case-sensitive.")
       pagename-sorting optname-sec-sortkey
       "f"
       (N_ "Sort by this criterion second.")
-      'register-order
+      sec-sortkey
       key-choice-list #f
       (lambda (x)
-        (gnc-option-db-set-option-selectable-by-name
-         options pagename-sorting optname-sec-subtotal
-         (and (member x subtotal-enabled) #t))
-        (gnc-option-db-set-option-selectable-by-name
-         options pagename-sorting optname-sec-date-subtotal
-         (if (member x date-sorting-types) #t #f)))))
-    
+        (set! sec-sortkey x)
+        (apply-selectable-by-name-sorting-options))))
+
     (gnc:register-trep-option
-     (gnc:make-simple-boolean-option
+     (gnc:make-complex-boolean-option
       pagename-sorting optname-sec-subtotal
-      "g" 
+      "i5"
       (N_ "Subtotal according to the secondary key?")
-      #t))
-    
+      sec-sortkey-subtotal-true #f
+      (lambda (x)
+        (set! sec-sortkey-subtotal-true x)
+        (apply-selectable-by-name-sorting-options))))
+
     (gnc:register-trep-option
      (gnc:make-multichoice-option
       pagename-sorting optname-sec-date-subtotal
-      "h" (N_ "Do a date subtotal.")
+      "i2" (N_ "Do a date subtotal.")
       'monthly
       subtotal-choice-list))
     
     (gnc:register-trep-option
      (gnc:make-multichoice-option
-      pagename-sorting (N_ "Secondary Sort Order")
+      pagename-sorting optname-sec-sortorder
       "i" (N_ "Order of Secondary sorting.")
       'ascend
       ascending-choice-list)))
   
   ;; Display options
   
+    (let ((options gnc:*transaction-report-options*)
+          (disp-memo? #t)
+          (disp-accname? #t)
+          (disp-other-accname? #f)
+          (is-single? #t))
+
+      (define (apply-selectable-by-name-display-options)
+        (gnc-option-db-set-option-selectable-by-name
+         options gnc:pagename-display (N_ "Use Full Account Name")
+         disp-accname?)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options gnc:pagename-display (N_ "Other Account Name")
+         is-single?)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options gnc:pagename-display (N_ "Use Full Other Account Name")
+         (and disp-other-accname? is-single?))
+
+        (gnc-option-db-set-option-selectable-by-name
+         options gnc:pagename-display (N_ "Other Account Code")
+         is-single?)
+
+        (gnc-option-db-set-option-selectable-by-name
+         options gnc:pagename-display (N_ "Notes")
+         disp-memo?))
+
   (for-each
    (lambda (l)
      (gnc:register-trep-option
@@ -945,12 +1021,11 @@ disable the substring filter. This filter is case-sensitive.")
         (list (N_ "Num")                      "b"  (N_ "Display the check number?") #t))
     (list (N_ "Description")                  "c"  (N_ "Display the description?") #t)
     (list (N_ "Notes")                        "d2" (N_ "Display the notes if the memo is unavailable?") #t)
-    (list (N_ "Account Name")                 "e"  (N_ "Display the account name?") #f)
+    ;; account name option appears here
     (list (N_ "Use Full Account Name")        "f"  (N_ "Display the full account name?") #t)
     (list (N_ "Account Code")                 "g"  (N_ "Display the account code?") #f)
-    (list (N_ "Other Account Name")           "h1" (N_ "Display the other account name?\
- (if this is a split transaction, this parameter is guessed).") #f)
-    (list (N_ "Use Full Other Account Name")  "i"  (N_ "Display the full account name?") #t)
+    ;; other account name option appears here
+    (list (N_ "Use Full Other Account Name")  "i"  (N_ "Display the full account name?") #f)
     (list (N_ "Other Account Code")           "j"  (N_ "Display the other account code?") #f)
     (list (N_ "Shares")                       "k"  (N_ "Display the number of shares?") #f)
     (list (N_ "Price")                        "l"  (N_ "Display the shares price?") #f)
@@ -971,11 +1046,29 @@ disable the substring filter. This filter is case-sensitive.")
     gnc:pagename-display (N_ "Memo")
     "d"  (N_ "Display the memo?") #t
     #f
-    (lambda (x) (gnc-option-db-set-option-selectable-by-name
-		 gnc:*transaction-report-options*
-		 gnc:pagename-display
-		 (N_ "Notes")
-		 x))))
+    (lambda (x)
+        (set! disp-memo? x)
+        (apply-selectable-by-name-display-options))))
+
+  ;; Ditto for Account Name #t -> Use Full Account Name is selectable
+  (gnc:register-trep-option
+   (gnc:make-complex-boolean-option
+    gnc:pagename-display (N_ "Account Name")
+    "e"  (N_ "Display the account name?") #t
+    #f
+    (lambda (x)
+        (set! disp-accname? x)
+        (apply-selectable-by-name-display-options))))
+
+  ;; Ditto for Other Account Name #t -> Use Full Other Account Name is selectable
+  (gnc:register-trep-option
+   (gnc:make-complex-boolean-option
+    gnc:pagename-display (N_ "Other Account Name")
+    "h5"  (N_ "Display the other account name? (if this is a split transaction, this parameter is guessed).") #f
+    #f
+    (lambda (x)
+        (set! disp-other-accname? x)
+        (apply-selectable-by-name-display-options))))
 
   (gnc:register-trep-option
    (gnc:make-multichoice-callback-option
@@ -990,17 +1083,8 @@ disable the substring filter. This filter is case-sensitive.")
                   (N_ "Display one line per transaction, merging multiple splits where required.")))
     #f
     (lambda (x)
-      (let ((is-single? (eq? x 'single)))
-           (gnc-option-db-set-option-selectable-by-name
-                gnc:*transaction-report-options*
-                gnc:pagename-display (N_ "Other Account Name") is-single?)
-           (gnc-option-db-set-option-selectable-by-name
-                gnc:*transaction-report-options*
-                gnc:pagename-display (N_ "Use Full Other Account Name") is-single?)
-           (gnc-option-db-set-option-selectable-by-name
-                gnc:*transaction-report-options*
-                gnc:pagename-display (N_ "Other Account Code") is-single?)))))
-
+        (set! is-single? (eq? x 'single))
+        (apply-selectable-by-name-display-options))))
 
   (gnc:register-trep-option
    (gnc:make-multichoice-option
@@ -1023,7 +1107,7 @@ disable the substring filter. This filter is case-sensitive.")
              (N_ "Reverse amount display for Income and Expense Accounts."))
      (vector 'credit-accounts (N_ "Credit Accounts")
              (N_ "Reverse amount display for Liability, Payable, Equity, \
-Credit Card, and Income accounts.")))))
+Credit Card, and Income accounts."))))))
 
 
   (gnc:options-set-default-section gnc:*transaction-report-options*



Summary of changes:
 gnucash/report/standard-reports/transaction.scm | 192 +++++++++++++++++-------
 1 file changed, 138 insertions(+), 54 deletions(-)



More information about the gnucash-changes mailing list