paper_trail_history 0.1.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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +188 -0
- data/Rakefile +29 -0
- data/app/assets/stylesheets/paper_trail_history/application.css +93 -0
- data/app/controllers/paper_trail_history/application_controller.rb +6 -0
- data/app/controllers/paper_trail_history/models_controller.rb +57 -0
- data/app/controllers/paper_trail_history/records_controller.rb +58 -0
- data/app/controllers/paper_trail_history/versions_controller.rb +33 -0
- data/app/helpers/paper_trail_history/application_helper.rb +7 -0
- data/app/jobs/paper_trail_history/application_job.rb +6 -0
- data/app/mailers/paper_trail_history/application_mailer.rb +9 -0
- data/app/models/paper_trail_history/application_record.rb +8 -0
- data/app/models/paper_trail_history/trackable_model.rb +112 -0
- data/app/models/paper_trail_history/version_decorator.rb +104 -0
- data/app/models/paper_trail_history/version_service.rb +158 -0
- data/app/views/layouts/paper_trail_history/application.html.erb +64 -0
- data/app/views/paper_trail_history/models/index.html.erb +65 -0
- data/app/views/paper_trail_history/models/show.html.erb +49 -0
- data/app/views/paper_trail_history/models/versions.html.erb +30 -0
- data/app/views/paper_trail_history/records/show.html.erb +57 -0
- data/app/views/paper_trail_history/records/versions.html.erb +36 -0
- data/app/views/paper_trail_history/shared/_version_filters.html.erb +54 -0
- data/app/views/paper_trail_history/shared/_versions_table.html.erb +60 -0
- data/app/views/paper_trail_history/versions/show.html.erb +134 -0
- data/config/locales/de.yml +16 -0
- data/config/locales/en.yml +16 -0
- data/config/routes.rb +23 -0
- data/lib/paper_trail_history/engine.rb +8 -0
- data/lib/paper_trail_history/version.rb +5 -0
- data/lib/paper_trail_history.rb +15 -0
- data/lib/tasks/paper_trail_history_tasks.rake +6 -0
- metadata +106 -0
@@ -0,0 +1,134 @@
|
|
1
|
+
<nav aria-label="breadcrumb">
|
2
|
+
<ol class="breadcrumb">
|
3
|
+
<li class="breadcrumb-item"><%= link_to "Models", models_path %></li>
|
4
|
+
<li class="breadcrumb-item"><%= link_to @trackable_model.human_name, model_path(@trackable_model.name) %></li>
|
5
|
+
<li class="breadcrumb-item active">Version #<%= @version.id %></li>
|
6
|
+
</ol>
|
7
|
+
</nav>
|
8
|
+
|
9
|
+
<div class="d-flex justify-content-between align-items-center mb-4">
|
10
|
+
<h1>Version Details</h1>
|
11
|
+
<div>
|
12
|
+
<% if @decorated_version.can_restore? %>
|
13
|
+
<%= link_to "Restore This Version",
|
14
|
+
restore_version_path(@version),
|
15
|
+
method: :patch,
|
16
|
+
data: {
|
17
|
+
confirm: "Are you sure you want to restore this version? This will overwrite the current data."
|
18
|
+
},
|
19
|
+
class: "btn btn-warning" %>
|
20
|
+
<% end %>
|
21
|
+
<%= link_to "View Record", model_record_path(@trackable_model.name, @version.item_id), class: "btn btn-outline-primary" %>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<div class="row">
|
26
|
+
<div class="col-md-6 mb-4">
|
27
|
+
<div class="card">
|
28
|
+
<div class="card-body">
|
29
|
+
<h5 class="card-title">Version Information</h5>
|
30
|
+
<dl class="row">
|
31
|
+
<dt class="col-sm-4">Version ID:</dt>
|
32
|
+
<dd class="col-sm-8"><code><%= @version.id %></code></dd>
|
33
|
+
|
34
|
+
<dt class="col-sm-4">Event:</dt>
|
35
|
+
<dd class="col-sm-8">
|
36
|
+
<span class="badge bg-<%= @decorated_version.event_class %>">
|
37
|
+
<i class="bi bi-<%= @decorated_version.event == 'create' ? 'plus' : @decorated_version.event == 'update' ? 'pencil' : 'trash' %>"></i>
|
38
|
+
<%= @decorated_version.event_label %>
|
39
|
+
</span>
|
40
|
+
</dd>
|
41
|
+
|
42
|
+
<dt class="col-sm-4">When:</dt>
|
43
|
+
<dd class="col-sm-8"><%= @decorated_version.formatted_created_at %></dd>
|
44
|
+
|
45
|
+
<dt class="col-sm-4">Who:</dt>
|
46
|
+
<dd class="col-sm-8"><%= @decorated_version.whodunnit_display %></dd>
|
47
|
+
|
48
|
+
<dt class="col-sm-4">Item:</dt>
|
49
|
+
<dd class="col-sm-8">
|
50
|
+
<%= link_to @decorated_version.item_display_name,
|
51
|
+
model_record_path(@trackable_model.name, @version.item_id),
|
52
|
+
class: "text-decoration-none" %>
|
53
|
+
</dd>
|
54
|
+
</dl>
|
55
|
+
</div>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
|
59
|
+
<div class="col-md-6 mb-4">
|
60
|
+
<% if @decorated_version.can_restore? %>
|
61
|
+
<div class="card border-warning">
|
62
|
+
<div class="card-body">
|
63
|
+
<h5 class="card-title text-warning">
|
64
|
+
<i class="bi bi-exclamation-triangle"></i>
|
65
|
+
Restore Version
|
66
|
+
</h5>
|
67
|
+
<p class="card-text">
|
68
|
+
This will restore the record to the state it was in at this version.
|
69
|
+
<strong>This action cannot be undone</strong>, but will create a new version entry.
|
70
|
+
</p>
|
71
|
+
<%= link_to "Restore This Version",
|
72
|
+
restore_version_path(@version),
|
73
|
+
method: :patch,
|
74
|
+
data: {
|
75
|
+
confirm: "Are you sure you want to restore this version? This will overwrite the current data and cannot be undone."
|
76
|
+
},
|
77
|
+
class: "btn btn-warning" %>
|
78
|
+
</div>
|
79
|
+
</div>
|
80
|
+
<% else %>
|
81
|
+
<div class="card border-secondary">
|
82
|
+
<div class="card-body">
|
83
|
+
<h5 class="card-title text-muted">
|
84
|
+
<i class="bi bi-info-circle"></i>
|
85
|
+
Cannot Restore
|
86
|
+
</h5>
|
87
|
+
<p class="card-text text-muted">
|
88
|
+
This version represents the initial creation of the record and cannot be restored.
|
89
|
+
</p>
|
90
|
+
</div>
|
91
|
+
</div>
|
92
|
+
<% end %>
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
|
96
|
+
<% if @decorated_version.changed_attributes.any? %>
|
97
|
+
<div class="card">
|
98
|
+
<div class="card-header">
|
99
|
+
<h5 class="mb-0">
|
100
|
+
<i class="bi bi-code-square"></i>
|
101
|
+
Changes Made
|
102
|
+
</h5>
|
103
|
+
</div>
|
104
|
+
<div class="card-body">
|
105
|
+
<div class="diff-container">
|
106
|
+
<% @decorated_version.changed_attributes.each do |change| %>
|
107
|
+
<div class="diff-section mb-4">
|
108
|
+
<div class="diff-header">
|
109
|
+
<i class="bi bi-at"></i>
|
110
|
+
<strong><%= change[:attribute] %></strong>
|
111
|
+
</div>
|
112
|
+
<div class="diff-content">
|
113
|
+
<div class="diff-line diff-removed">
|
114
|
+
<span class="diff-marker">-</span>
|
115
|
+
<code><%= change[:old_value] %></code>
|
116
|
+
</div>
|
117
|
+
<div class="diff-line diff-added">
|
118
|
+
<span class="diff-marker">+</span>
|
119
|
+
<code><%= change[:new_value] %></code>
|
120
|
+
</div>
|
121
|
+
</div>
|
122
|
+
</div>
|
123
|
+
<% end %>
|
124
|
+
</div>
|
125
|
+
</div>
|
126
|
+
</div>
|
127
|
+
<% else %>
|
128
|
+
<div class="card">
|
129
|
+
<div class="card-body text-center text-muted">
|
130
|
+
<i class="bi bi-info-circle"></i>
|
131
|
+
No detailed change information available for this version.
|
132
|
+
</div>
|
133
|
+
</div>
|
134
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
de:
|
2
|
+
paper_trail_history:
|
3
|
+
errors:
|
4
|
+
version_not_found: "Version nicht gefunden"
|
5
|
+
model_not_found: "Modell '%{model_name}' nicht gefunden oder nicht verfolgbar"
|
6
|
+
restore_failed: "Wiederherstellung fehlgeschlagen: %{error}"
|
7
|
+
cannot_restore_create: "Erstell-Ereignisse können nicht wiederhergestellt werden"
|
8
|
+
messages:
|
9
|
+
restore_from_deletion: "Datensatz aus Löschung wiederhergestellt"
|
10
|
+
restore_to_previous: "Datensatz auf vorherige Version wiederhergestellt"
|
11
|
+
events:
|
12
|
+
created: "Erstellt"
|
13
|
+
updated: "Aktualisiert"
|
14
|
+
deleted: "Gelöscht"
|
15
|
+
actors:
|
16
|
+
system: "System"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
en:
|
2
|
+
paper_trail_history:
|
3
|
+
errors:
|
4
|
+
version_not_found: "Version not found"
|
5
|
+
model_not_found: "Model '%{model_name}' not found or not trackable"
|
6
|
+
restore_failed: "Failed to restore: %{error}"
|
7
|
+
cannot_restore_create: "Cannot restore create events"
|
8
|
+
messages:
|
9
|
+
restore_from_deletion: "Record restored from deletion"
|
10
|
+
restore_to_previous: "Record restored to previous version"
|
11
|
+
events:
|
12
|
+
created: "Created"
|
13
|
+
updated: "Updated"
|
14
|
+
deleted: "Deleted"
|
15
|
+
actors:
|
16
|
+
system: "System"
|
data/config/routes.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
PaperTrailHistory::Engine.routes.draw do
|
4
|
+
root 'models#index'
|
5
|
+
|
6
|
+
resources :models, only: %i[index show], param: :name do
|
7
|
+
member do
|
8
|
+
get :versions
|
9
|
+
end
|
10
|
+
|
11
|
+
resources :records, only: [:show], param: :record_id do
|
12
|
+
member do
|
13
|
+
get :versions
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
resources :versions, only: [:show] do
|
19
|
+
member do
|
20
|
+
patch :restore
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'paper_trail'
|
4
|
+
require 'paper_trail_history/version'
|
5
|
+
require 'paper_trail_history/engine'
|
6
|
+
|
7
|
+
# PaperTrailHistory is a Ruby on Rails engine that provides a history of changes made to models using
|
8
|
+
# the PaperTrail gem. It allows you to track changes, view previous versions of records, and restore them if needed.
|
9
|
+
#
|
10
|
+
# This engine integrates with the PaperTrail gem to provide a user-friendly interface for viewing and managing
|
11
|
+
# the history of changes made to your models. It includes routes, controllers, and views to display the history
|
12
|
+
# of changes in a structured manner.
|
13
|
+
module PaperTrailHistory
|
14
|
+
# Your code goes here...
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paper_trail_history
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Benjamin Deutscher
|
8
|
+
bindir: bin
|
9
|
+
cert_chain: []
|
10
|
+
date: 2025-08-06 00:00:00.000000000 Z
|
11
|
+
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: paper_trail
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - ">="
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '15.0'
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '15.0'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rails
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '7.2'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '7.2'
|
40
|
+
description: |
|
41
|
+
PaperTrailHistory is a mountable Rails engine that provides a comprehensive web interface for viewing, searching,
|
42
|
+
and managing audit trail versions created by the PaperTrail gem. Features include listing trackable models,
|
43
|
+
browsing version history, filtering and searching changes, and restoring previous versions of records.
|
44
|
+
email:
|
45
|
+
- ben@bdeutscher.org
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- MIT-LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- app/assets/stylesheets/paper_trail_history/application.css
|
54
|
+
- app/controllers/paper_trail_history/application_controller.rb
|
55
|
+
- app/controllers/paper_trail_history/models_controller.rb
|
56
|
+
- app/controllers/paper_trail_history/records_controller.rb
|
57
|
+
- app/controllers/paper_trail_history/versions_controller.rb
|
58
|
+
- app/helpers/paper_trail_history/application_helper.rb
|
59
|
+
- app/jobs/paper_trail_history/application_job.rb
|
60
|
+
- app/mailers/paper_trail_history/application_mailer.rb
|
61
|
+
- app/models/paper_trail_history/application_record.rb
|
62
|
+
- app/models/paper_trail_history/trackable_model.rb
|
63
|
+
- app/models/paper_trail_history/version_decorator.rb
|
64
|
+
- app/models/paper_trail_history/version_service.rb
|
65
|
+
- app/views/layouts/paper_trail_history/application.html.erb
|
66
|
+
- app/views/paper_trail_history/models/index.html.erb
|
67
|
+
- app/views/paper_trail_history/models/show.html.erb
|
68
|
+
- app/views/paper_trail_history/models/versions.html.erb
|
69
|
+
- app/views/paper_trail_history/records/show.html.erb
|
70
|
+
- app/views/paper_trail_history/records/versions.html.erb
|
71
|
+
- app/views/paper_trail_history/shared/_version_filters.html.erb
|
72
|
+
- app/views/paper_trail_history/shared/_versions_table.html.erb
|
73
|
+
- app/views/paper_trail_history/versions/show.html.erb
|
74
|
+
- config/locales/de.yml
|
75
|
+
- config/locales/en.yml
|
76
|
+
- config/routes.rb
|
77
|
+
- lib/paper_trail_history.rb
|
78
|
+
- lib/paper_trail_history/engine.rb
|
79
|
+
- lib/paper_trail_history/version.rb
|
80
|
+
- lib/tasks/paper_trail_history_tasks.rake
|
81
|
+
homepage: https://github.com/its-bede/paper_trail_history
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
metadata:
|
85
|
+
homepage_uri: https://github.com/its-bede/paper_trail_history
|
86
|
+
source_code_uri: https://github.com/its-bede/paper_trail_history
|
87
|
+
changelog_uri: https://github.com/its-bede/paper_trail_history/blob/main/CHANGELOG.md
|
88
|
+
rubygems_mfa_required: 'true'
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.1.0
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubygems_version: 3.6.6
|
104
|
+
specification_version: 4
|
105
|
+
summary: A Rails engine providing a web interface for managing PaperTrail versions.
|
106
|
+
test_files: []
|