Skip to content

Commit

Permalink
Feature/summary display (#6)
Browse files Browse the repository at this point in the history
* Adding better formatting to publish dialog for summaries.

* Doc string added
  • Loading branch information
Liametc authored and Joseph Yu committed May 18, 2021
1 parent fdd309d commit 4485752
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions python/tk_multi_publish2/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ def _create_item_details(self, tree_item):

else:
summary_text = "<p>The following items will be processed:</p>"
summary_text += "<style>ul { margin-left:-20px; }</style>"
summary_text += "".join(["<p>%s</p>" % line for line in summary])

self.ui.item_summary.setText(summary_text)
Expand Down
20 changes: 15 additions & 5 deletions python/tk_multi_publish2/publish_tree_widget/tree_node_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ def __repr__(self):
def __str__(self):
return "%s %s" % (self._item.type_display, self._item.name)

def create_summary(self):
def create_summary(self, level=0):
"""
Creates summary of actions
:param level: Indentation level of this item lives within the tree.
:type level: int
:returns: List of strings
"""
if self.checked:
Expand All @@ -91,16 +94,23 @@ def create_summary(self):
task_summaries.extend(child_item.create_summary())
else:
# sub-items
items_summaries.extend(child_item.create_summary())
items_summaries.extend(child_item.create_summary(level + 1))

summary = []

if len(task_summaries) > 0:

summary_str = "<b>%s</b><br>" % self.item.name
summary_str += "<br>".join(
["&ndash; %s" % task_summary for task_summary in task_summaries]
summary_str = "<ul><li>" * level
summary_str += "<b>%s</b>" % self.item.name
summary_str += '<ul style="list-style-type:circle;">'
summary_str += "".join(
[
"<li><i>%s</i></li>" % task_summary
for task_summary in task_summaries
]
)
summary_str += "</ul>"
summary_str += "</li></ul>" * level
summary.append(summary_str)

summary.extend(items_summaries)
Expand Down

0 comments on commit 4485752

Please sign in to comment.