paper_view 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,11 +8,11 @@
8
8
  <span class="pv-detail__stamp"><%= paper_view_time(row.version.created_at) %></span>
9
9
  </div>
10
10
 
11
- <div class="pv-detail__meta<%= " pv-detail__meta--split" if stream %>">
12
- <% if stream %>
11
+ <div class="pv-detail__meta<%= " pv-detail__meta--split" if multi_item_view %>">
12
+ <% if multi_item_view %>
13
13
  <div class="pv-detail__field">
14
14
  <span class="pv-label">Item</span>
15
- <%= link_to row.item_label, paper_view_item_path(row.version), class: "pv-detail__item" %>
15
+ <%= link_to row.item_label, paper_view_item_path(row.version), class: "pv-detail__item", title: row.item_label %>
16
16
  </div>
17
17
  <% end %>
18
18
 
@@ -22,15 +22,52 @@
22
22
  </div>
23
23
  </div>
24
24
 
25
+ <% if row.metadata.any? %>
26
+ <div class="pv-detail__metadata">
27
+ <span class="pv-label">Metadata</span>
28
+
29
+ <div class="pv-meta">
30
+ <% row.metadata.visible.each do |entry| %>
31
+ <span class="pv-meta__key"><%= entry.name %></span>
32
+ <span class="pv-meta__value"><%= entry.text %></span>
33
+ <% end %>
34
+ </div>
35
+
36
+ <% if row.metadata.hidden.any? %>
37
+ <% rest_id = "pv-meta-#{row.id}" %>
38
+ <button
39
+ type="button"
40
+ class="pv-meta__more"
41
+ aria-expanded="false"
42
+ aria-controls="<%= rest_id %>"
43
+ data-pv-toggle="<%= rest_id %>"
44
+ >
45
+ <span class="pv-disclosure__arrow">▸</span>
46
+ <%= row.metadata.hidden.size %> more
47
+ <%= "key".pluralize(row.metadata.hidden.size) %>
48
+ </button>
49
+
50
+ <div class="pv-meta" id="<%= rest_id %>" hidden>
51
+ <% row.metadata.hidden.each do |entry| %>
52
+ <span class="pv-meta__key"><%= entry.name %></span>
53
+ <span class="pv-meta__value"><%= entry.text %></span>
54
+ <% end %>
55
+ </div>
56
+ <% end %>
57
+ </div>
58
+ <% end %>
59
+
25
60
  <div class="pv-detail__body">
26
61
  <% if row.change_set.unreadable? %>
27
62
  <p class="pv-detail__note">
28
63
  The <code>object_changes</code> payload is neither readable YAML nor
29
- JSON, so it cannot be diffed. The stored bytes are below under
30
- <strong>Raw object_changes</strong>.
64
+ JSON, so it cannot be diffed.
65
+ <% unless row.created? %>
66
+ The stored bytes are below under <strong>Raw object_changes</strong>.
67
+ <% end %>
31
68
  </p>
32
69
  <% else %>
33
- <span class="pv-label"><%= row.change_set.size %> changed <%= "field".pluralize(row.change_set.size) %></span>
70
+ <span class="pv-label"><%= row.change_label %></span>
34
71
 
35
72
  <% if row.change_set.empty? %>
36
73
  <p class="pv-detail__note">
@@ -42,7 +79,15 @@
42
79
  <div class="pv-attribute">
43
80
  <span class="pv-attribute__name"><%= change.name %></span>
44
81
 
45
- <% if change.nested? %>
82
+ <% if row.created? %>
83
+ <div class="pv-bars">
84
+ <div class="pv-bar pv-bar--new"><%= change.new_text %></div>
85
+ </div>
86
+ <% elsif row.destroyed? %>
87
+ <div class="pv-bars">
88
+ <div class="pv-bar pv-bar--old"><%= change.old_text %></div>
89
+ </div>
90
+ <% elsif change.nested? %>
46
91
  <% change.leaf_changes.each do |leaf| %>
47
92
  <div class="pv-keys">
48
93
  <span class="pv-keys__name"><%= leaf.path %></span>
@@ -83,44 +128,46 @@
83
128
  <% end %>
84
129
  <% end %>
85
130
 
86
- <div class="pv-disclosures">
87
- <button
88
- type="button"
89
- class="pv-disclosure"
90
- aria-expanded="false"
91
- aria-controls="pv-raw-<%= row.id %>"
92
- data-pv-toggle="pv-raw-<%= row.id %>"
93
- >
94
- <span class="pv-disclosure__arrow">▸</span> Raw object_changes
95
- </button>
96
-
97
- <button
98
- type="button"
99
- class="pv-disclosure pv-disclosure--end"
100
- aria-expanded="false"
101
- aria-controls="pv-reify-<%= row.id %>"
102
- data-pv-toggle="pv-reify-<%= row.id %>"
103
- >
104
- <span class="pv-disclosure__arrow">▸</span> Reify
105
- </button>
106
-
107
- <pre class="pv-raw" id="pv-raw-<%= row.id %>" hidden><%= row.change_set.raw_text %></pre>
108
-
109
- <div class="pv-snippet" id="pv-reify-<%= row.id %>" hidden>
110
- <div class="pv-snippet__head">
111
- <span class="pv-snippet__label">Rails console</span>
112
-
113
- <button
114
- type="button"
115
- class="pv-snippet__copy"
116
- data-pv-copy="pv-snippet-<%= row.id %>"
117
- >
118
- Copy
119
- </button>
120
- </div>
131
+ <% unless row.created? %>
132
+ <div class="pv-disclosures">
133
+ <button
134
+ type="button"
135
+ class="pv-disclosure"
136
+ aria-expanded="false"
137
+ aria-controls="pv-raw-<%= row.id %>"
138
+ data-pv-toggle="pv-raw-<%= row.id %>"
139
+ >
140
+ <span class="pv-disclosure__arrow">▸</span> Raw object_changes
141
+ </button>
142
+
143
+ <button
144
+ type="button"
145
+ class="pv-disclosure pv-disclosure--end"
146
+ aria-expanded="false"
147
+ aria-controls="pv-reify-<%= row.id %>"
148
+ data-pv-toggle="pv-reify-<%= row.id %>"
149
+ >
150
+ <span class="pv-disclosure__arrow">▸</span> Reify
151
+ </button>
152
+
153
+ <pre class="pv-raw" id="pv-raw-<%= row.id %>" hidden><%= row.change_set.raw_text %></pre>
121
154
 
122
- <pre class="pv-snippet__code" id="pv-snippet-<%= row.id %>"><%= row.console_snippet %></pre>
155
+ <div class="pv-snippet" id="pv-reify-<%= row.id %>" hidden>
156
+ <div class="pv-snippet__head">
157
+ <span class="pv-snippet__label">Rails console</span>
158
+
159
+ <button
160
+ type="button"
161
+ class="pv-snippet__copy"
162
+ data-pv-copy="pv-snippet-<%= row.id %>"
163
+ >
164
+ Copy
165
+ </button>
166
+ </div>
167
+
168
+ <pre class="pv-snippet__code" id="pv-snippet-<%= row.id %>"><%= row.console_snippet %></pre>
169
+ </div>
123
170
  </div>
124
- </div>
171
+ <% end %>
125
172
  </div>
126
173
  </section>
@@ -1,5 +1,5 @@
1
1
  <div
2
- class="pv-version<%= " pv-version--selected" if selected %><%= " pv-version--stream" if stream %>"
2
+ class="pv-version<%= " pv-version--selected" if selected %><%= " pv-version--multi-item-view" if multi_item_view %>"
3
3
  data-pv-version="<%= row.id %>"
4
4
  role="button"
5
5
  tabindex="0"
@@ -12,7 +12,7 @@
12
12
  <span class="pv-version__line"></span>
13
13
  </div>
14
14
 
15
- <% if stream %>
15
+ <% if multi_item_view %>
16
16
  <div class="pv-version__item">
17
17
  <%= link_to row.item_label, paper_view_item_path(row.version), class: "pv-version__item-link" %>
18
18
  <span class="pv-pill pv-pill--<%= row.event %>"><%= row.event %></span>
@@ -23,12 +23,12 @@
23
23
  <div class="pv-version__meta">
24
24
  <span class="pv-version__actor"><%= paper_view_whodunnit(row.version) %></span>
25
25
 
26
- <% unless stream %>
26
+ <% if !multi_item_view %>
27
27
  <span class="pv-pill pv-pill--event"><%= row.event %></span>
28
- <% end %>
29
28
 
30
- <% if row.burst? %>
31
- <span class="pv-pill pv-pill--burst"><%= row.burst_label %></span>
29
+ <% if row.burst? %>
30
+ <span class="pv-pill pv-pill--burst"><%= row.burst_label %></span>
31
+ <% end %>
32
32
  <% end %>
33
33
  </div>
34
34
 
@@ -31,12 +31,12 @@
31
31
 
32
32
  <span class="pv-card__meta">
33
33
  <%= number_with_delimiter(@paginator.total_count) %>
34
- <%= "version".pluralize(@paginator.total_count) %><%= " · #{@timeline.items.size} items" if @timeline.stream? %>
34
+ <%= "version".pluralize(@paginator.total_count) %><%= " · #{@timeline.items.size} items" if @timeline.multi_item_view? %>
35
35
  </span>
36
36
 
37
37
  <span class="pv-spacer"></span>
38
38
 
39
- <%= form_with url: versions_path, method: :get, local: true, data: {turbo: false}, class: "pv-head-form" do %>
39
+ <%= form_with url: versions_path, method: :get, local: true, class: "pv-head-form" do %>
40
40
  <%= paper_view_hidden_filters(except: :sort) %>
41
41
 
42
42
  <select
@@ -58,7 +58,7 @@
58
58
  <div class="pv-timeline__day"><%= group.label %></div>
59
59
 
60
60
  <% group.rows.each do |row| %>
61
- <%= render "paper_view/versions/timeline_row", row: row, stream: @timeline.stream?, selected: row == @timeline.selected %>
61
+ <%= render "paper_view/versions/timeline_row", row: row, multi_item_view: @timeline.multi_item_view?, selected: row == @timeline.selected %>
62
62
  <% end %>
63
63
  </div>
64
64
  <% end %>
@@ -69,7 +69,7 @@
69
69
 
70
70
  <aside class="pv-side" data-pv-panels>
71
71
  <% @timeline.rows.each do |row| %>
72
- <%= render "paper_view/versions/panel", row: row, stream: @timeline.stream?, active: row == @timeline.selected %>
72
+ <%= render "paper_view/versions/panel", row: row, multi_item_view: @timeline.multi_item_view?, active: row == @timeline.selected %>
73
73
  <% end %>
74
74
  </aside>
75
75
  </div>
data/config/routes.rb CHANGED
@@ -2,4 +2,7 @@ PaperView::Engine.routes.draw do
2
2
  root "versions#index"
3
3
 
4
4
  resources :versions, only: :index
5
+ resource :stats, only: :show
6
+
7
+ get "turbo-:digest.js", to: PaperView::TurboAsset, as: :turbo_asset
5
8
  end