card 1.19.6 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/card.gemspec +8 -7
- data/config/initializers/01_core_extensions/array.rb +4 -0
- data/config/initializers/01_core_extensions/persistent_identifiers.rb +12 -0
- data/config/initializers/02_patches/better_errors.rb +56 -0
- data/config/initializers/core_extensions.rb +13 -18
- data/config/initializers/patches.rb +8 -0
- data/config/locales/de.yml +0 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +22 -12
- data/db/migrate_core_cards/20161102202156_tweak_recaptcha_setting_cards.rb +17 -0
- data/db/migrate_core_cards/20161103154836_update_keys.rb +46 -0
- data/lib/card.rb +1 -8
- data/lib/card/act_manager.rb +4 -0
- data/lib/card/auth/permissions.rb +5 -3
- data/lib/card/cache.rb +1 -20
- data/lib/card/cache/persistent.rb +6 -0
- data/lib/card/content/chunk.rb +4 -3
- data/lib/card/content/diff.rb +2 -2
- data/lib/card/content/diff/result.rb +11 -0
- data/lib/card/env/success.rb +4 -0
- data/lib/card/error.rb +2 -0
- data/lib/card/format.rb +14 -17
- data/lib/card/format/content.rb +16 -8
- data/lib/card/format/error.rb +3 -5
- data/lib/card/format/names.rb +22 -16
- data/lib/card/format/nest.rb +67 -61
- data/lib/card/format/nest/fetch.rb +40 -33
- data/lib/card/format/nest/main.rb +39 -19
- data/lib/card/format/nest/subformat.rb +3 -16
- data/lib/card/format/nest/view.rb +23 -32
- data/lib/card/format/permission.rb +49 -34
- data/lib/card/format/registration.rb +12 -6
- data/lib/card/format/render.rb +62 -73
- data/lib/card/migration.rb +14 -10
- data/lib/card/migration/import.rb +20 -19
- data/lib/card/migration/import/import_data.rb +50 -59
- data/lib/card/migration/import/import_data/card_attributes.rb +56 -0
- data/lib/card/migration/import/import_data/card_content.rb +33 -0
- data/lib/card/migration/import/merger.rb +47 -0
- data/lib/card/mod/loader.rb +4 -4
- data/lib/card/model/save_helper.rb +49 -10
- data/lib/card/name.rb +16 -52
- data/lib/card/name/fields_and_traits.rb +67 -0
- data/lib/card/name/variants.rb +17 -0
- data/lib/card/query.rb +6 -2
- data/lib/card/query/attributes.rb +1 -1
- data/lib/card/query/interpretation.rb +3 -3
- data/lib/card/set/event.rb +2 -1
- data/lib/card/set/format.rb +18 -7
- data/lib/card/set_pattern.rb +17 -13
- data/lib/card/tasks/card.rake +1 -1
- data/lib/card/view.rb +55 -0
- data/lib/card/view/cache.rb +90 -0
- data/lib/card/view/fetch.rb +109 -0
- data/lib/card/view/options.rb +164 -0
- data/lib/card/view/stub.rb +30 -0
- data/lib/card/view/visibility.rb +95 -0
- data/lib/cardio.rb +3 -2
- data/lib/cardio/schema.rb +21 -8
- data/lib/generators/card.rb +16 -2
- data/lib/generators/card/format/format_generator.rb +10 -9
- data/lib/generators/card/migration/migration_generator.rb +10 -5
- data/lib/generators/card/set/USAGE +1 -1
- data/lib/generators/card/set/set_generator.rb +11 -9
- data/mod/account/set/right/account.rb +38 -40
- data/mod/account/set/right/token.rb +2 -1
- data/mod/account/set/self/account_links.rb +34 -54
- data/mod/account/set/self/signin.rb +107 -93
- data/mod/account/set/type/signup.rb +33 -32
- data/mod/account/set/type/user.rb +28 -21
- data/mod/account/spec/set/all/account_spec.rb +9 -9
- data/mod/account/spec/set/right/account_spec.rb +23 -14
- data/mod/account/spec/set/right/email_spec.rb +6 -6
- data/mod/account/spec/set/right/password_spec.rb +4 -4
- data/mod/account/spec/set/right/token_spec.rb +3 -3
- data/mod/account/spec/set/self/account_links_spec.rb +3 -3
- data/mod/account/spec/set/self/signin_spec.rb +2 -2
- data/mod/account/spec/set/type/signup_spec.rb +7 -8
- data/mod/ace_editor/set/abstract/ace_editor.rb +1 -4
- data/mod/admin/set/self/admin.rb +2 -2
- data/mod/admin/set/self/admin_info.rb +1 -1
- data/mod/admin/set/self/recaptcha_private_key.rb +3 -0
- data/mod/admin/set/self/recaptcha_proxy.rb +3 -0
- data/mod/admin/set/self/recaptcha_public_key.rb +3 -0
- data/mod/admin/set/self/trash.rb +4 -4
- data/mod/admin/spec/set/self/admin_spec.rb +4 -4
- data/mod/admin/spec/set/self/version_spec.rb +1 -1
- data/mod/basic_formats/set/all/all_css.rb +3 -3
- data/mod/basic_formats/set/all/all_csv.rb +6 -6
- data/mod/basic_formats/set/all/all_js.rb +4 -0
- data/mod/basic_formats/set/all/base.rb +40 -62
- data/mod/basic_formats/set/all/json.rb +34 -39
- data/mod/basic_formats/set/all/rss.rb +6 -6
- data/mod/basic_formats/set/all/text.rb +3 -2
- data/mod/basic_formats/set/self/01_head/javascript.rb +2 -2
- data/mod/basic_formats/set/self/head.rb +6 -10
- data/mod/basic_formats/spec/set/all/all_css_spec.rb +1 -1
- data/mod/basic_formats/spec/set/all/all_csv_spec.rb +1 -1
- data/mod/basic_formats/spec/set/all/base_spec.rb +8 -5
- data/mod/basic_formats/spec/set/all/json_spec.rb +2 -2
- data/mod/basic_formats/spec/set/all/rss_spec.rb +4 -4
- data/mod/basic_types/set/type/plain_text.rb +3 -5
- data/mod/basic_types/spec/set/type/plain_text_spec.rb +2 -2
- data/mod/bootstrap/lib/bootstrap.rb +16 -0
- data/mod/bootstrap/lib/bootstrap/basic_tags.rb +26 -0
- data/mod/bootstrap/lib/bootstrap/component.rb +133 -0
- data/mod/bootstrap/lib/bootstrap/component/form.rb +31 -0
- data/mod/bootstrap/lib/bootstrap/component/horizontal_form.rb +38 -0
- data/mod/bootstrap/lib/bootstrap/component/layout.rb +83 -0
- data/mod/bootstrap/lib/bootstrap/component/panel.rb +9 -0
- data/mod/bootstrap/lib/bootstrap/component_loader.rb +30 -0
- data/mod/bootstrap/lib/bootstrap/delegate.rb +16 -0
- data/mod/bootstrap/lib/bootstrapper.rb +16 -0
- data/mod/bootstrap/lib/stylesheets/bootstrap/_tables.scss +55 -52
- data/mod/bootstrap/lib/stylesheets/bootstrap/mixins/_table-row.scss +12 -12
- data/mod/bootstrap/lib/stylesheets/bootstrap_cards.scss +12 -0
- data/mod/bootstrap/set/all/bootstrap/accordion.rb +63 -0
- data/mod/bootstrap/set/all/bootstrap/helper.rb +7 -140
- data/mod/bootstrap/set/all/bootstrap/navbar.rb +74 -0
- data/mod/bootstrap/set/all/bootstrap/table.rb +76 -46
- data/mod/bootstrap/set/all/bootstrap/tabs.rb +58 -23
- data/mod/bootstrap/set/all/bootstrap/wrapper.rb +14 -8
- data/mod/bootstrap/set/all/rich_bootstrap.rb +5 -3
- data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_builder_spec.rb +31 -0
- data/mod/bootstrap/spec/set/all/bootstrap/bootstrap_spec.rb +20 -0
- data/mod/bootstrap/spec/set/all/bootstrap/form_spec.rb +59 -1
- data/mod/bootstrap/spec/set/all/bootstrap/layout_spec.rb +104 -15
- data/mod/carrierwave/set/abstract/attachment.rb +4 -3
- data/mod/carrierwave/set/abstract/attachment/paths.rb +1 -1
- data/mod/carrierwave/set/abstract/attachment/storage_type.rb +5 -11
- data/mod/carrierwave/set/type/file.rb +39 -32
- data/mod/carrierwave/set/type/image.rb +59 -34
- data/mod/carrierwave/spec/set/type/image_spec.rb +3 -3
- data/mod/core/chunk/link.rb +5 -0
- data/mod/core/chunk/{include.rb → nest.rb} +8 -29
- data/mod/core/chunk/reference.rb +5 -6
- data/mod/core/chunk/view_stub.rb +42 -0
- data/mod/core/format/html_format.rb +23 -26
- data/mod/core/set/abstract/code_file.rb +1 -1
- data/mod/core/set/all/actify.rb +1 -1
- data/mod/core/set/all/active_card.rb +0 -1
- data/mod/core/set/all/{tracked_attributes.rb → assign_attributes.rb} +55 -24
- data/mod/core/set/all/collection.rb +136 -122
- data/mod/core/set/all/content.rb +8 -0
- data/mod/core/set/all/event.rb +5 -2
- data/mod/core/set/all/export.rb +7 -7
- data/mod/core/set/all/fetch.rb +90 -26
- data/mod/core/set/all/initialize.rb +17 -6
- data/mod/core/set/all/name.rb +2 -3
- data/mod/core/set/all/permissions.rb +19 -11
- data/mod/core/set/all/states.rb +12 -2
- data/mod/core/set/all/trash.rb +1 -1
- data/mod/core/set/all/type.rb +2 -0
- data/mod/core/set/all/utils.rb +4 -3
- data/mod/core/spec/chunk/literal_spec.rb +2 -2
- data/mod/core/spec/chunk/uri_spec.rb +17 -17
- data/mod/core/spec/format/html_format_spec.rb +11 -13
- data/mod/core/spec/set/all/attribute_tracking_spec.rb +2 -2
- data/mod/core/spec/set/all/collection_spec.rb +21 -24
- data/mod/core/spec/set/all/content_spec.rb +1 -1
- data/mod/core/spec/set/all/export_spec.rb +3 -3
- data/mod/core/spec/set/all/fetch_spec.rb +5 -5
- data/mod/core/spec/set/all/initialize_spec.rb +4 -4
- data/mod/core/spec/set/all/name_spec.rb +6 -6
- data/mod/core/spec/set/all/permissions_spec.rb +10 -10
- data/mod/core/spec/set/all/references_spec.rb +1 -1
- data/mod/core/spec/set/all/rules2_spec.rb +24 -24
- data/mod/core/spec/set/all/rules_spec.rb +1 -1
- data/mod/core/spec/set/all/templating_spec.rb +8 -8
- data/mod/core/spec/set/all/tracked_attributes_spec.rb +6 -6
- data/mod/core/spec/set/all/type_spec.rb +5 -5
- data/mod/developer/spec/set/all/event_viz_spec.rb +1 -1
- data/mod/developer/spec/set/right/debug_spec.rb +1 -1
- data/mod/email/set/all/email_html.rb +2 -2
- data/mod/email/set/all/notify.rb +8 -3
- data/mod/email/set/right/bcc.rb +3 -3
- data/mod/email/set/right/follow.rb +5 -5
- data/mod/email/set/right/following.rb +1 -1
- data/mod/email/set/self/follow_defaults.rb +27 -16
- data/mod/email/set/type/email_template.rb +1 -1
- data/mod/email/set/type_plus_right/user/follow.rb +10 -9
- data/mod/history/lib/card/act.rb +4 -0
- data/mod/history/lib/card/act/act_renderer.rb +194 -0
- data/mod/history/lib/card/act/act_renderer/absolute_act_renderer.rb +25 -0
- data/mod/history/lib/card/act/act_renderer/relative_act_renderer.rb +41 -0
- data/mod/history/lib/card/action.rb +1 -0
- data/mod/history/lib/card/action/action_renderer.rb +92 -0
- data/mod/history/lib/card/action/differ.rb +6 -1
- data/mod/history/set/all/act_view.rb +64 -0
- data/mod/history/set/all/action_view.rb +65 -0
- data/mod/history/set/all/content_history.rb +44 -37
- data/mod/history/set/all/history.rb +49 -263
- data/mod/machines/lib/stylesheets/style_cards.scss +30 -115
- data/mod/machines/set/abstract/script.rb +42 -7
- data/mod/machines/set/right/machine_input.rb +4 -0
- data/mod/machines/set/type/coffee_script.rb +8 -22
- data/mod/machines/set/type/css.rb +2 -2
- data/mod/machines/set/type/java_script.rb +4 -24
- data/mod/machines/set/type/scss.rb +1 -1
- data/mod/machines/spec/set/type/css_spec.rb +1 -1
- data/mod/machines/spec/set/type/scss_spec.rb +3 -3
- data/mod/machines/spec/set/type/skin_spec.rb +7 -7
- data/mod/pointer/set/abstract/01_pointer.rb +44 -46
- data/mod/pointer/set/abstract/01_pointer/edit.rb +13 -13
- data/mod/pointer/set/right/options.rb +4 -0
- data/mod/pointer/spec/set/type/pointer_spec.rb +7 -7
- data/mod/prosemirror_editor/set/abstract/prosemirror_editor.rb +3 -3
- data/mod/settings/set/abstract/permission.rb +25 -18
- data/mod/settings/set/right/add_help.rb +3 -3
- data/mod/settings/set/right/structure.rb +10 -16
- data/mod/settings/spec/set/right/comment_spec.rb +3 -3
- data/mod/settings/spec/set/right/create_spec.rb +1 -1
- data/mod/settings/spec/set/right/style_spec.rb +1 -1
- data/mod/settings/spec/set/type/setting_spec.rb +1 -1
- data/mod/solid_cache/set/abstract/solid_cache.rb +4 -4
- data/mod/solid_cache/set/right/solid_cache.rb +9 -10
- data/mod/standard/set/abstract/01_search_params.rb +41 -0
- data/mod/standard/set/abstract/search.rb +132 -0
- data/mod/standard/set/abstract/search/paging.rb +81 -0
- data/mod/standard/set/abstract/search/paging/paging_links.rb +90 -0
- data/mod/standard/set/abstract/wql_search.rb +67 -0
- data/mod/standard/set/all/error.rb +89 -82
- data/mod/standard/set/all/links.rb +1 -1
- data/mod/standard/set/all/rich_html/content.rb +125 -141
- data/mod/standard/set/all/rich_html/editing.rb +115 -178
- data/mod/standard/set/all/rich_html/form.rb +111 -131
- data/mod/standard/set/all/rich_html/header.rb +57 -39
- data/mod/standard/set/all/rich_html/menu.rb +94 -94
- data/mod/standard/set/all/rich_html/modal.rb +5 -10
- data/mod/standard/set/all/rich_html/new.rb +103 -0
- data/mod/standard/set/all/rich_html/toolbar.rb +54 -74
- data/mod/standard/set/all/rich_html/wrapper.rb +111 -138
- data/mod/standard/set/rstar/rules.rb +27 -38
- data/mod/standard/set/rstar/rules_editor.rb +298 -277
- data/mod/standard/set/self/navbox.rb +20 -15
- data/mod/standard/set/self/recent.rb +25 -17
- data/mod/standard/set/self/search.rb +25 -4
- data/mod/standard/set/type/cardtype.rb +11 -9
- data/mod/standard/set/type/date.rb +1 -1
- data/mod/standard/set/type/number.rb +1 -1
- data/mod/standard/set/type/phrase.rb +1 -1
- data/mod/standard/set/type/search_type.rb +17 -282
- data/mod/standard/set/type/session.rb +1 -1
- data/mod/standard/set/type/set.rb +155 -131
- data/mod/standard/set/type/toggle.rb +1 -1
- data/mod/standard/set/type/uri.rb +4 -4
- data/mod/standard/spec/chunk/include_spec.rb +13 -31
- data/mod/standard/spec/chunk/link_spec.rb +1 -1
- data/mod/standard/spec/set/all/error_spec.rb +1 -1
- data/mod/standard/spec/set/all/history_spec.rb +2 -2
- data/mod/standard/spec/set/all/rich_html/form_spec.rb +4 -4
- data/mod/standard/spec/set/all/rich_html/toolbar_spec.rb +22 -0
- data/mod/standard/spec/set/all/rich_html/wrapper_spec.rb +3 -2
- data/mod/standard/spec/set/right/when_created_spec.rb +1 -1
- data/mod/standard/spec/set/right/when_last_edited_spec.rb +1 -1
- data/mod/standard/spec/set/rstar/rules_spec.rb +2 -3
- data/mod/standard/spec/set/self/head_spec.rb +2 -2
- data/mod/standard/spec/set/self/navbox_spec.rb +1 -1
- data/mod/standard/spec/set/self/now_spec.rb +1 -1
- data/mod/standard/spec/set/type/date_spec.rb +1 -1
- data/mod/standard/spec/set/type/email_template_spec.rb +1 -1
- data/mod/standard/spec/set/type/layout_type_spec.rb +1 -1
- data/mod/standard/spec/set/type/number_spec.rb +1 -1
- data/mod/standard/spec/set/type/phrase_spec.rb +1 -1
- data/mod/standard/spec/set/type/search_type_spec.rb +2 -2
- data/mod/standard/spec/set/type/set_spec.rb +2 -2
- data/mod/standard/spec/set/type/toggle_spec.rb +2 -2
- data/mod/standard/spec/set/type/uri_spec.rb +3 -1
- data/mod/tinymce_editor/set/abstract/tinymce_editor.rb +1 -1
- data/spec/config/initializers/core_extensions_spec.rb +40 -10
- data/spec/lib/card/auth_spec.rb +8 -8
- data/spec/lib/card/cache_spec.rb +3 -3
- data/spec/lib/card/chunk_spec.rb +4 -4
- data/spec/lib/card/codename_spec.rb +2 -2
- data/spec/lib/card/content_spec.rb +23 -23
- data/spec/lib/card/diff_spec.rb +1 -1
- data/spec/lib/card/format_spec.rb +19 -24
- data/spec/lib/card/loader_spec.rb +4 -4
- data/spec/lib/card/name_spec.rb +16 -16
- data/spec/lib/card/query_spec.rb +80 -80
- data/spec/lib/card/reference_spec.rb +5 -5
- data/spec/lib/card/set_spec.rb +6 -6
- data/spec/lib/card/subcards_spec.rb +14 -0
- data/spec/lib/card/view_cache_spec.rb +5 -5
- data/spec/models/card/cardtype_spec.rb +15 -15
- data/spec/models/card/create_spec.rb +2 -2
- data/spec/models/card/trash_spec.rb +24 -24
- data/spec/models/card/type_transition_spec.rb +8 -8
- data/spec/models/card/validation_spec.rb +5 -5
- data/spec/models/card_spec.rb +14 -14
- data/spec/spec_helper.rb +6 -2
- data/spec/support/card_spec_helper.rb +21 -11
- data/spec/support/helper/card_helper.rb +11 -4
- metadata +73 -15
- data/lib/card/cache/view_cache.rb +0 -103
- data/mod/bootstrap/set/all/bootstrap/layout.rb +0 -58
- data/mod/core/set/all/view_cache.rb +0 -9
@@ -0,0 +1,25 @@
|
|
1
|
+
class Card
|
2
|
+
class Act
|
3
|
+
class ActRenderer
|
4
|
+
class AbsoluteActRenderer < ActRenderer
|
5
|
+
def title
|
6
|
+
absolute_title
|
7
|
+
end
|
8
|
+
|
9
|
+
def subtitle
|
10
|
+
wrap_with :small do
|
11
|
+
[
|
12
|
+
@format.link_to_card(@act.actor),
|
13
|
+
edited_ago
|
14
|
+
]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def actions
|
19
|
+
@act.actions
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Card
|
2
|
+
class Act
|
3
|
+
class ActRenderer
|
4
|
+
class RelativeActRenderer < ActRenderer
|
5
|
+
def title
|
6
|
+
"<span class=\"nr\">##{@args[:act_seq]}</span>" +
|
7
|
+
accordion_expand_link(@act.actor.name) +
|
8
|
+
" " +
|
9
|
+
wrap_with(:small, edited_ago)
|
10
|
+
end
|
11
|
+
|
12
|
+
def subtitle
|
13
|
+
return "" unless @act.card_id != @format.card.id
|
14
|
+
wrap_with :small, "act on #{absolute_title}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def act_links
|
18
|
+
return unless (content = rollback_or_edit_link)
|
19
|
+
wrap_with :small, content
|
20
|
+
end
|
21
|
+
|
22
|
+
def rollback_or_edit_link
|
23
|
+
if @act.draft?
|
24
|
+
autosaved_draft_link text: "continue editing",
|
25
|
+
class: "collapse #{collapse_id}"
|
26
|
+
elsif !current_act?
|
27
|
+
rollback_link
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def current_act?
|
32
|
+
@act.id == @format.card.last_act.id
|
33
|
+
end
|
34
|
+
|
35
|
+
def actions
|
36
|
+
@actions ||= @act.actions_affecting(@card)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
class Card
|
2
|
+
class Action
|
3
|
+
class ActionRenderer
|
4
|
+
attr_reader :action, :header
|
5
|
+
def initialize format, action, header=true, action_view=:summary, hide_diff=false
|
6
|
+
@format = format
|
7
|
+
@action = action
|
8
|
+
@header = header
|
9
|
+
@action_view = action_view
|
10
|
+
@hide_diff = hide_diff
|
11
|
+
end
|
12
|
+
|
13
|
+
include ::Bootstrapper
|
14
|
+
def method_missing(method_name, *args, &block)
|
15
|
+
if block_given?
|
16
|
+
@format.send(method_name, *args, &block)
|
17
|
+
else
|
18
|
+
@format.send(method_name, *args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def respond_to_missing? method_name, _include_private=false
|
23
|
+
@format.respond_to? method_name
|
24
|
+
end
|
25
|
+
|
26
|
+
def render
|
27
|
+
bs_layout container: true, fluid: true do
|
28
|
+
row do
|
29
|
+
html <<-HTML
|
30
|
+
<ul class="action-list">
|
31
|
+
<li class="glyphicon-bullet #{action.action_type}">
|
32
|
+
#{action_panel}
|
33
|
+
</li>
|
34
|
+
</ul>
|
35
|
+
HTML
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def action_panel
|
41
|
+
bs_panel do
|
42
|
+
if header
|
43
|
+
heading do
|
44
|
+
div type_diff, class: "pull-right"
|
45
|
+
div name_diff
|
46
|
+
end
|
47
|
+
end
|
48
|
+
body do
|
49
|
+
content_diff
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def name_diff
|
55
|
+
if @action.card == @format.card
|
56
|
+
name_changes
|
57
|
+
else
|
58
|
+
link_to_view(
|
59
|
+
:related, name_changes,
|
60
|
+
path: { related: { view: "history", name: @action.card.name } },
|
61
|
+
remote: true,
|
62
|
+
class: "slotter",
|
63
|
+
#"data-slot-selector" => ".card-slot.history-view"
|
64
|
+
)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def content_diff
|
69
|
+
return @action.raw_view if @action.action_type == :delete
|
70
|
+
@format.subformat(@action.card)._render_action_summary action: @action
|
71
|
+
end
|
72
|
+
|
73
|
+
def type_diff
|
74
|
+
return "" unless @action.new_type?
|
75
|
+
@hide_diff ? @action.value(:cardtype) : @action.cardtype_diff
|
76
|
+
end
|
77
|
+
|
78
|
+
def name_changes
|
79
|
+
return old_name unless @action.new_name?
|
80
|
+
@hide_diff ? new_name : Card::Content::Diff.complete(old_name, new_name)
|
81
|
+
end
|
82
|
+
|
83
|
+
def old_name
|
84
|
+
(name = @action.previous_value :name) && showname(name).to_s
|
85
|
+
end
|
86
|
+
|
87
|
+
def new_name
|
88
|
+
showname(@action.value(:name)).to_s
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -44,6 +44,10 @@ class Card
|
|
44
44
|
card.db_content = original_content
|
45
45
|
end
|
46
46
|
|
47
|
+
def summary_diff_omits_content?
|
48
|
+
content_diff_object.summary_omits_content?
|
49
|
+
end
|
50
|
+
|
47
51
|
private
|
48
52
|
|
49
53
|
def diff_object field, opts
|
@@ -53,7 +57,8 @@ class Card
|
|
53
57
|
def content_diff_object opts=nil
|
54
58
|
@diff ||= begin
|
55
59
|
diff_args = opts || card.include_set_modules.diff_args
|
56
|
-
|
60
|
+
previous_value = previous_value(:content)
|
61
|
+
previous = previous_value ? raw_view(previous_value) : ""
|
57
62
|
current = raw_view
|
58
63
|
Card::Content::Diff.new previous, current, diff_args
|
59
64
|
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
ACTS_PER_PAGE = Card.config.acts_per_page
|
2
|
+
|
3
|
+
format :html do
|
4
|
+
def default_act_args args
|
5
|
+
act = (args[:act] ||= Act.find(params["act_id"]))
|
6
|
+
args[:act_seq] ||= params["act_seq"]
|
7
|
+
args[:hide_diff] ||= hide_diff?
|
8
|
+
args[:slot_class] ||= "revision-#{act.id} history-slot list-group-item"
|
9
|
+
args[:action_view] ||= action_view
|
10
|
+
act_context args
|
11
|
+
end
|
12
|
+
|
13
|
+
view :act_list, cache: :never do |args|
|
14
|
+
acts = args.delete :acts
|
15
|
+
page = params["page"] || 1
|
16
|
+
count = acts.size + 1 - (page.to_i - 1) * ACTS_PER_PAGE
|
17
|
+
accordion_group(acts.map do |act|
|
18
|
+
if (act_card = act.card)
|
19
|
+
count -= 1
|
20
|
+
act_card.format(:html).render_act args.merge(act: act, act_seq: count)
|
21
|
+
else
|
22
|
+
Rails.logger.info "bad data, act: #{act}"
|
23
|
+
""
|
24
|
+
end
|
25
|
+
end, nil, class: "clear-both")
|
26
|
+
end
|
27
|
+
|
28
|
+
view :act, cache: :never do |args|
|
29
|
+
act_renderer(args[:act_context]).new(self, args[:act], args).render
|
30
|
+
end
|
31
|
+
|
32
|
+
def action_icon action_type, extra_class=nil
|
33
|
+
icon = case action_type
|
34
|
+
when :create then "plus"
|
35
|
+
when :update then "pencil"
|
36
|
+
when :delete then "trash"
|
37
|
+
when :draft then "wrench"
|
38
|
+
end
|
39
|
+
glyphicon icon, extra_class
|
40
|
+
end
|
41
|
+
|
42
|
+
def action_view
|
43
|
+
(params["action_view"] || "summary").to_sym
|
44
|
+
end
|
45
|
+
|
46
|
+
def hide_diff?
|
47
|
+
params["hide_diff"].to_s.strip == "true"
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def act_renderer context
|
53
|
+
if context == :absolute
|
54
|
+
Act::ActRenderer::AbsoluteActRenderer
|
55
|
+
else
|
56
|
+
Act::ActRenderer::RelativeActRenderer
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def act_context args
|
61
|
+
args[:act_context] =
|
62
|
+
(args[:act_context] || params["act_context"] || :relative).to_sym
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
format :html do
|
2
|
+
def default_action_expanded_args args
|
3
|
+
args[:action] ||= action_from_params || card.last_action
|
4
|
+
args[:header] ||= params[:header]
|
5
|
+
end
|
6
|
+
|
7
|
+
view :action_expanded do |args|
|
8
|
+
render_action_content args[:action], :expanded
|
9
|
+
end
|
10
|
+
|
11
|
+
def default_action_summary_args args
|
12
|
+
default_action_expanded_args args
|
13
|
+
end
|
14
|
+
|
15
|
+
view :action_summary do |args|
|
16
|
+
render_action_content args[:action], :summary
|
17
|
+
end
|
18
|
+
|
19
|
+
view :action_content_toggle do |args|
|
20
|
+
toggle_action_content_link args[:action], args[:view_type]
|
21
|
+
end
|
22
|
+
|
23
|
+
def render_action_content action, view_type
|
24
|
+
return "" unless action.present?
|
25
|
+
wrap do
|
26
|
+
[
|
27
|
+
action_content_toggle(action, view_type),
|
28
|
+
content_diff(action, view_type)
|
29
|
+
]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def content_diff action, view_type
|
34
|
+
diff = action.new_content? &&
|
35
|
+
_render_content_changes(action: action, diff_type: view_type) #, hide_diff: @hide_diff
|
36
|
+
return "<i>empty</i>" unless diff.present?
|
37
|
+
diff
|
38
|
+
end
|
39
|
+
|
40
|
+
def action_from_params
|
41
|
+
return unless (action_id = params[:action_id])
|
42
|
+
Action.find action_id
|
43
|
+
end
|
44
|
+
|
45
|
+
def action_content_toggle action, view_type
|
46
|
+
return unless show_action_content_toggle?(action, view_type)
|
47
|
+
toggle_action_content_link action, view_type
|
48
|
+
end
|
49
|
+
|
50
|
+
def show_action_content_toggle? action, view_type
|
51
|
+
action.summary_diff_omits_content? || view_type == :expanded
|
52
|
+
end
|
53
|
+
|
54
|
+
def toggle_action_content_link action, view_type
|
55
|
+
other_view_type = view_type == :expanded ? :summary : :expanded
|
56
|
+
link_to_view "action_#{other_view_type}",
|
57
|
+
glyphicon(arrow_dir(view_type)),
|
58
|
+
class: "slotter revision-#{action.card_act_id} pull-right",
|
59
|
+
path: { action_id: action.id, look_in_trash: true }
|
60
|
+
end
|
61
|
+
|
62
|
+
def arrow_dir view_type
|
63
|
+
view_type == :expanded ? "triangle-left" : "triangle-right"
|
64
|
+
end
|
65
|
+
end
|
@@ -22,29 +22,33 @@ end
|
|
22
22
|
def save_content_draft content
|
23
23
|
super
|
24
24
|
acts.create do |act|
|
25
|
-
act.actions.build(draft: true, card_id: id)
|
25
|
+
act.actions.build(draft: true, card_id: id, action_type: :update)
|
26
26
|
.card_changes.build(field: :db_content, value: content)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def last_change_on field, opts={}
|
31
|
-
where_sql = "card_actions.card_id = :card_id AND field = :field"
|
32
|
-
where_sql += " AND (draft is not true)" unless opts[:including_drafts]
|
33
|
-
if opts[:before]
|
34
|
-
where_sql += " AND card_action_id < :action_id"
|
35
|
-
elsif opts[:not_after]
|
36
|
-
where_sql += " AND card_action_id <= :action_id"
|
37
|
-
end
|
38
|
-
|
39
|
-
action_arg = opts[:before] || opts[:not_after]
|
40
|
-
action_id = action_arg.is_a?(Card::Action) ? action_arg.id : action_arg
|
41
31
|
Change.joins(:action).where(
|
42
|
-
|
43
|
-
|
44
|
-
|
32
|
+
last_change_sql_conditions(opts),
|
33
|
+
card_id: id,
|
34
|
+
action_id: extract_action_id(opts[:before] || opts[:not_after]),
|
35
|
+
field: Card::Change.field_index(field)
|
45
36
|
).order(:id).last
|
46
37
|
end
|
47
38
|
|
39
|
+
def extract_action_id action_arg
|
40
|
+
action_arg.is_a?(Card::Action) ? action_arg.id : action_arg
|
41
|
+
end
|
42
|
+
|
43
|
+
def last_change_sql_conditions opts
|
44
|
+
cond = "card_actions.card_id = :card_id AND field = :field"
|
45
|
+
cond += " AND (draft is not true)" unless opts[:including_drafts]
|
46
|
+
operator = "<" if opts[:before]
|
47
|
+
operator = "<=" if opts[:not_after]
|
48
|
+
cond += " AND card_action_id #{operator} :action_id" if operator
|
49
|
+
cond
|
50
|
+
end
|
51
|
+
|
48
52
|
def selected_action_id
|
49
53
|
@selected_action_id || (@current_action && @current_action.id) ||
|
50
54
|
last_action_id
|
@@ -61,14 +65,16 @@ end
|
|
61
65
|
|
62
66
|
def with_selected_action_id action_id
|
63
67
|
current_action_id = @selected_action_id
|
64
|
-
|
65
|
-
self.selected_action_id = action_id
|
66
|
-
end
|
68
|
+
select_action_id action_id
|
67
69
|
result = yield
|
70
|
+
select_action_id current_action_id
|
71
|
+
result
|
72
|
+
end
|
73
|
+
|
74
|
+
def select_action_id action_id
|
68
75
|
run_callbacks :select_action do
|
69
|
-
self.selected_action_id =
|
76
|
+
self.selected_action_id = action_id
|
70
77
|
end
|
71
|
-
result
|
72
78
|
end
|
73
79
|
|
74
80
|
def selected_content_action_id
|
@@ -76,10 +82,12 @@ def selected_content_action_id
|
|
76
82
|
end
|
77
83
|
|
78
84
|
def new_content_action_id
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
85
|
+
return unless @current_action && current_action_changes_content?
|
86
|
+
@current_action.id
|
87
|
+
end
|
88
|
+
|
89
|
+
def current_action_changes_content?
|
90
|
+
new_card? || @current_action.new_content? || db_content_changed?
|
83
91
|
end
|
84
92
|
|
85
93
|
def last_action_id
|
@@ -108,7 +116,7 @@ def last_act
|
|
108
116
|
@last_act ||=
|
109
117
|
if (action = last_action)
|
110
118
|
last_act_on_self = acts.last
|
111
|
-
if last_act_on_self &&
|
119
|
+
if last_act_on_self && action.act &&
|
112
120
|
(action.act == last_act_on_self ||
|
113
121
|
last_act_on_self.acted_at > action.act.acted_at)
|
114
122
|
last_act_on_self
|
@@ -123,12 +131,9 @@ def acted_at
|
|
123
131
|
end
|
124
132
|
|
125
133
|
def previous_action action_id
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
end
|
130
|
-
actions[action_index - 1] if action_index.to_i != 0
|
131
|
-
end
|
134
|
+
return unless action_id
|
135
|
+
action_index = actions.find_index { |a| a.id == action_id }
|
136
|
+
actions[action_index - 1] if action_index.to_i.nonzero?
|
132
137
|
end
|
133
138
|
|
134
139
|
def revised_at
|
@@ -151,11 +156,13 @@ def draft_acts
|
|
151
156
|
drafts.created_by(Card::Auth.current_id).map(&:act)
|
152
157
|
end
|
153
158
|
|
154
|
-
event :detect_conflict, :validate,
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
159
|
+
event :detect_conflict, :validate, on: :update,
|
160
|
+
when: proc { |c| c.edit_conflict? } do
|
161
|
+
errors.add :conflict, "changes not based on latest revision"
|
162
|
+
end
|
163
|
+
|
164
|
+
def edit_conflict?
|
165
|
+
last_action_id_before_edit &&
|
166
|
+
last_action_id_before_edit.to_i != last_action_id &&
|
167
|
+
last_action.act.actor_id != Auth.current_id
|
161
168
|
end
|