glib-web 8.2.0 → 8.3.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/auth/policy.rb +8 -4
- data/app/controllers/concerns/glib/params/multi_column_sort.rb +131 -0
- data/app/controllers/glib/glib_direct_uploads_controller.rb +2 -1
- data/app/controllers/glib/home_controller.rb +0 -38
- data/app/helpers/glib/json_ui/action_builder/commands.rb +1 -0
- data/app/helpers/glib/json_ui/sort_helper.rb +30 -0
- data/app/helpers/glib/json_ui/view_builder/fields.rb +36 -0
- data/app/helpers/glib/json_ui/view_builder.rb +15 -1
- data/app/models/concerns/glib/soft_deletable.rb +64 -9
- data/app/views/json_ui/garage/actions/sheet_content.json.jbuilder +1 -1
- data/app/views/json_ui/garage/forms/_action_text_conversion.json.jbuilder +12 -0
- data/app/views/json_ui/garage/forms/action_text.json.jbuilder +23 -0
- data/app/views/json_ui/garage/forms/action_text_conversion.json.jbuilder +5 -0
- data/app/views/json_ui/garage/forms/action_text_mentions.json.jbuilder +4 -0
- data/app/views/json_ui/garage/forms/dialogs_form.json.jbuilder +10 -10
- data/app/views/json_ui/garage/forms/dirty_prompt.json.jbuilder +1 -1
- data/app/views/json_ui/garage/forms/dynamic_group.json.jbuilder +1 -1
- data/app/views/json_ui/garage/forms/show_hide.json.jbuilder +1 -1
- data/app/views/json_ui/garage/tables/layout.json.jbuilder +24 -17
- data/app/views/json_ui/garage/test_page/charts.json.jbuilder +4 -2
- data/app/views/json_ui/garage/test_page/commands.json.jbuilder +26 -0
- data/app/views/json_ui/garage/test_page/fields_actionText.json.jbuilder +103 -1
- data/app/views/json_ui/garage/test_page/fields_richText.json.jbuilder +45 -1
- data/app/views/json_ui/garage/test_page/form_dirty_fields.json.jbuilder +1 -1
- data/app/views/json_ui/garage/test_page/form_hidden_panels.json.jbuilder +3 -22
- data/app/views/json_ui/garage/views/charts.json.jbuilder +4 -2
- data/lib/glib/all_helpers.rb +1 -0
- metadata +7 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eacabf1b562907ccace552b122acc1f7b8a6e42e8b36c2b53e6cc7d901f0e4f8
|
|
4
|
+
data.tar.gz: add189a2ea6958b00bd5a730bc770cc02cdd661b1e22f9504718d0c7d6d558d9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 84bdf2d49d1c73a4d83237a4cdcf3435829ddf9ada881b9fa05b1146c163748c20e1bded132b245c4f552cb2ab1ab3c2bf0baf1e36827868e18ddb1bd5ceba00
|
|
7
|
+
data.tar.gz: 288b0d4b03afbded4f9cdece339b87e72bdc2e6a74a15b86c48b46696fa5d7921bec97dcd708cb2d5e33b904922c581818b190c121787d9057c28a13eac66395
|
|
@@ -37,11 +37,15 @@ module Glib::Auth
|
|
|
37
37
|
# Override
|
|
38
38
|
def policy(record, policy_name = nil, context = nil)
|
|
39
39
|
policy_name ||= record
|
|
40
|
+
# The record is part of the key: within one request, a second authorize of
|
|
41
|
+
# another record under the same policy name must not reuse the first record's
|
|
42
|
+
# instance (glib-web#524).
|
|
43
|
+
key = [policy_name, record]
|
|
40
44
|
|
|
41
45
|
@__pundit_policies ||= {}
|
|
42
|
-
if @__pundit_policies[
|
|
43
|
-
|
|
44
|
-
return
|
|
46
|
+
if (cached = @__pundit_policies[key])
|
|
47
|
+
cached.context = context
|
|
48
|
+
return cached
|
|
45
49
|
end
|
|
46
50
|
|
|
47
51
|
# if policy_name.is_a?(Symbol) && policy_name.to_s.ends_with?('_admin')
|
|
@@ -57,7 +61,7 @@ module Glib::Auth
|
|
|
57
61
|
policy_instance = policy_class.new(current_user, record, policy_name, self, request, params)
|
|
58
62
|
policy_instance.context = context
|
|
59
63
|
|
|
60
|
-
@__pundit_policies[
|
|
64
|
+
@__pundit_policies[key] = policy_instance
|
|
61
65
|
end
|
|
62
66
|
|
|
63
67
|
# Expose protected method
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
module Glib::Params
|
|
2
|
+
# Multi-column table sorting driven by one request param, e.g.
|
|
3
|
+
# `sort=sent-desc,title-asc`: order by sent descending, ties by title.
|
|
4
|
+
#
|
|
5
|
+
# Clicking a header makes that column the PRIMARY key (flipping its
|
|
6
|
+
# direction if it was already sorted, else ascending) and keeps the earlier
|
|
7
|
+
# keys behind it as tie-breakers, most recent first, up to +max+ columns
|
|
8
|
+
# (the oldest falls off). So "sort A, then sort B" orders by B, then A: the
|
|
9
|
+
# param's column order IS the sort, and is never re-sorted.
|
|
10
|
+
#
|
|
11
|
+
# The param comes from the URL, so parsing degrades quietly, like
|
|
12
|
+
# Glib::Params::Allowlist on a GET: a key outside +allowed+, a direction
|
|
13
|
+
# other than asc/desc, and a repeated key (the first occurrence wins) are
|
|
14
|
+
# dropped rather than raised. The direction is split off at the LAST '-',
|
|
15
|
+
# so a hyphenated key survives. Keys stay strings and a direction becomes a
|
|
16
|
+
# symbol only through the DIRECTIONS lookup, so input never mints a symbol.
|
|
17
|
+
#
|
|
18
|
+
# Route- and model-agnostic: it parses, toggles and serialises the param,
|
|
19
|
+
# yields Arel orderings (#arel_orderings) and sorts in-memory rows
|
|
20
|
+
# (#sort_rows). Calling `order` and building URLs stay with the caller; the
|
|
21
|
+
# header side is Glib::JsonUi::SortHelper#glib_sort_header.
|
|
22
|
+
#
|
|
23
|
+
# NULLs (nil) sort last in both directions, in SQL and in Ruby: a missing
|
|
24
|
+
# value is neither smallest nor largest, and flipping the direction must
|
|
25
|
+
# not move blanks to the top.
|
|
26
|
+
class MultiColumnSort
|
|
27
|
+
MAX_COLUMNS = 3
|
|
28
|
+
DIRECTIONS = { 'asc' => :asc, 'desc' => :desc }.freeze
|
|
29
|
+
|
|
30
|
+
Order = Struct.new(:key, :direction)
|
|
31
|
+
|
|
32
|
+
attr_reader :orders
|
|
33
|
+
|
|
34
|
+
# +default+ is a param string used when +param+ is blank, e.g. 'sent-desc'
|
|
35
|
+
# so the header shows its arrow on first load. Only BLANK falls back: a
|
|
36
|
+
# present param whose tokens are all invalid yields no sort at all, not
|
|
37
|
+
# the default (as in mapping-web's class this one replaces).
|
|
38
|
+
def initialize(param, allowed:, default: nil, max: MAX_COLUMNS)
|
|
39
|
+
@allowed = allowed.map(&:to_s)
|
|
40
|
+
@max = max
|
|
41
|
+
@orders = parse(param.presence || default)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def present?
|
|
45
|
+
orders.any?
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# :asc or :desc, nil when +key+ is not sorted.
|
|
49
|
+
def direction(key)
|
|
50
|
+
find(key)&.direction
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# 1-based precedence of +key+, nil when the column is not sorted.
|
|
54
|
+
def priority(key)
|
|
55
|
+
index = orders.index { |order| order.key == key.to_s }
|
|
56
|
+
index && (index + 1)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# The param a click on +key+'s header should produce.
|
|
60
|
+
def toggled_param(key)
|
|
61
|
+
key = key.to_s
|
|
62
|
+
clicked = Order.new(key, direction(key) == :asc ? :desc : :asc)
|
|
63
|
+
serialize([clicked] + orders.reject { |order| order.key == key })
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def to_param
|
|
67
|
+
serialize(orders)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Orderings for `relation.order(*...)`, in precedence order, each NULLS
|
|
71
|
+
# LAST. The block maps a key to one Arel node or an array of them
|
|
72
|
+
# (attributes, Groupings around a subquery); every node of a key takes
|
|
73
|
+
# that key's direction. Append the caller's own tie-breaker after them.
|
|
74
|
+
# Array.wrap, not Array(): an Arel attribute is a Struct, which Array()
|
|
75
|
+
# would split into its fields.
|
|
76
|
+
def arel_orderings
|
|
77
|
+
orders.flat_map do |order|
|
|
78
|
+
Array.wrap(yield(order.key)).map { |node| node.public_send(order.direction).nulls_last }
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Sorts Ruby rows (hashes keyed by symbol) by the orders, each key in its
|
|
83
|
+
# own direction, nil last, then by +tie_breaker+ ascending. Text compares
|
|
84
|
+
# case-insensitively.
|
|
85
|
+
def sort_rows(rows, tie_breaker:)
|
|
86
|
+
rows.sort do |a, b|
|
|
87
|
+
decided = orders.lazy.map { |order| directed_compare(a, b, order) }.find(&:nonzero?)
|
|
88
|
+
decided || compare(a[tie_breaker], b[tie_breaker])
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
def parse(param)
|
|
94
|
+
entries = param.to_s.split(',').filter_map do |entry|
|
|
95
|
+
key, _, direction = entry.strip.rpartition('-')
|
|
96
|
+
symbol = DIRECTIONS[direction]
|
|
97
|
+
Order.new(key, symbol) if symbol && @allowed.include?(key)
|
|
98
|
+
end
|
|
99
|
+
entries.uniq(&:key).first(@max)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def serialize(orders)
|
|
103
|
+
orders.first(@max).map { |order| "#{order.key}-#{order.direction}" }.join(',')
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def find(key)
|
|
107
|
+
orders.find { |order| order.key == key.to_s }
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# nil sorts last in BOTH directions, matching #arel_orderings' NULLS LAST.
|
|
111
|
+
# Row keys are symbols the CALLER built; the allowlisted key is looked
|
|
112
|
+
# up by `to_sym` only after it matched +allowed+, never raw input.
|
|
113
|
+
def directed_compare(a, b, order)
|
|
114
|
+
left = a[order.key.to_sym]
|
|
115
|
+
right = b[order.key.to_sym]
|
|
116
|
+
return 0 if left.nil? && right.nil?
|
|
117
|
+
return 1 if left.nil?
|
|
118
|
+
return -1 if right.nil?
|
|
119
|
+
|
|
120
|
+
result = compare(left, right)
|
|
121
|
+
order.direction == :desc ? -result : result
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Text compares case-insensitively; incomparable values tie.
|
|
125
|
+
def compare(left, right)
|
|
126
|
+
left = left.downcase if left.is_a?(String)
|
|
127
|
+
right = right.downcase if right.is_a?(String)
|
|
128
|
+
(left <=> right) || 0
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
@@ -27,7 +27,8 @@ module Glib
|
|
|
27
27
|
blob.assign_attributes(**blob_args.except(:tagging, :prefix))
|
|
28
28
|
blob.save!
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
# GlibS3Service is only loaded when an app configures it, so referencing the constant breaks Disk-backed apps.
|
|
31
|
+
if blob.service.respond_to?(:tagging=)
|
|
31
32
|
blob.service.tagging = blob_args[:tagging]
|
|
32
33
|
end
|
|
33
34
|
|
|
@@ -10,8 +10,6 @@ module Glib
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def json_ui_garage
|
|
13
|
-
init_orders
|
|
14
|
-
|
|
15
13
|
@path_prefix = 'json_ui/garage'
|
|
16
14
|
|
|
17
15
|
@__glib_head_code =<<-eos
|
|
@@ -83,41 +81,5 @@ module Glib
|
|
|
83
81
|
|
|
84
82
|
render template: 'json_ui/garage/empty'
|
|
85
83
|
end
|
|
86
|
-
|
|
87
|
-
def init_orders
|
|
88
|
-
@order_headings = {}
|
|
89
|
-
@orders = params[:orders] || []
|
|
90
|
-
@orders.each do |order|
|
|
91
|
-
prop_name, direction = order.split('-')
|
|
92
|
-
index_order(prop_name, direction)
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
def index_order(prop_name, direction)
|
|
97
|
-
# In a real app, apply ordering to the model. For example:
|
|
98
|
-
# @users = @users.order(prop_name => direction)
|
|
99
|
-
|
|
100
|
-
# Garage example
|
|
101
|
-
@order_headings[prop_name] = direction
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
def reversed_order(order)
|
|
105
|
-
order.to_sym == :asc ? :desc : :asc
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
def reversed_order_params(prop_name)
|
|
109
|
-
prop_value = :asc
|
|
110
|
-
remaining = @orders.reject do |o|
|
|
111
|
-
tuple = o.split('-')
|
|
112
|
-
if tuple.first == prop_name.to_s
|
|
113
|
-
prop_value = reversed_order(tuple.second)
|
|
114
|
-
true
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
# Sort the params to produce predictable URLs which are useful for SEO
|
|
118
|
-
(["#{prop_name}-#{prop_value}"] + remaining).sort
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
helper_method :reversed_order_params
|
|
122
84
|
end
|
|
123
85
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module Glib
|
|
2
|
+
module JsonUi
|
|
3
|
+
module SortHelper
|
|
4
|
+
# A clickable table header cell that sorts server-side through a
|
|
5
|
+
# Glib::Params::MultiColumnSort. A click makes this column the primary
|
|
6
|
+
# sort and keeps the others behind it. The text is the label, an arrow
|
|
7
|
+
# on a sorted column and, when more than one column is sorted, its
|
|
8
|
+
# 1-based precedence (`Type ↑1`, `Date ↓2`).
|
|
9
|
+
#
|
|
10
|
+
# +url+ receives the toggled param string and returns the URL to open,
|
|
11
|
+
# so the helper stays route-agnostic. Drop the page param there so a
|
|
12
|
+
# re-sort starts on page 1:
|
|
13
|
+
#
|
|
14
|
+
# section.header cellViews: ->(header) do
|
|
15
|
+
# glib_sort_header header, sort: sort, key: 'name', label: 'Name',
|
|
16
|
+
# url: ->(param) { current_url(sort: param, page: nil) }
|
|
17
|
+
# end
|
|
18
|
+
def glib_sort_header(header, sort:, key:, label:, url:)
|
|
19
|
+
arrow = { asc: ' ↑', desc: ' ↓' }[sort.direction(key)]
|
|
20
|
+
priority = sort.priority(key) if sort.orders.size > 1
|
|
21
|
+
|
|
22
|
+
header.label \
|
|
23
|
+
text: "#{label}#{arrow}#{priority}",
|
|
24
|
+
onClick: ->(action) do
|
|
25
|
+
action.windows_open url: url.call(sort.toggled_param(key))
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -609,6 +609,10 @@ class Glib::JsonUi::ViewBuilder
|
|
|
609
609
|
|
|
610
610
|
# Rich text editor field with WYSIWYG editing.
|
|
611
611
|
#
|
|
612
|
+
# @deprecated Quill has an unfixed XSS advisory. Use `fields_actionText` for rich text, or
|
|
613
|
+
# `fields_textarea` where users write markdown themselves. See the glib-web-npm
|
|
614
|
+
# `doc/rich_text_migration.md` guide.
|
|
615
|
+
#
|
|
612
616
|
# Provides a full-featured text editor with formatting options, image uploads,
|
|
613
617
|
# and @mention support. Can output HTML or Markdown.
|
|
614
618
|
#
|
|
@@ -663,6 +667,16 @@ class Glib::JsonUi::ViewBuilder
|
|
|
663
667
|
|
|
664
668
|
# Enables debug mode with additional logging.
|
|
665
669
|
bool :debug
|
|
670
|
+
|
|
671
|
+
# Override
|
|
672
|
+
def created
|
|
673
|
+
super
|
|
674
|
+
# Local only: every render of every richText field would otherwise flood remote logging.
|
|
675
|
+
GLog.local_warn(
|
|
676
|
+
'`fields_richText` is deprecated: use `fields_actionText`, or `fields_textarea` for ' \
|
|
677
|
+
'markdown input. See doc/rich_text_migration.md in glib-web-npm.'
|
|
678
|
+
)
|
|
679
|
+
end
|
|
666
680
|
end
|
|
667
681
|
|
|
668
682
|
# Trix editor field that submits the same HTML as Rails' Action Text form helper,
|
|
@@ -709,6 +723,28 @@ class Glib::JsonUi::ViewBuilder
|
|
|
709
723
|
# @example libraryUrl: media_picks_url(target: 'post_body')
|
|
710
724
|
string :libraryUrl
|
|
711
725
|
|
|
726
|
+
# People offered when the user types `@`. Each item is
|
|
727
|
+
# `{ sgid:, value:, text:, avatar:, group: }`; only `value` is required. An item with an
|
|
728
|
+
# `sgid` is inserted as an Action Text attachment that `has_rich_text` resolves to the
|
|
729
|
+
# record (its model must include `ActionText::Attachable`). When the sgid does not resolve
|
|
730
|
+
# (a plain column, a deleted record), the attachment renders its own `@value` text. An
|
|
731
|
+
# item without an `sgid` is inserted as plain `@value` text.
|
|
732
|
+
# @example mentionList: users.map { |u| { sgid: u.attachable_sgid, value: u.name } }
|
|
733
|
+
array :mentionList
|
|
734
|
+
|
|
735
|
+
# Endpoint searched as the user types after `@` (`GET <url>?term=...`), returning
|
|
736
|
+
# `{ items: [...] }` in the `mentionList` item shape. Replaces filtering `mentionList`.
|
|
737
|
+
# @example mentionUrl: mention_searches_url
|
|
738
|
+
string :mentionUrl
|
|
739
|
+
|
|
740
|
+
# Hides the formatting toolbar, e.g. for a chat input. Keyboard shortcuts (Ctrl/Cmd+B, …)
|
|
741
|
+
# and pasting or dropping files (when uploads are configured) still work.
|
|
742
|
+
bool :hideToolbar
|
|
743
|
+
|
|
744
|
+
# Enter submits the enclosing form and Shift+Enter inserts a line break. While a mention
|
|
745
|
+
# list is open, Enter picks from it instead.
|
|
746
|
+
bool :submitOnEnter
|
|
747
|
+
|
|
712
748
|
def created
|
|
713
749
|
super
|
|
714
750
|
file_upload_error_handler_on_create
|
|
@@ -238,8 +238,22 @@ module Glib
|
|
|
238
238
|
# An `ActionText::RichText` (a `has_rich_text` attribute), `ActionText::Content`, or the
|
|
239
239
|
# HTML one of them rendered.
|
|
240
240
|
def richText(rich_text)
|
|
241
|
-
json.set! 'html', rich_text.to_s
|
|
241
|
+
json.set! 'html', ::ActionText::Content.with_renderer(html_renderer) { rich_text.to_s }
|
|
242
242
|
end
|
|
243
|
+
|
|
244
|
+
private
|
|
245
|
+
# Action Text renders through the current controller by default. Here that is a
|
|
246
|
+
# namespaced JSON controller, so a content attachment (e.g. a mention whose record is
|
|
247
|
+
# gone) would be looked up as `glib/action_text/contents/_content.json` and raise.
|
|
248
|
+
# A host-level HTML renderer resolves partials the way an HTML page would.
|
|
249
|
+
def html_renderer
|
|
250
|
+
request = page.context.request
|
|
251
|
+
::ApplicationController.renderer.new(
|
|
252
|
+
http_host: request.host_with_port,
|
|
253
|
+
https: request.ssl?,
|
|
254
|
+
script_name: request.script_name
|
|
255
|
+
)
|
|
256
|
+
end
|
|
243
257
|
end
|
|
244
258
|
|
|
245
259
|
class Label < AbstractText
|
|
@@ -153,8 +153,20 @@ module Glib
|
|
|
153
153
|
def _undo_soft_destroy
|
|
154
154
|
return unless deleted? # Already restored. Stop here to avoid redundant work and infinite recursion on circular associations.
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
# Read the bound from the database rather than trusting the in-memory attribute: a stale
|
|
157
|
+
# in-memory flag (or a concurrent undo that already restored this row) must be caught here,
|
|
158
|
+
# because a nil bound would match every row of the association. Reading the stored value also
|
|
159
|
+
# compares like with like — the children's timestamps as they were written — with no reliance
|
|
160
|
+
# on attribute casting matching the column's precision.
|
|
161
|
+
bound = stored_deleted_at
|
|
162
|
+
return if bound.nil?
|
|
163
|
+
|
|
164
|
+
# Restore this record BEFORE walking its children, mirroring `_soft_destroy` (which marks
|
|
165
|
+
# itself first): the walk below queries fresh instances, so with children first a cycle would
|
|
166
|
+
# reload this still-deleted record and recurse without end.
|
|
157
167
|
update_columns(deleted_at: nil) # rubocop:disable Rails/SkipsModelValidations
|
|
168
|
+
|
|
169
|
+
undo_soft_destroy_associated_records(bound)
|
|
158
170
|
end
|
|
159
171
|
|
|
160
172
|
private
|
|
@@ -172,6 +184,10 @@ module Glib
|
|
|
172
184
|
raise ActiveRecord::ConfigurationError, "Hard deletion is not allowed for #{self.class.name} (error #{code})"
|
|
173
185
|
end
|
|
174
186
|
|
|
187
|
+
# Serves the destroy path only. The cached `public_send` read is what the destroy needs
|
|
188
|
+
# (it must reuse loaded instances so `marked_for_destruction` survives); the undo walk
|
|
189
|
+
# reads through the target's default scope and would miss every row a cascade deleted,
|
|
190
|
+
# so it has its own read in `undo_soft_destroy_associated_records`.
|
|
175
191
|
def process_soft_deletable_relationship(relationship, &block)
|
|
176
192
|
association(relationship) # Raises an exception if relationship doesn't exist. This is a security safe guard.
|
|
177
193
|
|
|
@@ -199,15 +215,42 @@ module Glib
|
|
|
199
215
|
end
|
|
200
216
|
end
|
|
201
217
|
|
|
202
|
-
|
|
218
|
+
# Reads each association's deleted rows directly instead of through `process_soft_deletable_relationship`:
|
|
219
|
+
# the cached `public_send` read goes through the target's `auto_hide_soft_deleted_records` default scope,
|
|
220
|
+
# which hides every child a cascade soft-deleted, so a fresh load (how any real undo runs) would find
|
|
221
|
+
# nothing to restore. The read includes deleted rows and is bounded to `deleted_at >= bound` (the parent's
|
|
222
|
+
# own deletion time, taken first), so a child soft-deleted on its own before the parent is left alone.
|
|
223
|
+
# The bound has no upper edge: a child soft-deleted on its own after the parent (only reachable through
|
|
224
|
+
# `with_deleted`) is restored too, accepted because undo cannot distinguish it from a cascade victim.
|
|
225
|
+
def undo_soft_destroy_associated_records(bound)
|
|
203
226
|
__resolved_soft_deletable_associations.each do |relationship|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
227
|
+
assoc = association(relationship) # Raises an exception if relationship doesn't exist. This is a security safe guard.
|
|
228
|
+
|
|
229
|
+
# A polymorphic belongs_to with no stored target resolves to no class: nothing to
|
|
230
|
+
# restore, like the destroy walk's nil handling. With a target stored, `klass` is the
|
|
231
|
+
# concrete class Rails resolves from the owner's type column, default or custom named.
|
|
232
|
+
next if assoc.klass.nil?
|
|
233
|
+
|
|
234
|
+
# Fail fast BEFORE building the relation: the read below calls `with_deleted` on the
|
|
235
|
+
# target's relation, so a non-soft-deletable target has to fail here, with the clear
|
|
236
|
+
# error, rather than as an obscure NoMethodError from the read itself.
|
|
237
|
+
assert_soft_deletable_class!(relationship, assoc.klass)
|
|
238
|
+
|
|
239
|
+
assoc.scope.with_deleted.where(deleted_at: bound..).each(&:_undo_soft_destroy)
|
|
240
|
+
|
|
241
|
+
# The walk restored fresh instances; a previously loaded association on this owner would
|
|
242
|
+
# still hold the stale, still-deleted copies. Reset so the next read reloads.
|
|
243
|
+
assoc.reset
|
|
208
244
|
end
|
|
209
245
|
end
|
|
210
246
|
|
|
247
|
+
# The `deleted_at` as stored in the database: the undo compares it against the children's stored
|
|
248
|
+
# timestamps, so both sides come from the same place, and a nil result is the signal that this
|
|
249
|
+
# deletion was never stored (a stale in-memory flag, or a concurrent undo that already ran).
|
|
250
|
+
def stored_deleted_at
|
|
251
|
+
self.class.with_deleted.where(id: id).pick(:deleted_at)
|
|
252
|
+
end
|
|
253
|
+
|
|
211
254
|
# Resolves the associations to soft-delete. Honours a (deprecated) override of
|
|
212
255
|
# `soft_deletable_associations` if present, warning the caller; otherwise returns
|
|
213
256
|
# the associations declared via `soft_deletes_with`.
|
|
@@ -228,10 +271,22 @@ module Glib
|
|
|
228
271
|
def assert_soft_deletable!(relationship, record)
|
|
229
272
|
return if record.respond_to?(:_soft_destroy)
|
|
230
273
|
|
|
231
|
-
raise(
|
|
232
|
-
|
|
274
|
+
raise __soft_deletable_target_error(relationship, record.class)
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# Class-level twin of `assert_soft_deletable!`, used where the target is inspected as a class
|
|
278
|
+
# before any record exists — the undo read builds a relation on the target class, so the check
|
|
279
|
+
# has to happen there before `with_deleted` is called on it.
|
|
280
|
+
def assert_soft_deletable_class!(relationship, klass)
|
|
281
|
+
return if klass.include?(Glib::SoftDeletable)
|
|
282
|
+
|
|
283
|
+
raise __soft_deletable_target_error(relationship, klass)
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
def __soft_deletable_target_error(relationship, klass)
|
|
287
|
+
ActiveRecord::ConfigurationError.new(
|
|
233
288
|
"#{self.class.name} registers `#{relationship}` in `soft_deletable_associations`, " \
|
|
234
|
-
"but #{
|
|
289
|
+
"but #{klass.name} does not include Glib::SoftDeletable"
|
|
235
290
|
)
|
|
236
291
|
end
|
|
237
292
|
|
|
@@ -6,7 +6,7 @@ page.body(
|
|
|
6
6
|
body.panels_responsive(
|
|
7
7
|
padding: { all: 16 },
|
|
8
8
|
childViews: ->(res) do
|
|
9
|
-
res.
|
|
9
|
+
res.fields_actionText value: "<div>#{DateTime.current.to_fs(:rfc822)}</div><div>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>"
|
|
10
10
|
res.spacer height: 8
|
|
11
11
|
res.button(
|
|
12
12
|
text: 'close',
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
markdown = ReverseMarkdown.convert(html, unknown_tags: :bypass, github_flavored: true).strip
|
|
2
|
+
|
|
3
|
+
view.panels_vertical id: 'action_text_conversion', width: 'matchParent', childViews: ->(panel) do
|
|
4
|
+
panel.h3 text: 'Output HTML (what the field submits)'
|
|
5
|
+
panel.markdown text: "```html\n#{html.strip}\n```"
|
|
6
|
+
panel.spacer height: 8
|
|
7
|
+
panel.h3 text: 'Output Markdown (converted on the server)'
|
|
8
|
+
panel.markdown text: "```markdown\n#{markdown}\n```"
|
|
9
|
+
panel.spacer height: 8
|
|
10
|
+
panel.h3 text: 'Markdown rendered'
|
|
11
|
+
panel.markdown text: markdown
|
|
12
|
+
end
|
|
@@ -20,6 +20,29 @@ page.form url: json_ui_garage_url(path: 'forms/action_text_preview'), method: 'p
|
|
|
20
20
|
directUploadUrl: glib_direct_uploads_url,
|
|
21
21
|
blobUrlGenerator: glib_blob_url_generators_url,
|
|
22
22
|
accepts: { fileType: ['image', 'pdf'], maxFileSize: 5000 }
|
|
23
|
+
|
|
24
|
+
column.spacer height: 16
|
|
25
|
+
column.fields_actionText \
|
|
26
|
+
width: 'matchParent',
|
|
27
|
+
label: 'Comment (type @ to mention someone)',
|
|
28
|
+
name: 'post[comment]',
|
|
29
|
+
mentionList: User.all.map { |user| { sgid: user.attachable_sgid, value: user.full_name } }
|
|
30
|
+
|
|
31
|
+
column.spacer height: 16
|
|
32
|
+
column.fields_actionText \
|
|
33
|
+
width: 'matchParent',
|
|
34
|
+
label: 'Reply (mentions searched on the server)',
|
|
35
|
+
name: 'post[reply]',
|
|
36
|
+
mentionUrl: json_ui_garage_url(path: 'forms/action_text_mentions', format: 'json')
|
|
37
|
+
|
|
38
|
+
column.spacer height: 16
|
|
39
|
+
column.fields_actionText \
|
|
40
|
+
width: 'matchParent',
|
|
41
|
+
label: 'Chat-style: no toolbar',
|
|
42
|
+
name: 'post[chat]',
|
|
43
|
+
placeholder: 'Write a message',
|
|
44
|
+
hideToolbar: true,
|
|
45
|
+
mentionUrl: json_ui_garage_url(path: 'forms/action_text_mentions', format: 'json')
|
|
23
46
|
end
|
|
24
47
|
|
|
25
48
|
form.panels_column lg: { cols: 6 }, padding: { left: 10, right: 10 }, childViews: ->(column) do
|
|
@@ -34,17 +34,17 @@ page.scroll childViews: ->(scroll) do
|
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
form.
|
|
37
|
+
form.fields_actionText \
|
|
38
38
|
name: 'user[description]',
|
|
39
|
-
value:
|
|
40
|
-
This note serves as a reminder regarding the checklist assigned to you. This checklist is crucial for ensuring the safety and well-being of all staff
|
|
41
|
-
|
|
42
|
-
Please review the checklist carefully and ensure that all necessary steps are taken to implement the required safety measures
|
|
43
|
-
|
|
44
|
-
Your attention to detail and proactive approach to safety are greatly appreciated. If you have any questions or require assistance, please don't hesitate to reach out
|
|
45
|
-
|
|
46
|
-
Thank you for your cooperation
|
|
47
|
-
|
|
39
|
+
value: <<~HTML
|
|
40
|
+
<div>This note serves as a reminder regarding the checklist assigned to you. This checklist is crucial for ensuring the safety and well-being of all staff.</div>
|
|
41
|
+
<div><br></div>
|
|
42
|
+
<div>Please review the checklist carefully and ensure that all necessary steps are taken to implement the required safety measures.</div>
|
|
43
|
+
<div><br></div>
|
|
44
|
+
<div>Your attention to detail and proactive approach to safety are greatly appreciated. If you have any questions or require assistance, please don't hesitate to reach out.</div>
|
|
45
|
+
<div><br></div>
|
|
46
|
+
<div>Thank you for your cooperation.</div>
|
|
47
|
+
HTML
|
|
48
48
|
|
|
49
49
|
form.spacer height: 20
|
|
50
50
|
form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
|
|
@@ -55,7 +55,7 @@ page.form \
|
|
|
55
55
|
form.fields_check name: 'user[check][]', checkValue: 'choice2', label: 'choice3', value: 'choice2'
|
|
56
56
|
|
|
57
57
|
form.h3 text: 'Rich text'
|
|
58
|
-
form.
|
|
58
|
+
form.fields_actionText name: 'user[richtext]', value: '<div>Lorem ipsum dumet...</div>'
|
|
59
59
|
|
|
60
60
|
form.spacer height: 24
|
|
61
61
|
form.panels_split width: 'matchParent', content: ->(split) do
|
|
@@ -35,7 +35,7 @@ page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', p
|
|
|
35
35
|
template.spacer height: 10
|
|
36
36
|
template.fields_hidden name: 'message[error]'
|
|
37
37
|
template.fields_text width: 'matchParent', name: 'question', label: 'Question', placeholder: 'Question'
|
|
38
|
-
template.
|
|
38
|
+
template.fields_actionText width: 'matchParent', name: 'description', label: 'Desc', placeholder: 'Desc'
|
|
39
39
|
|
|
40
40
|
template.panels_responsive id: 'responsive_{{entryIndex}}', childViews: ->(column) do
|
|
41
41
|
column.panels_split width: 'matchParent', content: ->(split) do
|
|
@@ -437,7 +437,7 @@ page.form \
|
|
|
437
437
|
id: 'panel2',
|
|
438
438
|
width: 'matchParent',
|
|
439
439
|
childViews: ->(res) do
|
|
440
|
-
res.
|
|
440
|
+
res.fields_actionText name: 'user[loadIf_target4]', width: 'matchParent', value: '<div>Value 3</div>'
|
|
441
441
|
res.spacer height: 4
|
|
442
442
|
res.fields_radioGroup name: 'user[loadIf_target5]', width: 'matchParent', value: 'choice_1', childViews: ->(group) do
|
|
443
443
|
group.fields_radio label: 'Choice 1', value: 'choice_1'
|
|
@@ -3,7 +3,23 @@ json.title 'Tables'
|
|
|
3
3
|
page = json_ui_page json
|
|
4
4
|
render "#{@path_prefix}/nav_menu", json: json, page: page
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# Server-side multi-column sorting (Glib::Params::MultiColumnSort): click a
|
|
7
|
+
# header to make it the primary sort, then another to sort by that one with
|
|
8
|
+
# the first breaking its ties. Status repeats so the ties are visible, one
|
|
9
|
+
# row has no sign-ups (nil stays last both ways), `sign-ups` is a hyphenated
|
|
10
|
+
# key, and with four sortable columns the fourth click drops the oldest of
|
|
11
|
+
# the three a sort keeps.
|
|
12
|
+
columns = { 'name' => 'Name', 'status' => 'Status', 'sign-ups' => 'Sign-ups', 'joined' => 'Joined' }
|
|
13
|
+
sort = Glib::Params::MultiColumnSort.new(params[:sort], allowed: columns.keys)
|
|
14
|
+
# Listed out of name order on purpose, so the tie-breaker visibly decides.
|
|
15
|
+
items = sort.sort_rows([
|
|
16
|
+
{ name: 'Echo', status: 'Active', 'sign-ups': 2, joined: '2026-02-10' },
|
|
17
|
+
{ name: 'Charlie', status: 'Active', 'sign-ups': nil, joined: '2026-02-10' },
|
|
18
|
+
{ name: 'Alpha', status: 'Active', 'sign-ups': 3, joined: '2026-03-01' },
|
|
19
|
+
{ name: 'Delta', status: 'Archived', 'sign-ups': 3, joined: '2026-01-15' },
|
|
20
|
+
{ name: 'Bravo', status: 'Archived', 'sign-ups': 1, joined: '2026-01-15' },
|
|
21
|
+
], tie_breaker: :name)
|
|
22
|
+
|
|
7
23
|
page.table styleClass: 'table--grid', sections: [
|
|
8
24
|
->(section) do
|
|
9
25
|
section.rows builder: ->(row) do
|
|
@@ -17,22 +33,18 @@ page.table styleClass: 'table--grid', sections: [
|
|
|
17
33
|
end,
|
|
18
34
|
->(section) do
|
|
19
35
|
section.header cellViews: ->(header) do
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
header.label text: "Heading#{i} (#{order})", onClick: ->(action) do
|
|
24
|
-
action.windows_reload url: json_ui_garage_url(path: 'tables/layout', orders: reversed_order_params(order_key))
|
|
25
|
-
end
|
|
36
|
+
columns.each do |key, label|
|
|
37
|
+
glib_sort_header header, sort: sort, key: key, label: label,
|
|
38
|
+
url: ->(param) { json_ui_garage_current_url(sort: param) }
|
|
26
39
|
end
|
|
27
40
|
|
|
28
41
|
header.label text: 'Markdown'
|
|
29
42
|
end
|
|
30
43
|
|
|
31
|
-
items = [1, 2, 3]
|
|
32
44
|
section.rows objects: items, builder: ->(row, item, index) do
|
|
33
45
|
row.default colStyles: [{ width: 200, backgroundColor: '#eeeeee' }], cellViews: ->(cell) do
|
|
34
|
-
|
|
35
|
-
cell.label text:
|
|
46
|
+
columns.each_key do |key|
|
|
47
|
+
cell.label text: item[key.to_sym].to_s
|
|
36
48
|
end
|
|
37
49
|
|
|
38
50
|
markdown = "* [Item 1](#{json_ui_garage_url(path: 'home/blank')})\n"\
|
|
@@ -43,13 +55,8 @@ page.table styleClass: 'table--grid', sections: [
|
|
|
43
55
|
end
|
|
44
56
|
|
|
45
57
|
section.footer cellViews: ->(header) do
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
# order = @order_headings[order_key]
|
|
49
|
-
header.label text: "Footer#{i}"
|
|
50
|
-
# , onClick: ->(action) do
|
|
51
|
-
# action.windows_reload url: json_ui_garage_url(path: 'tables/layout', orders: reversed_order_params(order_key))
|
|
52
|
-
# end
|
|
58
|
+
columns.each_value do |label|
|
|
59
|
+
header.label text: "#{label} footer"
|
|
53
60
|
end
|
|
54
61
|
|
|
55
62
|
header.label text: ''
|
|
@@ -2,7 +2,6 @@ json.title 'Test Page (Charts)'
|
|
|
2
2
|
|
|
3
3
|
default_plugins = {
|
|
4
4
|
datalabels: {
|
|
5
|
-
backgroundColor: 'skyblue',
|
|
6
5
|
borderRadius: 4,
|
|
7
6
|
color: 'white',
|
|
8
7
|
font: {
|
|
@@ -12,6 +11,9 @@ default_plugins = {
|
|
|
12
11
|
}
|
|
13
12
|
}
|
|
14
13
|
|
|
14
|
+
custom_plugins = default_plugins.deep_dup
|
|
15
|
+
custom_plugins[:datalabels][:backgroundColor] = ['#1E5006', '#E36414']
|
|
16
|
+
|
|
15
17
|
line_series_revenue = [
|
|
16
18
|
-> do
|
|
17
19
|
json.title 'Revenue'
|
|
@@ -158,7 +160,7 @@ page.body childViews: ->(body) do
|
|
|
158
160
|
res.spacer height: 8
|
|
159
161
|
res.charts_line(
|
|
160
162
|
dataSeries: line_series_revenue,
|
|
161
|
-
plugins:
|
|
163
|
+
plugins: custom_plugins,
|
|
162
164
|
colors: ['#79AC78', '#3085C3'],
|
|
163
165
|
legend: { display: false },
|
|
164
166
|
formatYAxis: true
|
|
@@ -81,6 +81,32 @@ page.body(
|
|
|
81
81
|
end
|
|
82
82
|
)
|
|
83
83
|
|
|
84
|
+
res.spacer height: 8
|
|
85
|
+
res.button(
|
|
86
|
+
text: 'commands/copy (with onFailure)',
|
|
87
|
+
onClick: ->(action) do
|
|
88
|
+
action.commands_copy(
|
|
89
|
+
text: 'Copied with failure callback',
|
|
90
|
+
onCopy: ->(subaction) do
|
|
91
|
+
subaction.runMultiple(
|
|
92
|
+
childActions: ->(ssaction) do
|
|
93
|
+
ssaction.logics_set targetId: 'commands_status', data: { text: 'Status: copied' }
|
|
94
|
+
ssaction.snackbars_alert message: 'Copied', styleClass: 'success'
|
|
95
|
+
end
|
|
96
|
+
)
|
|
97
|
+
end,
|
|
98
|
+
onFailure: ->(subaction) do
|
|
99
|
+
subaction.runMultiple(
|
|
100
|
+
childActions: ->(ssaction) do
|
|
101
|
+
ssaction.logics_set targetId: 'commands_status', data: { text: 'Status: copy failed' }
|
|
102
|
+
ssaction.snackbars_alert message: 'Copy failed', styleClass: 'danger'
|
|
103
|
+
end
|
|
104
|
+
)
|
|
105
|
+
end
|
|
106
|
+
)
|
|
107
|
+
end
|
|
108
|
+
)
|
|
109
|
+
|
|
84
110
|
res.spacer height: 8
|
|
85
111
|
res.button(
|
|
86
112
|
text: 'commands/custom (with callbacks)',
|
|
@@ -4,6 +4,17 @@ page = json_ui_page json
|
|
|
4
4
|
|
|
5
5
|
render 'json_ui/garage/test_page/header', json: json, page: page
|
|
6
6
|
|
|
7
|
+
# User includes ActionText::Attachable, so `has_rich_text` resolves each submitted sgid back to
|
|
8
|
+
# its User. Users have no avatar column; a placeholder seeded by id stands in for one.
|
|
9
|
+
user_mentions = User.all.map do |user|
|
|
10
|
+
{
|
|
11
|
+
sgid: user.attachable_sgid,
|
|
12
|
+
value: user.full_name,
|
|
13
|
+
group: user.admin? ? 'Admins' : 'Members',
|
|
14
|
+
avatar: "https://picsum.photos/seed/user-#{user.id}/80/80"
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
|
|
7
18
|
page.body(
|
|
8
19
|
childViews: ->(body) do
|
|
9
20
|
body.panels_responsive(
|
|
@@ -67,7 +78,34 @@ page.body(
|
|
|
67
78
|
label: 'Locked',
|
|
68
79
|
name: 'post[locked]',
|
|
69
80
|
value: '<div>Cannot be edited.</div>',
|
|
70
|
-
readOnly: true
|
|
81
|
+
readOnly: true,
|
|
82
|
+
mentionList: user_mentions
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
form.spacer height: 12
|
|
86
|
+
form.h2 text: 'Mentions'
|
|
87
|
+
form.spacer height: 8
|
|
88
|
+
form.fields_actionText(
|
|
89
|
+
id: 'action_text_mentions',
|
|
90
|
+
width: 'matchParent',
|
|
91
|
+
label: 'Comment',
|
|
92
|
+
name: 'post[comment]',
|
|
93
|
+
mentionList: user_mentions + [
|
|
94
|
+
# Not a record: checks that a name with markup is inserted as text.
|
|
95
|
+
{ sgid: 'garage-markup', value: '<b>Grace</b>', text: 'Grace Hopper', group: 'Members' },
|
|
96
|
+
{ value: 'everyone', text: 'Everyone', group: 'Members' }
|
|
97
|
+
]
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
form.spacer height: 12
|
|
101
|
+
form.h2 text: 'Mentions from a search endpoint'
|
|
102
|
+
form.spacer height: 8
|
|
103
|
+
form.fields_actionText(
|
|
104
|
+
id: 'action_text_mention_search',
|
|
105
|
+
width: 'matchParent',
|
|
106
|
+
label: 'Reply',
|
|
107
|
+
name: 'post[reply]',
|
|
108
|
+
mentionUrl: json_ui_garage_url(path: 'forms/action_text_mentions', format: 'json')
|
|
71
109
|
)
|
|
72
110
|
|
|
73
111
|
form.spacer height: 12
|
|
@@ -81,6 +119,70 @@ page.body(
|
|
|
81
119
|
res.panels_vertical id: 'preview', childViews: ->(vertical) do
|
|
82
120
|
vertical.actionText richText: ActionText::Content.new('<div>Initial <strong>content</strong>.</div>')
|
|
83
121
|
end
|
|
122
|
+
|
|
123
|
+
res.spacer height: 12
|
|
124
|
+
res.hr width: 'matchParent'
|
|
125
|
+
res.spacer height: 12
|
|
126
|
+
|
|
127
|
+
stored_markdown = <<~MARKDOWN
|
|
128
|
+
# Release notes
|
|
129
|
+
This is a **message** with *emphasis* and a [link](https://example.com).
|
|
130
|
+
|
|
131
|
+
- Bullet one
|
|
132
|
+
- Bullet two
|
|
133
|
+
|
|
134
|
+
> Quoted text
|
|
135
|
+
MARKDOWN
|
|
136
|
+
|
|
137
|
+
res.h2 text: 'Markdown and HTML output'
|
|
138
|
+
res.spacer height: 8
|
|
139
|
+
res.p text: "Replaces fields_richText's produce/accept. The field only speaks HTML, so the server converts: " \
|
|
140
|
+
'stored Markdown becomes the HTML value, and the submitted HTML becomes Markdown.'
|
|
141
|
+
res.spacer height: 8
|
|
142
|
+
res.h3 text: 'Stored Markdown (input)'
|
|
143
|
+
res.markdown text: "```markdown\n#{stored_markdown.strip}\n```"
|
|
144
|
+
res.spacer height: 8
|
|
145
|
+
res.panels_form(
|
|
146
|
+
width: 'matchParent',
|
|
147
|
+
url: json_ui_garage_url(path: 'forms/action_text_conversion'),
|
|
148
|
+
method: 'post',
|
|
149
|
+
childViews: ->(form) do
|
|
150
|
+
form.fields_actionText(
|
|
151
|
+
id: 'action_text_markdown',
|
|
152
|
+
width: 'matchParent',
|
|
153
|
+
label: 'Value converted from Markdown on the server',
|
|
154
|
+
name: 'post[body]',
|
|
155
|
+
value: glib_format_markdown(stored_markdown)
|
|
156
|
+
)
|
|
157
|
+
form.spacer height: 8
|
|
158
|
+
form.fields_submit text: 'Convert output'
|
|
159
|
+
end
|
|
160
|
+
)
|
|
161
|
+
res.spacer height: 8
|
|
162
|
+
res.panels_vertical id: 'action_text_conversion', width: 'matchParent', childViews: ->(panel) do
|
|
163
|
+
panel.label text: 'Submit to see the HTML the field produces and its Markdown conversion.'
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
res.spacer height: 12
|
|
167
|
+
res.h2 text: 'Chat input'
|
|
168
|
+
res.spacer height: 8
|
|
169
|
+
res.label text: 'No toolbar, mentions, Enter sends and Shift+Enter adds a line.'
|
|
170
|
+
res.spacer height: 8
|
|
171
|
+
res.panels_form(
|
|
172
|
+
url: json_ui_garage_url(path: 'forms/generic_post'),
|
|
173
|
+
method: 'post',
|
|
174
|
+
childViews: ->(form) do
|
|
175
|
+
form.fields_actionText(
|
|
176
|
+
id: 'action_text_chat',
|
|
177
|
+
width: 'matchParent',
|
|
178
|
+
name: 'user[message]',
|
|
179
|
+
placeholder: 'Write a message',
|
|
180
|
+
hideToolbar: true,
|
|
181
|
+
submitOnEnter: true,
|
|
182
|
+
mentionList: user_mentions
|
|
183
|
+
)
|
|
184
|
+
end
|
|
185
|
+
)
|
|
84
186
|
end
|
|
85
187
|
)
|
|
86
188
|
end
|
|
@@ -12,7 +12,7 @@ page.body(
|
|
|
12
12
|
childViews: ->(res) do
|
|
13
13
|
res.h2 text: 'Fields RichText'
|
|
14
14
|
res.spacer height: 8
|
|
15
|
-
res.label text: 'WYSIWYG editor with markdown or HTML output, mentions, and image uploads.'
|
|
15
|
+
res.label text: 'Deprecated: use fields_actionText (see doc/rich_text_migration.md). WYSIWYG editor with markdown or HTML output, mentions, and image uploads.'
|
|
16
16
|
res.spacer height: 12
|
|
17
17
|
|
|
18
18
|
res.panels_form(
|
|
@@ -208,6 +208,50 @@ Try @mentioning a teammate here.
|
|
|
208
208
|
)
|
|
209
209
|
end
|
|
210
210
|
)
|
|
211
|
+
|
|
212
|
+
res.spacer height: 12
|
|
213
|
+
res.hr width: 'matchParent'
|
|
214
|
+
res.spacer height: 12
|
|
215
|
+
|
|
216
|
+
# An editor replaced in place by new content at the same position: the replacement's
|
|
217
|
+
# value must show, not the old value or old typing. A form of its own, so its dirty
|
|
218
|
+
# state is observable: `swap_ever_dirty` never resets, so a transient blip shows too.
|
|
219
|
+
res.h2 text: 'Replaced in place'
|
|
220
|
+
res.spacer height: 8
|
|
221
|
+
res.label id: 'swap_dirty_state', text: 'Form: pristine'
|
|
222
|
+
res.label id: 'swap_ever_dirty', text: 'Ever dirty: no'
|
|
223
|
+
res.spacer height: 8
|
|
224
|
+
res.panels_form(
|
|
225
|
+
url: json_ui_garage_url(path: 'forms/generic_post'),
|
|
226
|
+
method: 'post',
|
|
227
|
+
onDirty: ->(action) do
|
|
228
|
+
action.runMultiple childActions: ->(multiple) do
|
|
229
|
+
multiple.logics_set targetId: 'swap_dirty_state', data: { text: 'Form: dirty' }
|
|
230
|
+
multiple.logics_set targetId: 'swap_ever_dirty', data: { text: 'Ever dirty: yes' }
|
|
231
|
+
end
|
|
232
|
+
end,
|
|
233
|
+
onPristine: ->(action) do
|
|
234
|
+
action.logics_set targetId: 'swap_dirty_state', data: { text: 'Form: pristine' }
|
|
235
|
+
end,
|
|
236
|
+
childViews: ->(form) do
|
|
237
|
+
form.panels_vertical width: 'matchParent', id: 'rich_text_swap_panel', childViews: ->(panel) do
|
|
238
|
+
panel.fields_richText width: 'matchParent', name: 'user[swap]', value: 'Before swap',
|
|
239
|
+
placeholder: 'Before placeholder', mentionList: ['Alice Before']
|
|
240
|
+
end
|
|
241
|
+
form.button text: 'Swap to new value', onClick: ->(action) do
|
|
242
|
+
action.components_replaceChildren targetId: 'rich_text_swap_panel', childViews: ->(panel) do
|
|
243
|
+
panel.fields_richText width: 'matchParent', name: 'user[swap]', value: 'After swap',
|
|
244
|
+
placeholder: 'After placeholder', mentionList: ['Bob After']
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
form.button text: 'Swap to same value', onClick: ->(action) do
|
|
248
|
+
action.components_replaceChildren targetId: 'rich_text_swap_panel', childViews: ->(panel) do
|
|
249
|
+
panel.fields_richText width: 'matchParent', name: 'user[swap]', value: 'Before swap',
|
|
250
|
+
placeholder: 'Before placeholder', mentionList: ['Alice Before']
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
)
|
|
211
255
|
end
|
|
212
256
|
)
|
|
213
257
|
end
|
|
@@ -140,7 +140,7 @@ page.body childViews: ->(body) do
|
|
|
140
140
|
multiProgressView: { files: [{ name: 'cover.png', signed_id: 'saved-cover', url: 'https://picsum.photos/id/12/100/60' }] }
|
|
141
141
|
form.spacer height: 14
|
|
142
142
|
|
|
143
|
-
form.
|
|
143
|
+
form.fields_actionText id: 'dirty_rich_text', name: 'user[bio]', width: 'matchParent', label: 'Bio', value: '<div>hello</div>'
|
|
144
144
|
form.spacer height: 14
|
|
145
145
|
|
|
146
146
|
# Populated from the URL hash at mount; must be absorbed into the
|
|
@@ -52,12 +52,12 @@ page.body childViews: ->(body) do
|
|
|
52
52
|
|
|
53
53
|
form.panels_vertical width: 'matchParent', id: 'hidden_panel_a', submitWhenNotDisplayed: true, childViews: ->(panel) do
|
|
54
54
|
panel.label text: 'Panel A'
|
|
55
|
-
panel.
|
|
55
|
+
panel.fields_actionText id: 'hidden_text_a', width: 'matchParent', name: 'user[text_a]', value: '<div>Alpha start</div>', submitWhenNotDisplayed: true
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
form.panels_vertical width: 'matchParent', id: 'hidden_panel_b', displayed: false, submitWhenNotDisplayed: true, childViews: ->(panel) do
|
|
59
59
|
panel.label text: 'Panel B'
|
|
60
|
-
panel.
|
|
60
|
+
panel.fields_actionText id: 'hidden_text_b', width: 'matchParent', name: 'user[text_b]', value: '<div>Bravo start</div>', submitWhenNotDisplayed: true
|
|
61
61
|
panel.fields_upload \
|
|
62
62
|
id: 'hidden_upload_b',
|
|
63
63
|
name: 'user[file_b]',
|
|
@@ -71,7 +71,7 @@ page.body childViews: ->(body) do
|
|
|
71
71
|
|
|
72
72
|
form.panels_vertical width: 'matchParent', id: 'hidden_panel_c', displayed: false, submitWhenNotDisplayed: true, childViews: ->(panel) do
|
|
73
73
|
panel.label text: 'Panel C'
|
|
74
|
-
panel.
|
|
74
|
+
panel.fields_actionText id: 'hidden_text_c', width: 'matchParent', name: 'user[text_c]', value: '<div>Charlie start</div>', submitWhenNotDisplayed: true
|
|
75
75
|
end
|
|
76
76
|
|
|
77
77
|
form.spacer height: 12
|
|
@@ -98,25 +98,6 @@ page.body childViews: ->(body) do
|
|
|
98
98
|
end
|
|
99
99
|
form.spacer height: 12
|
|
100
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
101
|
form.spacer height: 20
|
|
121
102
|
form.fields_submit text: 'Submit'
|
|
122
103
|
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
default_plugins = {
|
|
2
2
|
datalabels: {
|
|
3
|
-
backgroundColor: 'skyblue',
|
|
4
3
|
borderRadius: 4,
|
|
5
4
|
color: 'white',
|
|
6
5
|
font: {
|
|
@@ -10,6 +9,9 @@ default_plugins = {
|
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
11
|
|
|
12
|
+
custom_plugins = default_plugins.deep_dup
|
|
13
|
+
custom_plugins[:datalabels][:backgroundColor] = ['#1E5006', '#E36414']
|
|
14
|
+
|
|
13
15
|
if params[:data_only].present?
|
|
14
16
|
json_ui_page json do |page|
|
|
15
17
|
page.data content: ->(data) do
|
|
@@ -54,7 +56,7 @@ else
|
|
|
54
56
|
json.points points.map { |k, v| { x: k, y: v, label: v > 5 ? 'Greater than five' : v } }
|
|
55
57
|
end
|
|
56
58
|
],
|
|
57
|
-
plugins:
|
|
59
|
+
plugins: custom_plugins,
|
|
58
60
|
colors: ['#79AC78', '#3085C3'], legend: { display: false }, formatYAxis: true
|
|
59
61
|
|
|
60
62
|
# scroll.spacer height: 20
|
data/lib/glib/all_helpers.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: glib-web
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.
|
|
4
|
+
version: 8.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- ''
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activestorage
|
|
@@ -230,6 +230,7 @@ files:
|
|
|
230
230
|
- app/controllers/concerns/glib/json/ui.rb
|
|
231
231
|
- app/controllers/concerns/glib/json/validation.rb
|
|
232
232
|
- app/controllers/concerns/glib/params/allowlist.rb
|
|
233
|
+
- app/controllers/concerns/glib/params/multi_column_sort.rb
|
|
233
234
|
- app/controllers/glib/api_controller.rb
|
|
234
235
|
- app/controllers/glib/blob_url_generators_controller.rb
|
|
235
236
|
- app/controllers/glib/errors_controller.rb
|
|
@@ -270,6 +271,7 @@ files:
|
|
|
270
271
|
- app/helpers/glib/json_ui/menu_builder.rb
|
|
271
272
|
- app/helpers/glib/json_ui/page_helper.rb
|
|
272
273
|
- app/helpers/glib/json_ui/response_helper.rb
|
|
274
|
+
- app/helpers/glib/json_ui/sort_helper.rb
|
|
273
275
|
- app/helpers/glib/json_ui/styling_helper.rb
|
|
274
276
|
- app/helpers/glib/json_ui/table_builders.rb
|
|
275
277
|
- app/helpers/glib/json_ui/view_builder.rb
|
|
@@ -332,6 +334,7 @@ files:
|
|
|
332
334
|
- app/views/json_ui/garage/content/web_panel_a.html.erb
|
|
333
335
|
- app/views/json_ui/garage/content/web_panel_b.html.erb
|
|
334
336
|
- app/views/json_ui/garage/empty.json.jbuilder
|
|
337
|
+
- app/views/json_ui/garage/forms/_action_text_conversion.json.jbuilder
|
|
335
338
|
- app/views/json_ui/garage/forms/_alert_post_all_data.json.jbuilder
|
|
336
339
|
- app/views/json_ui/garage/forms/_alert_post_data.json.jbuilder
|
|
337
340
|
- app/views/json_ui/garage/forms/_basic_content.json.jbuilder
|
|
@@ -340,7 +343,9 @@ files:
|
|
|
340
343
|
- app/views/json_ui/garage/forms/_read_more_text.json.jbuilder
|
|
341
344
|
- app/views/json_ui/garage/forms/action_text.json.jbuilder
|
|
342
345
|
- app/views/json_ui/garage/forms/action_text_attachment.json.jbuilder
|
|
346
|
+
- app/views/json_ui/garage/forms/action_text_conversion.json.jbuilder
|
|
343
347
|
- app/views/json_ui/garage/forms/action_text_library.json.jbuilder
|
|
348
|
+
- app/views/json_ui/garage/forms/action_text_mentions.json.jbuilder
|
|
344
349
|
- app/views/json_ui/garage/forms/action_text_preview.json.jbuilder
|
|
345
350
|
- app/views/json_ui/garage/forms/basic.json.jbuilder
|
|
346
351
|
- app/views/json_ui/garage/forms/basic_post.json.jbuilder
|