card 1.16.8 → 1.16.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/db/migrate_core_cards/{20150611203506_rails_inflection_updates.rb → 20120611203506_rails_inflection_updates.rb} +0 -0
- data/db/migrate_core_cards/20150326205655_bootswatch_themes.rb +0 -1
- data/db/migrate_core_cards/20150429090551_search_card_context.rb +1 -1
- data/db/migrate_core_cards/20150708224756_add_list_cards.rb +22 -0
- data/db/seed/new/card_actions.yml +789 -509
- data/db/seed/new/card_acts.yml +1 -1
- data/db/seed/new/card_changes.yml +2618 -1920
- data/db/seed/new/card_references.yml +1034 -901
- data/db/seed/new/cards.yml +2303 -1675
- data/db/seed/test/fixtures/card_actions.yml +1926 -1606
- data/db/seed/test/fixtures/card_acts.yml +354 -324
- data/db/seed/test/fixtures/card_changes.yml +5950 -5175
- data/db/seed/test/fixtures/card_references.yml +1861 -1630
- data/db/seed/test/fixtures/cards.yml +3768 -3048
- data/db/seed/test/seed.rb +121 -107
- data/lib/card.rb +2 -3
- data/lib/card/active_record_helper.rb +44 -0
- data/lib/card/auth.rb +51 -47
- data/lib/card/cache.rb +7 -3
- data/lib/card/codename.rb +7 -7
- data/lib/card/format.rb +2 -1
- data/lib/card/migration.rb +17 -16
- data/lib/card/name.rb +71 -20
- data/lib/card/set.rb +202 -166
- data/lib/card/simplecov_helper.rb +11 -7
- data/lib/card/subcards.rb +249 -0
- data/mod/01_core/set/all/collection.rb +1 -2
- data/mod/01_core/set/all/fetch.rb +167 -92
- data/mod/01_core/set/all/initialize.rb +8 -22
- data/mod/01_core/set/all/name.rb +128 -79
- data/mod/01_core/set/all/phases.rb +93 -95
- data/mod/01_core/set/all/subcards.rb +70 -0
- data/mod/01_core/set/all/tracked_attributes.rb +83 -59
- data/mod/01_core/set/all/trash.rb +14 -12
- data/mod/01_core/set/all/type.rb +3 -24
- data/mod/01_core/spec/set/all/initialize_spec.rb +44 -14
- data/mod/01_core/spec/set/all/permissions_spec.rb +206 -185
- data/mod/01_core/spec/set/all/tracked_attributes_spec.rb +0 -10
- data/mod/01_core/spec/set/all/trash_spec.rb +38 -13
- data/mod/01_core/spec/set/all/type_spec.rb +0 -19
- data/mod/01_history/set/all/content_history.rb +5 -3
- data/mod/01_history/set/all/history.rb +117 -82
- data/mod/02_basic_types/set/all/base.rb +50 -49
- data/mod/03_machines/lib/card/machine.rb +2 -1
- data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +55 -17
- data/mod/03_machines/spec/set/type/javascript_spec.rb +18 -12
- data/mod/05_email/set/right/followers.rb +5 -5
- data/mod/05_email/set/right/following.rb +1 -1
- data/mod/05_email/set/type_plus_right/user/follow.rb +1 -1
- data/mod/05_standard/lib/carrier_wave/cardmount.rb +19 -11
- data/mod/05_standard/lib/file_uploader.rb +1 -1
- data/mod/05_standard/set/abstract/attachment.rb +20 -8
- data/mod/05_standard/set/all/list_changes.rb +43 -0
- data/mod/05_standard/set/all/rich_html/form.rb +21 -11
- data/mod/05_standard/set/all/rich_html/menu.rb +1 -1
- data/mod/05_standard/set/right/account.rb +5 -5
- data/mod/05_standard/set/self/head.rb +0 -1
- data/mod/05_standard/set/self/signin.rb +43 -35
- data/mod/05_standard/set/type/file.rb +9 -2
- data/mod/05_standard/set/type/list.rb +134 -0
- data/mod/05_standard/set/type/listed_by.rb +94 -0
- data/mod/05_standard/set/type/search_type.rb +62 -61
- data/mod/05_standard/set/type/signup.rb +94 -63
- data/mod/05_standard/set/type/user.rb +48 -39
- data/mod/05_standard/spec/set/all/account_spec.rb +1 -1
- data/mod/05_standard/spec/set/all/rich_html/form_spec.rb +2 -2
- data/mod/05_standard/spec/set/self/signin_spec.rb +23 -27
- data/mod/05_standard/spec/set/type/email_template_spec.rb +0 -2
- data/mod/05_standard/spec/set/type/list_spec.rb +140 -0
- data/mod/05_standard/spec/set/type/listed_by_spec.rb +157 -0
- data/mod/05_standard/spec/set/type/signup_spec.rb +38 -32
- data/spec/lib/card/subcards_spec.rb +126 -0
- metadata +14 -3
@@ -35,19 +35,9 @@ include RenameMethods
|
|
35
35
|
|
36
36
|
describe Card::Set::All::TrackedAttributes do
|
37
37
|
|
38
|
-
describe '#extract_subcard_args!' do
|
39
|
-
it "should move plus keys into subcard hash" do
|
40
|
-
raw_args = { 'name'=>'test', 'subcards'=>{ '+*oldway'=>{'content'=>'old'}, }, '+*newway'=>{'content'=>'new'} }
|
41
|
-
subcards = Card.new.extract_subcard_args! raw_args
|
42
|
-
expect(raw_args['subcards']).to be_nil
|
43
|
-
expect(subcards.keys.sort).to eq(['+*newway', '+*oldway'])
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
38
|
|
48
39
|
describe 'set_name' do
|
49
40
|
|
50
|
-
|
51
41
|
it "should handle case variants" do
|
52
42
|
@c = Card.create! name: 'chump'
|
53
43
|
expect(@c.name).to eq('chump')
|
@@ -1,25 +1,24 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
describe Card::Set::All::Trash do
|
4
|
-
|
5
|
-
|
4
|
+
subject do
|
5
|
+
card = Card[@name]
|
6
6
|
Card::Auth.as_bot do
|
7
|
-
name = '*all+*default'
|
8
|
-
card = Card[name]
|
9
7
|
card.delete
|
10
|
-
expect(card.errors[:delete].first).to eq("#{name} is an indestructible rule")
|
11
|
-
expect(Card[name]).to be
|
12
8
|
end
|
9
|
+
card.errors[:delete].first
|
10
|
+
end
|
11
|
+
|
12
|
+
it "certain 'all rules' should be indestructable" do
|
13
|
+
@name = '*all+*default'
|
14
|
+
is_expected.to eq("#{@name} is an indestructible rule")
|
15
|
+
expect(Card[@name]).to be
|
13
16
|
end
|
14
17
|
|
15
18
|
it 'does not delete account with edits' do
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
card.delete
|
20
|
-
expect(card.errors[:delete].first).to match("Edits have been made with #{name}'s user account")
|
21
|
-
expect(Card[name]).to be
|
22
|
-
end
|
19
|
+
@name = 'Joe User'
|
20
|
+
is_expected.to match("Edits have been made with #{@name}'s user account")
|
21
|
+
expect(Card[@name]).to be
|
23
22
|
end
|
24
23
|
|
25
24
|
it 'deletes account without edits' do
|
@@ -31,4 +30,30 @@ describe Card::Set::All::Trash do
|
|
31
30
|
end
|
32
31
|
end
|
33
32
|
|
33
|
+
it 'deletes children' do
|
34
|
+
Card::Auth.as_bot do
|
35
|
+
name = 'born to die'
|
36
|
+
card = Card.create! name: name, '+sub' => 'a subcard'
|
37
|
+
expect(Card["#{name}+sub"]).to be
|
38
|
+
card.delete
|
39
|
+
expect(Card["#{name}+sub"]).not_to be
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'deletes account of user' do
|
44
|
+
Card::Auth.as_bot do
|
45
|
+
@signup = Card.create!(
|
46
|
+
name: 'born to die', type_id: Card::SignupID,
|
47
|
+
'+*account' => { '+*email' => 'wolf@wagn.org', '+*password' => 'wolf' }
|
48
|
+
)
|
49
|
+
@signup.update_attributes!({})
|
50
|
+
end
|
51
|
+
Card::Cache.reset_global
|
52
|
+
|
53
|
+
Card::Auth.as_bot do
|
54
|
+
expect(Card.search :right=>'*account').not_to be_empty
|
55
|
+
Card['born to die'].delete!
|
56
|
+
end
|
57
|
+
expect(Card['born to die+*account']).not_to be
|
58
|
+
end
|
34
59
|
end
|
@@ -1,25 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
describe Card::Set::All::Type do
|
4
|
-
|
5
|
-
describe 'get_type_id (#new)' do
|
6
|
-
it "should accept cardtype name and casespace variant as type" do
|
7
|
-
expect(Card.new( type: 'Phrase' ).type_id).to eq(Card::PhraseID)
|
8
|
-
expect(Card.new( type: 'PHRASE' ).type_id).to eq(Card::PhraseID)
|
9
|
-
expect(Card.new( type: 'phrase' ).type_id).to eq(Card::PhraseID)
|
10
|
-
expect(Card.new( type: 'phrase??' ).type_id).to eq(Card::PhraseID)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should accept type_code' do
|
14
|
-
expect(Card.new( type_code: 'phrase' ).type_id).to eq(Card::PhraseID)
|
15
|
-
expect(Card.new( type_code: :phrase ).type_id).to eq(Card::PhraseID)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should accept type_id' do
|
19
|
-
expect(Card.new( type_id: Card::PhraseID ).type_code).to eq(:phrase)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
4
|
describe 'card with wagneered type' do
|
24
5
|
before do
|
25
6
|
Card::Auth.as_bot do
|
@@ -88,11 +88,13 @@ def last_action
|
|
88
88
|
end
|
89
89
|
|
90
90
|
def last_content_action
|
91
|
-
l_c = last_change_on
|
91
|
+
l_c = last_change_on :db_content
|
92
|
+
l_c && l_c.action
|
92
93
|
end
|
93
94
|
|
94
95
|
def last_content_action_id
|
95
|
-
l_c = last_change_on
|
96
|
+
l_c = last_change_on :db_content
|
97
|
+
l_c && l_c.card_action_id
|
96
98
|
end
|
97
99
|
|
98
100
|
def last_actor
|
@@ -100,7 +102,7 @@ def last_actor
|
|
100
102
|
end
|
101
103
|
|
102
104
|
def last_act
|
103
|
-
if action = last_action
|
105
|
+
if (action = last_action)
|
104
106
|
last_act_on_self = acts.last
|
105
107
|
if last_act_on_self and ( action.act==last_act_on_self || last_act_on_self.acted_at>action.act.acted_at )
|
106
108
|
last_act_on_self
|
@@ -4,23 +4,35 @@ def history?
|
|
4
4
|
true
|
5
5
|
end
|
6
6
|
|
7
|
-
# must be called on all actions and before :set_name, :process_subcards and
|
8
|
-
|
9
|
-
|
7
|
+
# must be called on all actions and before :set_name, :process_subcards and
|
8
|
+
# :validate_delete_children
|
9
|
+
event :assign_act,
|
10
|
+
before: :prepare,
|
11
|
+
when: proc { |c| c.history? || c.respond_to?(:attachment) } do
|
12
|
+
@current_act = (@supercard && @supercard.current_act) ||
|
13
|
+
Card::Act.create(ip_address: Env.ip)
|
10
14
|
end
|
11
15
|
|
12
16
|
event :assign_action, after: :assign_act do
|
13
|
-
@current_action = Card::Action.create(
|
14
|
-
|
17
|
+
@current_action = Card::Action.create(
|
18
|
+
card_act_id: @current_act.id, action_type: @action,
|
19
|
+
draft: (Env.params['draft'] == 'true')
|
20
|
+
)
|
21
|
+
if @supercard && @supercard != self
|
15
22
|
@current_action.super_action = @supercard.current_action
|
16
23
|
end
|
17
24
|
end
|
18
25
|
|
19
|
-
|
20
26
|
# stores changes in the changes table and assigns them to the current action
|
21
27
|
# removes the action if there are no changes
|
22
|
-
event :finalize_action,
|
23
|
-
|
28
|
+
event :finalize_action,
|
29
|
+
after: :stored,
|
30
|
+
when: proc { |c|
|
31
|
+
(c.history? || c.respond_to?(:attachment)) && c.current_action
|
32
|
+
} do
|
33
|
+
@changed_fields = Card::TRACKED_FIELDS.select do |f|
|
34
|
+
changed_attributes.member? f
|
35
|
+
end
|
24
36
|
if @changed_fields.present?
|
25
37
|
@changed_fields.each{ |f| Card::Change.create field: f, value: self[f], card_action_id: @current_action.id }
|
26
38
|
@current_action.update_attributes! card_id: id
|
@@ -30,7 +42,9 @@ event :finalize_action, after: :stored, when: proc {|c| (c.history? || c.respond
|
|
30
42
|
end
|
31
43
|
end
|
32
44
|
|
33
|
-
event :finalize_act,
|
45
|
+
event :finalize_act,
|
46
|
+
after: :finalize_action,
|
47
|
+
when: proc { |c| !c.supercard } do
|
34
48
|
if @current_act.actions(true).empty?
|
35
49
|
@current_act.delete
|
36
50
|
@current_act = nil
|
@@ -39,9 +53,10 @@ event :finalize_act, after: :finalize_action, when: proc {|c| !c.supercard } do
|
|
39
53
|
end
|
40
54
|
end
|
41
55
|
|
42
|
-
|
43
|
-
|
44
|
-
|
56
|
+
event :rollback_actions,
|
57
|
+
before: :approve, on: :update,
|
58
|
+
when: proc { |c| c.rollback_request? } do
|
59
|
+
revision = { subcards: {} }
|
45
60
|
rollback_actions = Env.params['action_ids'].map do |a_id|
|
46
61
|
Action.fetch(a_id) || nil
|
47
62
|
end
|
@@ -62,18 +77,20 @@ event :rollback_actions, before: :approve, on: :update, when: proc{ |c| c.rollba
|
|
62
77
|
end
|
63
78
|
|
64
79
|
def rollback_request?
|
65
|
-
history? && Env && Env.params['action_ids'] &&
|
80
|
+
history? && Env && Env.params['action_ids'] &&
|
81
|
+
Env.params['action_ids'].class == Array
|
66
82
|
end
|
67
83
|
|
68
|
-
# alternative approach to handle act and action that doesn't change the
|
69
|
-
# stopped working with Rails 4
|
84
|
+
# alternative approach to handle act and action that doesn't change the
|
85
|
+
# database in the beginning stopped working with Rails 4
|
70
86
|
# def build_act_and_action
|
71
87
|
# @current_act = if @supercard
|
72
88
|
# @supercard.current_act || @supercard.acts.build(ip_address: Env.ip)
|
73
89
|
# else
|
74
90
|
# acts.build(ip_address: Env.ip)
|
75
91
|
# end
|
76
|
-
# @current_action = actions(true).build(action_type: @action, draft:
|
92
|
+
# @current_action = actions(true).build(action_type: @action, draft:
|
93
|
+
# (Env.params['draft'] == 'true') )
|
77
94
|
# @current_action.act = @current_act
|
78
95
|
#
|
79
96
|
# if (@supercard and @supercard !=self)
|
@@ -81,27 +98,35 @@ end
|
|
81
98
|
# end
|
82
99
|
# end
|
83
100
|
|
84
|
-
|
85
|
-
|
101
|
+
# all acts with actions on self and on cards that are descendants of self and
|
102
|
+
# included in self
|
103
|
+
def intrusive_family_acts args={}
|
86
104
|
@intrusive_family_acts ||= begin
|
87
|
-
Act.find_all_with_actions_on(
|
105
|
+
Act.find_all_with_actions_on((included_descendant_card_ids << id), args)
|
88
106
|
end
|
89
107
|
end
|
90
108
|
|
91
|
-
|
109
|
+
# all acts with actions on self and on cards included in self
|
110
|
+
def intrusive_acts args={ with_drafts: true }
|
92
111
|
@intrusive_acts ||= begin
|
93
|
-
Act.find_all_with_actions_on(
|
112
|
+
Act.find_all_with_actions_on((included_card_ids << id), args)
|
94
113
|
end
|
95
114
|
end
|
96
115
|
|
97
116
|
def current_rev_nr
|
98
117
|
@current_rev_nr ||= begin
|
99
|
-
intrusive_acts.first.actions.last.draft
|
118
|
+
if intrusive_acts.first.actions.last.draft
|
119
|
+
@intrusive_acts.size - 1
|
120
|
+
else
|
121
|
+
@intrusive_acts.size
|
122
|
+
end
|
100
123
|
end
|
101
124
|
end
|
102
125
|
|
103
126
|
def included_card_ids
|
104
|
-
Card::Reference.select(:referee_id).where(
|
127
|
+
Card::Reference.select(:referee_id).where(
|
128
|
+
ref_type: 'I', referer_id: id
|
129
|
+
).pluck('referee_id').compact.uniq
|
105
130
|
end
|
106
131
|
|
107
132
|
def descendant_card_ids parent_ids=[id]
|
@@ -119,7 +144,7 @@ end
|
|
119
144
|
|
120
145
|
format :html do
|
121
146
|
view :history do |args|
|
122
|
-
frame args.merge(body_class:
|
147
|
+
frame args.merge(body_class: 'history-slot list-group', content: true) do
|
123
148
|
[
|
124
149
|
history_legend,
|
125
150
|
_render_revisions
|
@@ -132,10 +157,10 @@ format :html do
|
|
132
157
|
|
133
158
|
view :revisions do |args|
|
134
159
|
page = params['page'] || 1
|
135
|
-
count = card.intrusive_acts.size+1-(page.to_i-1)*REVISIONS_PER_PAGE
|
160
|
+
count = card.intrusive_acts.size + 1 - (page.to_i - 1) * REVISIONS_PER_PAGE
|
136
161
|
card.intrusive_acts.page(page).per(REVISIONS_PER_PAGE).map do |act|
|
137
162
|
count -= 1
|
138
|
-
render_act_summary args.merge(act: act,rev_nr: count)
|
163
|
+
render_act_summary args.merge(act: act, rev_nr: count)
|
139
164
|
end.join
|
140
165
|
end
|
141
166
|
|
@@ -149,11 +174,11 @@ format :html do
|
|
149
174
|
%div.history-legend
|
150
175
|
%span.glyphicon.glyphicon-plus-sign.diff-green
|
151
176
|
%span
|
152
|
-
= Card::Diff.render_added_chunk(
|
177
|
+
= Card::Diff.render_added_chunk('Added')
|
153
178
|
|
|
154
179
|
%span.glyphicon.glyphicon-minus-sign.diff-red
|
155
180
|
%span
|
156
|
-
= Card::Diff.render_deleted_chunk(
|
181
|
+
= Card::Diff.render_deleted_chunk('Deleted')
|
157
182
|
HAML
|
158
183
|
end
|
159
184
|
end
|
@@ -167,11 +192,13 @@ format :html do
|
|
167
192
|
end
|
168
193
|
|
169
194
|
def render_act act_view, args
|
170
|
-
act = (params['act_id']
|
195
|
+
act = (params['act_id'] && Card::Act.find(params['act_id'])) || args[:act]
|
171
196
|
rev_nr = params['rev_nr'] || args[:rev_nr]
|
172
|
-
current_rev_nr = params['current_rev_nr'] || args[:current_rev_nr] ||
|
173
|
-
|
174
|
-
|
197
|
+
current_rev_nr = params['current_rev_nr'] || args[:current_rev_nr] ||
|
198
|
+
card.current_rev_nr
|
199
|
+
hide_diff = (params['hide_diff'] == ' true') || args[:hide_diff]
|
200
|
+
args[:slot_class] = "revision-#{act.id} history-slot list-group-item"
|
201
|
+
wrap(args) do
|
175
202
|
render_haml card: card, act: act, act_view: act_view,
|
176
203
|
current_rev_nr: current_rev_nr, rev_nr: rev_nr,
|
177
204
|
hide_diff: hide_diff do
|
@@ -182,7 +209,7 @@ format :html do
|
|
182
209
|
= "##{rev_nr}"
|
183
210
|
.title
|
184
211
|
.actor
|
185
|
-
= link_to act.actor.name, card_url(
|
212
|
+
= link_to act.actor.name, card_url(act.actor.cardname.url_key)
|
186
213
|
.time.timeago
|
187
214
|
= time_ago_in_words(act.acted_at)
|
188
215
|
ago
|
@@ -215,33 +242,15 @@ HAML
|
|
215
242
|
render_action :expanded, args
|
216
243
|
end
|
217
244
|
|
245
|
+
|
218
246
|
def render_action action_view, args
|
219
247
|
action = args[:action] || card.last_action
|
220
|
-
hide_diff = Env.params[
|
221
|
-
name_diff =
|
222
|
-
if action.card == card
|
223
|
-
name_changes(action, hide_diff)
|
224
|
-
else
|
225
|
-
link_to name_changes(action, hide_diff),
|
226
|
-
path(view: :related, related: {view: "history",name: action.card.name}),
|
227
|
-
class: 'slotter label label-default',
|
228
|
-
'data-slot-selector'=>".card-slot.history-view",
|
229
|
-
remote: true
|
230
|
-
end
|
231
|
-
|
232
|
-
type_diff =
|
233
|
-
action.new_type? &&
|
234
|
-
type_changes(action, hide_diff)
|
235
|
-
|
236
|
-
content_diff =
|
237
|
-
action.new_content? &&
|
238
|
-
action.card.format.render_content_changes(action: action, diff_type: action_view, hide_diff: hide_diff)
|
239
|
-
|
248
|
+
hide_diff = Env.params['hide_diff'] == 'true' || args[:hide_diff]
|
240
249
|
render_haml action: action,
|
241
250
|
action_view: action_view,
|
242
|
-
name_diff: name_diff,
|
243
|
-
type_diff: type_diff,
|
244
|
-
content_diff: content_diff do
|
251
|
+
name_diff: name_diff(action, hide_diff),
|
252
|
+
type_diff: type_diff(action, hide_diff),
|
253
|
+
content_diff: content_diff(action, action_view, hide_diff) do
|
245
254
|
<<-HAML
|
246
255
|
.action
|
247
256
|
.summary
|
@@ -261,27 +270,48 @@ HAML
|
|
261
270
|
end
|
262
271
|
end
|
263
272
|
|
264
|
-
def
|
265
|
-
if
|
266
|
-
|
267
|
-
<span class="#{field}-diff">
|
268
|
-
#{content}
|
269
|
-
</span>
|
270
|
-
}
|
273
|
+
def name_diff action, hide_diff
|
274
|
+
if action.card == card
|
275
|
+
name_changes(action, hide_diff)
|
271
276
|
else
|
272
|
-
|
277
|
+
link_path = path(
|
278
|
+
view: :related,
|
279
|
+
related: { view: 'history', name: action.card.name }
|
280
|
+
)
|
281
|
+
link_to name_changes(action, hide_diff), link_path,
|
282
|
+
class: 'slotter label label-default',
|
283
|
+
'data-slot-selector' => '.card-slot.history-view',
|
284
|
+
remote: true
|
273
285
|
end
|
274
286
|
end
|
275
287
|
|
288
|
+
def type_diff action, hide_diff
|
289
|
+
action.new_type? && type_changes(action, hide_diff)
|
290
|
+
end
|
291
|
+
|
292
|
+
def content_diff action, action_view, hide_diff
|
293
|
+
action.new_content? && action.card.format.render_content_changes(
|
294
|
+
action: action, diff_type: action_view, hide_diff: hide_diff
|
295
|
+
)
|
296
|
+
end
|
297
|
+
|
298
|
+
def wrap_diff field, content
|
299
|
+
return '' unless content.present?
|
300
|
+
%{
|
301
|
+
<span class="#{field}-diff">
|
302
|
+
#{content}
|
303
|
+
</span>
|
304
|
+
}
|
305
|
+
end
|
276
306
|
|
277
307
|
def name_changes action, hide_diff=false
|
278
|
-
old_name = (name = action.old_values[:name]
|
308
|
+
old_name = (name = action.old_values[:name]) && showname(name).to_s
|
279
309
|
if action.new_name?
|
280
310
|
new_name = showname(action.new_values[:name]).to_s
|
281
311
|
if hide_diff
|
282
312
|
new_name
|
283
313
|
else
|
284
|
-
Card::Diff.complete(old_name,new_name)
|
314
|
+
Card::Diff.complete(old_name, new_name)
|
285
315
|
end
|
286
316
|
else
|
287
317
|
old_name
|
@@ -293,7 +323,6 @@ HAML
|
|
293
323
|
"(#{change})"
|
294
324
|
end
|
295
325
|
|
296
|
-
|
297
326
|
view :content_changes do |args|
|
298
327
|
if args[:hide_diff]
|
299
328
|
args[:action].new_values[:content]
|
@@ -303,33 +332,39 @@ HAML
|
|
303
332
|
end
|
304
333
|
|
305
334
|
def rollback_link actions
|
306
|
-
not_current =
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
335
|
+
not_current =
|
336
|
+
actions.select { |action| action.card.last_action_id != action.id }
|
337
|
+
return unless card.ok?(:update) && not_current.present?
|
338
|
+
link_path = path action: :update, view: :open, action_ids: not_current
|
339
|
+
'| ' + link_to(
|
340
|
+
'Save as current', link_path,
|
341
|
+
class: 'slotter', 'data-slot-selector' => '.card-slot.history-view',
|
342
|
+
remote: true, method: :post, rel: 'nofollow'
|
343
|
+
)
|
311
344
|
end
|
312
345
|
|
313
346
|
def fold_or_unfold_link args
|
314
|
-
|
315
|
-
|
316
|
-
else
|
317
|
-
toggled_view = :act_expanded
|
318
|
-
end
|
347
|
+
toggled_view = args[:act_view] == :expanded ? :act_summary : :act_expanded
|
348
|
+
arrow_dir = args[:act_view] == :expanded ? 'arrow-down' : 'arrow-right'
|
319
349
|
link_to '', args.merge(view: toggled_view),
|
320
|
-
class: "slotter revision-#{args[:act_id]} #{
|
350
|
+
class: "slotter revision-#{args[:act_id]} #{arrow_dir}",
|
321
351
|
remote: true
|
322
352
|
end
|
323
353
|
|
324
354
|
def show_or_hide_changes_link hide_diff, args
|
325
|
-
|
355
|
+
text = (hide_diff ? 'Show' : 'Hide') + ' changes'
|
356
|
+
'| ' + view_link(
|
357
|
+
text, :act_expanded,
|
326
358
|
path_opts: args.merge(hide_diff: !hide_diff),
|
327
|
-
class: 'slotter', remote: true
|
359
|
+
class: 'slotter', remote: true
|
360
|
+
)
|
328
361
|
end
|
329
362
|
end
|
330
363
|
|
331
364
|
def diff_args
|
332
|
-
{format: :text}
|
365
|
+
{ format: :text }
|
333
366
|
end
|
334
367
|
|
335
|
-
|
368
|
+
def has_edits?
|
369
|
+
Card::Act.where(actor_id: id).where('card_id IS NOT NULL').present?
|
370
|
+
end
|