glib-web 8.1.0 → 8.2.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/app/controllers/concerns/glib/json/libs.rb +16 -0
- data/app/helpers/glib/app_feature_support_helper.rb +33 -8
- data/app/helpers/glib/json_ui/view_builder/fields.rb +74 -9
- data/app/helpers/glib/json_ui/view_builder.rb +15 -0
- data/app/jobs/glib/scheduled_job.rb +581 -0
- data/app/jobs/glib/scheduled_job_tick.rb +21 -0
- data/app/models/glib/scheduled_job_run.rb +16 -0
- data/app/views/json_ui/garage/forms/action_text.json.jbuilder +34 -0
- data/app/views/json_ui/garage/forms/action_text_attachment.json.jbuilder +7 -0
- data/app/views/json_ui/garage/forms/action_text_library.json.jbuilder +26 -0
- data/app/views/json_ui/garage/forms/action_text_preview.json.jbuilder +9 -0
- data/app/views/json_ui/garage/forms/index.json.jbuilder +6 -0
- data/app/views/json_ui/garage/forms/pickers.json.jbuilder +7 -0
- data/app/views/json_ui/garage/test_page/_header.json.jbuilder +6 -0
- data/app/views/json_ui/garage/test_page/fields_actionText.json.jbuilder +87 -0
- data/app/views/json_ui/garage/test_page/fields_sign.json.jbuilder +34 -3
- data/app/views/json_ui/garage/test_page/form_dirty_hooks.json.jbuilder +22 -0
- data/app/views/json_ui/garage/test_page/form_hidden_panels.json.jbuilder +124 -0
- data/app/views/layouts/json_ui/renderer.html.erb +11 -1
- data/engines/blog/README.md +172 -0
- data/engines/blog/app/assets/stylesheets/glib/blog/admin.css +855 -0
- data/engines/blog/app/assets/stylesheets/glib/blog/themes/clean.css +816 -0
- data/engines/blog/app/assets/stylesheets/glib/blog/themes/editorial.css +631 -0
- data/engines/blog/app/controllers/concerns/glib/blog/admin/media_listing.rb +27 -0
- data/engines/blog/app/controllers/concerns/glib/blog/pagination.rb +14 -0
- data/engines/blog/app/controllers/glib/blog/admin/application_controller.rb +28 -0
- data/engines/blog/app/controllers/glib/blog/admin/authors_controller.rb +55 -0
- data/engines/blog/app/controllers/glib/blog/admin/categories_controller.rb +53 -0
- data/engines/blog/app/controllers/glib/blog/admin/comment_replies_controller.rb +34 -0
- data/engines/blog/app/controllers/glib/blog/admin/comments_controller.rb +50 -0
- data/engines/blog/app/controllers/glib/blog/admin/dashboards_controller.rb +34 -0
- data/engines/blog/app/controllers/glib/blog/admin/direct_uploads_controller.rb +30 -0
- data/engines/blog/app/controllers/glib/blog/admin/editor_attachments_controller.rb +16 -0
- data/engines/blog/app/controllers/glib/blog/admin/media_item_trashes_controller.rb +43 -0
- data/engines/blog/app/controllers/glib/blog/admin/media_items_controller.rb +61 -0
- data/engines/blog/app/controllers/glib/blog/admin/media_picks_controller.rb +19 -0
- data/engines/blog/app/controllers/glib/blog/admin/post_bulk_actions_controller.rb +33 -0
- data/engines/blog/app/controllers/glib/blog/admin/posts_controller.rb +79 -0
- data/engines/blog/app/controllers/glib/blog/admin/settings_controller.rb +27 -0
- data/engines/blog/app/controllers/glib/blog/admin/tags_controller.rb +46 -0
- data/engines/blog/app/controllers/glib/blog/application_controller.rb +90 -0
- data/engines/blog/app/controllers/glib/blog/authors_controller.rb +15 -0
- data/engines/blog/app/controllers/glib/blog/categories_controller.rb +15 -0
- data/engines/blog/app/controllers/glib/blog/comments_controller.rb +41 -0
- data/engines/blog/app/controllers/glib/blog/posts_controller.rb +47 -0
- data/engines/blog/app/controllers/glib/blog/tags_controller.rb +15 -0
- data/engines/blog/app/helpers/glib/blog/admin_helper.rb +57 -0
- data/engines/blog/app/helpers/glib/blog/comments_helper.rb +16 -0
- data/engines/blog/app/helpers/glib/blog/post_list_helper.rb +26 -0
- data/engines/blog/app/helpers/glib/blog/theme_helper.rb +85 -0
- data/engines/blog/app/jobs/glib/blog/purge_trash_job.rb +13 -0
- data/engines/blog/app/models/concerns/glib/blog/sluggable.rb +72 -0
- data/engines/blog/app/models/concerns/glib/blog/uses_media.rb +35 -0
- data/engines/blog/app/models/glib/blog/application_record.rb +7 -0
- data/engines/blog/app/models/glib/blog/author.rb +47 -0
- data/engines/blog/app/models/glib/blog/category.rb +53 -0
- data/engines/blog/app/models/glib/blog/comment.rb +66 -0
- data/engines/blog/app/models/glib/blog/comment_token.rb +30 -0
- data/engines/blog/app/models/glib/blog/media_item.rb +121 -0
- data/engines/blog/app/models/glib/blog/media_upload.rb +97 -0
- data/engines/blog/app/models/glib/blog/media_usage.rb +10 -0
- data/engines/blog/app/models/glib/blog/post.rb +110 -0
- data/engines/blog/app/models/glib/blog/post_view.rb +24 -0
- data/engines/blog/app/models/glib/blog/setting.rb +55 -0
- data/engines/blog/app/models/glib/blog/slug_redirect.rb +7 -0
- data/engines/blog/app/models/glib/blog/tag.rb +15 -0
- data/engines/blog/app/models/glib/blog/tagging.rb +10 -0
- data/engines/blog/app/policies/glib/blog/admin/author_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/category_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/comment_policy.rb +16 -0
- data/engines/blog/app/policies/glib/blog/admin/comment_reply_policy.rb +12 -0
- data/engines/blog/app/policies/glib/blog/admin/dashboard_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/direct_upload_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/editor_attachment_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/media_item_policy.rb +20 -0
- data/engines/blog/app/policies/glib/blog/admin/media_item_trash_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/media_pick_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/post_bulk_action_policy.rb +12 -0
- data/engines/blog/app/policies/glib/blog/admin/post_policy.rb +16 -0
- data/engines/blog/app/policies/glib/blog/admin/setting_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/tag_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/application_policy.rb +16 -0
- data/engines/blog/app/policies/glib/blog/author_policy.rb +9 -0
- data/engines/blog/app/policies/glib/blog/category_policy.rb +9 -0
- data/engines/blog/app/policies/glib/blog/comment_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/post_policy.rb +9 -0
- data/engines/blog/app/policies/glib/blog/tag_policy.rb +9 -0
- data/engines/blog/app/views/glib/blog/admin/_delete_button.json.jbuilder +24 -0
- data/engines/blog/app/views/glib/blog/admin/_nav.json.jbuilder +45 -0
- data/engines/blog/app/views/glib/blog/admin/_status_chip.json.jbuilder +2 -0
- data/engines/blog/app/views/glib/blog/admin/authors/_form.json.jbuilder +17 -0
- data/engines/blog/app/views/glib/blog/admin/authors/edit.json.jbuilder +7 -0
- data/engines/blog/app/views/glib/blog/admin/authors/index.json.jbuilder +50 -0
- data/engines/blog/app/views/glib/blog/admin/authors/new.json.jbuilder +11 -0
- data/engines/blog/app/views/glib/blog/admin/categories/_form.json.jbuilder +13 -0
- data/engines/blog/app/views/glib/blog/admin/categories/edit.json.jbuilder +7 -0
- data/engines/blog/app/views/glib/blog/admin/categories/index.json.jbuilder +68 -0
- data/engines/blog/app/views/glib/blog/admin/categories/new.json.jbuilder +7 -0
- data/engines/blog/app/views/glib/blog/admin/comments/_moderation_buttons.json.jbuilder +35 -0
- data/engines/blog/app/views/glib/blog/admin/comments/index.json.jbuilder +59 -0
- data/engines/blog/app/views/glib/blog/admin/dashboards/show.json.jbuilder +109 -0
- data/engines/blog/app/views/glib/blog/admin/media_item_trashes/index.json.jbuilder +32 -0
- data/engines/blog/app/views/glib/blog/admin/media_items/_rows.json.jbuilder +32 -0
- data/engines/blog/app/views/glib/blog/admin/media_items/edit.json.jbuilder +68 -0
- data/engines/blog/app/views/glib/blog/admin/media_items/index.json.jbuilder +68 -0
- data/engines/blog/app/views/glib/blog/admin/media_items/new.json.jbuilder +18 -0
- data/engines/blog/app/views/glib/blog/admin/media_picks/index.json.jbuilder +29 -0
- data/engines/blog/app/views/glib/blog/admin/posts/_form.json.jbuilder +104 -0
- data/engines/blog/app/views/glib/blog/admin/posts/edit.json.jbuilder +1 -0
- data/engines/blog/app/views/glib/blog/admin/posts/index.json.jbuilder +109 -0
- data/engines/blog/app/views/glib/blog/admin/posts/new.json.jbuilder +1 -0
- data/engines/blog/app/views/glib/blog/admin/settings/edit.json.jbuilder +55 -0
- data/engines/blog/app/views/glib/blog/admin/tags/_form.json.jbuilder +6 -0
- data/engines/blog/app/views/glib/blog/admin/tags/edit.json.jbuilder +7 -0
- data/engines/blog/app/views/glib/blog/admin/tags/index.json.jbuilder +30 -0
- data/engines/blog/app/views/glib/blog/admin/tags/new.json.jbuilder +7 -0
- data/engines/blog/app/views/glib/blog/authors/show.json.jbuilder +4 -0
- data/engines/blog/app/views/glib/blog/categories/show.json.jbuilder +4 -0
- data/engines/blog/app/views/glib/blog/comments/pending.json.jbuilder +7 -0
- data/engines/blog/app/views/glib/blog/media_items/_media_item.html.erb +14 -0
- data/engines/blog/app/views/glib/blog/posts/_comment.json.jbuilder +23 -0
- data/engines/blog/app/views/glib/blog/posts/_comment_form.json.jbuilder +14 -0
- data/engines/blog/app/views/glib/blog/posts/_comments.json.jbuilder +21 -0
- data/engines/blog/app/views/glib/blog/posts/index.json.jbuilder +4 -0
- data/engines/blog/app/views/glib/blog/posts/show.json.jbuilder +5 -0
- data/engines/blog/app/views/glib/blog/shared/errors.json.jbuilder +5 -0
- data/engines/blog/app/views/glib/blog/tags/show.json.jbuilder +3 -0
- data/engines/blog/app/views/glib/blog/themes/_nav_links.json.jbuilder +12 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_brand.json.jbuilder +11 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_card.json.jbuilder +15 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_featured.json.jbuilder +23 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_footer.json.jbuilder +15 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_header.json.jbuilder +9 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_post.json.jbuilder +98 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_post_list.json.jbuilder +40 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_post_rows.json.jbuilder +10 -0
- data/engines/blog/app/views/glib/blog/themes/editorial/_footer.json.jbuilder +15 -0
- data/engines/blog/app/views/glib/blog/themes/editorial/_header.json.jbuilder +11 -0
- data/engines/blog/app/views/glib/blog/themes/editorial/_post.json.jbuilder +62 -0
- data/engines/blog/app/views/glib/blog/themes/editorial/_post_list.json.jbuilder +25 -0
- data/engines/blog/app/views/glib/blog/themes/editorial/_post_rows.json.jbuilder +18 -0
- data/engines/blog/config/locales/en.yml +500 -0
- data/engines/blog/config/routes.rb +33 -0
- data/engines/blog/db/migrate/20261103090000_create_glib_blog_tables.rb +70 -0
- data/engines/blog/db/migrate/20261104090000_create_glib_blog_media_tables.rb +44 -0
- data/engines/blog/db/migrate/20261104120000_create_glib_blog_comments.rb +23 -0
- data/engines/blog/db/migrate/20261105090000_add_glib_blog_comment_moderation.rb +16 -0
- data/engines/blog/db/migrate/20261105100000_add_deleted_at_to_glib_blog_posts.rb +6 -0
- data/engines/blog/db/migrate/20261105110000_add_parent_and_default_to_glib_blog_categories.rb +10 -0
- data/engines/blog/db/migrate/20261105120000_create_glib_blog_post_views.rb +13 -0
- data/engines/blog/db/migrate/20261105130000_create_glib_blog_settings.rb +26 -0
- data/engines/blog/db/migrate/20261106090000_add_theme_to_glib_blog_settings.rb +7 -0
- data/engines/blog/lib/tasks/glib_blog_tasks.rake +32 -0
- data/lib/generators/glib/blog/install_generator.rb +44 -0
- data/lib/generators/glib/blog/templates/initializer.rb +22 -0
- data/lib/generators/glib/scheduled_jobs_generator.rb +30 -0
- data/lib/generators/templates/scheduled_jobs/create_glib_scheduled_job_runs.rb +22 -0
- data/lib/glib/blog/engine.rb +20 -0
- data/lib/glib/blog/theme.rb +35 -0
- data/lib/glib/blog.rb +50 -0
- data/lib/glib/engine.rb +17 -0
- data/lib/glib/scheduled_jobs/config.rb +36 -0
- data/lib/glib/scheduled_jobs/loader.rb +98 -0
- data/lib/glib-web.rb +2 -0
- metadata +174 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 34303dceef76e44cc3f0530801993cedc604363504387a232bba9d7da04bd504
|
|
4
|
+
data.tar.gz: 772a21344d981cf98557d4dc9685dc437ce26265c2191e1b38d7c9462d280f23
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d6c73b777a6b8b63e09477dfa73b1370665c875b89217fc858a4eb071f19e7a74e74a6898ea3cd31d4803675308c72be0653a665e418a76fcd43090cbaf2874b
|
|
7
|
+
data.tar.gz: 2eb45d0ea0806f6f1a3eacfe7b0d12160a3f5e28d3eccf180cc73b8371fb6ce2ba26e31c0621e3548ec4ac63b64ff706a85de0b9a589ecfebb31e836734d8520
|
|
@@ -4,8 +4,15 @@ module Glib::Json::Libs
|
|
|
4
4
|
included do
|
|
5
5
|
extend ClassMethods
|
|
6
6
|
|
|
7
|
+
# Glib::AppFeatureSupportHelper ships as a view helper (AllHelpers does
|
|
8
|
+
# `base.helper`), which never reaches controller ancestry — but the
|
|
9
|
+
# json_ui_app_version_gte? predicate below delegates to
|
|
10
|
+
# glib_app_version_gte, so the concern includes it itself (spec 464).
|
|
11
|
+
include Glib::AppFeatureSupportHelper
|
|
12
|
+
|
|
7
13
|
helper_method :json_ui_app_bundle_id, :json_ui_app_build_version, :json_ui_app_device_os
|
|
8
14
|
helper_method :json_ui_app_is_android?, :json_ui_app_is_ios?, :json_ui_app_is_web?
|
|
15
|
+
helper_method :json_ui_app_version_gte?
|
|
9
16
|
# helper_method :json_ui_redirect_back_or_to
|
|
10
17
|
helper_method :delete_redirect_back_url, :redirect_back_url
|
|
11
18
|
|
|
@@ -41,6 +48,15 @@ module Glib::Json::Libs
|
|
|
41
48
|
json_ui_app_device_os == 'web'
|
|
42
49
|
end
|
|
43
50
|
|
|
51
|
+
# Version predicate beside the OS ones (spec 464, Decision 8), so a view
|
|
52
|
+
# can write `json_ui_app_is_ios? && json_ui_app_version_gte?('2.0')`
|
|
53
|
+
# without the dictionary. One compare: delegates to
|
|
54
|
+
# glib_app_version_gte, which treats a blank or malformed version as
|
|
55
|
+
# passing (web never sends one).
|
|
56
|
+
def json_ui_app_version_gte?(version)
|
|
57
|
+
glib_app_version_gte(version, json_ui_app_build_version)
|
|
58
|
+
end
|
|
59
|
+
|
|
44
60
|
def json_ui_etag
|
|
45
61
|
template = "#{controller_name}/#{action_name}"
|
|
46
62
|
|
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
module Glib
|
|
2
2
|
module AppFeatureSupportHelper
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
RESERVED_KEYS = %i[default except].freeze
|
|
4
|
+
# Feature-support gate (spec 464): per-feature, per-device minimum
|
|
5
|
+
# versions, read from what the request itself carries. Every feature
|
|
6
|
+
# entry is a Hash keyed by device (`:android`/`:ios`/`:web`), with
|
|
7
|
+
# `:default` and `:except` as the reserved keys — never read as
|
|
8
|
+
# devices:
|
|
9
|
+
#
|
|
10
|
+
# { my_feature: { android: '1.4.0', ios: '2.0', web: :all,
|
|
11
|
+
# default: '1.5', except: { android: '1.4.1' } } }
|
|
12
|
+
#
|
|
13
|
+
# A device key wins; a device without its own key falls back to
|
|
14
|
+
# `:default`; a feature with neither is unsupported. `:all` passes any
|
|
15
|
+
# client, and `except` excludes one exact version. An iOS-only
|
|
16
|
+
# component is `{ my_feature: { ios: '2.0' } }` — true only for iOS
|
|
17
|
+
# clients at 2.0 or later.
|
|
18
|
+
def glib_app_feature_supported?(name, dictionary, app_version: json_ui_app_build_version)
|
|
19
|
+
entry = dictionary[name.to_sym] or return false
|
|
20
|
+
device = json_ui_app_device_os.to_sym
|
|
21
|
+
# The device comes from a client header, so a client can send
|
|
22
|
+
# JsonUiApp-Device-Os: except — treating the reserved keys as
|
|
23
|
+
# devices would use the except Hash as a minimum version and raise
|
|
24
|
+
# inside Gem::Version (review round 1).
|
|
25
|
+
version = entry.key?(device) && !RESERVED_KEYS.include?(device) ? entry[device] : entry[:default]
|
|
26
|
+
except = entry.dig(:except, device)
|
|
27
|
+
!version.nil? && (version == :all || glib_app_version_gte(version, app_version)) &&
|
|
28
|
+
(except.nil? || except.to_s != app_version)
|
|
10
29
|
end
|
|
11
30
|
|
|
12
31
|
def glib_app_version_gte(feature_version, app_version)
|
|
13
|
-
|
|
32
|
+
# A blank version passes any minimum (web never sends one). A
|
|
33
|
+
# malformed one is treated as blank rather than raised: the version
|
|
34
|
+
# arrives as a client header, and a page render must not 500 on it
|
|
35
|
+
# (spec 464, Decision 7).
|
|
36
|
+
return true if app_version.blank? || !Gem::Version.correct?(app_version)
|
|
37
|
+
|
|
38
|
+
Gem::Version.new(app_version) >= Gem::Version.new(feature_version)
|
|
14
39
|
end
|
|
15
40
|
end
|
|
16
41
|
end
|
|
@@ -665,6 +665,62 @@ class Glib::JsonUi::ViewBuilder
|
|
|
665
665
|
bool :debug
|
|
666
666
|
end
|
|
667
667
|
|
|
668
|
+
# Trix editor field that submits the same HTML as Rails' Action Text form helper,
|
|
669
|
+
# so the value can be assigned straight to a `has_rich_text` attribute.
|
|
670
|
+
#
|
|
671
|
+
# Attached files are uploaded directly to Active Storage and embedded as Action Text
|
|
672
|
+
# attachments (identified by the blob's `attachable_sgid`), so `has_rich_text` resolves
|
|
673
|
+
# them on save without any custom parsing. Requires the host app to load
|
|
674
|
+
# `action_text/engine`.
|
|
675
|
+
#
|
|
676
|
+
# When `prop` refers to a `has_rich_text` attribute, the field is pre-filled with the
|
|
677
|
+
# attribute's `to_trix_html`.
|
|
678
|
+
#
|
|
679
|
+
# @example Action Text attribute on a model form
|
|
680
|
+
# form.fields_actionText \
|
|
681
|
+
# prop: :body,
|
|
682
|
+
# width: 'matchParent',
|
|
683
|
+
# directUploadUrl: glib_direct_uploads_url,
|
|
684
|
+
# blobUrlGenerator: glib_blob_url_generators_url,
|
|
685
|
+
# accepts: { fileType: ['image', 'pdf'], maxFileSize: 10_000 }
|
|
686
|
+
#
|
|
687
|
+
# @see app/views/json_ui/garage/forms/action_text.json.jbuilder Garage example
|
|
688
|
+
# @see ViewBuilder::ActionText View that renders the saved content
|
|
689
|
+
class ActionText < AbstractField
|
|
690
|
+
include Glib::JsonUi::Upload
|
|
691
|
+
include Glib::JsonUi::FileUploadErrorHandler
|
|
692
|
+
|
|
693
|
+
# Endpoint that receives `signed_id` and returns `{ url: ... }` for an uploaded blob.
|
|
694
|
+
# The URL becomes the attachment's preview in the editor. File attachments are
|
|
695
|
+
# disabled when `directUploadUrl` or both this and `attachmentUrl` are missing.
|
|
696
|
+
# @example blobUrlGenerator: glib_blob_url_generators_url
|
|
697
|
+
string :blobUrlGenerator
|
|
698
|
+
|
|
699
|
+
# Endpoint that receives an uploaded blob's `signed_id` and returns the Trix attachment
|
|
700
|
+
# attributes to embed instead of the blob's own (at least `sgid` and `url`). Lets an app
|
|
701
|
+
# turn uploads into its own Action Text attachables, e.g. media library items. Replaces
|
|
702
|
+
# `blobUrlGenerator` when set.
|
|
703
|
+
# @example attachmentUrl: editor_attachments_url
|
|
704
|
+
string :attachmentUrl
|
|
705
|
+
|
|
706
|
+
# Page opened in a dialog by an "Insert from library" toolbar button. The page inserts a
|
|
707
|
+
# file by invoking the field's `insertAttachment` method with the attachment attributes
|
|
708
|
+
# (`components_invoke targetId: <field id>, name: 'insertAttachment', arguments: {...}`).
|
|
709
|
+
# @example libraryUrl: media_picks_url(target: 'post_body')
|
|
710
|
+
string :libraryUrl
|
|
711
|
+
|
|
712
|
+
def created
|
|
713
|
+
super
|
|
714
|
+
file_upload_error_handler_on_create
|
|
715
|
+
end
|
|
716
|
+
|
|
717
|
+
# Override
|
|
718
|
+
def determine_value(context, prop)
|
|
719
|
+
value = super
|
|
720
|
+
value.is_a?(::ActionText::RichText) ? value.to_trix_html : value
|
|
721
|
+
end
|
|
722
|
+
end
|
|
723
|
+
|
|
668
724
|
class Select < AbstractField
|
|
669
725
|
attr_reader :_options
|
|
670
726
|
|
|
@@ -918,10 +974,16 @@ class Glib::JsonUi::ViewBuilder
|
|
|
918
974
|
# @example Offered saved signature
|
|
919
975
|
# # The app composes the menu on the empty box from generic pieces:
|
|
920
976
|
# # `onClick` runs while the field is blank, `popovers_show
|
|
921
|
-
# # anchor: 'pointer'` opens it at the tap point,
|
|
922
|
-
# #
|
|
923
|
-
# #
|
|
924
|
-
# #
|
|
977
|
+
# # anchor: 'pointer'` opens it at the tap point,
|
|
978
|
+
# # `components_invoke action_setSignature` applies a provided
|
|
979
|
+
# # signature as a USER gesture (the form's dirty tracking and onChange
|
|
980
|
+
# # hooks fire, so a pristine form becomes dirty), and
|
|
981
|
+
# # `components_invoke action_open` opens the dialog. The action takes the
|
|
982
|
+
# # signature as REQUIRED `arguments: { value, fileUrl }` -- the field
|
|
983
|
+
# # carries no saved signature of its own. A plain `logics_set` of the same
|
|
984
|
+
# # id previews it too but is the deliberate dirty-tracking non-trigger,
|
|
985
|
+
# # for flows that fill the field without a user gesture.
|
|
986
|
+
# # See the garage page for the full two-row composition.
|
|
925
987
|
# form.fields_sign \
|
|
926
988
|
# id: 'signature_offered',
|
|
927
989
|
# name: 'user[signature_offered]',
|
|
@@ -934,14 +996,14 @@ class Glib::JsonUi::ViewBuilder
|
|
|
934
996
|
# body.panels_horizontal styleClasses: ['popover-menu-item'], align: 'middle',
|
|
935
997
|
# childViews: ->(row) { row.label text: 'Use my saved signature' },
|
|
936
998
|
# onClick: ->(sub) do
|
|
937
|
-
# sub.
|
|
999
|
+
# sub.components_invoke targetId: 'signature_offered', name: 'action_setSignature',
|
|
1000
|
+
# arguments: { value: 'saved-signed-id', fileUrl: signature_url }
|
|
938
1001
|
# end
|
|
939
1002
|
# end
|
|
940
1003
|
# end
|
|
941
1004
|
# end,
|
|
942
1005
|
# draw: {
|
|
943
1006
|
# hint: 'Draw it once. We keep it for next time.',
|
|
944
|
-
# savedSignature: { value: 'saved-signed-id', fileUrl: signature_url },
|
|
945
1007
|
# saveOption: { name: 'user[save_signature_offered]', label: 'Save this signature for next time' }
|
|
946
1008
|
# }
|
|
947
1009
|
#
|
|
@@ -982,9 +1044,12 @@ class Glib::JsonUi::ViewBuilder
|
|
|
982
1044
|
# is a line under the canvas, shown only while the canvas is blank;
|
|
983
1045
|
# `placeholder` replaces the in-canvas "Draw your signature here" cue;
|
|
984
1046
|
# `confirmedHint` is the line under a painted (read-only) drawing on reopen;
|
|
985
|
-
# `savedSignature` is plain data
|
|
986
|
-
#
|
|
987
|
-
#
|
|
1047
|
+
# `savedSignature` is plain data serving ONE path: when an external
|
|
1048
|
+
# `logics_set` writes the field's value to `value` (not `action_setSignature`,
|
|
1049
|
+
# which takes its signature as arguments) the box previews `fileUrl`; a
|
|
1050
|
+
# `logics_set` stays a dirty-tracking non-trigger. Omit it unless the app
|
|
1051
|
+
# offers a signature through `logics_set`; `saveOption` is
|
|
1052
|
+
# a checkbox shown under fresh ink, in the
|
|
988
1053
|
# fields_check shape, whose tick is submitted under `saveOption[:name]` as a
|
|
989
1054
|
# SECOND hidden input -- the one exception to the field's single-param
|
|
990
1055
|
# contract, because a boolean cannot share the input that carries the signed
|
|
@@ -227,6 +227,21 @@ module Glib
|
|
|
227
227
|
class Html < AbstractText
|
|
228
228
|
end
|
|
229
229
|
|
|
230
|
+
# Renders Action Text content the way Rails' `rich_text.to_s` does: sanitized HTML
|
|
231
|
+
# with attachments expanded through their partials, styled as Trix content.
|
|
232
|
+
#
|
|
233
|
+
# @example Display a `has_rich_text` attribute
|
|
234
|
+
# panel.actionText richText: @post.body
|
|
235
|
+
#
|
|
236
|
+
# @see Fields::ActionText Field that edits the content
|
|
237
|
+
class ActionText < View
|
|
238
|
+
# An `ActionText::RichText` (a `has_rich_text` attribute), `ActionText::Content`, or the
|
|
239
|
+
# HTML one of them rendered.
|
|
240
|
+
def richText(rich_text)
|
|
241
|
+
json.set! 'html', rich_text.to_s
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
|
|
230
245
|
class Label < AbstractText
|
|
231
246
|
# hash :actionCable
|
|
232
247
|
# string :format
|