mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Custom Report Labels
- Added the ability to override the labels of custom reports (thanks to T. Charles Yun).
This commit is contained in:
parent
93ec320555
commit
41b60f88d3
5 changed files with 46 additions and 13 deletions
|
@ -20,6 +20,8 @@
|
||||||
frequency, a due date, and an optional until date.
|
frequency, a due date, and an optional until date.
|
||||||
+ When a recurring task is modified, all other instances of the recurring
|
+ When a recurring task is modified, all other instances of the recurring
|
||||||
task are also modified.
|
task are also modified.
|
||||||
|
+ Custom reports now support user-specified column labels (thanks to T.
|
||||||
|
Charles Yun).
|
||||||
|
|
||||||
------ old releases ------------------------------
|
------ old releases ------------------------------
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,18 @@ report.mine.sort=priority-,project+</pre></code>
|
||||||
in a report:
|
in a report:
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
It is also possible to override the default columns names, if
|
||||||
|
the following line is added to your .taskrc file:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<pre><code>report.mine.labels=ID,Project,Priority,Description of task</code></pre>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Note that there must be the same number of labels as there are
|
||||||
|
columns to label, and they must appear in the same sequence.
|
||||||
|
</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>id
|
<li>id
|
||||||
<li>uuid
|
<li>uuid
|
||||||
|
|
|
@ -117,6 +117,8 @@
|
||||||
frequency, a due date, and an optional until date.
|
frequency, a due date, and an optional until date.
|
||||||
<li>When a recurring task is modified, all other instances of the recurring
|
<li>When a recurring task is modified, all other instances of the recurring
|
||||||
task are also modified.
|
task are also modified.
|
||||||
|
<li>Custom reports now support user-specified column labels (thanks to T.
|
||||||
|
Charles Yun).
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -46,23 +46,28 @@ Config::Config ()
|
||||||
{
|
{
|
||||||
(*this)["report.long.description"] = "Lists all task, all data, matching the specified criteria";
|
(*this)["report.long.description"] = "Lists all task, all data, matching the specified criteria";
|
||||||
(*this)["report.long.columns"] = "id,project,priority,entry,start,due,recur,age,tags,description";
|
(*this)["report.long.columns"] = "id,project,priority,entry,start,due,recur,age,tags,description";
|
||||||
|
(*this)["report.long.labels"] = "ID,Project,Pri,Added,Started,Due,Recur,Age,Tags,Description";
|
||||||
(*this)["report.long.sort"] = "due+,priority-,project+";
|
(*this)["report.long.sort"] = "due+,priority-,project+";
|
||||||
|
|
||||||
(*this)["report.list.description"] = "Lists all tasks matching the specified criteria";
|
(*this)["report.list.description"] = "Lists all tasks matching the specified criteria";
|
||||||
(*this)["report.list.columns"] = "id,project,priority,due,active,age,description";
|
(*this)["report.list.columns"] = "id,project,priority,due,active,age,description";
|
||||||
|
(*this)["report.list.labels"] = "ID,Project,Pri,Due,Active,Age,Description";
|
||||||
(*this)["report.list.sort"] = "due+,priority-,project+";
|
(*this)["report.list.sort"] = "due+,priority-,project+";
|
||||||
|
|
||||||
(*this)["report.ls.description"] = "Minimal listing of all tasks matching the specified criteria";
|
(*this)["report.ls.description"] = "Minimal listing of all tasks matching the specified criteria";
|
||||||
(*this)["report.ls.columns"] = "id,project,priority,description";
|
(*this)["report.ls.columns"] = "id,project,priority,description";
|
||||||
|
(*this)["report.ls.labels"] = "ID,Project,Pri,Description";
|
||||||
(*this)["report.ls.sort"] = "priority-,project+";
|
(*this)["report.ls.sort"] = "priority-,project+";
|
||||||
|
|
||||||
(*this)["report.newest.description"] = "Shows the newest tasks";
|
(*this)["report.newest.description"] = "Shows the newest tasks";
|
||||||
(*this)["report.newest.columns"] = "id,project,priority,due,active,age,description";
|
(*this)["report.newest.columns"] = "id,project,priority,due,active,age,description";
|
||||||
|
(*this)["report.newest.labels"] = "ID,Project,Pri,Due,Active,Age,Description";
|
||||||
(*this)["report.newest.sort"] = "id-";
|
(*this)["report.newest.sort"] = "id-";
|
||||||
(*this)["report.newest.limit"] = "10";
|
(*this)["report.newest.limit"] = "10";
|
||||||
|
|
||||||
(*this)["report.oldest.description"] = "Shows the oldest tasks";
|
(*this)["report.oldest.description"] = "Shows the oldest tasks";
|
||||||
(*this)["report.oldest.columns"] = "id,project,priority,due,active,age,description";
|
(*this)["report.oldest.columns"] = "id,project,priority,due,active,age,description";
|
||||||
|
(*this)["report.oldest.labels"] = "ID,Project,Pri,Due,Active,Age,Description";
|
||||||
(*this)["report.oldest.sort"] = "id+";
|
(*this)["report.oldest.sort"] = "id+";
|
||||||
(*this)["report.oldest.limit"] = "10";
|
(*this)["report.oldest.limit"] = "10";
|
||||||
}
|
}
|
||||||
|
|
|
@ -2040,6 +2040,18 @@ std::string handleCustomReport (
|
||||||
split (columns, columnList, ',');
|
split (columns, columnList, ',');
|
||||||
validReportColumns (columns);
|
validReportColumns (columns);
|
||||||
|
|
||||||
|
std::string labelList = conf.get ("report." + report + ".labels");
|
||||||
|
std::vector <std::string> labels;
|
||||||
|
split (labels, labelList, ',');
|
||||||
|
|
||||||
|
if (columns.size () != labels.size ())
|
||||||
|
throw std::string ("There are a different number of columns than labels ") +
|
||||||
|
"for report '" + report + "'. Please correct this.";
|
||||||
|
|
||||||
|
std::map <std::string, std::string> columnLabels;
|
||||||
|
for (unsigned int i = 0; i < columns.size (); ++i)
|
||||||
|
columnLabels[columns[i]] = labels[i];
|
||||||
|
|
||||||
std::string sortList = conf.get ("report." + report + ".sort");
|
std::string sortList = conf.get ("report." + report + ".sort");
|
||||||
std::vector <std::string> sortOrder;
|
std::vector <std::string> sortOrder;
|
||||||
split (sortOrder, sortList, ',');
|
split (sortOrder, sortList, ',');
|
||||||
|
@ -2081,7 +2093,7 @@ std::string handleCustomReport (
|
||||||
// Add each column individually.
|
// Add each column individually.
|
||||||
if (*col == "id")
|
if (*col == "id")
|
||||||
{
|
{
|
||||||
table.addColumn ("ID");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "ID");
|
||||||
table.setColumnWidth (columnCount, Table::minimum);
|
table.setColumnWidth (columnCount, Table::minimum);
|
||||||
table.setColumnJustification (columnCount, Table::right);
|
table.setColumnJustification (columnCount, Table::right);
|
||||||
|
|
||||||
|
@ -2091,7 +2103,7 @@ std::string handleCustomReport (
|
||||||
|
|
||||||
else if (*col == "uuid")
|
else if (*col == "uuid")
|
||||||
{
|
{
|
||||||
table.addColumn ("UUID");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "UUID");
|
||||||
table.setColumnWidth (columnCount, Table::minimum);
|
table.setColumnWidth (columnCount, Table::minimum);
|
||||||
table.setColumnJustification (columnCount, Table::left);
|
table.setColumnJustification (columnCount, Table::left);
|
||||||
|
|
||||||
|
@ -2101,7 +2113,7 @@ std::string handleCustomReport (
|
||||||
|
|
||||||
else if (*col == "project")
|
else if (*col == "project")
|
||||||
{
|
{
|
||||||
table.addColumn ("Project");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Project");
|
||||||
table.setColumnWidth (columnCount, Table::minimum);
|
table.setColumnWidth (columnCount, Table::minimum);
|
||||||
table.setColumnJustification (columnCount, Table::left);
|
table.setColumnJustification (columnCount, Table::left);
|
||||||
|
|
||||||
|
@ -2111,7 +2123,7 @@ std::string handleCustomReport (
|
||||||
|
|
||||||
else if (*col == "priority")
|
else if (*col == "priority")
|
||||||
{
|
{
|
||||||
table.addColumn ("Pri");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Pri");
|
||||||
table.setColumnWidth (columnCount, Table::minimum);
|
table.setColumnWidth (columnCount, Table::minimum);
|
||||||
table.setColumnJustification (columnCount, Table::left);
|
table.setColumnJustification (columnCount, Table::left);
|
||||||
|
|
||||||
|
@ -2121,7 +2133,7 @@ std::string handleCustomReport (
|
||||||
|
|
||||||
else if (*col == "entry")
|
else if (*col == "entry")
|
||||||
{
|
{
|
||||||
table.addColumn ("Added");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Added");
|
||||||
table.setColumnWidth (columnCount, Table::minimum);
|
table.setColumnWidth (columnCount, Table::minimum);
|
||||||
table.setColumnJustification (columnCount, Table::right);
|
table.setColumnJustification (columnCount, Table::right);
|
||||||
|
|
||||||
|
@ -2140,7 +2152,7 @@ std::string handleCustomReport (
|
||||||
|
|
||||||
else if (*col == "start")
|
else if (*col == "start")
|
||||||
{
|
{
|
||||||
table.addColumn ("Started");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Started");
|
||||||
table.setColumnWidth (columnCount, Table::minimum);
|
table.setColumnWidth (columnCount, Table::minimum);
|
||||||
table.setColumnJustification (columnCount, Table::right);
|
table.setColumnJustification (columnCount, Table::right);
|
||||||
|
|
||||||
|
@ -2159,7 +2171,7 @@ std::string handleCustomReport (
|
||||||
|
|
||||||
else if (*col == "due")
|
else if (*col == "due")
|
||||||
{
|
{
|
||||||
table.addColumn ("Due");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Due");
|
||||||
table.setColumnWidth (columnCount, Table::minimum);
|
table.setColumnWidth (columnCount, Table::minimum);
|
||||||
table.setColumnJustification (columnCount, Table::right);
|
table.setColumnJustification (columnCount, Table::right);
|
||||||
|
|
||||||
|
@ -2180,7 +2192,7 @@ std::string handleCustomReport (
|
||||||
|
|
||||||
else if (*col == "age")
|
else if (*col == "age")
|
||||||
{
|
{
|
||||||
table.addColumn ("Age");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Age");
|
||||||
table.setColumnWidth (columnCount, Table::minimum);
|
table.setColumnWidth (columnCount, Table::minimum);
|
||||||
table.setColumnJustification (columnCount, Table::right);
|
table.setColumnJustification (columnCount, Table::right);
|
||||||
|
|
||||||
|
@ -2201,7 +2213,7 @@ std::string handleCustomReport (
|
||||||
|
|
||||||
else if (*col == "active")
|
else if (*col == "active")
|
||||||
{
|
{
|
||||||
table.addColumn ("Active");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Active");
|
||||||
table.setColumnWidth (columnCount, Table::minimum);
|
table.setColumnWidth (columnCount, Table::minimum);
|
||||||
table.setColumnJustification (columnCount, Table::left);
|
table.setColumnJustification (columnCount, Table::left);
|
||||||
|
|
||||||
|
@ -2212,7 +2224,7 @@ std::string handleCustomReport (
|
||||||
|
|
||||||
else if (*col == "tags")
|
else if (*col == "tags")
|
||||||
{
|
{
|
||||||
table.addColumn ("Tags");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Tags");
|
||||||
table.setColumnWidth (columnCount, Table::minimum);
|
table.setColumnWidth (columnCount, Table::minimum);
|
||||||
table.setColumnJustification (columnCount, Table::left);
|
table.setColumnJustification (columnCount, Table::left);
|
||||||
|
|
||||||
|
@ -2228,7 +2240,7 @@ std::string handleCustomReport (
|
||||||
|
|
||||||
else if (*col == "description_only")
|
else if (*col == "description_only")
|
||||||
{
|
{
|
||||||
table.addColumn ("Description");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Description");
|
||||||
table.setColumnWidth (columnCount, Table::flexible);
|
table.setColumnWidth (columnCount, Table::flexible);
|
||||||
table.setColumnJustification (columnCount, Table::left);
|
table.setColumnJustification (columnCount, Table::left);
|
||||||
|
|
||||||
|
@ -2238,7 +2250,7 @@ std::string handleCustomReport (
|
||||||
|
|
||||||
else if (*col == "description")
|
else if (*col == "description")
|
||||||
{
|
{
|
||||||
table.addColumn ("Description");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Description");
|
||||||
table.setColumnWidth (columnCount, Table::flexible);
|
table.setColumnWidth (columnCount, Table::flexible);
|
||||||
table.setColumnJustification (columnCount, Table::left);
|
table.setColumnJustification (columnCount, Table::left);
|
||||||
|
|
||||||
|
@ -2262,7 +2274,7 @@ std::string handleCustomReport (
|
||||||
|
|
||||||
else if (*col == "recur")
|
else if (*col == "recur")
|
||||||
{
|
{
|
||||||
table.addColumn ("Recur");
|
table.addColumn (columnLabels[*col] != "" ? columnLabels[*col] : "Recur");
|
||||||
table.setColumnWidth (columnCount, Table::minimum);
|
table.setColumnWidth (columnCount, Table::minimum);
|
||||||
table.setColumnJustification (columnCount, Table::right);
|
table.setColumnJustification (columnCount, Table::right);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue