card 1.16.9 → 1.16.10
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/20120611203506_rails_inflection_updates.rb +3 -1
- data/db/seed/new/card_actions.yml +389 -557
- data/db/seed/new/card_acts.yml +595 -1
- data/db/seed/new/card_changes.yml +22595 -7526
- data/db/seed/new/card_references.yml +379 -407
- data/db/seed/new/cards.yml +1694 -2072
- data/db/seed/test/fixtures/card_actions.yml +966 -1102
- data/db/seed/test/fixtures/card_acts.yml +1017 -399
- data/db/seed/test/fixtures/card_changes.yml +24750 -9681
- data/db/seed/test/fixtures/card_references.yml +603 -631
- data/db/seed/test/fixtures/cards.yml +2293 -2671
- data/lib/card/set.rb +1 -1
- data/mod/01_core/set/all/content.rb +14 -12
- data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +1 -1
- data/mod/05_standard/set/abstract/attachment.rb +9 -9
- data/mod/05_standard/set/all/rich_html/content.rb +115 -103
- data/mod/05_standard/set/type/file.rb +1 -1
- data/tmpsets/set/mod001-01_core/all/active_card.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/collection.rb +3 -3
- data/tmpsets/set/mod001-01_core/all/content.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/erb.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/fetch.rb +169 -93
- data/tmpsets/set/mod001-01_core/all/haml.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/initialize.rb +11 -23
- data/tmpsets/set/mod001-01_core/all/name.rb +130 -80
- data/tmpsets/set/mod001-01_core/all/pattern.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/permissions.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/phases.rb +95 -96
- data/tmpsets/set/mod001-01_core/all/references.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/rules.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/states.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/templating.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +85 -60
- data/tmpsets/set/mod001-01_core/all/trash.rb +16 -13
- data/tmpsets/set/mod001-01_core/all/type.rb +5 -25
- data/tmpsets/set/mod001-01_core/all/utils.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/view_cache.rb +2 -1
- data/tmpsets/set/mod002-01_history/all/actions.rb +2 -1
- data/tmpsets/set/mod002-01_history/all/content_history.rb +7 -4
- data/tmpsets/set/mod002-01_history/all/history.rb +119 -83
- data/tmpsets/set/mod003-02_basic_types/all/all_css.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/all/all_csv.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/all/all_js.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/all/base.rb +52 -50
- data/tmpsets/set/mod003-02_basic_types/all/file.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/all/json.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/all/rss.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/all/text.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/type/html.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +2 -1
- data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +10 -1
- data/tmpsets/set/mod004-03_machines/right/machine_input.rb +2 -1
- data/tmpsets/set/mod004-03_machines/right/machine_output.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_ace.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_card_menu.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_html5shiv_printshiv.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_jquery.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_jquery_helper.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_slot.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/script_tinymce.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/style_bootstrap_compatible.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/style_cards.rb +2 -1
- data/tmpsets/set/mod004-03_machines/self/style_jquery_ui_smoothness.rb +2 -1
- data/tmpsets/set/mod004-03_machines/type/coffee_script.rb +2 -1
- data/tmpsets/set/mod004-03_machines/type/css.rb +2 -1
- data/tmpsets/set/mod004-03_machines/type/java_script.rb +2 -1
- data/tmpsets/set/mod004-03_machines/type/scss.rb +2 -1
- data/tmpsets/set/mod004-03_machines/type/skin.rb +2 -1
- data/tmpsets/set/mod005-04_settings/abstract/permission.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/add_help.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/comment.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/create.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/default.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/delete.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/help.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/read.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/script.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/structure.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/style.rb +2 -1
- data/tmpsets/set/mod005-04_settings/right/update.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/accountable.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/add_help.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/autoname.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/captcha.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/create.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/default.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/delete.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/help.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/input.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/layout.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/on_create.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/on_delete.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/on_update.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/options.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/options_label.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/read.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/recent_settings.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/script.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/structure.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/style.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/table_of_contents.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/thanks.rb +2 -1
- data/tmpsets/set/mod005-04_settings/self/update.rb +2 -1
- data/tmpsets/set/mod005-04_settings/type/setting.rb +2 -1
- data/tmpsets/set/mod006-05_email/all/email_html.rb +2 -1
- data/tmpsets/set/mod006-05_email/all/email_text.rb +2 -1
- data/tmpsets/set/mod006-05_email/all/follow.rb +2 -1
- data/tmpsets/set/mod006-05_email/all/notify.rb +2 -1
- data/tmpsets/set/mod006-05_email/all/observer.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/bcc.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/cc.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/follow.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/follow_fields.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/followers.rb +7 -6
- data/tmpsets/set/mod006-05_email/right/following.rb +3 -2
- data/tmpsets/set/mod006-05_email/right/from.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/html_message.rb +2 -1
- data/tmpsets/set/mod006-05_email/right/to.rb +2 -1
- data/tmpsets/set/mod006-05_email/self/always.rb +2 -1
- data/tmpsets/set/mod006-05_email/self/created.rb +2 -1
- data/tmpsets/set/mod006-05_email/self/edited.rb +2 -1
- data/tmpsets/set/mod006-05_email/self/follow.rb +2 -1
- data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +2 -1
- data/tmpsets/set/mod006-05_email/self/never.rb +2 -1
- data/tmpsets/set/mod006-05_email/type/email_template.rb +2 -1
- data/tmpsets/set/mod006-05_email/type_plus_right/user/follow.rb +3 -2
- data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +22 -9
- data/tmpsets/set/mod007-05_standard/all/account.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/comment.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/error.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/event_viz.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/links.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +3 -2
- data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +23 -12
- data/tmpsets/set/mod007-05_standard/all/rich_html/header.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/rich_html/menu.rb +3 -2
- data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +2 -1
- data/tmpsets/set/mod007-05_standard/all/rich_html/wrapper.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/account.rb +7 -6
- data/tmpsets/set/mod007-05_standard/right/discussion.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/email.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/password.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/salt.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/stats.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/status.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/token.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/when_created.rb +2 -1
- data/tmpsets/set/mod007-05_standard/right/when_last_edited.rb +2 -1
- data/tmpsets/set/mod007-05_standard/rstar/rules.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/account_links.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/alerts.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/all.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/foot.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/head.rb +2 -2
- data/tmpsets/set/mod007-05_standard/self/navbox.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/now.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/recent.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/search.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/signin.rb +45 -36
- data/tmpsets/set/mod007-05_standard/self/stats.rb +2 -1
- data/tmpsets/set/mod007-05_standard/self/version.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/basic.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/cardtype.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/date.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/file.rb +11 -3
- data/tmpsets/set/mod007-05_standard/type/image.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/layout_type.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/number.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/phrase.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/search_type.rb +70 -64
- data/tmpsets/set/mod007-05_standard/type/session.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/set.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/signup.rb +96 -64
- data/tmpsets/set/mod007-05_standard/type/toggle.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/uri.rb +2 -1
- data/tmpsets/set/mod007-05_standard/type/user.rb +50 -40
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/form.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/wrapper.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/all/rich_bootstrap.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/self/bootstrap_cards.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/self/bootstrap_js.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/self/bootswatch_shared.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/self/smartmenu_css.rb +2 -1
- data/tmpsets/set/mod008-06_bootstrap/self/smartmenu_js.rb +2 -1
- metadata +2 -2
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module References; extend Card::Set
|
2
|
+
class Card; module Set; module All; module References; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/references.rb ~~~~~~~~~~~
|
3
4
|
|
4
5
|
def name_referencers link_name=nil
|
5
6
|
link_name = link_name.nil? ? key : link_name.to_name.key
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module Rules; extend Card::Set
|
2
|
+
class Card; module Set; module All; module Rules; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/rules.rb ~~~~~~~~~~~
|
3
4
|
|
4
5
|
|
5
6
|
RuleSQL = %{
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module States; extend Card::Set
|
2
|
+
class Card; module Set; module All; module States; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/states.rb ~~~~~~~~~~~
|
3
4
|
def new_card?
|
4
5
|
new_record? || # not yet in db (from ActiveRecord)
|
5
6
|
!!@from_trash # in process of restoration from trash, not yet "re-created"
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module Templating; extend Card::Set
|
2
|
+
class Card; module Set; module All; module Templating; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/templating.rb ~~~~~~~~~~~
|
3
4
|
|
4
5
|
def is_template?
|
5
6
|
cardname.trait_name? :structure, :default
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module TrackedAttributes; extend Card::Set
|
3
|
-
#
|
2
|
+
class Card; module Set; module All; module TrackedAttributes; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/tracked_attributes.rb ~~~~~~~~~~~
|
4
4
|
def assign_attributes args={}
|
5
5
|
if args
|
6
6
|
args = args.stringify_keys
|
@@ -10,127 +10,152 @@ def assign_attributes args={}
|
|
10
10
|
@set_specific[key] = args.delete(key) if args[key]
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@subcards = extract_subcard_args! args
|
13
|
+
new_type_id = extract_type_id! args unless args.delete('skip_type_lookup')
|
14
|
+
subcard_args = extract_subcard_args! args
|
15
|
+
args['type_id'] = new_type_id if new_type_id
|
17
16
|
reset_patterns
|
18
17
|
end
|
19
18
|
params = ActionController::Parameters.new(args)
|
20
19
|
params.permit!
|
21
20
|
super params
|
21
|
+
return unless args && subcard_args.present?
|
22
|
+
# name= must come before process subcards
|
23
|
+
subcards.add subcard_args
|
22
24
|
end
|
23
25
|
|
24
26
|
def assign_set_specific_attributes
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
27
|
+
return unless @set_specific && @set_specific.present?
|
28
|
+
@set_specific.each_pair do |name, value|
|
29
|
+
send "#{name}=", value
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
|
-
|
33
|
-
|
33
|
+
protected
|
34
|
+
|
35
|
+
def extract_subcard_args! args
|
36
|
+
subcards = args.delete('subcards') || {}
|
34
37
|
args.keys.each do |key|
|
35
38
|
if key =~ /^\+/
|
36
|
-
|
37
|
-
val = { 'content' => val } if String === val
|
38
|
-
extracted_subcards[key] = val
|
39
|
+
subcards[key] = args.delete(key)
|
39
40
|
end
|
40
41
|
end
|
41
|
-
|
42
|
+
subcards
|
42
43
|
end
|
43
44
|
|
45
|
+
def extract_type_id! args={}
|
46
|
+
type_id =
|
47
|
+
case
|
48
|
+
when args['type_id']
|
49
|
+
id = args.delete('type_id').to_i
|
50
|
+
# type_id can come in as 0,'' or nil
|
51
|
+
id == 0 ? nil : id
|
52
|
+
when args['type_code']
|
53
|
+
Card.fetch_id args.delete('type_code').to_sym
|
54
|
+
when args['type']
|
55
|
+
Card.fetch_id args.delete('type')
|
56
|
+
else
|
57
|
+
return nil
|
58
|
+
end
|
44
59
|
|
45
|
-
|
60
|
+
if !type_id
|
61
|
+
errors.add :type, "#{args[:type] || args[:type_code]} is not a known type."
|
62
|
+
end
|
63
|
+
type_id
|
64
|
+
end
|
46
65
|
|
47
66
|
event :set_content, before: :store, on: :save do
|
48
|
-
self.db_content = content || '' #necessary?
|
49
|
-
self.db_content = Card::Content.clean!
|
67
|
+
self.db_content = content || '' # necessary?
|
68
|
+
self.db_content = Card::Content.clean!(db_content) if clean_html?
|
50
69
|
@selected_action_id = @selected_content = nil
|
51
70
|
clear_drafts
|
52
71
|
reset_patterns_if_rule saving=true
|
53
72
|
end
|
54
73
|
|
55
|
-
|
56
|
-
#
|
74
|
+
# FIXME: the following don't really belong here, but they have to come after
|
75
|
+
# the reference stuff. we need to organize a bit!
|
57
76
|
|
58
77
|
event :update_ruled_cards, after: :store do
|
59
78
|
if is_rule?
|
60
|
-
#
|
79
|
+
# warn "updating ruled cards for #{name}"
|
61
80
|
self.class.clear_rule_cache
|
62
81
|
set = rule_set
|
63
82
|
set.reset_set_patterns
|
64
83
|
|
65
|
-
if right_id==Card::ReadID
|
84
|
+
if right_id == Card::ReadID && (name_changed? || trash_changed?)
|
66
85
|
self.class.clear_read_rule_cache
|
67
86
|
Card.cache.reset # maybe be more surgical, just Auth.user related
|
68
|
-
expire #probably shouldn't be necessary,
|
69
|
-
# but was sometimes getting cached version when card should be in the
|
70
|
-
# could be related to other bugs?
|
87
|
+
expire # probably shouldn't be necessary,
|
88
|
+
# but was sometimes getting cached version when card should be in the
|
89
|
+
# trash. could be related to other bugs?
|
71
90
|
in_set = {}
|
72
|
-
if !(
|
73
|
-
if class_id =
|
91
|
+
if !trash && set && (set_class = set.tag)
|
92
|
+
if (class_id = set_class.id)
|
74
93
|
rule_class_ids = set_patterns.map &:pattern_id
|
75
|
-
#warn "rule_class_id #{class_id}, #{rule_class_ids.inspect}"
|
76
|
-
|
77
|
-
#first update all cards in set that aren't governed by narrower rule
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
end
|
94
|
+
# warn "rule_class_id #{class_id}, #{rule_class_ids.inspect}"
|
95
|
+
|
96
|
+
# first update all cards in set that aren't governed by narrower rule
|
97
|
+
Auth.as_bot do
|
98
|
+
cur_index = rule_class_ids.index Card[read_rule_class].id
|
99
|
+
if (rule_class_index = rule_class_ids.index(class_id))
|
100
|
+
set.item_cards(limit: 0).each do |item_card|
|
101
|
+
in_set[item_card.key] = true
|
102
|
+
next if cur_index < rule_class_index
|
103
|
+
if cur_index >= rule_class_index
|
104
|
+
item_card.update_read_rule
|
87
105
|
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
106
|
+
end
|
107
|
+
# elsif rule_class_index = rule_class_ids.index( 0 )
|
108
|
+
# in_set[trunk.key] = true
|
109
|
+
# #warn "self rule update: #{trunk.inspect}, #{rule_class_index},
|
110
|
+
# #{cur_index}"
|
111
|
+
# trunk.update_read_rule if cur_index > rule_class_index
|
112
|
+
else warn "No current rule index #{class_id}, " \
|
113
|
+
"#{rule_class_ids.inspect}"
|
114
|
+
end
|
94
115
|
end
|
95
116
|
|
96
117
|
end
|
97
118
|
end
|
98
119
|
|
99
|
-
#then find all cards with me as read_rule_id that were not just updated
|
120
|
+
# then find all cards with me as read_rule_id that were not just updated
|
121
|
+
# and regenerate their read_rules
|
100
122
|
if !new_record?
|
101
|
-
Card.where(
|
102
|
-
in_set[
|
103
|
-
end.each
|
123
|
+
Card.where(read_rule_id: self.id, trash: false).reject do |w|
|
124
|
+
in_set[w.key]
|
125
|
+
end.each(&:update_read_rule)
|
104
126
|
end
|
105
127
|
end
|
106
|
-
|
107
128
|
end
|
108
129
|
end
|
109
130
|
|
110
131
|
event :process_read_rule_update_queue, after: :store do
|
111
|
-
Array.wrap(@read_rule_update_queue).each
|
132
|
+
Array.wrap(@read_rule_update_queue).each(&:update_read_rule)
|
112
133
|
@read_rule_update_queue = []
|
113
134
|
end
|
114
135
|
|
115
136
|
# set_callback :store, :after, :process_read_rule_update_queue, prepend: true
|
116
137
|
|
117
138
|
event :expire_related, after: :store do
|
118
|
-
|
139
|
+
subcards.keys.each do |key|
|
140
|
+
Card.cache.delete_local key
|
141
|
+
end
|
142
|
+
expire true
|
119
143
|
|
120
144
|
if self.is_structure?
|
121
|
-
|
122
|
-
Card.expire name
|
145
|
+
structuree_names.each do |name|
|
146
|
+
Card.expire name, true
|
123
147
|
end
|
124
148
|
end
|
125
|
-
|
149
|
+
|
150
|
+
# FIXME: really shouldn't be instantiating all the following bastards.
|
151
|
+
# Just need the key.
|
126
152
|
# fix in id_cache branch
|
127
|
-
|
128
|
-
# self.referencers.each { |c| c.expire }
|
129
|
-
|
153
|
+
dependents.each { |c| c.expire(true) }
|
154
|
+
# self.referencers.each { |c| c.expire(true) }
|
155
|
+
name_referencers.each { |c| c.expire(true) }
|
130
156
|
# FIXME: this will need review when we do the new defaults/templating system
|
131
157
|
end
|
132
158
|
|
133
159
|
|
134
|
-
|
135
160
|
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/tracked_attributes.rb ~~~~~~~~~~~
|
136
161
|
end;end;end;end;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module Trash; extend Card::Set
|
2
|
+
class Card; module Set; module All; module Trash; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/trash.rb ~~~~~~~~~~~
|
3
4
|
def delete
|
4
5
|
update_attributes trash: true unless new_card?
|
5
6
|
end
|
@@ -8,13 +9,15 @@ def delete!
|
|
8
9
|
update_attributes! trash: true unless new_card?
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
12
|
event :pull_from_trash, before: :store, on: :create do
|
13
|
-
if trashed_card = Card.find_by_key_and_trash(key, true)
|
14
|
-
# a. (Rails way) tried Card.where(key: 'wagn_bot').select(:id), but it
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
13
|
+
if (trashed_card = Card.find_by_key_and_trash(key, true))
|
14
|
+
# a. (Rails way) tried Card.where(key: 'wagn_bot').select(:id), but it
|
15
|
+
# wouldn't work. This #select generally breaks on cards. I think our
|
16
|
+
# initialization process screws with something
|
17
|
+
# b. (Wagn way) we could get card directly from fetch if we add
|
18
|
+
# :include_trashed (eg).
|
19
|
+
# likely low ROI, but would be nice to have interface to retrieve cards
|
20
|
+
# from trash...m
|
18
21
|
self.id = trashed_card.id
|
19
22
|
@from_trash = true
|
20
23
|
@new_record = false
|
@@ -29,20 +32,21 @@ event :validate_delete, before: :approve, on: :delete do
|
|
29
32
|
end
|
30
33
|
|
31
34
|
undeletable_all_rules_tags = %w{ default style layout create read update delete }
|
32
|
-
if junction?
|
35
|
+
if junction? && (l = left) && l.codename == 'all' &&
|
36
|
+
undeletable_all_rules_tags.member?(right.codename)
|
33
37
|
errors.add :delete, "#{name} is an indestructible rule"
|
34
38
|
end
|
35
39
|
|
36
|
-
if account &&
|
37
|
-
errors.add :delete, "Edits have been made with #{name}'s user account.\
|
40
|
+
if account && self.has_edits?
|
41
|
+
errors.add :delete, "Edits have been made with #{name}'s user account.\n" \
|
42
|
+
'Deleting this card would mess up our history.'
|
38
43
|
end
|
39
44
|
end
|
40
45
|
|
41
46
|
event :validate_delete_children, after: :approve, on: :delete do
|
42
47
|
children.each do |child|
|
43
|
-
child.supercard = self
|
44
|
-
subcards[child.name]=child
|
45
48
|
child.trash = true
|
49
|
+
add_subcard child
|
46
50
|
unless child.valid?
|
47
51
|
child.errors.each do |field, message|
|
48
52
|
errors.add field, "can't delete #{child.name}: #{message}"
|
@@ -52,6 +56,5 @@ event :validate_delete_children, after: :approve, on: :delete do
|
|
52
56
|
end
|
53
57
|
|
54
58
|
|
55
|
-
|
56
59
|
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/trash.rb ~~~~~~~~~~~
|
57
60
|
end;end;end;end;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module Type; extend Card::Set
|
2
|
+
class Card; module Set; module All; module Type; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/type.rb ~~~~~~~~~~~
|
3
4
|
|
4
5
|
module ClassMethods
|
5
6
|
def default_type_id
|
@@ -28,34 +29,13 @@ def type= type_name
|
|
28
29
|
self.type_id = Card.fetch_id type_name
|
29
30
|
end
|
30
31
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
type_id = case
|
35
|
-
when args[:type_code]
|
36
|
-
if code=args[:type_code]
|
37
|
-
Card::Codename[code] || ( c=Card[code] and c.id)
|
38
|
-
end
|
39
|
-
when args[:type]
|
40
|
-
Card.fetch_id args[:type]
|
41
|
-
else :noop
|
42
|
-
end
|
43
|
-
|
44
|
-
case type_id
|
45
|
-
when :noop
|
46
|
-
when false, nil
|
47
|
-
errors.add :type, "#{args[:type] || args[:type_code]} is not a known type."
|
48
|
-
else
|
49
|
-
return type_id
|
50
|
-
end
|
51
|
-
|
52
|
-
if name && t=template
|
53
|
-
reset_patterns #still necessary even with new template handling?
|
32
|
+
def get_type_id_from_structure
|
33
|
+
if name && (t = template)
|
34
|
+
reset_patterns # still necessary even with new template handling?
|
54
35
|
t.type_id
|
55
36
|
end
|
56
37
|
end
|
57
38
|
|
58
|
-
|
59
39
|
event :validate_type_change, before: :approve, on: :update, changed: :type_id do
|
60
40
|
if c = dup and c.action == :create and !c.valid?
|
61
41
|
errors.add :type, "of #{ name } can't be changed; errors creating new #{ type_id }: #{ c.errors.full_messages * ', ' }"
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module Utils; extend Card::Set
|
2
|
+
class Card; module Set; module All; module Utils; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/utils.rb ~~~~~~~~~~~
|
3
4
|
|
4
5
|
module ClassMethods
|
5
6
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module ViewCache; extend Card::Set
|
2
|
+
class Card; module Set; module All; module ViewCache; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_core/set/all/view_cache.rb ~~~~~~~~~~~
|
3
4
|
event :clear_view_cache, after: :store do
|
4
5
|
Card::ViewCache.reset
|
5
6
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module Actions; extend Card::Set
|
2
|
+
class Card; module Set; module All; module Actions; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_history/set/all/actions.rb ~~~~~~~~~~~
|
3
4
|
# -*- encoding : utf-8 -*-
|
4
5
|
|
5
6
|
def select_action_by_params params
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module ContentHistory; extend Card::Set
|
2
|
+
class Card; module Set; module All; module ContentHistory; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_history/set/all/content_history.rb ~~~~~~~~~~~
|
3
4
|
|
4
5
|
# if these aren't in a nested module, the methods just overwrite the base methods,
|
5
6
|
# but we need a distict module so that super will be able to refer to the base methods.
|
@@ -90,11 +91,13 @@ def last_action
|
|
90
91
|
end
|
91
92
|
|
92
93
|
def last_content_action
|
93
|
-
l_c = last_change_on
|
94
|
+
l_c = last_change_on :db_content
|
95
|
+
l_c && l_c.action
|
94
96
|
end
|
95
97
|
|
96
98
|
def last_content_action_id
|
97
|
-
l_c = last_change_on
|
99
|
+
l_c = last_change_on :db_content
|
100
|
+
l_c && l_c.card_action_id
|
98
101
|
end
|
99
102
|
|
100
103
|
def last_actor
|
@@ -102,7 +105,7 @@ def last_actor
|
|
102
105
|
end
|
103
106
|
|
104
107
|
def last_act
|
105
|
-
if action = last_action
|
108
|
+
if (action = last_action)
|
106
109
|
last_act_on_self = acts.last
|
107
110
|
if last_act_on_self and ( action.act==last_act_on_self || last_act_on_self.acted_at>action.act.acted_at )
|
108
111
|
last_act_on_self
|
@@ -1,28 +1,41 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
|
-
class Card; module Set; module All; module History; extend Card::Set
|
2
|
+
class Card; module Set; module All; module History; extend Card::Set
|
3
|
+
# ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/01_history/set/all/history.rb ~~~~~~~~~~~
|
3
4
|
REVISIONS_PER_PAGE = Card.config.revisions_per_page
|
4
5
|
|
5
6
|
def history?
|
6
7
|
true
|
7
8
|
end
|
8
9
|
|
9
|
-
# must be called on all actions and before :set_name, :process_subcards and
|
10
|
-
|
11
|
-
|
10
|
+
# must be called on all actions and before :set_name, :process_subcards and
|
11
|
+
# :validate_delete_children
|
12
|
+
event :assign_act,
|
13
|
+
before: :prepare,
|
14
|
+
when: proc { |c| c.history? || c.respond_to?(:attachment) } do
|
15
|
+
@current_act = (@supercard && @supercard.current_act) ||
|
16
|
+
Card::Act.create(ip_address: Env.ip)
|
12
17
|
end
|
13
18
|
|
14
19
|
event :assign_action, after: :assign_act do
|
15
|
-
@current_action = Card::Action.create(
|
16
|
-
|
20
|
+
@current_action = Card::Action.create(
|
21
|
+
card_act_id: @current_act.id, action_type: @action,
|
22
|
+
draft: (Env.params['draft'] == 'true')
|
23
|
+
)
|
24
|
+
if @supercard && @supercard != self
|
17
25
|
@current_action.super_action = @supercard.current_action
|
18
26
|
end
|
19
27
|
end
|
20
28
|
|
21
|
-
|
22
29
|
# stores changes in the changes table and assigns them to the current action
|
23
30
|
# removes the action if there are no changes
|
24
|
-
event :finalize_action,
|
25
|
-
|
31
|
+
event :finalize_action,
|
32
|
+
after: :stored,
|
33
|
+
when: proc { |c|
|
34
|
+
(c.history? || c.respond_to?(:attachment)) && c.current_action
|
35
|
+
} do
|
36
|
+
@changed_fields = Card::TRACKED_FIELDS.select do |f|
|
37
|
+
changed_attributes.member? f
|
38
|
+
end
|
26
39
|
if @changed_fields.present?
|
27
40
|
@changed_fields.each{ |f| Card::Change.create field: f, value: self[f], card_action_id: @current_action.id }
|
28
41
|
@current_action.update_attributes! card_id: id
|
@@ -32,7 +45,9 @@ event :finalize_action, after: :stored, when: proc {|c| (c.history? || c.respond
|
|
32
45
|
end
|
33
46
|
end
|
34
47
|
|
35
|
-
event :finalize_act,
|
48
|
+
event :finalize_act,
|
49
|
+
after: :finalize_action,
|
50
|
+
when: proc { |c| !c.supercard } do
|
36
51
|
if @current_act.actions(true).empty?
|
37
52
|
@current_act.delete
|
38
53
|
@current_act = nil
|
@@ -41,9 +56,10 @@ event :finalize_act, after: :finalize_action, when: proc {|c| !c.supercard } do
|
|
41
56
|
end
|
42
57
|
end
|
43
58
|
|
44
|
-
|
45
|
-
|
46
|
-
|
59
|
+
event :rollback_actions,
|
60
|
+
before: :approve, on: :update,
|
61
|
+
when: proc { |c| c.rollback_request? } do
|
62
|
+
revision = { subcards: {} }
|
47
63
|
rollback_actions = Env.params['action_ids'].map do |a_id|
|
48
64
|
Action.fetch(a_id) || nil
|
49
65
|
end
|
@@ -64,18 +80,20 @@ event :rollback_actions, before: :approve, on: :update, when: proc{ |c| c.rollba
|
|
64
80
|
end
|
65
81
|
|
66
82
|
def rollback_request?
|
67
|
-
history? && Env && Env.params['action_ids'] &&
|
83
|
+
history? && Env && Env.params['action_ids'] &&
|
84
|
+
Env.params['action_ids'].class == Array
|
68
85
|
end
|
69
86
|
|
70
|
-
# alternative approach to handle act and action that doesn't change the
|
71
|
-
# stopped working with Rails 4
|
87
|
+
# alternative approach to handle act and action that doesn't change the
|
88
|
+
# database in the beginning stopped working with Rails 4
|
72
89
|
# def build_act_and_action
|
73
90
|
# @current_act = if @supercard
|
74
91
|
# @supercard.current_act || @supercard.acts.build(ip_address: Env.ip)
|
75
92
|
# else
|
76
93
|
# acts.build(ip_address: Env.ip)
|
77
94
|
# end
|
78
|
-
# @current_action = actions(true).build(action_type: @action, draft:
|
95
|
+
# @current_action = actions(true).build(action_type: @action, draft:
|
96
|
+
# (Env.params['draft'] == 'true') )
|
79
97
|
# @current_action.act = @current_act
|
80
98
|
#
|
81
99
|
# if (@supercard and @supercard !=self)
|
@@ -83,27 +101,35 @@ end
|
|
83
101
|
# end
|
84
102
|
# end
|
85
103
|
|
86
|
-
|
87
|
-
|
104
|
+
# all acts with actions on self and on cards that are descendants of self and
|
105
|
+
# included in self
|
106
|
+
def intrusive_family_acts args={}
|
88
107
|
@intrusive_family_acts ||= begin
|
89
|
-
Act.find_all_with_actions_on(
|
108
|
+
Act.find_all_with_actions_on((included_descendant_card_ids << id), args)
|
90
109
|
end
|
91
110
|
end
|
92
111
|
|
93
|
-
|
112
|
+
# all acts with actions on self and on cards included in self
|
113
|
+
def intrusive_acts args={ with_drafts: true }
|
94
114
|
@intrusive_acts ||= begin
|
95
|
-
Act.find_all_with_actions_on(
|
115
|
+
Act.find_all_with_actions_on((included_card_ids << id), args)
|
96
116
|
end
|
97
117
|
end
|
98
118
|
|
99
119
|
def current_rev_nr
|
100
120
|
@current_rev_nr ||= begin
|
101
|
-
intrusive_acts.first.actions.last.draft
|
121
|
+
if intrusive_acts.first.actions.last.draft
|
122
|
+
@intrusive_acts.size - 1
|
123
|
+
else
|
124
|
+
@intrusive_acts.size
|
125
|
+
end
|
102
126
|
end
|
103
127
|
end
|
104
128
|
|
105
129
|
def included_card_ids
|
106
|
-
Card::Reference.select(:referee_id).where(
|
130
|
+
Card::Reference.select(:referee_id).where(
|
131
|
+
ref_type: 'I', referer_id: id
|
132
|
+
).pluck('referee_id').compact.uniq
|
107
133
|
end
|
108
134
|
|
109
135
|
def descendant_card_ids parent_ids=[id]
|
@@ -121,7 +147,7 @@ end
|
|
121
147
|
|
122
148
|
format :html do
|
123
149
|
view :history do |args|
|
124
|
-
frame args.merge(body_class:
|
150
|
+
frame args.merge(body_class: 'history-slot list-group', content: true) do
|
125
151
|
[
|
126
152
|
history_legend,
|
127
153
|
_render_revisions
|
@@ -134,10 +160,10 @@ format :html do
|
|
134
160
|
|
135
161
|
view :revisions do |args|
|
136
162
|
page = params['page'] || 1
|
137
|
-
count = card.intrusive_acts.size+1-(page.to_i-1)*REVISIONS_PER_PAGE
|
163
|
+
count = card.intrusive_acts.size + 1 - (page.to_i - 1) * REVISIONS_PER_PAGE
|
138
164
|
card.intrusive_acts.page(page).per(REVISIONS_PER_PAGE).map do |act|
|
139
165
|
count -= 1
|
140
|
-
render_act_summary args.merge(act: act,rev_nr: count)
|
166
|
+
render_act_summary args.merge(act: act, rev_nr: count)
|
141
167
|
end.join
|
142
168
|
end
|
143
169
|
|
@@ -151,11 +177,11 @@ format :html do
|
|
151
177
|
%div.history-legend
|
152
178
|
%span.glyphicon.glyphicon-plus-sign.diff-green
|
153
179
|
%span
|
154
|
-
= Card::Diff.render_added_chunk(
|
180
|
+
= Card::Diff.render_added_chunk('Added')
|
155
181
|
|
|
156
182
|
%span.glyphicon.glyphicon-minus-sign.diff-red
|
157
183
|
%span
|
158
|
-
= Card::Diff.render_deleted_chunk(
|
184
|
+
= Card::Diff.render_deleted_chunk('Deleted')
|
159
185
|
HAML
|
160
186
|
end
|
161
187
|
end
|
@@ -169,11 +195,13 @@ format :html do
|
|
169
195
|
end
|
170
196
|
|
171
197
|
def render_act act_view, args
|
172
|
-
act = (params['act_id']
|
198
|
+
act = (params['act_id'] && Card::Act.find(params['act_id'])) || args[:act]
|
173
199
|
rev_nr = params['rev_nr'] || args[:rev_nr]
|
174
|
-
current_rev_nr = params['current_rev_nr'] || args[:current_rev_nr] ||
|
175
|
-
|
176
|
-
|
200
|
+
current_rev_nr = params['current_rev_nr'] || args[:current_rev_nr] ||
|
201
|
+
card.current_rev_nr
|
202
|
+
hide_diff = (params['hide_diff'] == ' true') || args[:hide_diff]
|
203
|
+
args[:slot_class] = "revision-#{act.id} history-slot list-group-item"
|
204
|
+
wrap(args) do
|
177
205
|
render_haml card: card, act: act, act_view: act_view,
|
178
206
|
current_rev_nr: current_rev_nr, rev_nr: rev_nr,
|
179
207
|
hide_diff: hide_diff do
|
@@ -184,7 +212,7 @@ format :html do
|
|
184
212
|
= "##{rev_nr}"
|
185
213
|
.title
|
186
214
|
.actor
|
187
|
-
= link_to act.actor.name, card_url(
|
215
|
+
= link_to act.actor.name, card_url(act.actor.cardname.url_key)
|
188
216
|
.time.timeago
|
189
217
|
= time_ago_in_words(act.acted_at)
|
190
218
|
ago
|
@@ -217,33 +245,15 @@ HAML
|
|
217
245
|
render_action :expanded, args
|
218
246
|
end
|
219
247
|
|
248
|
+
|
220
249
|
def render_action action_view, args
|
221
250
|
action = args[:action] || card.last_action
|
222
|
-
hide_diff = Env.params[
|
223
|
-
name_diff =
|
224
|
-
if action.card == card
|
225
|
-
name_changes(action, hide_diff)
|
226
|
-
else
|
227
|
-
link_to name_changes(action, hide_diff),
|
228
|
-
path(view: :related, related: {view: "history",name: action.card.name}),
|
229
|
-
class: 'slotter label label-default',
|
230
|
-
'data-slot-selector'=>".card-slot.history-view",
|
231
|
-
remote: true
|
232
|
-
end
|
233
|
-
|
234
|
-
type_diff =
|
235
|
-
action.new_type? &&
|
236
|
-
type_changes(action, hide_diff)
|
237
|
-
|
238
|
-
content_diff =
|
239
|
-
action.new_content? &&
|
240
|
-
action.card.format.render_content_changes(action: action, diff_type: action_view, hide_diff: hide_diff)
|
241
|
-
|
251
|
+
hide_diff = Env.params['hide_diff'] == 'true' || args[:hide_diff]
|
242
252
|
render_haml action: action,
|
243
253
|
action_view: action_view,
|
244
|
-
name_diff: name_diff,
|
245
|
-
type_diff: type_diff,
|
246
|
-
content_diff: content_diff do
|
254
|
+
name_diff: name_diff(action, hide_diff),
|
255
|
+
type_diff: type_diff(action, hide_diff),
|
256
|
+
content_diff: content_diff(action, action_view, hide_diff) do
|
247
257
|
<<-HAML
|
248
258
|
.action
|
249
259
|
.summary
|
@@ -263,27 +273,48 @@ HAML
|
|
263
273
|
end
|
264
274
|
end
|
265
275
|
|
266
|
-
def
|
267
|
-
if
|
268
|
-
|
269
|
-
<span class="#{field}-diff">
|
270
|
-
#{content}
|
271
|
-
</span>
|
272
|
-
}
|
276
|
+
def name_diff action, hide_diff
|
277
|
+
if action.card == card
|
278
|
+
name_changes(action, hide_diff)
|
273
279
|
else
|
274
|
-
|
280
|
+
link_path = path(
|
281
|
+
view: :related,
|
282
|
+
related: { view: 'history', name: action.card.name }
|
283
|
+
)
|
284
|
+
link_to name_changes(action, hide_diff), link_path,
|
285
|
+
class: 'slotter label label-default',
|
286
|
+
'data-slot-selector' => '.card-slot.history-view',
|
287
|
+
remote: true
|
275
288
|
end
|
276
289
|
end
|
277
290
|
|
291
|
+
def type_diff action, hide_diff
|
292
|
+
action.new_type? && type_changes(action, hide_diff)
|
293
|
+
end
|
294
|
+
|
295
|
+
def content_diff action, action_view, hide_diff
|
296
|
+
action.new_content? && action.card.format.render_content_changes(
|
297
|
+
action: action, diff_type: action_view, hide_diff: hide_diff
|
298
|
+
)
|
299
|
+
end
|
300
|
+
|
301
|
+
def wrap_diff field, content
|
302
|
+
return '' unless content.present?
|
303
|
+
%{
|
304
|
+
<span class="#{field}-diff">
|
305
|
+
#{content}
|
306
|
+
</span>
|
307
|
+
}
|
308
|
+
end
|
278
309
|
|
279
310
|
def name_changes action, hide_diff=false
|
280
|
-
old_name = (name = action.old_values[:name]
|
311
|
+
old_name = (name = action.old_values[:name]) && showname(name).to_s
|
281
312
|
if action.new_name?
|
282
313
|
new_name = showname(action.new_values[:name]).to_s
|
283
314
|
if hide_diff
|
284
315
|
new_name
|
285
316
|
else
|
286
|
-
Card::Diff.complete(old_name,new_name)
|
317
|
+
Card::Diff.complete(old_name, new_name)
|
287
318
|
end
|
288
319
|
else
|
289
320
|
old_name
|
@@ -295,7 +326,6 @@ HAML
|
|
295
326
|
"(#{change})"
|
296
327
|
end
|
297
328
|
|
298
|
-
|
299
329
|
view :content_changes do |args|
|
300
330
|
if args[:hide_diff]
|
301
331
|
args[:action].new_values[:content]
|
@@ -305,36 +335,42 @@ HAML
|
|
305
335
|
end
|
306
336
|
|
307
337
|
def rollback_link actions
|
308
|
-
not_current =
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
338
|
+
not_current =
|
339
|
+
actions.select { |action| action.card.last_action_id != action.id }
|
340
|
+
return unless card.ok?(:update) && not_current.present?
|
341
|
+
link_path = path action: :update, view: :open, action_ids: not_current
|
342
|
+
'| ' + link_to(
|
343
|
+
'Save as current', link_path,
|
344
|
+
class: 'slotter', 'data-slot-selector' => '.card-slot.history-view',
|
345
|
+
remote: true, method: :post, rel: 'nofollow'
|
346
|
+
)
|
313
347
|
end
|
314
348
|
|
315
349
|
def fold_or_unfold_link args
|
316
|
-
|
317
|
-
|
318
|
-
else
|
319
|
-
toggled_view = :act_expanded
|
320
|
-
end
|
350
|
+
toggled_view = args[:act_view] == :expanded ? :act_summary : :act_expanded
|
351
|
+
arrow_dir = args[:act_view] == :expanded ? 'arrow-down' : 'arrow-right'
|
321
352
|
link_to '', args.merge(view: toggled_view),
|
322
|
-
class: "slotter revision-#{args[:act_id]} #{
|
353
|
+
class: "slotter revision-#{args[:act_id]} #{arrow_dir}",
|
323
354
|
remote: true
|
324
355
|
end
|
325
356
|
|
326
357
|
def show_or_hide_changes_link hide_diff, args
|
327
|
-
|
358
|
+
text = (hide_diff ? 'Show' : 'Hide') + ' changes'
|
359
|
+
'| ' + view_link(
|
360
|
+
text, :act_expanded,
|
328
361
|
path_opts: args.merge(hide_diff: !hide_diff),
|
329
|
-
class: 'slotter', remote: true
|
362
|
+
class: 'slotter', remote: true
|
363
|
+
)
|
330
364
|
end
|
331
365
|
end
|
332
366
|
|
333
367
|
def diff_args
|
334
|
-
{format: :text}
|
368
|
+
{ format: :text }
|
335
369
|
end
|
336
370
|
|
337
|
-
|
371
|
+
def has_edits?
|
372
|
+
Card::Act.where(actor_id: id).where('card_id IS NOT NULL').present?
|
373
|
+
end
|
338
374
|
|
339
375
|
|
340
376
|
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/01_history/set/all/history.rb ~~~~~~~~~~~
|