glib-web 8.0.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.
Files changed (171) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/glib/json/libs.rb +16 -0
  3. data/app/helpers/glib/app_feature_support_helper.rb +33 -8
  4. data/app/helpers/glib/json_ui/view_builder/fields.rb +74 -9
  5. data/app/helpers/glib/json_ui/view_builder/panels.rb +1 -0
  6. data/app/helpers/glib/json_ui/view_builder.rb +15 -0
  7. data/app/jobs/glib/scheduled_job.rb +581 -0
  8. data/app/jobs/glib/scheduled_job_tick.rb +21 -0
  9. data/app/models/concerns/glib/enum_symbolization.rb +41 -4
  10. data/app/models/glib/scheduled_job_run.rb +16 -0
  11. data/app/views/json_ui/garage/forms/action_text.json.jbuilder +34 -0
  12. data/app/views/json_ui/garage/forms/action_text_attachment.json.jbuilder +7 -0
  13. data/app/views/json_ui/garage/forms/action_text_library.json.jbuilder +26 -0
  14. data/app/views/json_ui/garage/forms/action_text_preview.json.jbuilder +9 -0
  15. data/app/views/json_ui/garage/forms/index.json.jbuilder +6 -0
  16. data/app/views/json_ui/garage/forms/pickers.json.jbuilder +7 -0
  17. data/app/views/json_ui/garage/panels/carousel.json.jbuilder +7 -0
  18. data/app/views/json_ui/garage/test_page/_header.json.jbuilder +6 -0
  19. data/app/views/json_ui/garage/test_page/fields_actionText.json.jbuilder +87 -0
  20. data/app/views/json_ui/garage/test_page/fields_sign.json.jbuilder +34 -3
  21. data/app/views/json_ui/garage/test_page/form_dirty_hooks.json.jbuilder +22 -0
  22. data/app/views/json_ui/garage/test_page/form_hidden_panels.json.jbuilder +124 -0
  23. data/app/views/json_ui/garage/test_page/logics_set.json.jbuilder +35 -0
  24. data/app/views/json_ui/garage/test_page/panels_association.json.jbuilder +42 -0
  25. data/app/views/layouts/json_ui/renderer.html.erb +11 -1
  26. data/engines/blog/README.md +172 -0
  27. data/engines/blog/app/assets/stylesheets/glib/blog/admin.css +855 -0
  28. data/engines/blog/app/assets/stylesheets/glib/blog/themes/clean.css +816 -0
  29. data/engines/blog/app/assets/stylesheets/glib/blog/themes/editorial.css +631 -0
  30. data/engines/blog/app/controllers/concerns/glib/blog/admin/media_listing.rb +27 -0
  31. data/engines/blog/app/controllers/concerns/glib/blog/pagination.rb +14 -0
  32. data/engines/blog/app/controllers/glib/blog/admin/application_controller.rb +28 -0
  33. data/engines/blog/app/controllers/glib/blog/admin/authors_controller.rb +55 -0
  34. data/engines/blog/app/controllers/glib/blog/admin/categories_controller.rb +53 -0
  35. data/engines/blog/app/controllers/glib/blog/admin/comment_replies_controller.rb +34 -0
  36. data/engines/blog/app/controllers/glib/blog/admin/comments_controller.rb +50 -0
  37. data/engines/blog/app/controllers/glib/blog/admin/dashboards_controller.rb +34 -0
  38. data/engines/blog/app/controllers/glib/blog/admin/direct_uploads_controller.rb +30 -0
  39. data/engines/blog/app/controllers/glib/blog/admin/editor_attachments_controller.rb +16 -0
  40. data/engines/blog/app/controllers/glib/blog/admin/media_item_trashes_controller.rb +43 -0
  41. data/engines/blog/app/controllers/glib/blog/admin/media_items_controller.rb +61 -0
  42. data/engines/blog/app/controllers/glib/blog/admin/media_picks_controller.rb +19 -0
  43. data/engines/blog/app/controllers/glib/blog/admin/post_bulk_actions_controller.rb +33 -0
  44. data/engines/blog/app/controllers/glib/blog/admin/posts_controller.rb +79 -0
  45. data/engines/blog/app/controllers/glib/blog/admin/settings_controller.rb +27 -0
  46. data/engines/blog/app/controllers/glib/blog/admin/tags_controller.rb +46 -0
  47. data/engines/blog/app/controllers/glib/blog/application_controller.rb +90 -0
  48. data/engines/blog/app/controllers/glib/blog/authors_controller.rb +15 -0
  49. data/engines/blog/app/controllers/glib/blog/categories_controller.rb +15 -0
  50. data/engines/blog/app/controllers/glib/blog/comments_controller.rb +41 -0
  51. data/engines/blog/app/controllers/glib/blog/posts_controller.rb +47 -0
  52. data/engines/blog/app/controllers/glib/blog/tags_controller.rb +15 -0
  53. data/engines/blog/app/helpers/glib/blog/admin_helper.rb +57 -0
  54. data/engines/blog/app/helpers/glib/blog/comments_helper.rb +16 -0
  55. data/engines/blog/app/helpers/glib/blog/post_list_helper.rb +26 -0
  56. data/engines/blog/app/helpers/glib/blog/theme_helper.rb +85 -0
  57. data/engines/blog/app/jobs/glib/blog/purge_trash_job.rb +13 -0
  58. data/engines/blog/app/models/concerns/glib/blog/sluggable.rb +72 -0
  59. data/engines/blog/app/models/concerns/glib/blog/uses_media.rb +35 -0
  60. data/engines/blog/app/models/glib/blog/application_record.rb +7 -0
  61. data/engines/blog/app/models/glib/blog/author.rb +47 -0
  62. data/engines/blog/app/models/glib/blog/category.rb +53 -0
  63. data/engines/blog/app/models/glib/blog/comment.rb +66 -0
  64. data/engines/blog/app/models/glib/blog/comment_token.rb +30 -0
  65. data/engines/blog/app/models/glib/blog/media_item.rb +121 -0
  66. data/engines/blog/app/models/glib/blog/media_upload.rb +97 -0
  67. data/engines/blog/app/models/glib/blog/media_usage.rb +10 -0
  68. data/engines/blog/app/models/glib/blog/post.rb +110 -0
  69. data/engines/blog/app/models/glib/blog/post_view.rb +24 -0
  70. data/engines/blog/app/models/glib/blog/setting.rb +55 -0
  71. data/engines/blog/app/models/glib/blog/slug_redirect.rb +7 -0
  72. data/engines/blog/app/models/glib/blog/tag.rb +15 -0
  73. data/engines/blog/app/models/glib/blog/tagging.rb +10 -0
  74. data/engines/blog/app/policies/glib/blog/admin/author_policy.rb +11 -0
  75. data/engines/blog/app/policies/glib/blog/admin/category_policy.rb +11 -0
  76. data/engines/blog/app/policies/glib/blog/admin/comment_policy.rb +16 -0
  77. data/engines/blog/app/policies/glib/blog/admin/comment_reply_policy.rb +12 -0
  78. data/engines/blog/app/policies/glib/blog/admin/dashboard_policy.rb +11 -0
  79. data/engines/blog/app/policies/glib/blog/admin/direct_upload_policy.rb +11 -0
  80. data/engines/blog/app/policies/glib/blog/admin/editor_attachment_policy.rb +11 -0
  81. data/engines/blog/app/policies/glib/blog/admin/media_item_policy.rb +20 -0
  82. data/engines/blog/app/policies/glib/blog/admin/media_item_trash_policy.rb +11 -0
  83. data/engines/blog/app/policies/glib/blog/admin/media_pick_policy.rb +11 -0
  84. data/engines/blog/app/policies/glib/blog/admin/post_bulk_action_policy.rb +12 -0
  85. data/engines/blog/app/policies/glib/blog/admin/post_policy.rb +16 -0
  86. data/engines/blog/app/policies/glib/blog/admin/setting_policy.rb +11 -0
  87. data/engines/blog/app/policies/glib/blog/admin/tag_policy.rb +11 -0
  88. data/engines/blog/app/policies/glib/blog/application_policy.rb +16 -0
  89. data/engines/blog/app/policies/glib/blog/author_policy.rb +9 -0
  90. data/engines/blog/app/policies/glib/blog/category_policy.rb +9 -0
  91. data/engines/blog/app/policies/glib/blog/comment_policy.rb +11 -0
  92. data/engines/blog/app/policies/glib/blog/post_policy.rb +9 -0
  93. data/engines/blog/app/policies/glib/blog/tag_policy.rb +9 -0
  94. data/engines/blog/app/views/glib/blog/admin/_delete_button.json.jbuilder +24 -0
  95. data/engines/blog/app/views/glib/blog/admin/_nav.json.jbuilder +45 -0
  96. data/engines/blog/app/views/glib/blog/admin/_status_chip.json.jbuilder +2 -0
  97. data/engines/blog/app/views/glib/blog/admin/authors/_form.json.jbuilder +17 -0
  98. data/engines/blog/app/views/glib/blog/admin/authors/edit.json.jbuilder +7 -0
  99. data/engines/blog/app/views/glib/blog/admin/authors/index.json.jbuilder +50 -0
  100. data/engines/blog/app/views/glib/blog/admin/authors/new.json.jbuilder +11 -0
  101. data/engines/blog/app/views/glib/blog/admin/categories/_form.json.jbuilder +13 -0
  102. data/engines/blog/app/views/glib/blog/admin/categories/edit.json.jbuilder +7 -0
  103. data/engines/blog/app/views/glib/blog/admin/categories/index.json.jbuilder +68 -0
  104. data/engines/blog/app/views/glib/blog/admin/categories/new.json.jbuilder +7 -0
  105. data/engines/blog/app/views/glib/blog/admin/comments/_moderation_buttons.json.jbuilder +35 -0
  106. data/engines/blog/app/views/glib/blog/admin/comments/index.json.jbuilder +59 -0
  107. data/engines/blog/app/views/glib/blog/admin/dashboards/show.json.jbuilder +109 -0
  108. data/engines/blog/app/views/glib/blog/admin/media_item_trashes/index.json.jbuilder +32 -0
  109. data/engines/blog/app/views/glib/blog/admin/media_items/_rows.json.jbuilder +32 -0
  110. data/engines/blog/app/views/glib/blog/admin/media_items/edit.json.jbuilder +68 -0
  111. data/engines/blog/app/views/glib/blog/admin/media_items/index.json.jbuilder +68 -0
  112. data/engines/blog/app/views/glib/blog/admin/media_items/new.json.jbuilder +18 -0
  113. data/engines/blog/app/views/glib/blog/admin/media_picks/index.json.jbuilder +29 -0
  114. data/engines/blog/app/views/glib/blog/admin/posts/_form.json.jbuilder +104 -0
  115. data/engines/blog/app/views/glib/blog/admin/posts/edit.json.jbuilder +1 -0
  116. data/engines/blog/app/views/glib/blog/admin/posts/index.json.jbuilder +109 -0
  117. data/engines/blog/app/views/glib/blog/admin/posts/new.json.jbuilder +1 -0
  118. data/engines/blog/app/views/glib/blog/admin/settings/edit.json.jbuilder +55 -0
  119. data/engines/blog/app/views/glib/blog/admin/tags/_form.json.jbuilder +6 -0
  120. data/engines/blog/app/views/glib/blog/admin/tags/edit.json.jbuilder +7 -0
  121. data/engines/blog/app/views/glib/blog/admin/tags/index.json.jbuilder +30 -0
  122. data/engines/blog/app/views/glib/blog/admin/tags/new.json.jbuilder +7 -0
  123. data/engines/blog/app/views/glib/blog/authors/show.json.jbuilder +4 -0
  124. data/engines/blog/app/views/glib/blog/categories/show.json.jbuilder +4 -0
  125. data/engines/blog/app/views/glib/blog/comments/pending.json.jbuilder +7 -0
  126. data/engines/blog/app/views/glib/blog/media_items/_media_item.html.erb +14 -0
  127. data/engines/blog/app/views/glib/blog/posts/_comment.json.jbuilder +23 -0
  128. data/engines/blog/app/views/glib/blog/posts/_comment_form.json.jbuilder +14 -0
  129. data/engines/blog/app/views/glib/blog/posts/_comments.json.jbuilder +21 -0
  130. data/engines/blog/app/views/glib/blog/posts/index.json.jbuilder +4 -0
  131. data/engines/blog/app/views/glib/blog/posts/show.json.jbuilder +5 -0
  132. data/engines/blog/app/views/glib/blog/shared/errors.json.jbuilder +5 -0
  133. data/engines/blog/app/views/glib/blog/tags/show.json.jbuilder +3 -0
  134. data/engines/blog/app/views/glib/blog/themes/_nav_links.json.jbuilder +12 -0
  135. data/engines/blog/app/views/glib/blog/themes/clean/_brand.json.jbuilder +11 -0
  136. data/engines/blog/app/views/glib/blog/themes/clean/_card.json.jbuilder +15 -0
  137. data/engines/blog/app/views/glib/blog/themes/clean/_featured.json.jbuilder +23 -0
  138. data/engines/blog/app/views/glib/blog/themes/clean/_footer.json.jbuilder +15 -0
  139. data/engines/blog/app/views/glib/blog/themes/clean/_header.json.jbuilder +9 -0
  140. data/engines/blog/app/views/glib/blog/themes/clean/_post.json.jbuilder +98 -0
  141. data/engines/blog/app/views/glib/blog/themes/clean/_post_list.json.jbuilder +40 -0
  142. data/engines/blog/app/views/glib/blog/themes/clean/_post_rows.json.jbuilder +10 -0
  143. data/engines/blog/app/views/glib/blog/themes/editorial/_footer.json.jbuilder +15 -0
  144. data/engines/blog/app/views/glib/blog/themes/editorial/_header.json.jbuilder +11 -0
  145. data/engines/blog/app/views/glib/blog/themes/editorial/_post.json.jbuilder +62 -0
  146. data/engines/blog/app/views/glib/blog/themes/editorial/_post_list.json.jbuilder +25 -0
  147. data/engines/blog/app/views/glib/blog/themes/editorial/_post_rows.json.jbuilder +18 -0
  148. data/engines/blog/config/locales/en.yml +500 -0
  149. data/engines/blog/config/routes.rb +33 -0
  150. data/engines/blog/db/migrate/20261103090000_create_glib_blog_tables.rb +70 -0
  151. data/engines/blog/db/migrate/20261104090000_create_glib_blog_media_tables.rb +44 -0
  152. data/engines/blog/db/migrate/20261104120000_create_glib_blog_comments.rb +23 -0
  153. data/engines/blog/db/migrate/20261105090000_add_glib_blog_comment_moderation.rb +16 -0
  154. data/engines/blog/db/migrate/20261105100000_add_deleted_at_to_glib_blog_posts.rb +6 -0
  155. data/engines/blog/db/migrate/20261105110000_add_parent_and_default_to_glib_blog_categories.rb +10 -0
  156. data/engines/blog/db/migrate/20261105120000_create_glib_blog_post_views.rb +13 -0
  157. data/engines/blog/db/migrate/20261105130000_create_glib_blog_settings.rb +26 -0
  158. data/engines/blog/db/migrate/20261106090000_add_theme_to_glib_blog_settings.rb +7 -0
  159. data/engines/blog/lib/tasks/glib_blog_tasks.rake +32 -0
  160. data/lib/generators/glib/blog/install_generator.rb +44 -0
  161. data/lib/generators/glib/blog/templates/initializer.rb +22 -0
  162. data/lib/generators/glib/scheduled_jobs_generator.rb +30 -0
  163. data/lib/generators/templates/scheduled_jobs/create_glib_scheduled_job_runs.rb +22 -0
  164. data/lib/glib/blog/engine.rb +20 -0
  165. data/lib/glib/blog/theme.rb +35 -0
  166. data/lib/glib/blog.rb +50 -0
  167. data/lib/glib/engine.rb +17 -0
  168. data/lib/glib/scheduled_jobs/config.rb +36 -0
  169. data/lib/glib/scheduled_jobs/loader.rb +98 -0
  170. data/lib/glib-web.rb +2 -0
  171. metadata +175 -3
@@ -0,0 +1,16 @@
1
+ module Glib
2
+ # Persisted run gate for run_once Glib::ScheduledJob subclasses: one row per
3
+ # cron name holding the last completed period key. Installed by
4
+ # `rails g glib:scheduled_jobs`. Stored in the database (not Redis) so a
5
+ # flush or a mismatched restore cannot re-send a period's side effects.
6
+ #
7
+ # The framework writes through upsert, which SKIPS these validations -- on
8
+ # that path the columns' NOT NULL constraints are the guard. The presence
9
+ # validations below only guard hand-made create!/save calls (a console, a
10
+ # script).
11
+ class ScheduledJobRun < ApplicationRecord
12
+ self.table_name = 'glib_scheduled_job_runs'
13
+
14
+ validates :job_name, :period_key, :completed_at, presence: true
15
+ end
16
+ end
@@ -0,0 +1,34 @@
1
+ json.title 'Forms'
2
+
3
+ page = json_ui_page json
4
+
5
+ render "#{@path_prefix}/nav_menu", json: json, page: page
6
+
7
+ initial_content = <<~HTML
8
+ <h1>Action Text</h1>
9
+ <div>This editor submits the same HTML as Rails' <strong>Action Text</strong> form helper, so it can be assigned straight to a has_rich_text attribute.</div>
10
+ <ul><li>Attach or paste a file to upload it.</li><li>Submit to see the rendered content.</li></ul>
11
+ HTML
12
+
13
+ page.form url: json_ui_garage_url(path: 'forms/action_text_preview'), method: 'post', padding: { top: 20, bottom: 20 }, childViews: ->(form) do
14
+ form.panels_column lg: { cols: 6 }, padding: { left: 10, right: 10 }, childViews: ->(column) do
15
+ column.fields_actionText \
16
+ width: 'matchParent',
17
+ label: 'Content',
18
+ name: 'post[content]',
19
+ value: initial_content,
20
+ directUploadUrl: glib_direct_uploads_url,
21
+ blobUrlGenerator: glib_blob_url_generators_url,
22
+ accepts: { fileType: ['image', 'pdf'], maxFileSize: 5000 }
23
+ end
24
+
25
+ form.panels_column lg: { cols: 6 }, padding: { left: 10, right: 10 }, childViews: ->(column) do
26
+ column.panels_vertical id: 'preview', childViews: ->(inner) do
27
+ inner.actionText richText: ActionText::Content.new(initial_content)
28
+ end
29
+ end
30
+
31
+ form.panels_column lg: { cols: 12 }, padding: { top: 10, left: 10, right: 10 }, childViews: ->(column) do
32
+ column.fields_submit text: 'Submit'
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ # Stands in for an app's attachment endpoint (`fields_actionText attachmentUrl:`): an app would
2
+ # turn the uploaded blob into its own Action Text attachable and answer with its attributes.
3
+ json.sgid "garage-attachment-#{params[:signed_id]}"
4
+ json.url 'https://picsum.photos/id/10/300/200'
5
+ json.contentType 'image/jpeg'
6
+ json.filename 'from-attachment-url.jpg'
7
+ json.previewable true
@@ -0,0 +1,26 @@
1
+ json.title 'Insert from library'
2
+
3
+ page = json_ui_page json
4
+
5
+ library = [
6
+ { sgid: 'garage-library-1', url: 'https://picsum.photos/id/20/300/200', filename: 'desk.jpg' },
7
+ { sgid: 'garage-library-2', url: 'https://picsum.photos/id/30/300/200', filename: 'mug.jpg' }
8
+ ]
9
+
10
+ page.body childViews: ->(body) do
11
+ body.panels_list width: 'matchParent', firstSection: ->(section) do
12
+ section.rows builder: ->(template) do
13
+ library.each do |file|
14
+ template.thumbnail title: file[:filename], imageUrl: file[:url], onClick: ->(action) do
15
+ action.runMultiple childActions: ->(multiple) do
16
+ multiple.components_invoke \
17
+ targetId: params[:target],
18
+ name: 'insertAttachment',
19
+ arguments: file.merge(contentType: 'image/jpeg', previewable: true)
20
+ multiple.dialogs_close
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,9 @@
1
+ content = params.dig(:post, :content).to_s
2
+
3
+ json_ui_response json do |action|
4
+ action.components_replace targetId: 'preview', newView: ->(update) do
5
+ update.panels_vertical childViews: ->(vertical) do
6
+ vertical.actionText richText: ActionText::Content.new(content)
7
+ end
8
+ end
9
+ end
@@ -121,6 +121,12 @@ page.list sections: [
121
121
  end
122
122
 
123
123
  end
124
+
125
+ section.rows builder: ->(template) do
126
+ template.thumbnail title: 'Action Text Editor', onClick: ->(action) do
127
+ action.windows_open url: json_ui_garage_url(path: 'forms/action_text')
128
+ end
129
+ end
124
130
  end, ->(section) do
125
131
  section.header padding: glib_json_padding_list, childViews: ->(header) do
126
132
  header.h2 text: 'Experimental (not required yet)'
@@ -69,6 +69,13 @@ page.form \
69
69
  max: '2018-06-17T00:00',
70
70
  value: '2025-01-26T13:49:00.000+05:00',
71
71
  time_zone: 'Asia/Taipei' # +8
72
+ form.fields_datetime \
73
+ name: 'user[date_time]',
74
+ width: 'matchParent',
75
+ label: 'Date Time (offset only)',
76
+ min: '2018-06-09T00:00',
77
+ max: '2018-06-17T00:00',
78
+ value: '2025-01-26T13:49:00.000+05:00' # no time_zone: the device-zone fallback
72
79
  form.fields_date \
73
80
  name: 'user[month]',
74
81
  width: 'matchParent',
@@ -34,5 +34,12 @@ json_ui_page json do |page|
34
34
  panel.image height: height, url: image_url2
35
35
  end
36
36
  end
37
+
38
+ scroll.spacer height: 20
39
+ scroll.h1 text: 'Carousel with cycle'
40
+ scroll.panels_carousel width: 'matchParent', interval: 3000, childViews: ->(carousel) do
41
+ carousel.image url: image_url1, width: 'matchParent'
42
+ carousel.image url: image_url2, width: 'matchParent'
43
+ end
37
44
  end
38
45
  end
@@ -22,6 +22,11 @@ nav_groups = {
22
22
  'Forms' => [
23
23
  'auto_validate',
24
24
  'dirty_state',
25
+ 'form_dirty_hooks',
26
+ 'form_dirty_fields',
27
+ 'form_dynamic_dirty',
28
+ 'form_removed_field',
29
+ 'form_removed_field_onload',
25
30
  'fields_text',
26
31
  'fields_select',
27
32
  'fields_dynamicSelect',
@@ -32,6 +37,7 @@ nav_groups = {
32
37
  'fields_radio',
33
38
  'fields_rating',
34
39
  'fields_richText',
40
+ 'fields_actionText',
35
41
  'fields_sign',
36
42
  'fields_stripeToken',
37
43
  'fields_stripeExternalAccount',
@@ -0,0 +1,87 @@
1
+ json.title 'Test Page (Fields ActionText)'
2
+
3
+ page = json_ui_page json
4
+
5
+ render 'json_ui/garage/test_page/header', json: json, page: page
6
+
7
+ page.body(
8
+ childViews: ->(body) do
9
+ body.panels_responsive(
10
+ padding: glib_json_padding_body,
11
+ childViews: ->(res) do
12
+ res.h2 text: 'Fields ActionText'
13
+ res.spacer height: 8
14
+ res.label text: 'Trix editor that submits Action Text HTML, with direct-uploaded attachments.'
15
+ res.spacer height: 12
16
+
17
+ res.panels_form(
18
+ url: json_ui_garage_url(path: 'forms/action_text_preview'),
19
+ method: 'post',
20
+ childViews: ->(form) do
21
+ form.fields_actionText(
22
+ id: 'action_text_main',
23
+ width: 'matchParent',
24
+ label: 'Content',
25
+ name: 'post[content]',
26
+ value: '<div>Initial <strong>content</strong>.</div>',
27
+ directUploadUrl: glib_direct_uploads_url,
28
+ blobUrlGenerator: glib_blob_url_generators_url,
29
+ accepts: { fileType: ['image'], maxFileSize: 5000 },
30
+ onChange: ->(action) do
31
+ action.logics_set targetId: 'action_text_status', data: { text: 'Status: content changed' }
32
+ end
33
+ )
34
+ form.spacer height: 8
35
+ form.label id: 'action_text_status', text: 'Status: idle'
36
+
37
+ form.spacer height: 12
38
+ form.h2 text: 'App attachments and library'
39
+ form.spacer height: 8
40
+ form.fields_actionText(
41
+ id: 'action_text_library',
42
+ width: 'matchParent',
43
+ label: 'Story',
44
+ name: 'post[story]',
45
+ directUploadUrl: glib_direct_uploads_url,
46
+ attachmentUrl: json_ui_garage_url(path: 'forms/action_text_attachment'),
47
+ libraryUrl: json_ui_garage_url(path: 'forms/action_text_library', target: 'action_text_library'),
48
+ accepts: { fileType: ['image'], maxFileSize: 5000 }
49
+ )
50
+
51
+ form.spacer height: 12
52
+ form.h2 text: 'Without uploads'
53
+ form.spacer height: 8
54
+ form.fields_actionText(
55
+ id: 'action_text_no_upload',
56
+ width: 'matchParent',
57
+ label: 'Notes',
58
+ name: 'post[notes]'
59
+ )
60
+
61
+ form.spacer height: 12
62
+ form.h2 text: 'Read only'
63
+ form.spacer height: 8
64
+ form.fields_actionText(
65
+ id: 'action_text_read_only',
66
+ width: 'matchParent',
67
+ label: 'Locked',
68
+ name: 'post[locked]',
69
+ value: '<div>Cannot be edited.</div>',
70
+ readOnly: true
71
+ )
72
+
73
+ form.spacer height: 12
74
+ form.fields_submit text: 'Submit'
75
+ end
76
+ )
77
+
78
+ res.spacer height: 12
79
+ res.h2 text: 'Rendered'
80
+ res.spacer height: 8
81
+ res.panels_vertical id: 'preview', childViews: ->(vertical) do
82
+ vertical.actionText richText: ActionText::Content.new('<div>Initial <strong>content</strong>.</div>')
83
+ end
84
+ end
85
+ )
86
+ end
87
+ )
@@ -182,7 +182,7 @@ page.body(
182
182
 
183
183
  form.h2 text: 'Offered saved signature'
184
184
  form.spacer height: 8
185
- form.label text: 'onClick composes a menu on the empty box (popovers_show at the pointer): use the kept signature (logics_set) or open the dialog (components_invoke action_open); draw.saveOption asks whether a fresh drawing should be saved.'
185
+ form.label text: 'onClick composes a menu on the empty box (popovers_show at the pointer): use the kept signature (components_invoke action_setSignature) or open the dialog (components_invoke action_open); draw.saveOption asks whether a fresh drawing should be saved.'
186
186
  form.spacer height: 8
187
187
  form.fields_sign(
188
188
  id: 'signature_offered',
@@ -200,7 +200,7 @@ page.body(
200
200
  row.label text: 'Use my saved signature'
201
201
  end, onClick: ->(sub) do
202
202
  sub.runMultiple childActions: ->(m) do
203
- m.logics_set targetId: 'signature_offered', data: { value: 'saved-signed-id' }
203
+ m.components_invoke targetId: 'signature_offered', name: 'action_setSignature', arguments: { value: 'saved-signed-id', fileUrl: preview_data_uri }
204
204
  m.popovers_close key: 'menu'
205
205
  end
206
206
  end
@@ -221,7 +221,6 @@ page.body(
221
221
  hint: 'Draw it once. We keep it for next time.',
222
222
  placeholder: 'Sign inside the box',
223
223
  confirmedHint: 'Keep it, or clear it and sign again.',
224
- savedSignature: { value: 'saved-signed-id', fileUrl: preview_data_uri },
225
224
  saveOption: {
226
225
  name: 'user[save_signature_offered]',
227
226
  label: 'Save this signature for next time',
@@ -254,6 +253,38 @@ page.body(
254
253
  form.hr width: 'matchParent'
255
254
  form.spacer height: 12
256
255
 
256
+ form.h2 text: 'Externally offered saved signature'
257
+ form.spacer height: 8
258
+ form.label text: 'Optional draw.savedSignature: a logics_set write of that id previews its image on the box with no dialog and no upload (distinct from the action, which takes its signature as arguments).'
259
+ form.spacer height: 8
260
+ form.fields_sign(
261
+ id: 'signature_external',
262
+ name: 'user[signature_external]',
263
+ directUploadUrl: glib_direct_uploads_url,
264
+ width: 320,
265
+ height: 160,
266
+ draw: {
267
+ savedSignature: { value: 'external-saved-id', fileUrl: preview_data_uri }
268
+ }
269
+ )
270
+ form.spacer height: 8
271
+ form.panels_flow(
272
+ innerPadding: { bottom: 0 },
273
+ width: 'matchParent',
274
+ childViews: ->(flow) do
275
+ flow.button(
276
+ text: 'Fill external saved signature',
277
+ onClick: ->(action) do
278
+ action.logics_set targetId: 'signature_external', data: { value: 'external-saved-id' }
279
+ end
280
+ )
281
+ end
282
+ )
283
+
284
+ form.spacer height: 12
285
+ form.hr width: 'matchParent'
286
+ form.spacer height: 12
287
+
257
288
  form.h2 text: 'Hints on a blank canvas'
258
289
  form.spacer height: 8
259
290
  form.fields_sign(
@@ -4,6 +4,10 @@ page = json_ui_page json
4
4
 
5
5
  render 'json_ui/garage/test_page/header', json: json, page: page
6
6
 
7
+ # 60x20 ink stand-in for the sign field's offered saved signature (the same
8
+ # fixture image the fields_sign page uses).
9
+ dirty_hooks_signature_uri = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAAUCAYAAADRA14pAAAAoklEQVR4nO2XUQrAIAxDcwjvf9WNfQzG1NFqUt1mwL8a8hBtxfYzYXSAaC1glVJK2RohOXAJdCS4FNgCGw0tA7YAjQCXAHsBoqAPbzpwa3A19OkLpjkjsAL66gmWOTOo0gtvOJXe/VcP9JpH3DvmewBLkdeUKfaLD09xqSaid7bkqilrS57pKHJCYmWq9uFZQD2ZLLkeB49ZQO/qybX+w1/XDujJvn2bufeCAAAAAElFTkSuQmCC'
10
+
7
11
  page.body childViews: ->(body) do
8
12
  body.panels_form \
9
13
  padding: glib_json_padding_body,
@@ -37,6 +41,24 @@ page.body childViews: ->(body) do
37
41
  multiProgressView: { files: [] }
38
42
  form.spacer height: 14
39
43
 
44
+ # The sign field's saved-signature action: applying an offered
45
+ # signature (components_invoke action_setSignature) is a user
46
+ # gesture, so it must turn the form dirty and enable the submit -- a
47
+ # logics_set fill of the same id would not (deliberate non-trigger).
48
+ # The signature comes in as action arguments; the field carries no
49
+ # saved signature of its own.
50
+ form.fields_sign \
51
+ name: 'user[saved_signature]',
52
+ id: 'dirty_hooks_sign',
53
+ width: 320,
54
+ height: 160,
55
+ directUploadUrl: glib_direct_uploads_url
56
+ form.spacer height: 8
57
+ form.button text: 'Use saved signature', onClick: ->(action) do
58
+ action.components_invoke targetId: 'dirty_hooks_sign', name: 'action_setSignature', arguments: { value: 'saved-signed-id', fileUrl: dirty_hooks_signature_uri }
59
+ end
60
+ form.spacer height: 14
61
+
40
62
  form.fields_submit id: 'dirty_hooks_submit', text: 'Save'
41
63
  end
42
64
  end
@@ -0,0 +1,124 @@
1
+ json.title 'Test Page (Form Hidden Panels)'
2
+
3
+ page = json_ui_page json
4
+
5
+ render 'json_ui/garage/test_page/header', json: json, page: page
6
+
7
+ # Probes panels that are hidden and shown with ONE `logics_set` per panel
8
+ # while their fields keep what the user typed or attached. Every panel and
9
+ # field here is declared `submitWhenNotDisplayed: true`, so hiding keeps it
10
+ # mounted (display: none) and its value still submits. Siblings:
11
+ # form_removed_field (fields WITHOUT the flag unmount when hidden).
12
+ panel_ids = %w[hidden_panel_a hidden_panel_b hidden_panel_c]
13
+
14
+ show_panel = ->(action, shown_id) do
15
+ action.runMultiple childActions: ->(multiple) do
16
+ panel_ids.each do |panel_id|
17
+ multiple.logics_set targetId: panel_id, data: { displayed: panel_id == shown_id, submitWhenNotDisplayed: true }
18
+ end
19
+ end
20
+ end
21
+
22
+ page.body childViews: ->(body) do
23
+ body.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
24
+ res.h2 text: 'Hidden panels keep their fields'
25
+ res.spacer height: 8
26
+ # Dirty state, observable: `onDirty`/`onPristine` fire on transitions, and
27
+ # `hidden_ever_dirty` never resets, so a transient dirty blip shows too.
28
+ res.label id: 'hidden_dirty_state', text: 'Form: pristine'
29
+ res.label id: 'hidden_ever_dirty', text: 'Ever dirty: no'
30
+ res.spacer height: 8
31
+ res.panels_form \
32
+ url: json_ui_garage_url(path: 'forms/generic_post'),
33
+ method: 'post',
34
+ onDirty: ->(action) do
35
+ action.runMultiple childActions: ->(multiple) do
36
+ multiple.logics_set targetId: 'hidden_dirty_state', data: { text: 'Form: dirty' }
37
+ multiple.logics_set targetId: 'hidden_ever_dirty', data: { text: 'Ever dirty: yes' }
38
+ end
39
+ end,
40
+ onPristine: ->(action) do
41
+ action.logics_set targetId: 'hidden_dirty_state', data: { text: 'Form: pristine' }
42
+ end,
43
+ childViews: ->(form) do
44
+ form.panels_flow innerPadding: { bottom: 0 }, width: 'matchParent', childViews: ->(flow) do
45
+ flow.button text: 'Show A', onClick: ->(action) { show_panel.call(action, 'hidden_panel_a') }
46
+ flow.spacer width: 8
47
+ flow.button text: 'Show B', onClick: ->(action) { show_panel.call(action, 'hidden_panel_b') }
48
+ flow.spacer width: 8
49
+ flow.button text: 'Show C', onClick: ->(action) { show_panel.call(action, 'hidden_panel_c') }
50
+ end
51
+ form.spacer height: 8
52
+
53
+ form.panels_vertical width: 'matchParent', id: 'hidden_panel_a', submitWhenNotDisplayed: true, childViews: ->(panel) do
54
+ panel.label text: 'Panel A'
55
+ panel.fields_richText id: 'hidden_text_a', width: 'matchParent', name: 'user[text_a]', value: 'Alpha start', submitWhenNotDisplayed: true
56
+ end
57
+
58
+ form.panels_vertical width: 'matchParent', id: 'hidden_panel_b', displayed: false, submitWhenNotDisplayed: true, childViews: ->(panel) do
59
+ panel.label text: 'Panel B'
60
+ panel.fields_richText id: 'hidden_text_b', width: 'matchParent', name: 'user[text_b]', value: 'Bravo start', submitWhenNotDisplayed: true
61
+ panel.fields_upload \
62
+ id: 'hidden_upload_b',
63
+ name: 'user[file_b]',
64
+ label: 'Attach a file',
65
+ width: 320,
66
+ directUploadUrl: glib_direct_uploads_url,
67
+ accepts: { fileType: 'image' },
68
+ inputView: {},
69
+ submitWhenNotDisplayed: true
70
+ end
71
+
72
+ form.panels_vertical width: 'matchParent', id: 'hidden_panel_c', displayed: false, submitWhenNotDisplayed: true, childViews: ->(panel) do
73
+ panel.label text: 'Panel C'
74
+ panel.fields_richText id: 'hidden_text_c', width: 'matchParent', name: 'user[text_c]', value: 'Charlie start', submitWhenNotDisplayed: true
75
+ end
76
+
77
+ form.spacer height: 12
78
+ form.hr width: 'matchParent'
79
+ form.spacer height: 12
80
+
81
+ # A `logics_set` aimed straight at the upload (not its panel).
82
+ form.panels_flow innerPadding: { bottom: 0 }, width: 'matchParent', childViews: ->(flow) do
83
+ flow.button text: 'Hide upload', onClick: ->(action) do
84
+ action.logics_set targetId: 'hidden_upload_b', data: { displayed: false }
85
+ end
86
+ flow.spacer width: 8
87
+ flow.button text: 'Show upload', onClick: ->(action) do
88
+ action.logics_set targetId: 'hidden_upload_b', data: { displayed: true }
89
+ end
90
+ end
91
+ form.spacer height: 12
92
+
93
+ # A field declared with the flag, hidden by a `logics_set` that does
94
+ # not mention the flag: it must keep it, so it stays submitted.
95
+ form.fields_text id: 'hidden_lone_text', width: 'matchParent', name: 'user[lone]', label: 'Lone', value: 'Lone value', submitWhenNotDisplayed: true
96
+ form.button text: 'Hide lone', onClick: ->(action) do
97
+ action.logics_set targetId: 'hidden_lone_text', data: { displayed: false }
98
+ end
99
+ form.spacer height: 12
100
+
101
+ # An editor replaced in place by new content at the same position:
102
+ # the replacement's value must show, not the old value or old typing.
103
+ form.panels_vertical width: 'matchParent', id: 'hidden_swap_panel', childViews: ->(panel) do
104
+ panel.fields_richText width: 'matchParent', name: 'user[swap]', value: 'Before swap',
105
+ placeholder: 'Before placeholder', mentionList: ['Alice Before']
106
+ end
107
+ form.button text: 'Swap to new value', onClick: ->(action) do
108
+ action.components_replaceChildren targetId: 'hidden_swap_panel', childViews: ->(panel) do
109
+ panel.fields_richText width: 'matchParent', name: 'user[swap]', value: 'After swap',
110
+ placeholder: 'After placeholder', mentionList: ['Bob After']
111
+ end
112
+ end
113
+ form.button text: 'Swap to same value', onClick: ->(action) do
114
+ action.components_replaceChildren targetId: 'hidden_swap_panel', childViews: ->(panel) do
115
+ panel.fields_richText width: 'matchParent', name: 'user[swap]', value: 'Before swap',
116
+ placeholder: 'Before placeholder', mentionList: ['Alice Before']
117
+ end
118
+ end
119
+
120
+ form.spacer height: 20
121
+ form.fields_submit text: 'Submit'
122
+ end
123
+ end
124
+ end
@@ -153,6 +153,41 @@ page.form(
153
153
  res.fields_check name: 'user[tags][]', checkValue: 'b', label: 'Tag B', onChange: set_eq_check
154
154
  res.spacer height: 8
155
155
  res.label id: 'set_eq_status', text: 'PENDING'
156
+
157
+ res.spacer height: 16
158
+ res.h2 text: 'Logics Set - time of day'
159
+ res.spacer height: 8
160
+ # `minutesOfDay` parses a typed time of day exactly as a consuming
161
+ # app's server does and `formatHm` renders the length in explicit
162
+ # units ("4h", "1h 5m"), so a Start/End pair
163
+ # shows its duration live. The `+ 1440` before the `% 1440` keeps
164
+ # json-logic's JS remainder positive when the End is before the
165
+ # Start, which is also when "(next day)" is said. A missing time
166
+ # says a non-breaking space, not an empty string, so the label keeps
167
+ # its height and the page never jumps mid-typing.
168
+ duration_update = ->(action) do
169
+ start_minutes = { 'minutesOfDay' => { 'var' => 'user[start_time]' } }
170
+ end_minutes = { 'minutesOfDay' => { 'var' => 'user[end_time]' } }
171
+ action.logics_set(
172
+ targetId: 'duration_label',
173
+ conditionalData: {
174
+ text: {
175
+ 'if' => [
176
+ { 'or' => [{ '==' => [start_minutes, nil] }, { '==' => [end_minutes, nil] }] }, "\u00a0",
177
+ {
178
+ 'cat' => ['Duration ',
179
+ { 'formatHm' => { '%' => [{ '+' => [{ '-' => [end_minutes, start_minutes] }, 1440] }, 1440] } },
180
+ { 'if' => [{ '<' => [end_minutes, start_minutes] }, ' (next day)', ''] }]
181
+ }
182
+ ]
183
+ }
184
+ }
185
+ )
186
+ end
187
+ res.fields_text label: 'Start', name: 'user[start_time]', width: 300, onChange: duration_update
188
+ res.fields_text label: 'End', name: 'user[end_time]', width: 300, onChange: duration_update
189
+ res.spacer height: 8
190
+ res.label id: 'duration_label', text: 'PENDING'
156
191
  end
157
192
  )
158
193
  end
@@ -0,0 +1,42 @@
1
+ json.title 'Test Page (panels_association)'
2
+
3
+ page = json_ui_page json
4
+ render 'json_ui/garage/test_page/header', json: json, page: page
5
+
6
+ # The panels_association fixture (spec 353, D5): doculocker's submission-form
7
+ # shape on dummy-app models, unpersisted so the page is deterministic against
8
+ # the dummy host's empty database. One un-indexed association (the signature
9
+ # form's singular nested model), two indexed associations each holding an
10
+ # indexed nested association (the qualification form's two-deep shape), a
11
+ # panels_responsive inside one (the signature form nests one), hidden id and
12
+ # visible text props, and a submit.
13
+ page.form \
14
+ url: json_ui_garage_url(path: 'forms/generic_post'),
15
+ model: Post.new(title: 'Fixture post'),
16
+ method: 'post',
17
+ padding: glib_json_padding_body,
18
+ childViews: ->(form) do
19
+ form.fields_text prop: :title, label: 'Post title'
20
+
21
+ form.h3 text: 'Unindexed association'
22
+ form.panels_association model: Comment.new(content: 'Lead comment'), width: 'matchParent', childViews: ->(assoc) do
23
+ assoc.fields_hidden prop: :id
24
+ assoc.panels_responsive width: 'matchParent', childViews: ->(responsive) do
25
+ responsive.fields_text prop: :content, label: 'Lead comment'
26
+ end
27
+ end
28
+
29
+ form.h3 text: 'Indexed associations'
30
+ [['First comment', 'first.pdf'], ['Second comment', 'second.pdf']].each_with_index do |(content, filename), index|
31
+ form.panels_association model: Comment.new(content: content), width: 'matchParent', order_index: index,
32
+ childViews: ->(comment) do
33
+ comment.fields_text prop: :content, label: "Comment #{index}"
34
+ comment.panels_association model: CommentFile.new(filename: filename), width: 'matchParent', order_index: 0,
35
+ childViews: ->(file) do
36
+ file.fields_text prop: :filename, label: "Comment #{index} file"
37
+ end
38
+ end
39
+ end
40
+
41
+ form.fields_submit text: 'Submit'
42
+ end
@@ -16,7 +16,17 @@
16
16
  `crossorigin` is required on the font origin because fonts are fetched
17
17
  CORS-anonymously, and without it the preconnected socket is discarded.
18
18
  Note the icons themselves are held blank until this font resolves -- see
19
- Dom.hideIconsUntilFontReady in the npm package. %>
19
+ Dom.hideIconsUntilFontReady in the npm package.
20
+
21
+ The stylesheet URL deliberately has no `&display=swap`. Icons here are
22
+ LIGATURE TEXT, so `swap` paints the icon's NAME ("menu", "close") as
23
+ fallback immediately, while the default `auto`/`block` does the same
24
+ once its ~3s block period lapses -- neither keeps the icons correct
25
+ while the font is in flight. Instead we preconnect (above) to shorten
26
+ the handshake and let Dom.hideIconsUntilFontReady keep the icons BLANK
27
+ until the face actually resolves. Preconnect and font-display are
28
+ orthogonal: preconnect is connection setup, font-display is the
29
+ render-fallback policy. %>
20
30
  <link href="//fonts.googleapis.com" rel="preconnect">
21
31
  <link href="//fonts.gstatic.com" rel="preconnect" crossorigin>
22
32
  <link href="//fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet">