Skip to content

Commit

Permalink
Minimalist UI for prov and messages (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
mccalluc authored Jan 9, 2023
1 parent d315513 commit 8d549c3
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 49 deletions.
26 changes: 26 additions & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ details {
}

summary.show-changes {
font-weight: normal;
&::after {
content: 'Show Changes';
}
Expand Down Expand Up @@ -206,4 +207,29 @@ dl {
dd {
grid-column-start: 2;
}
}

ul.beads {
padding-left: 1em;
margin-left: 1em;
border-left: 2px solid;
li {
list-style: none;
}
li::before {
content: "";
margin-left: -1em;
font-size: 150%;
}
}

ul.no-beads {
padding-left: 0;
li {
list-style: none;
border: 1px solid #dddcdc;
border-radius: .25rem;
margin-bottom: 5px;
padding: 5px;
}
}
21 changes: 11 additions & 10 deletions app/models/work_activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ def comment_timestamp_html
"at #{event_timestamp}" if comment_event_type?
end

def event_html(children:)
def title_html
<<-HTML
<div class="activity-history-#{event_type}-title">
<span class="activity-history-title">
#{event_timestamp_html}
#{created_by_user_html}
#{comment_timestamp_html}
</div>
<span class="comment-html">#{children.chomp}</span>
HTML
</span>
HTML
end

def event_html(children:)
title_html + "<span class='comment-html'>#{children.chomp}</span>"
end

# Returns the message formatted to display _file_ changes that were logged as an activity
Expand All @@ -141,19 +144,17 @@ def file_changes_html

# Returns the message formatted to display _metadata_ changes that were logged as an activity
def metadata_changes_html
text = ""
html = title_html
changes = JSON.parse(message)

changes.keys.each do |field|
change = changes[field]
mapped = change.map { |value| change_value_html(value) }
values = mapped.join

children = "<details><summary class='show-changes'>#{field}</summary>#{values}</details>"
text += event_html(children: children)
html += "<details class='comment-html'><summary class='show-changes'>#{field}</summary>#{values}</details>"
end

text
html
end

# rubocop:disable Metrics/MethodLength
Expand Down
4 changes: 2 additions & 2 deletions app/views/works/_work_activity.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="activity-history-item activity-history-<%= event_type %>-item">
<li class="activity-history-item">
<%= activity.to_html.html_safe %>
</div>
</li>
47 changes: 26 additions & 21 deletions app/views/works/_work_activity_history.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@
<% if @comments.size == 0 && !@work.submission_notes.present? %>
No messages
<% end %>
<% @comments.each do |activity| %>
<%= render partial: 'work_activity', locals: {
activity: activity,
event_type: activity.event_type
} %>
<% end %>
<% if @work.submission_notes.present? %>
<div class="activity-history-item activity-history-comment-item">
<div class="activity-history-comment-title">
Submission message
</div>
<%= @work.submission_notes %>
</div>
<% end %>
<ul class="no-beads">
<% @comments.each do |activity| %>
<%= render partial: 'work_activity', locals: {
activity: activity,
event_type: activity.event_type
} %>
<% end %>
<% if @work.submission_notes.present? %>
<li class="activity-history-item">
<span class="activity-history-title">
Submission message
</span>
<div>
<%= @work.submission_notes %>
</div>
</li>
<% end %>
</ul>

<div id="new-comment-section">
<%= form_with url: add_comment_work_path(@work) do |f| %>
Expand All @@ -36,10 +39,12 @@
<% if @changes.size == 0 %>
No activity
<% end %>
<% @changes.each do |activity| %>
<%= render partial: 'work_activity', locals: {
activity: activity,
event_type: activity.event_type
} %>
<% end %>
<ul class="beads">
<% @changes.each do |activity| %>
<%= render partial: 'work_activity', locals: {
activity: activity,
event_type: activity.event_type
} %>
<% end %>
</ul>
</div>
17 changes: 2 additions & 15 deletions app/views/works/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,8 @@
font-size: 12px;
}

.activity-history-item {
border-style: solid;
border-width: 1px;
border-color: #dddcdc;
border-radius: .25rem;
margin-bottom: 5px;
padding-bottom: 10px;
}

.activity-history-comment-title {
background-color:#bfe9fd;
}

.activity-history-log-title {
background-color:#f4d28f;
.activity-history-title {
font-weight: bold;
}

.comment-html > p {
Expand Down
2 changes: 1 addition & 1 deletion spec/system/work_edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
fill_in "title_main", with: "UPDATED" + work.resource.titles.first.title
click_on "Save Work"
# This depends on the timezone configured in application.rb:
expect(page.first(".activity-history-log-title", visible: true)).to have_content "December 31, 2021 19:00"
expect(page.first(".activity-history-title", visible: true)).to have_content "December 31, 2021 19:00"
end
end

Expand Down

0 comments on commit 8d549c3

Please sign in to comment.