card 1.19.6 → 1.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (298) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +8 -7
  4. data/config/initializers/01_core_extensions/array.rb +4 -0
  5. data/config/initializers/01_core_extensions/persistent_identifiers.rb +12 -0
  6. data/config/initializers/02_patches/better_errors.rb +56 -0
  7. data/config/initializers/core_extensions.rb +13 -18
  8. data/config/initializers/patches.rb +8 -0
  9. data/config/locales/de.yml +0 -2
  10. data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +22 -12
  11. data/db/migrate_core_cards/20161102202156_tweak_recaptcha_setting_cards.rb +17 -0
  12. data/db/migrate_core_cards/20161103154836_update_keys.rb +46 -0
  13. data/lib/card.rb +1 -8
  14. data/lib/card/act_manager.rb +4 -0
  15. data/lib/card/auth/permissions.rb +5 -3
  16. data/lib/card/cache.rb +1 -20
  17. data/lib/card/cache/persistent.rb +6 -0
  18. data/lib/card/content/chunk.rb +4 -3
  19. data/lib/card/content/diff.rb +2 -2
  20. data/lib/card/content/diff/result.rb +11 -0
  21. data/lib/card/env/success.rb +4 -0
  22. data/lib/card/error.rb +2 -0
  23. data/lib/card/format.rb +14 -17
  24. data/lib/card/format/content.rb +16 -8
  25. data/lib/card/format/error.rb +3 -5
  26. data/lib/card/format/names.rb +22 -16
  27. data/lib/card/format/nest.rb +67 -61
  28. data/lib/card/format/nest/fetch.rb +40 -33
  29. data/lib/card/format/nest/main.rb +39 -19
  30. data/lib/card/format/nest/subformat.rb +3 -16
  31. data/lib/card/format/nest/view.rb +23 -32
  32. data/lib/card/format/permission.rb +49 -34
  33. data/lib/card/format/registration.rb +12 -6
  34. data/lib/card/format/render.rb +62 -73
  35. data/lib/card/migration.rb +14 -10
  36. data/lib/card/migration/import.rb +20 -19
  37. data/lib/card/migration/import/import_data.rb +50 -59
  38. data/lib/card/migration/import/import_data/card_attributes.rb +56 -0
  39. data/lib/card/migration/import/import_data/card_content.rb +33 -0
  40. data/lib/card/migration/import/merger.rb +47 -0
  41. data/lib/card/mod/loader.rb +4 -4
  42. data/lib/card/model/save_helper.rb +49 -10
  43. data/lib/card/name.rb +16 -52
  44. data/lib/card/name/fields_and_traits.rb +67 -0
  45. data/lib/card/name/variants.rb +17 -0
  46. data/lib/card/query.rb +6 -2
  47. data/lib/card/query/attributes.rb +1 -1
  48. data/lib/card/query/interpretation.rb +3 -3
  49. data/lib/card/set/event.rb +2 -1
  50. data/lib/card/set/format.rb +18 -7
  51. data/lib/card/set_pattern.rb +17 -13
  52. data/lib/card/tasks/card.rake +1 -1
  53. data/lib/card/view.rb +55 -0
  54. data/lib/card/view/cache.rb +90 -0
  55. data/lib/card/view/fetch.rb +109 -0
  56. data/lib/card/view/options.rb +164 -0
  57. data/lib/card/view/stub.rb +30 -0
  58. data/lib/card/view/visibility.rb +95 -0
  59. data/lib/cardio.rb +3 -2
  60. data/lib/cardio/schema.rb +21 -8
  61. data/lib/generators/card.rb +16 -2
  62. data/lib/generators/card/format/format_generator.rb +10 -9
  63. data/lib/generators/card/migration/migration_generator.rb +10 -5
  64. data/lib/generators/card/set/USAGE +1 -1
  65. data/lib/generators/card/set/set_generator.rb +11 -9
  66. data/mod/account/set/right/account.rb +38 -40
  67. data/mod/account/set/right/token.rb +2 -1
  68. data/mod/account/set/self/account_links.rb +34 -54
  69. data/mod/account/set/self/signin.rb +107 -93
  70. data/mod/account/set/type/signup.rb +33 -32
  71. data/mod/account/set/type/user.rb +28 -21
  72. data/mod/account/spec/set/all/account_spec.rb +9 -9
  73. data/mod/account/spec/set/right/account_spec.rb +23 -14
  74. data/mod/account/spec/set/right/email_spec.rb +6 -6
  75. data/mod/account/spec/set/right/password_spec.rb +4 -4
  76. data/mod/account/spec/set/right/token_spec.rb +3 -3
  77. data/mod/account/spec/set/self/account_links_spec.rb +3 -3
  78. data/mod/account/spec/set/self/signin_spec.rb +2 -2
  79. data/mod/account/spec/set/type/signup_spec.rb +7 -8
  80. data/mod/ace_editor/set/abstract/ace_editor.rb +1 -4
  81. data/mod/admin/set/self/admin.rb +2 -2
  82. data/mod/admin/set/self/admin_info.rb +1 -1
  83. data/mod/admin/set/self/recaptcha_private_key.rb +3 -0
  84. data/mod/admin/set/self/recaptcha_proxy.rb +3 -0
  85. data/mod/admin/set/self/recaptcha_public_key.rb +3 -0
  86. data/mod/admin/set/self/trash.rb +4 -4
  87. data/mod/admin/spec/set/self/admin_spec.rb +4 -4
  88. data/mod/admin/spec/set/self/version_spec.rb +1 -1
  89. data/mod/basic_formats/set/all/all_css.rb +3 -3
  90. data/mod/basic_formats/set/all/all_csv.rb +6 -6
  91. data/mod/basic_formats/set/all/all_js.rb +4 -0
  92. data/mod/basic_formats/set/all/base.rb +40 -62
  93. data/mod/basic_formats/set/all/json.rb +34 -39
  94. data/mod/basic_formats/set/all/rss.rb +6 -6
  95. data/mod/basic_formats/set/all/text.rb +3 -2
  96. data/mod/basic_formats/set/self/01_head/javascript.rb +2 -2
  97. data/mod/basic_formats/set/self/head.rb +6 -10
  98. data/mod/basic_formats/spec/set/all/all_css_spec.rb +1 -1
  99. data/mod/basic_formats/spec/set/all/all_csv_spec.rb +1 -1
  100. data/mod/basic_formats/spec/set/all/base_spec.rb +8 -5
  101. data/mod/basic_formats/spec/set/all/json_spec.rb +2 -2
  102. data/mod/basic_formats/spec/set/all/rss_spec.rb +4 -4
  103. data/mod/basic_types/set/type/plain_text.rb +3 -5
  104. data/mod/basic_types/spec/set/type/plain_text_spec.rb +2 -2
  105. data/mod/bootstrap/lib/bootstrap.rb +16 -0
  106. data/mod/bootstrap/lib/bootstrap/basic_tags.rb +26 -0
  107. data/mod/bootstrap/lib/bootstrap/component.rb +133 -0
  108. data/mod/bootstrap/lib/bootstrap/component/form.rb +31 -0
  109. data/mod/bootstrap/lib/bootstrap/component/horizontal_form.rb +38 -0
  110. data/mod/bootstrap/lib/bootstrap/component/layout.rb +83 -0
  111. data/mod/bootstrap/lib/bootstrap/component/panel.rb +9 -0
  112. data/mod/bootstrap/lib/bootstrap/component_loader.rb +30 -0
  113. data/mod/bootstrap/lib/bootstrap/delegate.rb +16 -0
  114. data/mod/bootstrap/lib/bootstrapper.rb +16 -0
  115. data/mod/bootstrap/lib/stylesheets/bootstrap/_tables.scss +55 -52
  116. data/mod/bootstrap/lib/stylesheets/bootstrap/mixins/_table-row.scss +12 -12
  117. data/mod/bootstrap/lib/stylesheets/bootstrap_cards.scss +12 -0
  118. data/mod/bootstrap/set/all/bootstrap/accordion.rb +63 -0
  119. data/mod/bootstrap/set/all/bootstrap/helper.rb +7 -140
  120. data/mod/bootstrap/set/all/bootstrap/navbar.rb +74 -0
  121. data/mod/bootstrap/set/all/bootstrap/table.rb +76 -46
  122. data/mod/bootstrap/set/all/bootstrap/tabs.rb +58 -23
  123. data/mod/bootstrap/set/all/bootstrap/wrapper.rb +14 -8
  124. data/mod/bootstrap/set/all/rich_bootstrap.rb +5 -3
  125. data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_builder_spec.rb +31 -0
  126. data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_spec.rb +20 -0
  127. data/mod/bootstrap/spec/set/all/bootstrap/form_spec.rb +59 -1
  128. data/mod/bootstrap/spec/set/all/bootstrap/layout_spec.rb +104 -15
  129. data/mod/carrierwave/set/abstract/attachment.rb +4 -3
  130. data/mod/carrierwave/set/abstract/attachment/paths.rb +1 -1
  131. data/mod/carrierwave/set/abstract/attachment/storage_type.rb +5 -11
  132. data/mod/carrierwave/set/type/file.rb +39 -32
  133. data/mod/carrierwave/set/type/image.rb +59 -34
  134. data/mod/carrierwave/spec/set/type/image_spec.rb +3 -3
  135. data/mod/core/chunk/link.rb +5 -0
  136. data/mod/core/chunk/{include.rb → nest.rb} +8 -29
  137. data/mod/core/chunk/reference.rb +5 -6
  138. data/mod/core/chunk/view_stub.rb +42 -0
  139. data/mod/core/format/html_format.rb +23 -26
  140. data/mod/core/set/abstract/code_file.rb +1 -1
  141. data/mod/core/set/all/actify.rb +1 -1
  142. data/mod/core/set/all/active_card.rb +0 -1
  143. data/mod/core/set/all/{tracked_attributes.rb → assign_attributes.rb} +55 -24
  144. data/mod/core/set/all/collection.rb +136 -122
  145. data/mod/core/set/all/content.rb +8 -0
  146. data/mod/core/set/all/event.rb +5 -2
  147. data/mod/core/set/all/export.rb +7 -7
  148. data/mod/core/set/all/fetch.rb +90 -26
  149. data/mod/core/set/all/initialize.rb +17 -6
  150. data/mod/core/set/all/name.rb +2 -3
  151. data/mod/core/set/all/permissions.rb +19 -11
  152. data/mod/core/set/all/states.rb +12 -2
  153. data/mod/core/set/all/trash.rb +1 -1
  154. data/mod/core/set/all/type.rb +2 -0
  155. data/mod/core/set/all/utils.rb +4 -3
  156. data/mod/core/spec/chunk/literal_spec.rb +2 -2
  157. data/mod/core/spec/chunk/uri_spec.rb +17 -17
  158. data/mod/core/spec/format/html_format_spec.rb +11 -13
  159. data/mod/core/spec/set/all/attribute_tracking_spec.rb +2 -2
  160. data/mod/core/spec/set/all/collection_spec.rb +21 -24
  161. data/mod/core/spec/set/all/content_spec.rb +1 -1
  162. data/mod/core/spec/set/all/export_spec.rb +3 -3
  163. data/mod/core/spec/set/all/fetch_spec.rb +5 -5
  164. data/mod/core/spec/set/all/initialize_spec.rb +4 -4
  165. data/mod/core/spec/set/all/name_spec.rb +6 -6
  166. data/mod/core/spec/set/all/permissions_spec.rb +10 -10
  167. data/mod/core/spec/set/all/references_spec.rb +1 -1
  168. data/mod/core/spec/set/all/rules2_spec.rb +24 -24
  169. data/mod/core/spec/set/all/rules_spec.rb +1 -1
  170. data/mod/core/spec/set/all/templating_spec.rb +8 -8
  171. data/mod/core/spec/set/all/tracked_attributes_spec.rb +6 -6
  172. data/mod/core/spec/set/all/type_spec.rb +5 -5
  173. data/mod/developer/spec/set/all/event_viz_spec.rb +1 -1
  174. data/mod/developer/spec/set/right/debug_spec.rb +1 -1
  175. data/mod/email/set/all/email_html.rb +2 -2
  176. data/mod/email/set/all/notify.rb +8 -3
  177. data/mod/email/set/right/bcc.rb +3 -3
  178. data/mod/email/set/right/follow.rb +5 -5
  179. data/mod/email/set/right/following.rb +1 -1
  180. data/mod/email/set/self/follow_defaults.rb +27 -16
  181. data/mod/email/set/type/email_template.rb +1 -1
  182. data/mod/email/set/type_plus_right/user/follow.rb +10 -9
  183. data/mod/history/lib/card/act.rb +4 -0
  184. data/mod/history/lib/card/act/act_renderer.rb +194 -0
  185. data/mod/history/lib/card/act/act_renderer/absolute_act_renderer.rb +25 -0
  186. data/mod/history/lib/card/act/act_renderer/relative_act_renderer.rb +41 -0
  187. data/mod/history/lib/card/action.rb +1 -0
  188. data/mod/history/lib/card/action/action_renderer.rb +92 -0
  189. data/mod/history/lib/card/action/differ.rb +6 -1
  190. data/mod/history/set/all/act_view.rb +64 -0
  191. data/mod/history/set/all/action_view.rb +65 -0
  192. data/mod/history/set/all/content_history.rb +44 -37
  193. data/mod/history/set/all/history.rb +49 -263
  194. data/mod/machines/lib/stylesheets/style_cards.scss +30 -115
  195. data/mod/machines/set/abstract/script.rb +42 -7
  196. data/mod/machines/set/right/machine_input.rb +4 -0
  197. data/mod/machines/set/type/coffee_script.rb +8 -22
  198. data/mod/machines/set/type/css.rb +2 -2
  199. data/mod/machines/set/type/java_script.rb +4 -24
  200. data/mod/machines/set/type/scss.rb +1 -1
  201. data/mod/machines/spec/set/type/css_spec.rb +1 -1
  202. data/mod/machines/spec/set/type/scss_spec.rb +3 -3
  203. data/mod/machines/spec/set/type/skin_spec.rb +7 -7
  204. data/mod/pointer/set/abstract/01_pointer.rb +44 -46
  205. data/mod/pointer/set/abstract/01_pointer/edit.rb +13 -13
  206. data/mod/pointer/set/right/options.rb +4 -0
  207. data/mod/pointer/spec/set/type/pointer_spec.rb +7 -7
  208. data/mod/prosemirror_editor/set/abstract/prosemirror_editor.rb +3 -3
  209. data/mod/settings/set/abstract/permission.rb +25 -18
  210. data/mod/settings/set/right/add_help.rb +3 -3
  211. data/mod/settings/set/right/structure.rb +10 -16
  212. data/mod/settings/spec/set/right/comment_spec.rb +3 -3
  213. data/mod/settings/spec/set/right/create_spec.rb +1 -1
  214. data/mod/settings/spec/set/right/style_spec.rb +1 -1
  215. data/mod/settings/spec/set/type/setting_spec.rb +1 -1
  216. data/mod/solid_cache/set/abstract/solid_cache.rb +4 -4
  217. data/mod/solid_cache/set/right/solid_cache.rb +9 -10
  218. data/mod/standard/set/abstract/01_search_params.rb +41 -0
  219. data/mod/standard/set/abstract/search.rb +132 -0
  220. data/mod/standard/set/abstract/search/paging.rb +81 -0
  221. data/mod/standard/set/abstract/search/paging/paging_links.rb +90 -0
  222. data/mod/standard/set/abstract/wql_search.rb +67 -0
  223. data/mod/standard/set/all/error.rb +89 -82
  224. data/mod/standard/set/all/links.rb +1 -1
  225. data/mod/standard/set/all/rich_html/content.rb +125 -141
  226. data/mod/standard/set/all/rich_html/editing.rb +115 -178
  227. data/mod/standard/set/all/rich_html/form.rb +111 -131
  228. data/mod/standard/set/all/rich_html/header.rb +57 -39
  229. data/mod/standard/set/all/rich_html/menu.rb +94 -94
  230. data/mod/standard/set/all/rich_html/modal.rb +5 -10
  231. data/mod/standard/set/all/rich_html/new.rb +103 -0
  232. data/mod/standard/set/all/rich_html/toolbar.rb +54 -74
  233. data/mod/standard/set/all/rich_html/wrapper.rb +111 -138
  234. data/mod/standard/set/rstar/rules.rb +27 -38
  235. data/mod/standard/set/rstar/rules_editor.rb +298 -277
  236. data/mod/standard/set/self/navbox.rb +20 -15
  237. data/mod/standard/set/self/recent.rb +25 -17
  238. data/mod/standard/set/self/search.rb +25 -4
  239. data/mod/standard/set/type/cardtype.rb +11 -9
  240. data/mod/standard/set/type/date.rb +1 -1
  241. data/mod/standard/set/type/number.rb +1 -1
  242. data/mod/standard/set/type/phrase.rb +1 -1
  243. data/mod/standard/set/type/search_type.rb +17 -282
  244. data/mod/standard/set/type/session.rb +1 -1
  245. data/mod/standard/set/type/set.rb +155 -131
  246. data/mod/standard/set/type/toggle.rb +1 -1
  247. data/mod/standard/set/type/uri.rb +4 -4
  248. data/mod/standard/spec/chunk/include_spec.rb +13 -31
  249. data/mod/standard/spec/chunk/link_spec.rb +1 -1
  250. data/mod/standard/spec/set/all/error_spec.rb +1 -1
  251. data/mod/standard/spec/set/all/history_spec.rb +2 -2
  252. data/mod/standard/spec/set/all/rich_html/form_spec.rb +4 -4
  253. data/mod/standard/spec/set/all/rich_html/toolbar_spec.rb +22 -0
  254. data/mod/standard/spec/set/all/rich_html/wrapper_spec.rb +3 -2
  255. data/mod/standard/spec/set/right/when_created_spec.rb +1 -1
  256. data/mod/standard/spec/set/right/when_last_edited_spec.rb +1 -1
  257. data/mod/standard/spec/set/rstar/rules_spec.rb +2 -3
  258. data/mod/standard/spec/set/self/head_spec.rb +2 -2
  259. data/mod/standard/spec/set/self/navbox_spec.rb +1 -1
  260. data/mod/standard/spec/set/self/now_spec.rb +1 -1
  261. data/mod/standard/spec/set/type/date_spec.rb +1 -1
  262. data/mod/standard/spec/set/type/email_template_spec.rb +1 -1
  263. data/mod/standard/spec/set/type/layout_type_spec.rb +1 -1
  264. data/mod/standard/spec/set/type/number_spec.rb +1 -1
  265. data/mod/standard/spec/set/type/phrase_spec.rb +1 -1
  266. data/mod/standard/spec/set/type/search_type_spec.rb +2 -2
  267. data/mod/standard/spec/set/type/set_spec.rb +2 -2
  268. data/mod/standard/spec/set/type/toggle_spec.rb +2 -2
  269. data/mod/standard/spec/set/type/uri_spec.rb +3 -1
  270. data/mod/tinymce_editor/set/abstract/tinymce_editor.rb +1 -1
  271. data/spec/config/initializers/core_extensions_spec.rb +40 -10
  272. data/spec/lib/card/auth_spec.rb +8 -8
  273. data/spec/lib/card/cache_spec.rb +3 -3
  274. data/spec/lib/card/chunk_spec.rb +4 -4
  275. data/spec/lib/card/codename_spec.rb +2 -2
  276. data/spec/lib/card/content_spec.rb +23 -23
  277. data/spec/lib/card/diff_spec.rb +1 -1
  278. data/spec/lib/card/format_spec.rb +19 -24
  279. data/spec/lib/card/loader_spec.rb +4 -4
  280. data/spec/lib/card/name_spec.rb +16 -16
  281. data/spec/lib/card/query_spec.rb +80 -80
  282. data/spec/lib/card/reference_spec.rb +5 -5
  283. data/spec/lib/card/set_spec.rb +6 -6
  284. data/spec/lib/card/subcards_spec.rb +14 -0
  285. data/spec/lib/card/view_cache_spec.rb +5 -5
  286. data/spec/models/card/cardtype_spec.rb +15 -15
  287. data/spec/models/card/create_spec.rb +2 -2
  288. data/spec/models/card/trash_spec.rb +24 -24
  289. data/spec/models/card/type_transition_spec.rb +8 -8
  290. data/spec/models/card/validation_spec.rb +5 -5
  291. data/spec/models/card_spec.rb +14 -14
  292. data/spec/spec_helper.rb +6 -2
  293. data/spec/support/card_spec_helper.rb +21 -11
  294. data/spec/support/helper/card_helper.rb +11 -4
  295. metadata +73 -15
  296. data/lib/card/cache/view_cache.rb +0 -103
  297. data/mod/bootstrap/set/all/bootstrap/layout.rb +0 -58
  298. data/mod/core/set/all/view_cache.rb +0 -9
@@ -11,8 +11,7 @@ def actionable?
11
11
  history? || respond_to?(:attachment)
12
12
  end
13
13
 
14
- event :assign_action, :initialize,
15
- when: proc { |c| c.actionable? } do
14
+ event :assign_action, :initialize, when: proc { |c| c.actionable? } do
16
15
  @current_act = director.need_act
17
16
  @current_action = Card::Action.create(
18
17
  card_act_id: @current_act.id,
@@ -24,14 +23,9 @@ event :assign_action, :initialize,
24
23
  end
25
24
  end
26
25
 
27
- def finalize_action?
28
- actionable? && current_action
29
- end
30
-
31
26
  # stores changes in the changes table and assigns them to the current action
32
27
  # removes the action if there are no changes
33
- event :finalize_action, :finalize,
34
- when: proc { |c| c.finalize_action? } do
28
+ event :finalize_action, :finalize, when: :finalize_action? do
35
29
  @changed_fields = Card::Change::TRACKED_FIELDS.select do |f|
36
30
  changed_attributes.member? f
37
31
  end
@@ -49,6 +43,10 @@ event :finalize_action, :finalize,
49
43
  end
50
44
  end
51
45
 
46
+ def finalize_action?
47
+ actionable? && current_action
48
+ end
49
+
52
50
  event :finalize_act,
53
51
  after: :finalize_action,
54
52
  when: proc { |c| c.act_card? } do
@@ -65,9 +63,8 @@ def act_card?
65
63
  self == Card::ActManager.act_card
66
64
  end
67
65
 
68
- event :rollback_actions, :prepare_to_validate,
69
- on: :update,
70
- when: proc { |c| c.rollback_request? } do
66
+ event :rollback_actions,
67
+ :prepare_to_validate, on: :update, when: :rollback_request? do
71
68
  revision = { subcards: {} }
72
69
  rollback_actions = Env.params["action_ids"].map do |a_id|
73
70
  Action.fetch(a_id) || nil
@@ -81,10 +78,6 @@ event :rollback_actions, :prepare_to_validate,
81
78
  end
82
79
  Env.params["action_ids"] = nil
83
80
  update_attributes! revision
84
- rollback_actions.each do |action|
85
- # rollback file and image cards
86
- action.card.try :rollback_to, action
87
- end
88
81
  clear_drafts
89
82
  abort :success
90
83
  end
@@ -137,277 +130,70 @@ def included_descendant_card_ids
137
130
  end
138
131
 
139
132
  format :html do
140
- view :history do |args|
141
- frame args.merge(body_class: "history-slot list-group", content: true) do
142
- [history_legend, _render_act_list]
143
- end
144
- end
145
-
146
- def default_history_args args
147
- args[:optional_toolbar] ||= :show
148
- end
149
-
150
- view :act_list do |args|
151
- page = params["page"] || 1
152
- count = card.intrusive_acts.size + 1 - (page.to_i - 1) * ACTS_PER_PAGE
153
- card.intrusive_acts.page(page).per(ACTS_PER_PAGE).map do |act|
154
- count -= 1
155
- render_act args.merge(act: act, act_seq: count)
156
- end.join
157
- end
158
-
159
- def history_legend
160
- intr = card.intrusive_acts.page(params["page"]).per(ACTS_PER_PAGE)
161
- render_haml intr: intr do
162
- <<-HAML.strip_heredoc
163
- .history-header
164
- %span.slotter
165
- = paginate intr, remote: true, theme: 'twitter-bootstrap-3'
166
- %div.history-legend
167
- = glyphicon "plus-sign", "added-mark"
168
- %span
169
- = Card::Content::Diff.render_added_chunk('Added')
170
- |
171
- = glyphicon "minus-sign", "deleted-mark"
172
- %span
173
- = Card::Content::Diff.render_deleted_chunk('Removed')
174
- |
175
- = glyphicon "trash", "deleted-mark"
176
- %span
177
- card deleted
178
- HAML
179
- end
180
- end
181
-
182
- def default_act_args args
183
- act = (args[:act] ||= Act.find(params["act_id"]))
184
- args[:act_seq] ||= params["act_seq"]
185
- args[:hide_diff] ||= hide_diff?
186
- args[:slot_class] ||= "revision-#{act.id} history-slot list-group-item"
187
- args[:action_view] ||= action_view
188
- args[:actions] ||= action_list args
189
- end
190
-
191
- def action_list args
192
- act = args[:act]
193
- actions =
194
- if act_context(args) == :absolute
195
- act.actions
196
- else
197
- act.actions_affecting(card)
133
+ view :history, cache: :never do
134
+ voo.show :toolbar
135
+ class_up "card-body", "history-slot"
136
+ frame do
137
+ bs_layout container: true, fluid: true do
138
+ html _optional_render_history_legend(with_drafts: true)
139
+ row 12 do
140
+ html _render_act_list acts: history_acts
141
+ end
142
+ row 12 do
143
+ col act_paging
144
+ end
198
145
  end
199
- actions.select { |a| a.card && a.card.ok?(:read) }
200
- # FIXME: should not need to test for presence of card here.
201
- end
202
-
203
- def act_context args
204
- args[:act_context] =
205
- (args[:act_context] || params["act_context"] || :relative).to_sym
206
- end
207
-
208
- def hide_diff?
209
- params["hide_diff"].to_s.strip == "true"
210
- end
211
-
212
- def action_view
213
- (params["action_view"] || "summary").to_sym
214
- end
215
-
216
- view :act do |args|
217
- wrap(args) do
218
- render_haml args.merge(card: card, args: args) do
219
- <<-HAML.strip_heredoc
220
- .act{style: "clear:both;"}
221
- - show_header = act_context == :absolute ? :show : :hide
222
- = optional_render :act_header, args, show_header
223
- .head
224
- = render :act_metadata, args
225
- .toggle
226
- = fold_or_unfold_link args
227
- .action-container
228
- - actions.each do |action|
229
- = render "action_#{args[:action_view]}", args.merge(action: action)
230
- HAML
231
- end
232
- end
233
- end
234
-
235
- view :act_header do |_args|
236
- %(<h5 class="act-header">#{link_to_card card}</h5>)
237
- end
238
-
239
- view :act_metadata do |args|
240
- render_haml args.merge(card: card, args: args) do
241
- <<-HAML.strip_heredoc
242
- - unless act_context == :absolute
243
- .nr
244
- = '#' + act_seq.to_s
245
- .title
246
- .actor
247
- = link_to_card act.actor
248
- .time.timeago
249
- = time_ago_in_words(act.acted_at)
250
- ago
251
- - if act.id == card.last_act.id
252
- %em.label.label-info Current
253
- - if action_view == :expanded
254
- - unless act.id == card.last_act.id
255
- = rollback_link act.actions_affecting(card)
256
- = show_or_hide_changes_link args
257
- HAML
258
146
  end
259
147
  end
260
148
 
261
- view :action_summary do |args|
262
- view_action :summary, args
263
- end
264
-
265
- view :action_expanded do |args|
266
- view_action :expanded, args
267
- end
268
-
269
- def view_action action_view, args
270
- action = args[:action] || card.last_action
271
- hide_diff = args[:hide_diff] || hide_diff?
272
- return trashed_view(action) if action.action_type == :delete
273
- render_haml action: action,
274
- action_view: action_view,
275
- name_diff: name_diff(action, hide_diff),
276
- type_diff: type_diff(action, hide_diff),
277
- content_diff: content_diff(action, action_view, hide_diff) do
278
- <<-HAML.strip_heredoc
279
- .action
280
- .summary
281
- %span.ampel
282
- = glyphicon 'minus-sign', (action.red? ? 'deleted-mark' : 'diff-invisible')
283
- = glyphicon 'plus-sign', (action.green? ? 'added-mark' : 'diff-invisible')
284
- = wrap_diff :name, name_diff
285
- = wrap_diff :type, type_diff
286
- -if content_diff && action_view == :summary
287
- = glyphicon 'arrow-right', 'arrow'
288
- = wrap_diff :content, content_diff
289
- -if content_diff and action_view == :expanded
290
- .expanded
291
- = wrap_diff :content, content_diff
292
- HAML
149
+ view :history_legend do |args|
150
+ bs_layout do
151
+ row md: [12, 12], lg: [7, 5] do
152
+ col action_legend(args[:with_drafts])
153
+ col content_legend, class: "text-right"
154
+ end
293
155
  end
294
156
  end
295
157
 
296
- def trashed_view action
297
- render_haml action: action do
298
- <<-HAML.strip_heredoc
299
- .action
300
- .summary
301
- %span.ampel
302
- = glyphicon 'trash', 'deleted-mark'
303
- = wrap_diff :name, action.card.name, ('label label-default' if action.card != card)
304
- HAML
305
- end
158
+ def history_acts
159
+ card.intrusive_acts.page(page_from_params).per(ACTS_PER_PAGE)
306
160
  end
307
161
 
308
- def name_diff action, hide_diff
309
- working_name = name_changes action, hide_diff
310
- if action.card == card
311
- working_name
312
- else
313
- link_to_view(
314
- :related, working_name,
315
- path: { related: { view: "history", name: action.card.name } },
316
- remote: true,
317
- class: "slotter label label-default",
318
- "data-slot-selector" => ".card-slot.history-view"
319
- )
162
+ def act_paging
163
+ intrusive_acts = card.intrusive_acts
164
+ .page(page_from_params).per(ACTS_PER_PAGE)
165
+ wrap_with :span, class: "slotter" do
166
+ paginate intrusive_acts, remote: true, theme: 'twitter-bootstrap-3'
320
167
  end
321
168
  end
322
169
 
323
- def type_diff action, hide_diff
324
- action.new_type? && type_changes(action, hide_diff)
170
+ def page_from_params
171
+ params["page"] || 1
325
172
  end
326
173
 
327
- def content_diff action, action_view, hide_diff
328
- diff = action.new_content? &&
329
- action.card.format.render_content_changes(
330
- action: action, diff_type: action_view, hide_diff: hide_diff
331
- )
332
- return "<i>empty</i>" unless diff.present?
333
- diff
174
+ def action_legend with_drafts=true
175
+ types = [:create, :update, :delete]
176
+ legend = types.map do |action_type|
177
+ "#{action_icon(action_type)} #{action_type}d"
178
+ end
179
+ legend << "#{action_icon(:draft)} unsaved draft" if with_drafts
180
+ "<small>Actions: #{legend.join ' | '}</small>"
334
181
  end
335
182
 
336
- def wrap_diff field, content, extra_class=nil
337
- return "" unless content.present?
338
- %(
339
- <span class="#{field}-diff #{extra_class}">
340
- #{content}
341
- </span>
342
- )
343
- end
344
-
345
- def name_changes action, hide_diff=false
346
- old_name = (name = action.previous_value :name) && showname(name).to_s
347
- if action.new_name?
348
- new_name = showname(action.value(:name)).to_s
349
- if hide_diff
350
- new_name
351
- else
352
- Card::Content::Diff.complete(old_name, new_name)
353
- end
354
- else
355
- old_name
356
- end
357
- end
358
-
359
- def type_changes action, hide_diff=false
360
- change = hide_diff ? action.value(:cardtype) : action.cardtype_diff
361
- "(#{change})"
183
+ def content_legend
184
+ legend = [Card::Content::Diff.render_added_chunk('Additions'),
185
+ Card::Content::Diff.render_deleted_chunk('Subtractions')]
186
+ "<small>Content changes: #{legend.join ' | '}</small>"
362
187
  end
363
188
 
364
189
  view :content_changes do |args|
190
+ action = args[:action]
365
191
  if args[:hide_diff]
366
- args[:action].raw_view
192
+ action.raw_view
367
193
  else
368
- args[:action].content_diff(args[:diff_type])
194
+ action.content_diff(args[:diff_type])
369
195
  end
370
196
  end
371
-
372
- def fold_or_unfold_link args
373
- act_id = args[:act].id
374
- action_view = args[:action_view] == :expanded ? :summary : :expanded
375
- arrow_dir = args[:action_view] == :expanded ? "arrow-down" : "arrow-right"
376
-
377
- link_to_view :act, "", class: "slotter revision-#{act_id} #{arrow_dir}",
378
- path: { act_id: act_id,
379
- act_seq: args[:act_seq],
380
- hide_diff: args[:hide_diff],
381
- act_context: args[:act_context],
382
- action_view: action_view,
383
- look_in_trash: true }
384
- end
385
-
386
- def rollback_link actions
387
- # FIXME -- doesn't this need to specify which action it wants?
388
- prior = # FIXME - should be a Card::Action method
389
- actions.select { |action| action.card.last_action_id != action.id }
390
- return unless card.ok?(:update) && prior.present?
391
- link = link_to(
392
- "Save as current", class: "slotter",
393
- "data-slot-selector" => ".card-slot.history-view",
394
- remote: true, method: :post, rel: "nofollow",
395
- path: { action: :update, action_ids: prior,
396
- view: :open, look_in_trash: true }
397
- )
398
- %(<div class="act-link">#{link}</div>)
399
- end
400
-
401
- def show_or_hide_changes_link args
402
- link = link_to_view(
403
- :act, "#{args[:hide_diff] ? 'Show' : 'Hide'} changes",
404
- class: "slotter",
405
- path: { act_id: args[:act].id, act_seq: args[:act_seq],
406
- hide_diff: !args[:hide_diff], action_view: :expanded,
407
- act_context: args[:act_context], look_in_trash: true }
408
- )
409
- %(<div class="act-link">#{link}</div>)
410
- end
411
197
  end
412
198
 
413
199
  def diff_args
@@ -507,122 +507,14 @@ ul.pointer {
507
507
  /*- HISTORY - */
508
508
  /*-------------------- */
509
509
 
510
-
511
-
512
510
  $diff-green: #41ad41;
513
511
  $diff-red: #ff5050;
514
- $action-white: #fdfdfd;
515
- $act-gray: #b7b7b7;
516
512
 
517
513
  .history-slot {
518
514
  overflow: hidden;
519
515
  clear: both;
520
516
  }
521
517
 
522
- .history-header {
523
- padding: 10px;
524
- background: $action-white;
525
- }
526
- .history-legend {
527
- text-align: right;
528
- }
529
- .history-header nav.pagination {
530
- display: inline;
531
- float: left;
532
- }
533
-
534
- .act {
535
- .head {
536
- float: left;
537
- margin-right:10px;
538
- min-width: 175px;
539
- }
540
- .nr {
541
- float: left;
542
- }
543
- .title {
544
- float: left;
545
- margin-left: 10px;
546
- }
547
- .actor {
548
- float: left;
549
- }
550
- .time {
551
- font-size: 8pt;
552
- float:left;
553
- clear:left;
554
- }
555
-
556
- .action-container {
557
- overflow: hidden;
558
- }
559
- .action {
560
- background-color: $action-white;
561
- margin: 5px 5px 2px 2px;
562
- padding: 6px 5px 6px 5px;
563
- overflow: hidden;
564
- }
565
- .ampel {
566
- margin: 2px 0 0 4px;
567
- }
568
- .arrow {
569
- margin: 0px 10px 0px 10px;
570
- color: green;
571
- }
572
- .toggle {
573
- float: right;
574
- margin: 12px 10px 0px 10px;
575
- width: 20px;
576
- }
577
- /*
578
- .name-diff {
579
- color: #000;
580
- border-style: solid;
581
- border-width: 1px;
582
- border-color: #E4E4E4;
583
- padding: 3px 8px 3px 8px;
584
- background-color: #EEEEEE;
585
- margin-left: 3px;
586
- }
587
- */
588
- .type-diff {
589
- padding: 1px 0px 1px 3px;
590
- }
591
- .content-diff {
592
- overflow: hidden;
593
- }
594
-
595
- .action {
596
- .expanded {
597
- clear:left;
598
- padding: 14px 10px 14px 24px;
599
- }
600
- .summary {
601
- padding: 6px 0px;
602
- }
603
- }
604
-
605
- .arrow-down {
606
- width: 0;
607
- height: 0;
608
- border-left: 7px solid transparent;
609
- border-right: 7px solid transparent;
610
- border-top: 11px solid $act-gray;
611
- display: block;
612
- }
613
- .arrow-right {
614
- width: 0;
615
- height: 0;
616
- border-top: 7px solid transparent;
617
- border-bottom: 7px solid transparent;
618
- border-left: 11px solid $act-gray;
619
- display: block;
620
- }
621
- .info {
622
- font-style: italic;
623
- }
624
- }
625
-
626
518
  .deleted-mark {
627
519
  color: $diff-red;
628
520
  }
@@ -645,14 +537,33 @@ $act-gray: #b7b7b7;
645
537
  border: 2px solid $diff-green;
646
538
  }
647
539
  }
648
- .diff-invisible {
649
- color: $action-white;
650
- }
651
540
 
652
- .diff-green,.diff-invisible{
653
- text-decoration: none;
654
- }
541
+ ul.action-list {
542
+ list-style-type: none;
543
+ padding-left: 15px;
544
+ li:before {
545
+ font-family: 'Glyphicons Halflings';
546
+ float: left;
547
+ margin-top: 4px;
548
+ margin-left: -17px;
549
+ }
655
550
 
551
+ li.update:before {
552
+ content: "\270f";
553
+ }
554
+
555
+ li.create:before {
556
+ content: "\2b";
557
+ }
558
+
559
+ li.delete:before {
560
+ content: "\e020";
561
+ }
562
+
563
+ li.draft:before {
564
+ content: "\e136";
565
+ }
566
+ }
656
567
 
657
568
 
658
569
  /*-------------------- */
@@ -822,7 +733,7 @@ td.rule-setting {
822
733
  margin: 0;
823
734
  }
824
735
  }
825
- td.missing-rule {
736
+ tr.missing-rule > td {
826
737
  background-color: #eee;
827
738
  border-bottom: 1px solid #fff;
828
739
  }
@@ -892,6 +803,10 @@ h2.set-label {
892
803
 
893
804
  /*------- permissions ------------------*/
894
805
 
806
+ .perm-editor {
807
+ margin-left: 40px;
808
+ }
809
+
895
810
  .perm-section {
896
811
  margin-bottom: 20px;
897
812
  }