Taskjuggler: Add valid project attributes

* ox-taskjuggler.el (org-taskjuggler--build-project): Insert all
   valid attributes from project.

* ox-taskjuggler.el (org-taskjuggler--build-attributes): Add project
  as possible ITEM to docstring.

* ox-taskjuggler.el (org-taskjuggler-valid-project-attributes): New
  defcustom.

As reported by Nick Garber, project attributes like 'timingresolution'
could not be changed via Org-mode properties. This patch makes the
exporter treat project-attributes just like it treats task-, resource-
and report-attributes.
This commit is contained in:
tj@data-driven.de 2014-06-25 16:27:42 +02:00 committed by Bastien Guerry
parent 2aec9fddd4
commit feb048de3f
1 changed files with 37 additions and 15 deletions
contrib/lisp

View File

@ -310,6 +310,19 @@ If one of these appears as a property for a headline, it will be
exported with the corresponding task." exported with the corresponding task."
:group 'org-export-taskjuggler) :group 'org-export-taskjuggler)
(defcustom org-taskjuggler-valid-project-attributes
'(timingresolution timezone alertlevels currency currencyformat
dailyworkinghours extend includejournalentry now numberformat
outputdir scenario shorttimeformat timeformat trackingscenario
weekstartsmonday weekstartssunday workinghours
yearlyworkingdays)
"Valid attributes for Taskjuggler project.
If one of these appears as a property for a headline that is a
project definition, it will be exported with the corresponding
task. Attribute 'timingresolution' should be the first in the
list."
:group 'org-export-taskjuggler)
(defcustom org-taskjuggler-valid-resource-attributes (defcustom org-taskjuggler-valid-resource-attributes
'(limits vacation shift booking efficiency journalentry rate '(limits vacation shift booking efficiency journalentry rate
workinghours flags) workinghours flags)
@ -483,9 +496,9 @@ Return new string. If S is the empty string, return it."
(if (equal "" s) s (replace-regexp-in-string "^ *\\S-" " \\&" s))) (if (equal "" s) s (replace-regexp-in-string "^ *\\S-" " \\&" s)))
(defun org-taskjuggler--build-attributes (item attributes) (defun org-taskjuggler--build-attributes (item attributes)
"Return attributes string for task, resource or report ITEM. "Return attributes string for ITEM.
ITEM is a headline. ATTRIBUTES is a list of symbols ITEM is a project, task, resource or report headline. ATTRIBUTES
representing valid attributes for ITEM." is a list of symbols representing valid attributes for ITEM."
(mapconcat (mapconcat
(lambda (attribute) (lambda (attribute)
(let ((value (org-element-property (let ((value (org-element-property
@ -715,7 +728,9 @@ PROJECT is a headline. INFO is a plist used as a communication
channel. If no start date is specified, start today. If no end channel. If no start date is specified, start today. If no end
date is specified, end `org-taskjuggler-default-project-duration' date is specified, end `org-taskjuggler-default-project-duration'
days from now." days from now."
(format "project %s \"%s\" \"%s\" %s %s {\n}\n" (concat
;; Opening project.
(format "project %s \"%s\" \"%s\" %s %s {\n"
(org-taskjuggler-get-id project info) (org-taskjuggler-get-id project info)
(org-taskjuggler-get-name project) (org-taskjuggler-get-name project)
;; Version is obtained through :TASKJUGGLER_VERSION: ;; Version is obtained through :TASKJUGGLER_VERSION:
@ -726,7 +741,14 @@ days from now."
(format-time-string "%Y-%m-%d")) (format-time-string "%Y-%m-%d"))
(let ((end (org-taskjuggler-get-end project))) (let ((end (org-taskjuggler-get-end project)))
(or (and end (format "- %s" end)) (or (and end (format "- %s" end))
(format "+%sd" org-taskjuggler-default-project-duration))))) (format "+%sd"
org-taskjuggler-default-project-duration))))
;; Add attributes.
(org-taskjuggler--indent-string
(org-taskjuggler--build-attributes
project org-taskjuggler-valid-project-attributes))
;; Closing project.
"}\n"))
(defun org-taskjuggler--build-resource (resource info) (defun org-taskjuggler--build-resource (resource info)
"Return a resource declaration. "Return a resource declaration.