JSON encode/decode string UDAs
Previously, multiline string UDAs were not preserved when editing a task via 'task X edit'. String UDAs are now JSON encoded/decoded during the edit cycle to allow preservation of multiline
This commit is contained in:
committed by
Paul Beckingham
parent
e961181b64
commit
cd62e65a13
@@ -299,7 +299,12 @@ std::string CmdEdit::formatTask (Task task, const std::string& dateformat)
|
|||||||
|
|
||||||
std::string type = Context::getContext ().config.get ("uda." + uda + ".type");
|
std::string type = Context::getContext ().config.get ("uda." + uda + ".type");
|
||||||
if (type == "string" || type == "numeric")
|
if (type == "string" || type == "numeric")
|
||||||
before << " UDA " << uda << ": " << padding << task.get (uda) << '\n';
|
{
|
||||||
|
auto value = task.get (uda);
|
||||||
|
if (type == "string")
|
||||||
|
value = json::encode (value);
|
||||||
|
before << " UDA " << uda << ": " << padding << value << '\n';
|
||||||
|
}
|
||||||
else if (type == "date")
|
else if (type == "date")
|
||||||
before << " UDA " << uda << ": " << padding << formatDate (task, uda, dateformat) << '\n';
|
before << " UDA " << uda << ": " << padding << formatDate (task, uda, dateformat) << '\n';
|
||||||
else if (type == "duration")
|
else if (type == "duration")
|
||||||
@@ -663,6 +668,8 @@ void CmdEdit::parseTask (Task& task, const std::string& after, const std::string
|
|||||||
if (type != "")
|
if (type != "")
|
||||||
{
|
{
|
||||||
auto value = findValue (after, "\n UDA " + col.first + ":");
|
auto value = findValue (after, "\n UDA " + col.first + ":");
|
||||||
|
if (type == "string")
|
||||||
|
value = json::decode (value);
|
||||||
if ((task.get (col.first) != value) && (type != "date" ||
|
if ((task.get (col.first) != value) && (type != "date" ||
|
||||||
(task.get (col.first) != Datetime (value, dateformat).toEpochString ())) &&
|
(task.get (col.first) != Datetime (value, dateformat).toEpochString ())) &&
|
||||||
(type != "duration" ||
|
(type != "duration" ||
|
||||||
|
|||||||
Reference in New Issue
Block a user