"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.
This commit is contained in:
christopherlam 2017-09-11 23:27:04 +08:00
parent 75b5a41eee
commit 53fbc6f62f

View File

@ -51,9 +51,13 @@
(define pagename-sorting (N_ "Sorting")) (define pagename-sorting (N_ "Sorting"))
(define optname-prime-sortkey (N_ "Primary Key")) (define optname-prime-sortkey (N_ "Primary Key"))
(define optname-prime-subtotal (N_ "Primary Subtotal")) (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-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-sortkey (N_ "Secondary Key"))
(define optname-sec-subtotal (N_ "Secondary Subtotal")) (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-sec-date-subtotal (N_ "Secondary Subtotal for Date Key"))
(define optname-void-transactions (N_ "Void Transactions")) (define optname-void-transactions (N_ "Void Transactions"))
(define optname-table-export (N_ "Table for Exporting")) (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 'weekly (N_ "Weekly") (N_ "Weekly."))
(vector 'monthly (N_ "Monthly") (N_ "Monthly.")) (vector 'monthly (N_ "Monthly") (N_ "Monthly."))
(vector 'quarterly (N_ "Quarterly") (N_ "Quarterly.")) (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 ;; primary sorting criterion
(gnc:register-trep-option (gnc:register-trep-option
(gnc:make-multichoice-callback-option (gnc:make-multichoice-callback-option
pagename-sorting optname-prime-sortkey pagename-sorting optname-prime-sortkey
"a" (N_ "Sort by this criterion first.") "a" (N_ "Sort by this criterion first.")
'account-name prime-sortkey
key-choice-list #f key-choice-list #f
(lambda (x) (lambda (x)
(gnc-option-db-set-option-selectable-by-name (set! prime-sortkey x)
options pagename-sorting optname-prime-subtotal (apply-selectable-by-name-sorting-options))))
(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)))))
(gnc:register-trep-option (gnc:register-trep-option
(gnc:make-simple-boolean-option (gnc:make-simple-boolean-option
pagename-sorting (N_ "Show Full Account Name") pagename-sorting optname-full-account-name
"a1" "j1"
(N_ "Show the full account name for subtotals and subtitles?") (N_ "Show the full account name for subtotals and subtitles?")
#f)) #f))
(gnc:register-trep-option (gnc:register-trep-option
(gnc:make-simple-boolean-option (gnc:make-simple-boolean-option
pagename-sorting (N_ "Show Account Code") pagename-sorting optname-show-account-code
"a2" "j2"
(N_ "Show the account code for subtotals and subtitles?") (N_ "Show the account code for subtotals and subtitles?")
#f)) #f))
(gnc:register-trep-option (gnc:register-trep-option
(gnc:make-simple-boolean-option (gnc:make-complex-boolean-option
pagename-sorting optname-prime-subtotal pagename-sorting optname-prime-subtotal
"c" "e5"
(N_ "Subtotal according to the primary key?") (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:register-trep-option
(gnc:make-multichoice-option (gnc:make-multichoice-option
pagename-sorting optname-prime-date-subtotal pagename-sorting optname-prime-date-subtotal
"d" (N_ "Do a date subtotal.") "e2" (N_ "Do a date subtotal.")
'monthly 'monthly
subtotal-choice-list)) subtotal-choice-list))
(gnc:register-trep-option (gnc:register-trep-option
(gnc:make-multichoice-option (gnc:make-multichoice-option
pagename-sorting (N_ "Primary Sort Order") pagename-sorting optname-prime-sortorder
"e" (N_ "Order of primary sorting.") "e" (N_ "Order of primary sorting.")
'ascend 'ascend
ascending-choice-list)) ascending-choice-list))
@ -897,39 +947,65 @@ disable the substring filter. This filter is case-sensitive.")
pagename-sorting optname-sec-sortkey pagename-sorting optname-sec-sortkey
"f" "f"
(N_ "Sort by this criterion second.") (N_ "Sort by this criterion second.")
'register-order sec-sortkey
key-choice-list #f key-choice-list #f
(lambda (x) (lambda (x)
(gnc-option-db-set-option-selectable-by-name (set! sec-sortkey x)
options pagename-sorting optname-sec-subtotal (apply-selectable-by-name-sorting-options))))
(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)))))
(gnc:register-trep-option (gnc:register-trep-option
(gnc:make-simple-boolean-option (gnc:make-complex-boolean-option
pagename-sorting optname-sec-subtotal pagename-sorting optname-sec-subtotal
"g" "i5"
(N_ "Subtotal according to the secondary key?") (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:register-trep-option
(gnc:make-multichoice-option (gnc:make-multichoice-option
pagename-sorting optname-sec-date-subtotal pagename-sorting optname-sec-date-subtotal
"h" (N_ "Do a date subtotal.") "i2" (N_ "Do a date subtotal.")
'monthly 'monthly
subtotal-choice-list)) subtotal-choice-list))
(gnc:register-trep-option (gnc:register-trep-option
(gnc:make-multichoice-option (gnc:make-multichoice-option
pagename-sorting (N_ "Secondary Sort Order") pagename-sorting optname-sec-sortorder
"i" (N_ "Order of Secondary sorting.") "i" (N_ "Order of Secondary sorting.")
'ascend 'ascend
ascending-choice-list))) ascending-choice-list)))
;; Display options ;; 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 (for-each
(lambda (l) (lambda (l)
(gnc:register-trep-option (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_ "Num") "b" (N_ "Display the check number?") #t))
(list (N_ "Description") "c" (N_ "Display the description?") #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_ "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_ "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_ "Account Code") "g" (N_ "Display the account code?") #f)
(list (N_ "Other Account Name") "h1" (N_ "Display the other account name?\ ;; other account name option appears here
(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?") #f)
(list (N_ "Use Full Other Account Name") "i" (N_ "Display the full account name?") #t)
(list (N_ "Other Account Code") "j" (N_ "Display the other account code?") #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_ "Shares") "k" (N_ "Display the number of shares?") #f)
(list (N_ "Price") "l" (N_ "Display the shares price?") #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") gnc:pagename-display (N_ "Memo")
"d" (N_ "Display the memo?") #t "d" (N_ "Display the memo?") #t
#f #f
(lambda (x) (gnc-option-db-set-option-selectable-by-name (lambda (x)
gnc:*transaction-report-options* (set! disp-memo? x)
gnc:pagename-display (apply-selectable-by-name-display-options))))
(N_ "Notes")
x)))) ;; 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:register-trep-option
(gnc:make-multichoice-callback-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."))) (N_ "Display one line per transaction, merging multiple splits where required.")))
#f #f
(lambda (x) (lambda (x)
(let ((is-single? (eq? x 'single))) (set! is-single? (eq? x 'single))
(gnc-option-db-set-option-selectable-by-name (apply-selectable-by-name-display-options))))
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?)))))
(gnc:register-trep-option (gnc:register-trep-option
(gnc:make-multichoice-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.")) (N_ "Reverse amount display for Income and Expense Accounts."))
(vector 'credit-accounts (N_ "Credit Accounts") (vector 'credit-accounts (N_ "Credit Accounts")
(N_ "Reverse amount display for Liability, Payable, Equity, \ (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* (gnc:options-set-default-section gnc:*transaction-report-options*