From a04df10d11c7bd67197602b27a994ddbb33a38d2 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 3 Jul 2014 17:41:39 -0400 Subject: [PATCH] TW-1267 - TW-1267 If default.project is defined it's not possible to add a task without a project (thanks to Renato Alves). --- ChangeLog | 2 ++ src/Task.cpp | 60 +++++++++++++++++++++++++--------------------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 50ab44278..66223fa63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -71,6 +71,8 @@ - TW-1263 Command Reference Redesign. - TW-1264 Project | Tags assigned ratio of tasks (thanks to Benjamin Weber). - TW-1265 cannot add UDA with underscore (thanks to Jakub Wilk). +- TW-1267 If default.project is defined it's not possible to add a task without + a project (thanks to Renato Alves). - TW-1273 Words in task descriptions and annotations are cut-off after a hyphen (thanks to Elias Probst). - TW-1274 Map 'modification' attribute to 'modified' (thanks to jck). diff --git a/src/Task.cpp b/src/Task.cpp index c8a77e64b..b85d6d1a4 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -1490,37 +1490,34 @@ void Task::validate (bool applyDefault /* = true */) (! has ("end") || get ("end") == "")) setEnd (); - // Override with default.project, if not specified. - if (applyDefault && - Task::defaultProject != "" && - (! has ("project") || get ("project") == "")) - { - if (context.columns["project"]->validate (Task::defaultProject)) - set ("project", Task::defaultProject); - } - - // Override with default.priority, if not specified. - if (applyDefault && - Task::defaultPriority != "" && - (! has ("priority") || get ("priority") == "")) - { - if (context.columns["priority"]->validate (Task::defaultPriority)) - set ("priority", Task::defaultPriority); - } - - // Override with default.due, if not specified. - if (applyDefault && - Task::defaultDue != "" && - (! has ("due") || get ("due") == "")) - { - if (context.columns["due"]->validate (Task::defaultDue)) - set ("due", Date (Task::defaultDue).toEpoch ()); - } - - // If a UDA has a default value in the configuration, - // override with uda.(uda).default, if not specified. if (applyDefault) { + // Override with default.project, if not specified. + if (Task::defaultProject != "" && + ! has ("project")) + { + if (context.columns["project"]->validate (Task::defaultProject)) + set ("project", Task::defaultProject); + } + + // Override with default.priority, if not specified. + if (Task::defaultPriority != "" && + ! has ("priority")) + { + if (context.columns["priority"]->validate (Task::defaultPriority)) + set ("priority", Task::defaultPriority); + } + + // Override with default.due, if not specified. + if (Task::defaultDue != "" && + ! has ("due")) + { + if (context.columns["due"]->validate (Task::defaultDue)) + set ("due", Date (Task::defaultDue).toEpoch ()); + } + + // If a UDA has a default value in the configuration, + // override with uda.(uda).default, if not specified. // Gather a list of all UDAs with a .default value std::vector udas; Config::const_iterator var; @@ -1956,8 +1953,9 @@ void Task::modify (modType type, bool text_required /* = false */) value == "''" || value == "\"\"") { - // Remove attribute if the value is blank. - (*this).remove (name); + // ::composeF4 will skip if the value is blank, but the presence of + // the attribute will prevent ::validate from applying defaults. + set (name, ""); context.debug (label + name + " <-- ''"); ++modCount; }