card 1.15.2 → 1.15.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +15 -0
  4. data/db/seed/new/card_actions.yml +342 -314
  5. data/db/seed/new/card_acts.yml +1 -1
  6. data/db/seed/new/card_changes.yml +1284 -1199
  7. data/db/seed/new/card_references.yml +664 -622
  8. data/db/seed/new/cards.yml +1355 -1278
  9. data/db/seed/test/fixtures/card_actions.yml +1239 -1204
  10. data/db/seed/test/fixtures/card_acts.yml +281 -275
  11. data/db/seed/test/fixtures/card_changes.yml +4127 -4022
  12. data/db/seed/test/fixtures/card_references.yml +1338 -1296
  13. data/db/seed/test/fixtures/cards.yml +2635 -2540
  14. data/db/version_core_cards.txt +1 -1
  15. data/lib/card/core_ext.rb +11 -7
  16. data/lib/card/format.rb +1 -1
  17. data/lib/card/name.rb +1 -1
  18. data/lib/card/set.rb +47 -47
  19. data/lib/card/simplecov_helper.rb +2 -2
  20. data/lib/card/spec_helper.rb +17 -7
  21. data/lib/card/view_name.rb +44 -0
  22. data/mod/01_core/chunk/include.rb +1 -1
  23. data/mod/01_core/set/all/collection.rb +90 -7
  24. data/mod/01_core/spec/set/all/collection_spec.rb +37 -3
  25. data/mod/01_history/lib/card/act.rb +15 -11
  26. data/mod/01_history/lib/card/action.rb +38 -38
  27. data/mod/01_history/set/all/history.rb +8 -4
  28. data/mod/02_basic_types/set/type/pointer.rb +29 -28
  29. data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +39 -0
  30. data/mod/03_machines/lib/stylesheets/style_cards.scss +6 -1
  31. data/mod/05_email/set/all/notify.rb +47 -49
  32. data/mod/05_email/set/self/follow_defaults.rb +7 -7
  33. data/mod/05_email/set/type_plus_right/user/follow.rb +1 -1
  34. data/mod/05_standard/set/all/error.rb +1 -1
  35. data/mod/05_standard/set/all/links.rb +1 -1
  36. data/mod/05_standard/set/all/rich_html/content.rb +23 -21
  37. data/mod/05_standard/set/all/rich_html/editing.rb +64 -8
  38. data/mod/05_standard/set/all/rich_html/form.rb +26 -26
  39. data/mod/05_standard/set/all/rich_html/header.rb +2 -2
  40. data/mod/05_standard/set/all/rich_html/menu.rb +9 -10
  41. data/mod/05_standard/set/all/rich_html/toolbar.rb +100 -71
  42. data/mod/05_standard/set/all/rich_html/wrapper.rb +6 -0
  43. data/mod/05_standard/set/right/discussion.rb +3 -0
  44. data/mod/05_standard/set/rstar/rules.rb +5 -24
  45. data/mod/05_standard/set/type/cardtype.rb +31 -2
  46. data/mod/05_standard/set/type/session.rb +29 -0
  47. data/mod/05_standard/set/type/set.rb +1 -1
  48. data/mod/05_standard/spec/set/all/rich_html/editing_spec.rb +60 -0
  49. data/mod/05_standard/spec/set/all/rich_html/form_spec.rb +6 -6
  50. data/mod/05_standard/spec/set/type/cardtype_spec.rb +15 -1
  51. data/mod/06_bootstrap/lib/javascript/bootstrap_modal_wagn.js +27 -0
  52. data/mod/06_bootstrap/set/all/rich_bootstrap.rb +4 -3
  53. data/mod/06_bootstrap/set/self/bootstrap_js.rb +3 -1
  54. metadata +8 -2
@@ -1,5 +1,9 @@
1
1
  REVISIONS_PER_PAGE = Card.config.revisions_per_page
2
2
 
3
+ def history?
4
+ true
5
+ end
6
+
3
7
  # must be called on all actions and before :set_name, :process_subcards and :validate_delete_children
4
8
  def create_act_and_action
5
9
  @current_act = if @supercard
@@ -18,11 +22,11 @@ end
18
22
 
19
23
 
20
24
 
21
- event(:create_act_and_action_for_save, :before=>:process_subcards, :on=>:save) { create_act_and_action }
22
- event(:create_act_and_action_for_delete, :before =>:validate_delete_children, :on=>:delete) { create_act_and_action }
25
+ event(:create_act_and_action_for_save, :before=>:process_subcards, :on=>:save, :when=>proc {|c| c.history?} ) { create_act_and_action }
26
+ event(:create_act_and_action_for_delete, :before =>:validate_delete_children, :on=>:delete, :when=>proc {|c| c.history? }) { create_act_and_action }
23
27
 
24
28
 
25
- event :remove_empty_act, :after=>:extend do
29
+ event :remove_empty_act, :after=>:extend, :when=>proc {|c| c.history? } do
26
30
  # if not @supercard and not @current_act.actions.empty?
27
31
  # @current_act.save
28
32
  # end
@@ -35,7 +39,7 @@ end
35
39
 
36
40
 
37
41
 
38
- event :rollback_actions, :before=>:approve, :on=>:update, :when=>proc{ |c| Env and Env.params['action_ids'] and Env.params['action_ids'].class == Array} do
42
+ event :rollback_actions, :before=>:approve, :on=>:update, :when=>proc{ |c| c.history? && Env && Env.params['action_ids'] && Env.params['action_ids'].class == Array} do
39
43
  revision = { :subcards => {}}
40
44
  rollback_actions = Env.params['action_ids'].map do |a_id|
41
45
  Action.fetch(a_id) || nil
@@ -4,6 +4,11 @@ event :add_and_drop_items, :before=>:approve, :on=>:save do
4
4
  self.drop_item Env.params['drop_item'] if Env.params['drop_item']
5
5
  end
6
6
 
7
+ event :insert_item_event, :before=>:approve, :on=>:save, :when=> proc {|c| Env.params['insert_item']} do
8
+ index = Env.params['item_index'] || 0
9
+ self.insert_item index.to_i, Env.params['insert_item']
10
+ end
11
+
7
12
  format do
8
13
  def item_links args={}
9
14
  card.item_cards(args).map do |item_card|
@@ -12,26 +17,20 @@ format do
12
17
  end
13
18
 
14
19
  def wrap_item item, args={}
15
- item #no wrap in base
20
+ item #no wrap in base
16
21
  end
17
-
22
+
18
23
  view :core do |args|
19
24
  render_pointer_items args.merge(:joint=>', ')
20
25
  end
21
-
26
+
22
27
  view :pointer_items, :tags=>:unknown_ok do |args|
23
- item_args = { :view => ( args[:item] || (@inclusion_opts && @inclusion_opts[:view]) || default_item_view ) }
28
+ i_args = item_args(args)
24
29
  joint = args[:joint] || ' '
25
-
26
- if type = card.item_type
27
- item_args[:type] = type
28
- end
29
-
30
- card.item_cards.map do |icard|
31
- wrap_item nest(icard, item_args.clone), item_args
30
+ card.item_cards.map do |i_card|
31
+ wrap_item nest(i_card, i_args.clone), i_args
32
32
  end.join joint
33
33
  end
34
-
35
34
  end
36
35
 
37
36
  format :html do
@@ -54,7 +53,7 @@ format :html do
54
53
  part_view = (c = card.rule(:input)) ? c.gsub(/[\[\]]/,'') : :list
55
54
  hidden_field( :content, :class=>'card-content') +
56
55
  raw(_render part_view, args)
57
-
56
+
58
57
  #.merge(:pointer_item_class=>'form-control')))
59
58
  end
60
59
 
@@ -68,7 +67,7 @@ format :html do
68
67
 
69
68
  %{
70
69
  <ul class="pointer-list-editor #{extra_css_class}" options-card="#{options_card_name}">
71
- #{
70
+ #{
72
71
  items.map do |item|
73
72
  _render_list_item args.merge( :pointer_item=>item )
74
73
  end * "\n"
@@ -77,7 +76,7 @@ format :html do
77
76
  #{ add_item_button }
78
77
  }
79
78
  end
80
-
79
+
81
80
  def add_item_button
82
81
  content_tag :span, :class=>'input-group' do
83
82
  button_tag :class=>'pointer-item-add' do
@@ -85,7 +84,7 @@ format :html do
85
84
  end
86
85
  end
87
86
  end
88
-
87
+
89
88
  view :list_item do |args|
90
89
  %{
91
90
  <li class="pointer-li">
@@ -135,7 +134,7 @@ format :html do
135
134
  checked = (option.name==card.item_names.first)
136
135
  id = "pointer-radio-#{option.cardname.key}"
137
136
  description = pointer_option_description option
138
- %{
137
+ %{
139
138
  <li class="pointer-radio radio">
140
139
  #{ radio_button_tag input_name, option.name, checked, :id=>id, :class=>'pointer-radio-button' }
141
140
  <label for="#{id}">#{ option.label }</label>
@@ -162,14 +161,14 @@ format :html do
162
161
  end
163
162
  end
164
163
  end
165
-
166
164
 
167
-
165
+
166
+
168
167
  def wrap_item item, args
169
168
  %{<div class="pointer-item item-#{args[:view]}">#{item}</div>}
170
169
  end
171
-
172
-
170
+
171
+
173
172
  end
174
173
 
175
174
 
@@ -177,15 +176,15 @@ format :css do
177
176
  view :titled do |args|
178
177
  %(#{major_comment "STYLE GROUP: \"#{card.name}\"", '='}#{ _render_core })
179
178
  end
180
-
179
+
181
180
  view :core do |args|
182
181
  card.item_cards.map do |item|
183
182
  nest item, :view=>(params[:item] || args[:item] || :content)
184
183
  end.join "\n\n"
185
184
  end
186
-
185
+
187
186
  view :content, :core
188
-
187
+
189
188
  end
190
189
 
191
190
 
@@ -213,7 +212,7 @@ event :standardize_items, :before=>:approve, :on=>:save do
213
212
  end
214
213
  end
215
214
 
216
- def diff_args
215
+ def diff_args
217
216
  {:format => :pointer}
218
217
  end
219
218
 
@@ -222,7 +221,7 @@ def item_cards args={}
222
221
  #warn "item_card[#{args.inspect}], :complete"
223
222
  Card::Query.new({:referred_to_by=>name}.merge(args)).run
224
223
  else
225
-
224
+
226
225
  itype = args[:type] || item_type
227
226
  #warn "item_card[#{inspect}], :complete"
228
227
  item_names(args).map do |name|
@@ -294,7 +293,9 @@ def drop_item name
294
293
  end
295
294
 
296
295
  def insert_item index, name
297
- new_names = item_names.insert(index,name)
296
+ new_names = item_names
297
+ new_names.delete(name)
298
+ new_names.insert(index,name)
298
299
  self.content = new_names.map { |name| "[[#{name}]]" }.join "\n"
299
300
  end
300
301
 
@@ -303,7 +304,7 @@ def options_card
303
304
  self.rule_card :options
304
305
  end
305
306
 
306
- def options
307
+ def options
307
308
  result_cards = if oc = options_card
308
309
  oc.item_cards :default_limit=>50, :context=>name
309
310
  else
@@ -163,6 +163,45 @@ $(window).ready ->
163
163
  else
164
164
  item.find('input').val ''
165
165
 
166
+ $('body').on 'show.bs.tab', 'a.load[data-toggle=tab][data-url]', (e) ->
167
+ tab_id = $(e.target).attr('href')
168
+ url = $(e.target).data('url')
169
+ $(e.target).removeClass('load')
170
+ $(tab_id).load(url)
171
+
172
+
173
+ # toolbar mod
174
+ $('body').on 'click', '.edit-toolbar-pin.active > a', (e) ->
175
+ e.preventDefault()
176
+ $(this).blur()
177
+ $('.edit-toolbar-pin').removeClass('active').addClass('inactive')
178
+ $.ajax '/*edit_toolbar_pinned',
179
+ type : 'PUT'
180
+ data : 'card[content]=false'
181
+
182
+ $('body').on 'click', '.edit-toolbar-pin.inactive > a', (e) ->
183
+ e.preventDefault()
184
+ $('.edit-toolbar-pin').removeClass('inactive').addClass('active')
185
+ $.ajax '/*edit_toolbar_pinned',
186
+ type : 'PUT'
187
+ data : 'card[content]=true'
188
+
189
+ $('body').on 'click', '.toolbar-pin.active > a', (e) ->
190
+ e.preventDefault()
191
+ $(this).blur()
192
+ $('.toolbar-pin').removeClass('active').addClass('inactive')
193
+ $.ajax '/*toolbar_pinned',
194
+ type : 'PUT'
195
+ data : 'card[content]=false'
196
+
197
+ $('body').on 'click', '.toolbar-pin.inactive > a', (e) ->
198
+ e.preventDefault()
199
+ $('.toolbar-pin').removeClass('inactive').addClass('active')
200
+ $.ajax '/*toolbar_pinned',
201
+ type : 'PUT'
202
+ data : 'card[content]=true'
203
+
204
+
166
205
  # following mod
167
206
  $('body').on 'click', '.btn-item-delete', ->
168
207
  $(this).find('.glyphicon').addClass("glyphicon-hourglass").removeClass("glyphicon-remove")
@@ -269,7 +269,7 @@ in your skin. Choosing (b) will mean your CSS will not be affected by automated
269
269
  > .card-frame, & {
270
270
  > .card-body {
271
271
  background: #bbb;
272
- padding: 5px;
272
+ padding: 35px 5px 5px 5px;
273
273
  > .ALL {
274
274
  background: #fff;
275
275
  > .card-header {
@@ -282,6 +282,11 @@ in your skin. Choosing (b) will mean your CSS will not be affected by automated
282
282
  }
283
283
  }
284
284
  }
285
+ > a.close-related-view {
286
+ color: inherit;
287
+ margin-right: 5px;
288
+ margin-top: 5px;
289
+ }
285
290
  }
286
291
  }
287
292
 
@@ -1,11 +1,11 @@
1
1
 
2
- class FollowerStash
2
+ class FollowerStash
3
3
  def initialize card=nil
4
- @followed_affected_cards = Hash.new { |h,v| h[v]=[] }
4
+ @followed_affected_cards = Hash.new { |h,v| h[v]=[] }
5
5
  @visited = ::Set.new
6
6
  add_affected_card(card) if card
7
7
  end
8
-
8
+
9
9
  def add_affected_card card
10
10
  Auth.as_bot do
11
11
  if !@visited.include? card.key
@@ -14,8 +14,8 @@ class FollowerStash
14
14
  notify Card.fetch(user_id), :of=>reason
15
15
  end
16
16
  if card.left and !@visited.include?(card.left.name) and follow_field_rule = card.left.rule_card(:follow_fields)
17
-
18
- follow_field_rule.item_names(:context=>card.left.cardname).each do |item|
17
+
18
+ follow_field_rule.item_names(:context=>card.left.cardname).each do |item|
19
19
  if @visited.include? item.to_name.key
20
20
  add_affected_card card.left
21
21
  break
@@ -27,30 +27,30 @@ class FollowerStash
27
27
  end
28
28
  end
29
29
  end
30
-
31
- end
32
-
30
+
31
+ end
32
+
33
33
  end
34
34
 
35
35
  end
36
36
  end
37
-
37
+
38
38
  def followers
39
39
  @followed_affected_cards.keys
40
40
  end
41
-
41
+
42
42
  def each_follower_with_reason # "follower" is a card object, "followed" a card name
43
43
  @followed_affected_cards.each do |user, reasons|
44
44
  yield(user,reasons.first)
45
45
  end
46
46
  end
47
-
47
+
48
48
  private
49
-
49
+
50
50
  def notify follower, because
51
51
  @followed_affected_cards[follower] << because[:of]
52
52
  end
53
-
53
+
54
54
  end
55
55
 
56
56
  def act_card
@@ -63,9 +63,9 @@ event :stash_followers, :after=>:approve, :on=>:delete do
63
63
  end
64
64
 
65
65
  event :notify_followers, :after=>:extend, :when=>proc{ |c|
66
- !c.supercard and c.current_act and Card::Auth.current_id != WagnBotID
66
+ !c.supercard and c.current_act and Card::Auth.current_id != WagnBotID
67
67
  } do
68
-
68
+
69
69
  begin
70
70
  @current_act.reload
71
71
  @follower_stash ||= FollowerStash.new
@@ -83,47 +83,47 @@ event :notify_followers, :after=>:extend, :when=>proc{ |c|
83
83
  notable_exception_raised
84
84
  end
85
85
  end
86
-
87
- format do
86
+
87
+ format do
88
88
  view :list_of_changes, :denial=>:blank do |args|
89
89
  action = get_action(args)
90
-
90
+
91
91
  relevant_fields = case action.action_type
92
92
  when :create then [:cardtype, :content]
93
93
  when :update then [:name, :cardtype, :content]
94
94
  when :delete then [:content]
95
95
  end
96
-
97
- relevant_fields.map do |type|
96
+
97
+ relevant_fields.map do |type|
98
98
  edit_info_for(type, action)
99
99
  end.compact.join
100
100
  end
101
-
102
-
101
+
102
+
103
103
  view :subedits, :perms=>:none do |args|
104
- subedits = get_act(args).relevant_actions_for(card).map do |action|
105
- if action.card_id != card.id
104
+ subedits = get_act(args).relevant_actions_for(card).map do |action|
105
+ if action.card_id != card.id
106
106
  action.card.format(:format=>@format).render_subedit_notice(:action=>action)
107
107
  end
108
108
  end.compact.join
109
-
109
+
110
110
  if subedits.present?
111
111
  wrap_subedits subedits
112
112
  else
113
113
  ''
114
114
  end
115
115
  end
116
-
116
+
117
117
  view :subedit_notice, :denial=>:blank do |args|
118
118
  action = get_action(args)
119
119
  name_before_action = (action.new_values[:name] && action.old_values[:name]) || card.name
120
-
120
+
121
121
  wrap_subedit_item %{#{name_before_action} #{action.action_type}d
122
122
  #{ render_list_of_changes(args) }}
123
123
  end
124
-
124
+
125
125
  view :followed, :perms=>:none, :closed=>true do |args|
126
- if args[:followed_set] && (set_card = Card.fetch(args[:followed_set])) &&
126
+ if args[:followed_set] && (set_card = Card.fetch(args[:followed_set])) &&
127
127
  args[:follow_option] && (option_card = Card.fetch(args[:follow_option]))
128
128
  option_card.description set_card
129
129
  else
@@ -134,19 +134,19 @@ format do
134
134
  view :follower, :perms=>:none, :closed=>true do |args|
135
135
  args[:follower] || 'follower'
136
136
  end
137
-
137
+
138
138
  view :unfollow_url, :perms=>:none, :closed=>true do |args|
139
139
  if args[:followed_set] && (set_card = Card.fetch(args[:followed_set])) && args[:follow_option] && args[:follower]
140
- rule_name = set_card.follow_rule_name args[:follower]
140
+ rule_name = set_card.follow_rule_name args[:follower]
141
141
  target_name = "#{args[:follower]}+#{Card[:follow].name}"
142
142
  update_path = page_path target_name, :action=>:update, :card=>{:subcards=>{rule_name=>Card[:never].name}}
143
143
  card_url update_path # absolutize path
144
144
  end
145
145
  end
146
-
146
+
147
147
  def edit_info_for field, action
148
148
  return nil unless action.new_values[field]
149
-
149
+
150
150
  item_title = case action.action_type
151
151
  when :update then 'new '
152
152
  when :delete then 'deleted '
@@ -159,52 +159,50 @@ format do
159
159
  else
160
160
  action.new_values[field]
161
161
  end
162
-
162
+
163
163
  wrap_list_item "#{item_title}#{item_value}"
164
164
  end
165
-
165
+
166
166
  def get_act args
167
167
  @notification_act ||= args[:act] || (args[:act_id] and Act.find(args[:act_id])) || card.acts.last
168
168
  end
169
-
169
+
170
170
  def get_action args
171
171
  args[:action] || (args[:action_id] and Action.fetch(args[:action_id])) || card.last_action
172
172
  end
173
-
174
-
173
+
174
+
175
175
  def wrap_subedits subedits
176
176
  "\nThis update included the following changes:#{wrap_list subedits}"
177
177
  end
178
-
178
+
179
179
  def wrap_list list
180
180
  "\n#{list}\n"
181
181
  end
182
-
182
+
183
183
  def wrap_list_item item
184
184
  " #{item}\n"
185
185
  end
186
-
186
+
187
187
  def wrap_subedit_item text
188
188
  "\n#{text}\n"
189
189
  end
190
190
  end
191
191
 
192
192
 
193
- format :email_text do
193
+ format :email_text do
194
194
  view :last_action, :perms=>:none do |args|
195
195
  act = get_act(args)
196
- action_on_card = act.action_on(act.card_id) || act.actions.first
197
- "#{action_on_card.action_type}d"
196
+ "#{act.main_action.action_type}d"
198
197
  end
199
198
  end
200
199
 
201
- format :email_html do
200
+ format :email_html do
202
201
  view :last_action, :perms=>:none do |args|
203
202
  act = get_act(args)
204
- action_on_card = act.action_on(act.card_id) || act.actions.first
205
- "#{action_on_card.action_type}d"
203
+ "#{act.main_action.action_type}d"
206
204
  end
207
-
205
+
208
206
  def wrap_list list
209
207
  "<ul>#{list}</ul>\n"
210
208
  end
@@ -212,7 +210,7 @@ format :email_html do
212
210
  def wrap_list_item item
213
211
  "<li>#{item}</li>\n"
214
212
  end
215
-
213
+
216
214
  def wrap_subedit_item text
217
215
  "<li>#{text}</li>\n"
218
216
  end