card-mod-history 0.14.1 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: effd8939e9e0f5c613e28c66b4a305532d3bc7716cbdc334125c6dbaf43ec03f
4
- data.tar.gz: 87e3698768122493be322d770402d2b9edf82e5ffd89feb5d341df70717eb7c6
3
+ metadata.gz: e2d78dcfb78596c37468e86dc3e3a72ac08d03cdf0d5440dfa5c295dbcf2b039
4
+ data.tar.gz: c1f9f5eb97b32949b0a348fa0947d0f4026bd0d7d3c72ebf881b64784091f9ef
5
5
  SHA512:
6
- metadata.gz: 24d1a7d332a940f196f61ad03bee8345d35840fc8b1646471bb93ecdacf625be376aeb2b7af4deb842bafb7512aed457008152444018f0be170a1cd5a52e12a9
7
- data.tar.gz: 808133e07ca2a6592e9e187922ec053195ceb4a676a960b7a3d857039d75cc0a3d20aceef77f9967d4978bff7b4e3881603250d8ecd36d9f7a9e176fee4947e2
6
+ metadata.gz: 6e45cfc294d0badd2c4ab9aecc141187ebf9d3d984b428b1bd1e74e96c33655d9fabc43280e7c08d4420e362ce78bed36f28795caa6a74f4461ff381ccf371ab
7
+ data.tar.gz: 007a9e2f96b32ec1f2e247b8c95a7874a0072b5a18b6cf5f0301588684eb66672cec10c475683ff93ee71fc7c6405e21da6a0e48da336f93b993d304de5fed5c
@@ -0,0 +1,92 @@
1
+ .history-slot {
2
+ overflow: hidden;
3
+ clear: both;
4
+ }
5
+
6
+ ul.action-list {
7
+ list-style-type: none;
8
+ padding-left: 15px;
9
+ li {
10
+ border: 1px solid $border-color;
11
+ }
12
+ li:before {
13
+ font-family: 'Material Icons';
14
+ font-weight: normal;
15
+ font-style: normal;
16
+ display: inline-block;
17
+ line-height: 1;
18
+ text-transform: none;
19
+ letter-spacing: normal;
20
+ word-wrap: normal;
21
+ white-space: nowrap;
22
+ direction: ltr;
23
+ -webkit-font-smoothing: antialiased;
24
+ text-rendering: optimizeLegibility;
25
+ -moz-osx-font-smoothing: grayscale;
26
+ font-feature-settings: 'liga';
27
+
28
+
29
+ float: left;
30
+ margin-top: 8px;
31
+ margin-left: -2rem;
32
+ font-size: 120%;
33
+ padding-left: 4px;
34
+ max-height: 30px;
35
+ }
36
+
37
+ li.update:before {
38
+ content: "edit";
39
+ color: $gray-600;
40
+ }
41
+
42
+ li.create:before {
43
+ content: "add_circle";
44
+ color: $green;
45
+ }
46
+
47
+ li.delete:before {
48
+ content: "remove_circle";
49
+ color: $red;
50
+ }
51
+
52
+ li.draft:before {
53
+ content: "build";
54
+ color: $gray-600;
55
+ }
56
+ }
57
+
58
+
59
+ /*----------- Change View ---------*/
60
+
61
+ .change-view {
62
+ padding: 5px 0px;
63
+ clear: both;
64
+ .change-card{
65
+ font-weight: bold;
66
+ }
67
+ .last-update {
68
+ float:right;
69
+ text-align: right;
70
+ a {
71
+ white-space: nowrap;
72
+ }
73
+ }
74
+ }
75
+
76
+ .diff-deleted {
77
+ text-decoration: line-through;
78
+ color: $red;
79
+ background: $red-200;
80
+ img {
81
+ border: 2px solid $red;
82
+ }
83
+ }
84
+ .diff-added {
85
+ color: $green;
86
+ background: $green-200;
87
+ text-decoration: none;
88
+ img {
89
+ margin: 0px 4px 0px 4px;
90
+ border: 2px solid $green;
91
+ }
92
+ }
data/data/test.yml ADDED
@@ -0,0 +1,11 @@
1
+ ---
2
+ - :name: First
3
+ :content: egg
4
+ - :name: First
5
+ :content: chicken
6
+ - :name: First
7
+ :content: chick
8
+ :user: Joe User
9
+ :time: "+1"
10
+ # note: user and time change ensures card is not considered pristine and won't be
11
+ # updated.
@@ -9,13 +9,7 @@ class Card
9
9
  end
10
10
 
11
11
  def subtitle
12
- wrap_with :small do
13
- [
14
- @format.link_to_card(@act.actor, nil, class: "_stop_propagation"),
15
- edited_ago,
16
- rollback_link
17
- ]
18
- end
12
+ actor_and_ago
19
13
  end
20
14
 
21
15
  # FIXME: how do we know we need main here??
@@ -4,8 +4,8 @@ class Card
4
4
  # Used for the bridge
5
5
  class BridgeActRenderer < RelativeActRenderer
6
6
  def title
7
- wrap_with(:div, left_title, class: "mr-2") +
8
- wrap_with(:div, right_title, class: "ml-auto act-summary")
7
+ wrap_with(:div, left_title, class: "me-2") +
8
+ wrap_with(:div, right_title, class: "ms-auto act-summary")
9
9
  end
10
10
 
11
11
  def left_title
@@ -25,7 +25,7 @@ class Card
25
25
  def bridge_link
26
26
  opts = @format.bridge_link_opts(
27
27
  path: { act_id: @act.id, view: :bridge_act, act_seq: @args[:act_seq] },
28
- "data-toggle": "pill"
28
+ "data-bs-toggle": "pill"
29
29
  )
30
30
  add_class opts, "d-flex nav-link"
31
31
  opts[:path].delete :layout
@@ -6,9 +6,7 @@ class Card
6
6
  # for the card of the format that renders the act.
7
7
  class RelativeActRenderer < ActRenderer
8
8
  def title
9
- %(<span class="nr">##{@args[:act_seq]}</span>) +
10
- accordion_expand_link(@act.actor.name) +
11
- wrap_with(:small, edited_ago)
9
+ %(<span class="nr">##{@args[:act_seq]}</span> #{actor_and_ago})
12
10
  end
13
11
 
14
12
  def subtitle
@@ -25,8 +23,7 @@ class Card
25
23
 
26
24
  def rollback_or_edit_link
27
25
  if @act.draft?
28
- autosaved_draft_link text: "continue editing",
29
- class: "collapse #{collapse_id}"
26
+ autosaved_draft_link text: "continue editing"
30
27
  elsif show_rollback_link?
31
28
  rollback_link
32
29
  end
@@ -52,6 +49,31 @@ class Card
52
49
  { class: "_close-modal",
53
50
  "data-slotter-mode": "update-modal-origin" }
54
51
  end
52
+
53
+ # Revert:
54
+ # current update
55
+ # Restore:
56
+ # current deletion
57
+ # Revert and Restore:
58
+ # old deletions
59
+ # blank:
60
+ # current create
61
+ # save as current:
62
+ # not current, not deletion
63
+ def rollback_link
64
+ return unless @card.ok? :update
65
+
66
+ wrap_with :div, class: "act-link float-end" do
67
+ content_tag(:small, revert_link)
68
+
69
+ # link_to "Save as current",
70
+ # class: "slotter", remote: true,
71
+ # method: :post, rel: "nofollow",
72
+ # "data-slot-selector" => ".card-slot.history-view",
73
+ # path: { action: :update, action_ids: prior,
74
+ # view: :open, look_in_trash: true }
75
+ end
76
+ end
55
77
  end
56
78
  end
57
79
  end
@@ -25,44 +25,50 @@ class Card
25
25
  end
26
26
 
27
27
  def render
28
- return "" unless @act_card
29
-
30
- act_accordion
28
+ @act_card ? accordion_item : ""
31
29
  end
32
30
 
33
31
  def header
34
32
  # Card::Bootstrap.new(self).render do
35
33
  bs_layout do
36
- row xs: [10, 2] do
34
+ row xs: [8, 4], class: "w-100" do
37
35
  column do
38
36
  html title
39
- tag(:span, "text-muted pl-1 badge") { summary }
37
+ tag(:span, "text-muted ps-1 badge") { summary }
40
38
  end
41
- column act_links, class: "text-right"
39
+ column subtitle, class: "text-end"
42
40
  end
43
41
  end
44
42
  # end
45
43
  end
46
44
 
47
45
  def absolute_title
48
- accordion_expand_link(@act_card.name)
46
+ @act_card.name
47
+ end
48
+
49
+ def actor_and_ago
50
+ wrap_with(:small) { [@format.link_to_card(@act.actor), edited_ago] }
49
51
  end
50
52
 
51
53
  def details
52
54
  approved_actions[0..20].map do |action|
53
- Action::ActionRenderer.new(@format, action, action_header?,
54
- :summary).render
55
+ Action::ActionRenderer.new(@format, action, true, :summary).render
55
56
  end.join
56
57
  end
57
58
 
58
59
  def summary
59
60
  %i[create update delete draft].map do |type|
60
- next unless count_types[type].positive?
61
-
62
- "#{@format.action_icon type}<small> #{count_types[type]}</small>"
61
+ action_summary type
63
62
  end.compact.join "<small class='text-muted'> | </small>"
64
63
  end
65
64
 
65
+ def action_summary type
66
+ count = count_types[type]
67
+ return unless count.positive?
68
+
69
+ "#{@format.action_icon type}<small> #{count if count > 1}</small>"
70
+ end
71
+
66
72
  def act_links
67
73
  [
68
74
  link_to_history,
@@ -86,12 +92,6 @@ class Card
86
92
  # FIXME: should not need to test for presence of card here.
87
93
  end
88
94
 
89
- def action_header?
90
- true
91
- # @action_header ||= approved_actions.size != 1 ||
92
- # approved_actions[0].card_id != @format.card.id
93
- end
94
-
95
95
  def count_types
96
96
  @count_types ||=
97
97
  approved_actions.each_with_object(
@@ -107,104 +107,28 @@ class Card
107
107
  "#{time_ago_in_words(@act.acted_at)} ago"
108
108
  end
109
109
 
110
- def collapse_id
111
- "act-id-#{@act.id}"
112
- end
113
-
114
- def accordion_expand_link text
115
- <<-HTML
116
- <a>
117
- #{text}
118
- </a>
119
- HTML
120
- end
121
-
122
- # TODO: change accordion API in bootstrap/helper.rb so that it can be used
123
- # here. The problem is that here we have extra links in the title
124
- # that are not supposed to expand the accordion
125
- def act_accordion
126
- context = @act.main_action&.draft ? :warning : :default
127
- <<-HTML
128
- <div class="card card-#{context} nodblclick">
129
- #{act_accordion_panel}
130
- </div>
131
- HTML
132
- end
133
-
134
- def accordion_expand_options
135
- {
136
- "data-toggle" => "collapse",
137
- "data-target" => ".#{collapse_id}",
138
- "aria-expanded" => true,
139
- "aria-controls" => collapse_id
140
- }
141
- end
142
-
143
- def act_panel_options
144
- { class: "card-header", role: "tab", id: "heading-#{collapse_id}" }
145
- end
146
-
147
- def act_accordion_panel
148
- act_accordion_heading + act_accordion_body
149
- end
150
-
151
- def act_accordion_heading
152
- wrap_with :div, act_panel_options.merge(accordion_expand_options) do
153
- wrap_with(:h5, header, class: "mb-0") + subtitle
154
- end
155
- end
156
-
157
- def act_accordion_body
158
- wrap_with :div, id: collapse_id,
159
- class: "collapse #{collapse_id}",
160
- "data-parent": ".act-accordion-group" do
161
- wrap_with :div, details, class: "card-body"
162
- end
163
- end
164
-
165
- # Revert:
166
- # current update
167
- # Restore:
168
- # current deletion
169
- # Revert and Restore:
170
- # old deletions
171
- # blank:
172
- # current create
173
- # save as current:
174
- # not current, not deletion
175
- def rollback_link
176
- return unless @card.ok? :update
177
-
178
- wrap_with :div, class: "act-link collapse #{collapse_id} float-right" do
179
- content_tag(:small, revert_link)
180
-
181
- # link_to "Save as current",
182
- # class: "slotter", remote: true,
183
- # method: :post, rel: "nofollow",
184
- # "data-slot-selector" => ".card-slot.history-view",
185
- # path: { action: :update, action_ids: prior,
186
- # view: :open, look_in_trash: true }
187
- end
188
- end
189
-
190
- def deletion_act?
191
- act_type == :delete
110
+ def accordion_item
111
+ # context = @act.main_action&.draft ? :warning : :default
112
+ @format.accordion_item header,
113
+ subheader: act_links,
114
+ body: details, collapse_id: "act-id-#{@act.id}"
192
115
  end
193
116
 
194
117
  def act_type
195
118
  @act.main_action.action_type
196
119
  end
197
120
 
198
- def show_or_hide_changes_link
199
- wrap_with :div, class: "act-link" do
200
- @format.link_to_view(
201
- :act, "#{@args[:hide_diff] ? 'Show' : 'Hide'} changes",
202
- path: { act_id: @args[:act].id, act_seq: @args[:act_seq],
203
- hide_diff: !@args[:hide_diff], action_view: :expanded,
204
- act_context: @args[:act_context], look_in_trash: true }
205
- )
206
- end
207
- end
121
+ # TODO: get this working again, perhaps in action
122
+ # def show_or_hide_changes_link
123
+ # wrap_with :div, class: "act-link" do
124
+ # @format.link_to_view(
125
+ # :act, "#{@args[:hide_diff] ? 'Show' : 'Hide'} changes",
126
+ # path: { act_id: @act.id, act_seq: @args[:act_seq],
127
+ # hide_diff: !@args[:hide_diff], action_view: :expanded,
128
+ # act_context: @args[:act_context], look_in_trash: true }
129
+ # )
130
+ # end
131
+ # end
208
132
 
209
133
  def autosaved_draft_link opts={}
210
134
  text = opts.delete(:text) || "autosaved draft"
@@ -43,7 +43,7 @@ class Card
43
43
  bs_panel do
44
44
  if header
45
45
  heading do
46
- div type_diff, class: "float-right"
46
+ div type_diff, class: "float-end"
47
47
  div name_diff
48
48
  end
49
49
  end
@@ -54,6 +54,9 @@ class Card
54
54
  end
55
55
 
56
56
  def name_diff
57
+ return @action.card.name if @action.card.name.compound?
58
+ # TODO: handle compound names better
59
+
57
60
  if @action.card == @format.card
58
61
  name_changes
59
62
  else
@@ -2,13 +2,13 @@ class Card
2
2
  class Action
3
3
  # a collection of methods for comparing actions
4
4
  module Differ
5
- # compare action's name value with previous name value
6
- # @return [rendered diff]
7
- def name_diff opts={}
8
- return unless new_name?
9
-
10
- diff_object(:name, opts).complete
11
- end
5
+ # # compare action's name value with previous name value
6
+ # # @return [rendered diff]
7
+ # def name_diff opts={}
8
+ # return unless new_name?
9
+ #
10
+ # diff_object(:name, opts).complete
11
+ # end
12
12
 
13
13
  # does action change card's name?
14
14
  # @return [true/false]
@@ -45,17 +45,17 @@ class Card
45
45
  !value(:db_content).nil?
46
46
  end
47
47
 
48
- # test whether content was visibly removed
49
- # @return [true/false]
50
- def red?
51
- content_diff_object.red?
52
- end
53
-
54
- # test whether content was visibly added
55
- # @return [true/false]
56
- def green?
57
- content_diff_object.green?
58
- end
48
+ # # test whether content was visibly removed
49
+ # # @return [true/false]
50
+ # def red?
51
+ # content_diff_object.red?
52
+ # end
53
+ #
54
+ # # test whether content was visibly added
55
+ # # @return [true/false]
56
+ # def green?
57
+ # content_diff_object.green?
58
+ # end
59
59
 
60
60
  def raw_view content=nil
61
61
  original_content = card.db_content
data/lib/card/action.rb CHANGED
@@ -77,23 +77,6 @@ class Card
77
77
  # @return [Card]
78
78
  def card
79
79
  Card.fetch card_id, look_in_trash: true
80
-
81
- # I'm not sure what the rationale for the following was/is, but it was causing
82
- # problems in cases where slot attributes are overridden (eg see #wrap_data in
83
- # sources on wikirate). The problem is the format object had the set modules but
84
- # the card didn't.
85
- #
86
- # My guess is that the need for the following had something to do with errors
87
- # associated with changed types. If so, the solution probably needs to handle
88
- # including the set modules associated with the type at the time of the action
89
- # rather than including no set modules at all.
90
- #
91
- # What's more, we _definitely_ don't want to hard code special behavior for
92
- # specific types in here!
93
-
94
- # , skip_modules: true
95
- # return res unless res && res.type_id.in?([Card::FileID, Card::ImageID])
96
- # res.include_set_modules
97
80
  end
98
81
 
99
82
  # remove action from action cache
@@ -0,0 +1 @@
1
+ Cardio::Railtie.config.acts_per_page = 10
@@ -16,7 +16,7 @@ format :html do
16
16
  bs_layout container: false, fluid: false do
17
17
  html _render_act_legend(draft_legend => :draft_legend)
18
18
  row(12) { act_list acts, context }
19
- row(12) { act_paging acts, context }
19
+ # row(12) { act_paging acts, context }
20
20
  end
21
21
  end
22
22
 
@@ -43,7 +43,9 @@ format :html do
43
43
  end
44
44
 
45
45
  def act_accordion acts, context, &block
46
- accordion_group acts_for_accordion(acts, context, &block), nil, class: "clear-both"
46
+ accordion do
47
+ acts_for_accordion(acts, context, &block).join
48
+ end
47
49
  end
48
50
 
49
51
  def acts_for_accordion acts, context
@@ -4,21 +4,6 @@ def all_action_ids
4
4
  Card::Action.where(card_id: id).pluck :id
5
5
  end
6
6
 
7
- def action_from_id action_id
8
- return unless action_id.is_a?(Integer) || action_id =~ /^\d+$/
9
-
10
- # if not an integer, action_id is probably a mod (e.g. if you request
11
- # files/:logo/standard.png)
12
-
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
20
- end
21
-
22
7
  def old_actions
23
8
  actions.where("id != ?", last_action_id)
24
9
  end
@@ -35,16 +20,6 @@ def nth_action index
35
20
  .order(:id).limit(1).offset(index - 1).first
36
21
  end
37
22
 
38
- def new_content_action_id
39
- return unless @current_action && current_action_changes_content?
40
-
41
- @current_action.id
42
- end
43
-
44
- def current_action_changes_content?
45
- new_card? || @current_action.new_content? || db_content_is_changing?
46
- end
47
-
48
23
  format :html do
49
24
  def action_from_context
50
25
  if (action_id = voo.action_id || params[:action_id])
@@ -82,7 +57,7 @@ format :html do
82
57
 
83
58
  def toggle_action_content_link action, view_type
84
59
  other_view_type = view_type == :expanded ? :summary : :expanded
85
- css_class = "revision-#{action.card_act_id} float-right"
60
+ css_class = "revision-#{action.card_act_id} float-end"
86
61
  link_to_view "action_#{other_view_type}",
87
62
  icon_tag(action_arrow_dir(view_type), class: "md-24"),
88
63
  class: css_class,
@@ -1,5 +1,5 @@
1
1
  # must be called on all actions and before :set_name, :process_subcards and
2
- # :validate_delete_children
2
+ # :delete_children
3
3
  event :assign_action, :initialize, when: :actionable? do
4
4
  act = director.need_act
5
5
  @current_action = Card::Action.create(
@@ -90,7 +90,8 @@ event :finalize_act, after: :finalize_action, when: :act_card? do
90
90
  Card::Director.act.update! card_id: id
91
91
  end
92
92
 
93
- event :remove_empty_act, :integrate_with_delay_final, when: :remove_empty_act? do
93
+ event :remove_empty_act, :integrate_with_delay_final,
94
+ priority: 100, when: :remove_empty_act? do
94
95
  # Card::Director.act.delete
95
96
  # Card::Director.act = nil
96
97
  end
@@ -12,9 +12,7 @@ end
12
12
 
13
13
  def select_action_by_params params
14
14
  action = nth_action(params[:rev]) || action_from_id(params[:rev_id])
15
- return unless action
16
-
17
- select_action action.id
15
+ select_action action.id if action
18
16
  end
19
17
 
20
18
  def select_action action_id
@@ -62,3 +60,29 @@ end
62
60
  def selected_content_action_id
63
61
  @selected_action_id || new_content_action_id || last_content_action_id
64
62
  end
63
+
64
+ private
65
+
66
+ def new_content_action_id
67
+ return unless @current_action && current_action_changes_content?
68
+
69
+ @current_action.id
70
+ end
71
+
72
+ def current_action_changes_content?
73
+ new_card? || @current_action.new_content? || db_content_is_changing?
74
+ end
75
+
76
+ def action_from_id action_id
77
+ return unless action_id.is_a?(Integer) || action_id =~ /^\d+$/
78
+ # if not an integer, action_id is probably a mod (e.g. if you request
79
+ # files/:logo/standard.png)
80
+
81
+ action_if_on_self Action.fetch(action_id)
82
+ end
83
+
84
+ def action_if_on_self action
85
+ return unless action.is_a? Action
86
+
87
+ action if action.card_id == id
88
+ end
@@ -14,9 +14,9 @@ format :html do
14
14
 
15
15
  view :act_legend do
16
16
  bs_layout do
17
- row md: [12, 12], lg: [7, 5] do
17
+ row md: [12, 12], lg: [7, 5], class: "pb-3" do
18
18
  col action_legend
19
- col content_legend, class: "text-right"
19
+ col content_legend, class: "text-end"
20
20
  end
21
21
  end
22
22
  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.14.1
4
+ version: 0.15.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: 2022-01-04 00:00:00.000000000 Z
13
+ date: 2023-01-04 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.104.1
21
+ version: 1.105.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.104.1
28
+ version: 1.105.0
29
29
  description: ''
30
30
  email:
31
31
  - info@decko.org
@@ -33,6 +33,8 @@ executables: []
33
33
  extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
+ - assets/style/history.scss
37
+ - data/test.yml
36
38
  - lib/card/act.rb
37
39
  - lib/card/act/act_renderer.rb
38
40
  - lib/card/act/act_renderer/absolute_act_renderer.rb
@@ -44,6 +46,7 @@ files:
44
46
  - lib/card/action/changes.rb
45
47
  - lib/card/action/differ.rb
46
48
  - lib/card/change.rb
49
+ - lib/card/mod/history.rb
47
50
  - locales/de.yml
48
51
  - locales/en.yml
49
52
  - set/all/history.rb
@@ -66,6 +69,7 @@ metadata:
66
69
  wiki_uri: https://decko.org
67
70
  documentation_url: http://docs.decko.org/
68
71
  card-mod: history
72
+ card-mod-group: gem-defaults
69
73
  post_install_message:
70
74
  rdoc_options: []
71
75
  require_paths:
@@ -81,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
85
  - !ruby/object:Gem::Version
82
86
  version: '0'
83
87
  requirements: []
84
- rubygems_version: 3.2.15
88
+ rubygems_version: 3.3.11
85
89
  signing_key:
86
90
  specification_version: 4
87
91
  summary: Revision histories in acts, actions, and changes