mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
refactor saved-reports-2.4 migration to eliminate duplicate code and
fix the report template renderer name reference. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17972 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
5456ef6eba
commit
ad7e8d3876
@ -497,6 +497,31 @@
|
|||||||
embedded-reports))
|
embedded-reports))
|
||||||
result-string))
|
result-string))
|
||||||
|
|
||||||
|
(define (gnc:report-generate-saved-forms-string name type templ-name options embedded-options guid)
|
||||||
|
(let ((result (string-append
|
||||||
|
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
|
||||||
|
(simple-format #f ";; Options for saved report ~S, based on template ~S\n"
|
||||||
|
name type)
|
||||||
|
(simple-format
|
||||||
|
#f "(let ()\n (define (options-gen)\n (let ((options (gnc:report-template-new-options/report-guid ~S ~S)))\n"
|
||||||
|
type templ-name)
|
||||||
|
(gnc:generate-restore-forms options "options")
|
||||||
|
(if embedded-options
|
||||||
|
embedded-options
|
||||||
|
"")
|
||||||
|
" options))\n"
|
||||||
|
(simple-format
|
||||||
|
#f " (gnc:define-report \n 'version 1\n 'name ~S\n 'report-guid ~S\n 'parent-type ~S\n 'options-generator options-gen\n 'menu-path (list gnc:menuname-custom)\n 'renderer (gnc:report-template-renderer/report-guid ~S ~S)))\n\n"
|
||||||
|
name
|
||||||
|
(if guid
|
||||||
|
guid
|
||||||
|
(guid-new-return)) ;; when saving a report, we need to create a guid for it for later reloading
|
||||||
|
type
|
||||||
|
type
|
||||||
|
templ-name))))
|
||||||
|
(gnc:debug result)
|
||||||
|
result))
|
||||||
|
|
||||||
(define (gnc:report-generate-saved-forms report)
|
(define (gnc:report-generate-saved-forms report)
|
||||||
;; clean up the options if necessary. this is only needed
|
;; clean up the options if necessary. this is only needed
|
||||||
;; in special cases.
|
;; in special cases.
|
||||||
@ -507,48 +532,23 @@
|
|||||||
(if thunk
|
(if thunk
|
||||||
(thunk report)))
|
(thunk report)))
|
||||||
|
|
||||||
;; save them
|
;; save them
|
||||||
(string-append
|
(let ((name (gnc:report-name report))
|
||||||
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
|
(type (gnc:report-type report))
|
||||||
(simple-format #f ";; Options for saved report ~S, based on template ~S\n"
|
(templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report))))
|
||||||
(gnc:report-name report) (gnc:report-type report))
|
(options (gnc:report-options report))
|
||||||
(simple-format
|
(embedded-options (gnc:report-generate-options-embedded report)))
|
||||||
#f "(let ()\n (define (options-gen)\n (let ((options (gnc:report-template-new-options/report-guid ~S ~S)))\n"
|
(gnc:report-generate-saved-forms-string name type templ-name options embedded-options #f)))
|
||||||
(gnc:report-type report) (gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report))))
|
|
||||||
(gnc:generate-restore-forms (gnc:report-options report) "options")
|
|
||||||
;; get options of embedded reports
|
|
||||||
(gnc:report-generate-options-embedded report)
|
|
||||||
" options))\n"
|
|
||||||
(simple-format
|
|
||||||
#f " (gnc:define-report \n 'version 1\n 'name ~S\n 'report-guid ~S\n 'parent-type ~S\n 'options-generator options-gen\n 'menu-path (list gnc:menuname-custom)\n 'renderer (gnc:report-template-renderer/report-guid ~S ~S)))\n\n"
|
|
||||||
(gnc:report-name report)
|
|
||||||
(guid-new-return) ;; when saving a report, we need to create a guid for it for later reloading
|
|
||||||
(gnc:report-type report) ;;a saved report also needs its type stored separately to reference the template
|
|
||||||
(gnc:report-type report)
|
|
||||||
(gnc:report-template-name (hash-ref *gnc:_report-templates_* (gnc:report-type report))))))
|
|
||||||
|
|
||||||
(define (gnc:report-template-generate-saved-forms report-template)
|
(define (gnc:report-template-generate-saved-forms report-template)
|
||||||
(string-append
|
(let* ((name (gnc:report-template-name report-template))
|
||||||
";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n"
|
(type (gnc:report-template-parent-type report-template))
|
||||||
(simple-format #f ";; Options for saved report ~S, based on template ~S\n"
|
(templ-name (gnc:report-template-name (hash-ref *gnc:_report-templates_* type)))
|
||||||
(gnc:report-template-name report-template) (gnc:report-template-parent-type report-template))
|
(options (gnc:report-template-new-options report-template))
|
||||||
(simple-format
|
(embedded-options #f)
|
||||||
#f "(let ()\n (define (options-gen)\n (let ((options (gnc:report-template-new-options/report-guid ~S ~S)))\n"
|
(guid (gnc:report-template-report-guid report-template))
|
||||||
(gnc:report-template-parent-type report-template) (gnc:report-template-name report-template))
|
)
|
||||||
(gnc:generate-restore-forms (gnc:report-template-new-options report-template) "options")
|
(gnc:report-generate-saved-forms-string name type templ-name options embedded-options guid)))
|
||||||
|
|
||||||
;; get options of embedded reports
|
|
||||||
;; (gnc:report-generate-options-embedded report)
|
|
||||||
;; we really should do this, except the whole embedded report thing is broken
|
|
||||||
|
|
||||||
" options))\n"
|
|
||||||
(simple-format
|
|
||||||
#f " (gnc:define-report \n 'version 1\n 'name ~S\n 'report-guid ~S\n 'parent-type ~S\n 'options-generator options-gen\n 'menu-path (list gnc:menuname-custom)\n 'renderer (gnc:report-template-renderer/report-guid ~S ~S)))\n\n"
|
|
||||||
(gnc:report-template-name report-template)
|
|
||||||
(gnc:report-template-report-guid report-template)
|
|
||||||
(gnc:report-template-parent-type report-template) ;;a saved report also needs its type stored separately to reference the template
|
|
||||||
(gnc:report-template-parent-type report-template)
|
|
||||||
(gnc:report-template-name report-template))))
|
|
||||||
|
|
||||||
(define gnc:current-saved-reports
|
(define gnc:current-saved-reports
|
||||||
(gnc-build-dotgnucash-path "saved-reports-2.4"))
|
(gnc-build-dotgnucash-path "saved-reports-2.4"))
|
||||||
|
Loading…
Reference in New Issue
Block a user