card-mod-history 0.11.2 → 0.12.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 +4 -4
- data/lib/card/act.rb +2 -2
- data/lib/card/act/act_renderer.rb +4 -4
- data/lib/card/act/act_renderer/absolute_act_renderer.rb +1 -1
- data/lib/card/act/act_renderer/relative_act_renderer.rb +3 -4
- data/lib/card/action.rb +3 -5
- data/lib/card/action/action_renderer.rb +3 -2
- data/lib/card/change.rb +3 -2
- data/set/all/history.rb +2 -1
- data/set/all/history/act_listing.rb +4 -1
- data/set/all/history/actions.rb +8 -4
- data/set/all/history/events.rb +3 -3
- data/set/all/history/selected.rb +3 -3
- data/set/all/history_bridge.rb +31 -17
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d848324e8a24e138fcc1ec9f18e99ecfd18f7ea5e0ff9799e2b82f0f5a2becca
|
4
|
+
data.tar.gz: 505d838330e918f31384618fe6ec82464f13a28cd62027194d8a10ddcad99eee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2188ff8e94fc293926720efdc1577ac67f57c311388ff0f2aea52ebe237ad27b52a10c64519bd58cc700f5bc6a56eda3129af9e5648127af9a053d3b73d5fa79
|
7
|
+
data.tar.gz: d1fd88f32ba0976226a5722e76542f3c83a934c2bcd2c4ac103b22feee3be0c2bbcd42b69092837dae111dcfc7030fead37e4ce75bbc65026c37fe5032005816
|
data/lib/card/act.rb
CHANGED
@@ -16,7 +16,7 @@ class Card
|
|
16
16
|
# - _acted_at_, a timestamp of the action
|
17
17
|
# - the _ip_address_ of the actor where applicable.
|
18
18
|
#
|
19
|
-
class Act <
|
19
|
+
class Act < Cardio::Record
|
20
20
|
before_save :assign_actor
|
21
21
|
has_many :ar_actions, -> { order :id }, foreign_key: :card_act_id,
|
22
22
|
inverse_of: :act,
|
@@ -108,7 +108,7 @@ class Card
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def draft?
|
111
|
-
main_action
|
111
|
+
main_action&.draft
|
112
112
|
end
|
113
113
|
|
114
114
|
# time (in words) since act took place
|
@@ -10,7 +10,7 @@ class Card
|
|
10
10
|
@context = @args[:act_context]
|
11
11
|
end
|
12
12
|
|
13
|
-
include ::Bootstrapper
|
13
|
+
include Card::Bootstrapper
|
14
14
|
|
15
15
|
def method_missing method_name, *args, &block
|
16
16
|
if block_given?
|
@@ -31,7 +31,7 @@ class Card
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def header
|
34
|
-
|
34
|
+
# Card::Bootstrap.new(self).render do
|
35
35
|
bs_layout do
|
36
36
|
row xs: [10, 2] do
|
37
37
|
column do
|
@@ -123,7 +123,7 @@ class Card
|
|
123
123
|
# here. The problem is that here we have extra links in the title
|
124
124
|
# that are not supposed to expand the accordion
|
125
125
|
def act_accordion
|
126
|
-
context = @act.main_action
|
126
|
+
context = @act.main_action&.draft ? :warning : :default
|
127
127
|
<<-HTML
|
128
128
|
<div class="card card-#{context} nodblclick">
|
129
129
|
#{act_accordion_panel}
|
@@ -173,7 +173,7 @@ class Card
|
|
173
173
|
# save as current:
|
174
174
|
# not current, not deletion
|
175
175
|
def rollback_link
|
176
|
-
return unless card.ok? :update
|
176
|
+
return unless @card.ok? :update
|
177
177
|
|
178
178
|
wrap_with :div, class: "act-link collapse #{collapse_id} float-right" do
|
179
179
|
content_tag(:small, revert_link)
|
@@ -6,9 +6,8 @@ class Card
|
|
6
6
|
# for the card of the format that renders the act.
|
7
7
|
class RelativeActRenderer < ActRenderer
|
8
8
|
def title
|
9
|
-
|
9
|
+
%(<span class="nr">##{@args[:act_seq]}</span>) +
|
10
10
|
accordion_expand_link(@act.actor.name) +
|
11
|
-
" " +
|
12
11
|
wrap_with(:small, edited_ago)
|
13
12
|
end
|
14
13
|
|
@@ -50,8 +49,8 @@ class Card
|
|
50
49
|
def revert_link
|
51
50
|
revert_actions_link "revert to this",
|
52
51
|
{ revert_actions: actions.map(&:id) },
|
53
|
-
class: "_close-modal",
|
54
|
-
|
52
|
+
{ class: "_close-modal",
|
53
|
+
"data-slotter-mode": "update-modal-origin" }
|
55
54
|
end
|
56
55
|
end
|
57
56
|
end
|
data/lib/card/action.rb
CHANGED
@@ -20,7 +20,7 @@ class Card
|
|
20
20
|
# * a boolean indicated whether the action is a _draft_
|
21
21
|
# * a _comment_ (where applicable)
|
22
22
|
#
|
23
|
-
class Action <
|
23
|
+
class Action < Cardio::Record
|
24
24
|
include Differ
|
25
25
|
extend Admin
|
26
26
|
|
@@ -48,7 +48,7 @@ class Card
|
|
48
48
|
# @return [Action, nil]
|
49
49
|
def fetch id
|
50
50
|
cache.fetch id.to_s do
|
51
|
-
|
51
|
+
where(id: id.to_i).take
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -177,9 +177,7 @@ class Card
|
|
177
177
|
|
178
178
|
# all changed values in hash form. { field1: new_value }
|
179
179
|
def changed_values
|
180
|
-
@changed_values ||= changes.
|
181
|
-
h[key] = change.value
|
182
|
-
end
|
180
|
+
@changed_values ||= changes.transform_values(&:value)
|
183
181
|
end
|
184
182
|
|
185
183
|
# @return [Hash]
|
@@ -2,6 +2,7 @@ class Card
|
|
2
2
|
class Action
|
3
3
|
class ActionRenderer
|
4
4
|
attr_reader :action, :header
|
5
|
+
|
5
6
|
def initialize format, action, header=true, action_view=:summary, hide_diff=false
|
6
7
|
@format = format
|
7
8
|
@action = action
|
@@ -10,7 +11,7 @@ class Card
|
|
10
11
|
@hide_diff = hide_diff
|
11
12
|
end
|
12
13
|
|
13
|
-
include ::Bootstrapper
|
14
|
+
include Card::Bootstrapper
|
14
15
|
def method_missing method_name, *args, &block
|
15
16
|
if block_given?
|
16
17
|
@format.send(method_name, *args, &block)
|
@@ -58,7 +59,7 @@ class Card
|
|
58
59
|
else
|
59
60
|
link_to_view(
|
60
61
|
:related, name_changes,
|
61
|
-
path: { slot: { items: { view: "history", nest_name: @action.card.name } } }
|
62
|
+
path: { slot: { items: { view: "history", nest_name: @action.card.name } } }
|
62
63
|
# "data-slot-selector" => ".card-slot.history-view"
|
63
64
|
)
|
64
65
|
end
|
data/lib/card/change.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
|
2
|
+
|
3
|
+
require "activerecord-import"
|
3
4
|
|
4
5
|
class Card
|
5
6
|
# A _change_ is an alteration to a card's name, type, content, or trash state.
|
@@ -16,7 +17,7 @@ class Card
|
|
16
17
|
# * the new _value_ of that field
|
17
18
|
# * the {Action action} of which the change is part
|
18
19
|
#
|
19
|
-
class Change <
|
20
|
+
class Change < Cardio::Record
|
20
21
|
belongs_to :action, foreign_key: :card_action_id,
|
21
22
|
inverse_of: :card_changes
|
22
23
|
|
data/set/all/history.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
event :update_ancestor_timestamps, :integrate do
|
2
2
|
ids = history_ancestor_ids
|
3
3
|
return unless ids.present?
|
4
|
+
|
4
5
|
Card.where(id: ids).update_all(updater_id: Auth.current_id, updated_at: Time.now)
|
5
6
|
ids.map { |anc_id| Card.expire anc_id.cardname }
|
6
7
|
end
|
@@ -24,7 +25,7 @@ def history_ancestor_ids recursion_level=0
|
|
24
25
|
return [] if recursion_level > 5
|
25
26
|
|
26
27
|
ids = history_parent_ids +
|
27
|
-
|
28
|
+
history_parent_ids.map { |id| Card[id].history_ancestor_ids(recursion_level + 1) }
|
28
29
|
ids.flatten
|
29
30
|
end
|
30
31
|
|
@@ -86,8 +86,11 @@ format :html do
|
|
86
86
|
|
87
87
|
def act_paging acts, context
|
88
88
|
return unless controller.request # paginate requires a request
|
89
|
+
|
89
90
|
wrap_with :div, class: "slotter btn-sm" do
|
90
|
-
|
91
|
+
# normally we let method_missing handle the action_view stuff,
|
92
|
+
# but that doesn't handle **arguments yet
|
93
|
+
action_view.send :paginate, current_page_acts(acts), **act_paging_opts(context)
|
91
94
|
end
|
92
95
|
end
|
93
96
|
|
data/set/all/history/actions.rb
CHANGED
@@ -7,12 +7,16 @@ end
|
|
7
7
|
def action_from_id action_id
|
8
8
|
return unless action_id.is_a?(Integer) || action_id =~ /^\d+$/
|
9
9
|
|
10
|
-
# if not an integer
|
10
|
+
# if not an integer, action_id is probably a mod (e.g. if you request
|
11
11
|
# files/:logo/standard.png)
|
12
|
-
action = Action.fetch action_id
|
13
|
-
return unless action.card_id == id
|
14
12
|
|
15
|
-
|
13
|
+
action_if_on_self Action.fetch(action_id)
|
14
|
+
end
|
15
|
+
|
16
|
+
def action_if_on_self action
|
17
|
+
return unless action.is_a? Action
|
18
|
+
|
19
|
+
action if action.card_id == id
|
16
20
|
end
|
17
21
|
|
18
22
|
def old_actions
|
data/set/all/history/events.rb
CHANGED
@@ -18,7 +18,7 @@ def actionable?
|
|
18
18
|
end
|
19
19
|
|
20
20
|
event :detect_conflict, :validate, on: :update, when: :edit_conflict? do
|
21
|
-
errors.add :conflict,
|
21
|
+
errors.add :conflict, Cardio.t(:history_error_not_latest_revision)
|
22
22
|
end
|
23
23
|
|
24
24
|
def edit_conflict?
|
@@ -34,7 +34,7 @@ event :finalize_action, :finalize, when: :finalize_action? do
|
|
34
34
|
if changed_fields.present?
|
35
35
|
@current_action.update! card_id: id
|
36
36
|
|
37
|
-
#
|
37
|
+
# NOTE: #last_change_on uses the id to sort by date
|
38
38
|
# so the changes for the create changes have to be created before the first change
|
39
39
|
store_card_changes_for_create_action if first_change?
|
40
40
|
store_card_changes unless first_create?
|
@@ -64,7 +64,7 @@ def store_each_history_field action_id, fields=nil
|
|
64
64
|
if false # Card::Change.supports_import?
|
65
65
|
# attach.feature fails with this
|
66
66
|
values = fields.map.with_index { |field, index| [index, yield(field), action_id] }
|
67
|
-
Card::Change.import [
|
67
|
+
Card::Change.import %i[field value card_action_id], values # , validate: false
|
68
68
|
else
|
69
69
|
fields.each do |field|
|
70
70
|
Card::Change.create field: field,
|
data/set/all/history/selected.rb
CHANGED
@@ -24,7 +24,7 @@ def select_action action_id
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def selected_action_id
|
27
|
-
@selected_action_id ||
|
27
|
+
@selected_action_id || @current_action&.id || last_action_id
|
28
28
|
end
|
29
29
|
|
30
30
|
def selected_action_id= action_id
|
@@ -41,8 +41,8 @@ def selected_content
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def content_at_time_of_selected_action
|
44
|
-
|
45
|
-
|
44
|
+
last_change_on(:db_content, not_after: selected_action_id,
|
45
|
+
including_drafts: true)&.value
|
46
46
|
end
|
47
47
|
|
48
48
|
def with_selected_action_id action_id
|
data/set/all/history_bridge.rb
CHANGED
@@ -2,30 +2,17 @@ format :html do
|
|
2
2
|
view :creator_credit,
|
3
3
|
wrap: { div: { class: "text-muted creator-credit" } }, cache: :never do
|
4
4
|
return "" unless card.real?
|
5
|
+
|
5
6
|
"Created by #{nest card.creator, view: :link} "\
|
6
7
|
"#{time_ago_in_words(card.created_at)} ago"
|
7
8
|
end
|
8
9
|
|
9
10
|
view :updated_by, wrap: { div: { class: "text-muted" } } do
|
10
|
-
|
11
|
-
updaters = Card.search(updater_of: { id: card.id })
|
12
|
-
return "" unless updaters.present?
|
13
|
-
|
14
|
-
updaters = updater_links updaters, others_target: Card.fetch(card, :editors)
|
15
|
-
"Updated by #{updaters}"
|
16
|
-
end
|
17
|
-
|
18
|
-
def updater_links updaters, item_view: :link, max_count: 3, others_target: card
|
11
|
+
updaters = Card.search(updater_of: { id: card.id }) if card.id
|
19
12
|
return "" unless updaters.present?
|
20
13
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
reduced = first_card(fetch_count).map { |c| nest c, view: item_view }
|
25
|
-
if total > max_count
|
26
|
-
reduced << link_to_card(others_target, "#{total - fetch_count} others")
|
27
|
-
end
|
28
|
-
reduced.to_sentence
|
14
|
+
links = updater_links updaters, others_target: card.fetch(:editors)
|
15
|
+
"Updated by #{links}"
|
29
16
|
end
|
30
17
|
|
31
18
|
def acts_bridge_layout acts, context=:bridge
|
@@ -62,4 +49,31 @@ format :html do
|
|
62
49
|
act_listing(act, opts[:act_seq], :bridge)
|
63
50
|
end
|
64
51
|
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def updater_links updaters, item_view: :link, max_count: 3, others_target: card
|
56
|
+
total = updaters.size
|
57
|
+
num_to_show = number_of_updaters_to_show total, max_count
|
58
|
+
|
59
|
+
links =
|
60
|
+
links_to_updaters(updaters, num_to_show, item_view) +
|
61
|
+
link_to_other_updaters(total, others_target, num_to_show)
|
62
|
+
|
63
|
+
links.to_sentence
|
64
|
+
end
|
65
|
+
|
66
|
+
def number_of_updaters_to_show total, max_count
|
67
|
+
total > max_count ? max_count - 1 : max_count
|
68
|
+
end
|
69
|
+
|
70
|
+
def links_to_updaters updaters, num_to_show, item_view
|
71
|
+
updaters[0..(num_to_show - 1)].map { |c| nest c, view: item_view }
|
72
|
+
end
|
73
|
+
|
74
|
+
def link_to_other_updaters total, target, num_to_show
|
75
|
+
return [] unless total > num_to_show
|
76
|
+
|
77
|
+
link_to_card target, "#{total - num_to_show} others"
|
78
|
+
end
|
65
79
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card-mod-history
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-07-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: card
|
@@ -18,14 +18,14 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.102.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.
|
28
|
+
version: 1.102.0
|
29
29
|
description: ''
|
30
30
|
email:
|
31
31
|
- info@decko.org
|
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
|
-
rubygems_version: 3.
|
81
|
+
rubygems_version: 3.2.15
|
82
82
|
signing_key:
|
83
83
|
specification_version: 4
|
84
84
|
summary: Revision histories in acts, actions, and changes
|