inline_forms 8.1.65 → 8.1.67
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/CHANGELOG.md +66 -0
- data/app/assets/javascripts/inline_forms/inline_forms.js +36 -21
- data/app/assets/stylesheets/inline_forms/foundation_and_overrides.scss +8 -1
- data/app/assets/stylesheets/inline_forms/inline_forms.scss +13 -0
- data/app/helpers/inline_forms_helper.rb +21 -0
- data/app/views/devise/inline_forms/_content_for_devise_login.html.erb +3 -2
- data/app/views/devise/passwords/_top-bar-and-flash.html.erb +1 -1
- data/app/views/devise/sessions/_top-bar.html.erb +1 -1
- data/app/views/devise/sessions/new.html.erb +1 -1
- data/app/views/devise/shared/_header_and_errors.html.erb +1 -1
- data/app/views/inline_forms/_generic_search.html.erb +3 -3
- data/app/views/inline_forms/_versions_file_entry.html.erb +1 -1
- data/app/views/inline_forms/_versions_list.html.erb +1 -1
- data/app/views/inline_forms/file_trash/index.html.erb +4 -4
- data/app/views/inline_forms/file_trash_panel.html.erb +3 -3
- data/app/views/layouts/application.html.erb +1 -1
- data/app/views/layouts/devise.html.erb +1 -1
- data/app/views/layouts/inline_forms.html.erb +18 -9
- data/lib/inline_forms/searchable.rb +12 -5
- data/lib/inline_forms/version.rb +1 -1
- data/lib/inline_forms.rb +24 -1
- data/lib/locales/inline_forms.en.yml +15 -4
- data/lib/locales/inline_forms.nl.yml +15 -4
- data/lib/locales/inline_forms_titles.rb +16 -0
- data/test/integration/locale_test.rb +86 -1
- data/test/integration/model_top_bar_test.rb +20 -0
- data/test/integration/turbo_menu_test.rb +60 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: faafc3188dc88f06ee65cc379452eb7dde62753fe63b488b0250841c4cdb641d
|
|
4
|
+
data.tar.gz: 880f68f083664c8bf6de77fb522577365c43069523da92ca42a01bdd2fa7378a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e378f136a965b95f21f0e09e55776b1019eb3fa8a3ada7c1117ab101f2f2a117d654ebfe1b3cbf2c02b01cfd01c7e2096de3cf3d00ffa1d73b6c5474b0b81c3d
|
|
7
|
+
data.tar.gz: 86d6a6d5553a2b98227a3367b0f8cbdc703646bfa01b5a5f55a59dcf798a1c9bf029a0dfcfe7506d2a18e0eaf960155743266e146e4b9ab62d5678ac45b1bf51
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,72 @@ All notable changes to this project are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
### Known issues
|
|
8
|
+
|
|
9
|
+
- Known issues, parked (local note `stuff/2026-10-31-dropdown-rule-3-parked.md`) with dropdown order rule 3: `includes`, `group` or `select` in `inline_forms_list` make `dropdown` and `dropdown_with_other` raise while `/index` works, so 8.1.65's fix for a list order on a joined table holds only for `joins`, `left_joins` and `eager_load`; a has_many join gives duplicate options. Present since 8.1.60. No host's list scope has these today. Parked; not changed.
|
|
10
|
+
|
|
11
|
+
## [8.1.67] - 2026-11-06
|
|
12
|
+
|
|
13
|
+
Fixes from a code review of 8.1.66.
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- **Version and file trash pages no longer crash in a locale without `time.formats.inline_forms`.** 8.1.66 defined the format in en and nl only, and a bare `l(time, format: :inline_forms)` raises `I18n::MissingTranslationData` in any other locale when the host has no i18n fallbacks (rails-i18n's `:short`, used before, exists in every locale). The versions list, the file entries and the file trash now go through `inline_forms_time_text`, which passes the same format (`InlineForms::TIME_FORMAT`) as the default; the month names still come from the locale.
|
|
18
|
+
- **No more document listeners piling up on Turbo visits.** 8.1.66's once-guard in `inline_forms.js` left the `turbo:frame-load` listener and the `.translation_missing` mouseover handler outside it, so a layout that re-runs the bundle added another of each per visit (after 10 visits every frame load rebuilt each tooltip 11 times). Both are inside the guard now (the mouseover handler is a plain DOM listener).
|
|
19
|
+
- **Foundation and the widgets initialise once per page.** The first page ran `foundation()` and `initInlineFormsWidgets` from both the ready event and `turbo:load`, which destroyed and rebuilt every tooltip; one boot function now runs once per `<body>`.
|
|
20
|
+
- **The submenu rule no longer hides drilldown submenus.** 8.1.66 hid every `.dropdown.menu` submenu without `is-dropdown-submenu`, which beats Foundation's own `.is-drilldown-submenu` rules for a `data-responsive-menu` on small screens. It now applies to `[data-dropdown-menu]` menus only.
|
|
21
|
+
- **The title keys exist again, and say the application's name.** 8.1.66 removed `inline_forms.general.application_title`, `inline_forms.devise.title_for_devise` and `inline_forms.devise.welcome`, so a host view calling one bare (Papiamentu has several) showed "translation missing" in any locale it did not translate and that had no fallbacks. In en and nl they are now lambdas (`lib/locales/inline_forms_titles.rb`) that return `InlineForms.application_title`; a host's own translation still wins (its locale files load after the gem's; the example app checks the order).
|
|
22
|
+
- **One source for the application's name.** `InlineForms.application_title` is the host's `application_name` translation, else its `ApplicationHelper#application_name` (8.1.66 skipped that and used the titleized module name, so an app could say "MyApp" in en and "My App" in nl), else the Rails module name. `inline_forms_application_title`, the admin layout's `<title>` and the Devise header use it.
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- **The admin layout loads Popper, Tippy and `inline_forms.js` in `<head>`.** In `<body>` Turbo Drive re-ran them on every visit with a fresh jQuery, the cause of 8.1.66's menu flash; Turbo runs head scripts once and appends missing ones in order on a visit from another layout. `no-js`, the once-guard and the submenu rule stay for host layouts that still load the bundle in `<body>`.
|
|
27
|
+
- **Installer: the generated `config/locales/inline_forms_local.en.yml` has only `application_name`.** It also wrote the three title keys, in en only.
|
|
28
|
+
- **`inline_forms_search_on` builds its clause once,** on the first search (`inline_forms_search_clause`), instead of on every search.
|
|
29
|
+
|
|
30
|
+
### Tests
|
|
31
|
+
|
|
32
|
+
- `turbo_menu_test`: the scripts in `<head>` in order, no document listener outside the guard, one boot per body, the `[data-dropdown-menu]` rule.
|
|
33
|
+
- `locale_test`: the title keys resolve to the app's name in en and nl (translation, then the helper), a host translation wins, timestamps render in a locale without the gem's format.
|
|
34
|
+
- `model_top_bar_test`: the search clause is built once.
|
|
35
|
+
- Example app: `example_app_layout_title_test` checks the host's locale files load after the gem's title keys and that the keys say the app name in en and nl; `example_app_stylesheet_test` expects the scoped rule.
|
|
36
|
+
|
|
37
|
+
### Lockstep
|
|
38
|
+
|
|
39
|
+
- validation_hints 8.1.67, inline_forms_installer 8.1.67, inline_forms_schema_edit 8.1.67.
|
|
40
|
+
|
|
41
|
+
## [8.1.66] - 2026-11-06
|
|
42
|
+
|
|
43
|
+
Requests from Papiamentu's move to the 8.1.65 admin (gem layout, engine model top bar, gem stylesheet); each was worked around in the apps.
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- **Top-bar submenus no longer flash open after a Turbo Drive visit.** Turbo replaced `<body>` and re-ran the inline_forms bundle, which loaded a fresh jQuery; until it finished, the new body's "more..." and user submenus showed as plain lists. StProject, Scouting and Papiamentu each copied the admin layout to fix it. Now `layouts/inline_forms` starts as `<html class="no-js">`; `inline_forms.js` re-initialises Foundation on `turbo:load`, behind a once-guard (Turbo still re-runs the bundle on each visit, so a visit from a layout without it works; the guard stops the listeners piling up and a second `foundation()` from the fresh jQuery); and `inline_forms.scss` hides a submenu until Foundation has marked it `is-dropdown-submenu`.
|
|
48
|
+
- **No more 404 for `/vendor/assets/stylesheets/tippy.css`.** `foundation_and_overrides.scss` imported `tippy.css` with its extension, which Dart Sass keeps as a plain CSS `@import`; the browser resolved it next to the compiled stylesheet. The vendored file is now inlined with `meta.load-css` (no new `@import` deprecation), in admin and devise CSS. Apps can delete their `public/vendor/assets/stylesheets/tippy.css`.
|
|
49
|
+
- **Version and file timestamps show the year.** The versions list, the file entries in it and the file trash used `l(time, format: :short)`, and rails-i18n's `:short` has no year. They now use the gem's `time.formats.inline_forms` (`"%d %b %Y %H:%M"` in en and nl; a host can override it). The versions list and file entries render a `<time>` with the ISO 8601 time as `datetime` and `title` (new helper `inline_forms_time`).
|
|
50
|
+
- **The generic search box is translated.** `_generic_search` had "zoek op naam...", "zoek" and "reset" hard-coded; now `inline_forms.search.placeholder` / `.submit` / `.reset` (en: "search...", "search", "reset"; nl: "zoeken...", "zoek", "wissen").
|
|
51
|
+
- **No placeholder titles.** The gem's en and nl locales defined `general.application_title: Application Title`, `devise.title_for_devise: Title for Devise` and `devise.welcome: Welcome for Devise`, shown in any locale the host did not override (the installer only writes en). The keys are gone; the application and devise layouts and the devise top bars fall back to the host's `application_name` translation, else the Rails module name (new helper `inline_forms_application_title`), and the sign-in page to `inline_forms.devise.welcome_to` ("Welcome to %{name}!" / "Welkom bij %{name}!"). A host's own translations still win.
|
|
52
|
+
- **`inline_forms_search_on` no longer touches the database when the model loads.** It quoted the table and column names in the class body, so loading the model needed a connection; the clause is now built when the scope runs.
|
|
53
|
+
|
|
54
|
+
### Changed
|
|
55
|
+
|
|
56
|
+
- **Installer: the Dart Sass self-import guard no longer patches dartsass-rails.** The generated `config/initializers/inline_forms_dartsass_builds.rb` prepended the gem's stylesheet dir to `Dartsass::Runner.dartsass_load_paths`, an internal (a silent no-op if renamed; a boot error if `dartsass/runner` moved). The two `inline_forms_install/*_main.scss` entries now `@use "inline_forms/inline_forms.scss"` and `"inline_forms/devise.scss"` with the extension, which Dart Sass never resolves to a previous `app/assets/builds/*.css`, and which fails loudly if the gem renames the file. Existing apps keep their initializer until they change it.
|
|
57
|
+
|
|
58
|
+
### Not done
|
|
59
|
+
|
|
60
|
+
- **Autocomplete in the generic search** (a `rails-jquery-autocomplete` field when the controller declares `autocomplete :<model>, :name`): that gem needs jQuery UI, which inline_forms dropped in 8.1.26, and it is not an inline_forms dependency. An app that wants it keeps its own `_generic_search` override.
|
|
61
|
+
|
|
62
|
+
### Tests
|
|
63
|
+
|
|
64
|
+
- `turbo_menu_test` (new): the layout's `no-js`, the once-guarded `turbo:load` re-init, the submenu rule, tippy inlined.
|
|
65
|
+
- `locale_test`: timestamps with the year and an ISO `title`, the search box in en and nl, no placeholder titles (devise and application layouts, the devise top bar).
|
|
66
|
+
- `model_top_bar_test`: `inline_forms_search_on` declared on a model whose connection raises.
|
|
67
|
+
- Example app: `example_app_stylesheet_test` (new) checks the compiled CSS has no `@import`, inlines tippy and hides uninitialised submenus; `example_app_dartsass_build_test` checks the `.scss` extensions instead of the patched load path. `example_app_user_locale_test` and `example_app_layout_title_test` expect `<html lang="…" class="no-js">`.
|
|
68
|
+
|
|
69
|
+
### Lockstep
|
|
70
|
+
|
|
71
|
+
- validation_hints 8.1.66, inline_forms_installer 8.1.66, inline_forms_schema_edit 8.1.66.
|
|
72
|
+
|
|
7
73
|
## [8.1.65] - 2026-10-31
|
|
8
74
|
|
|
9
75
|
Fixes from a review of 8.1.60 to 8.1.64.
|
|
@@ -14,14 +14,43 @@
|
|
|
14
14
|
// dropdown_with_other combobox is an <input list> + <datalist>, and
|
|
15
15
|
// slider_with_values is a native <input type="range">. jQuery itself stays
|
|
16
16
|
// only because Foundation 6's JS requires it.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
// Listeners are added once per page load. The gem's layouts load this bundle
|
|
18
|
+
// in <head>, which Turbo Drive keeps across visits, but a host layout may
|
|
19
|
+
// still have it in <body>, which Turbo re-runs on every visit (each run with a
|
|
20
|
+
// fresh jQuery): without the guard every run would add another set.
|
|
21
|
+
if (!window.inlineFormsBooted) {
|
|
22
|
+
window.inlineFormsBooted = true;
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
// Foundation and the widgets, once per <body>. Turbo Drive replaces <body>
|
|
25
|
+
// on a visit, and the new top bar's DropdownMenu needs initialising or its
|
|
26
|
+
// submenus show as plain lists. The first page gets both the ready event
|
|
27
|
+
// and turbo:load (and a layout without Turbo only the first), so the body
|
|
28
|
+
// check keeps it to one init. jQuery is looked up at call time.
|
|
29
|
+
var inlineFormsBootedBody = null;
|
|
30
|
+
var bootInlineFormsPage = function() {
|
|
31
|
+
if (!document.body || document.body === inlineFormsBootedBody) { return; }
|
|
32
|
+
inlineFormsBootedBody = document.body;
|
|
33
|
+
if (window.jQuery && window.jQuery.fn.foundation) {
|
|
34
|
+
window.jQuery(document).foundation();
|
|
35
|
+
}
|
|
36
|
+
initInlineFormsWidgets(document);
|
|
37
|
+
};
|
|
38
|
+
$(bootInlineFormsPage);
|
|
39
|
+
document.addEventListener("turbo:load", bootInlineFormsPage);
|
|
40
|
+
|
|
41
|
+
// Re-bind widgets (tooltips) after Turbo Frame swaps.
|
|
42
|
+
document.addEventListener("turbo:frame-load", function(event) {
|
|
43
|
+
var root = event.target;
|
|
44
|
+
if (!root || !root.querySelectorAll) { return; }
|
|
45
|
+
initInlineFormsWidgets(root);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// get rid of translation_missing tooltips
|
|
49
|
+
document.addEventListener("mouseover", function(event) {
|
|
50
|
+
var el = event.target.closest && event.target.closest(".translation_missing");
|
|
51
|
+
if (el) { el.setAttribute("title", ""); }
|
|
52
|
+
});
|
|
53
|
+
}
|
|
25
54
|
|
|
26
55
|
// Widget init: one path for first paint, turbo:load and turbo:frame-load.
|
|
27
56
|
// Form element helpers emit class hooks only — no inline <script> tags.
|
|
@@ -88,17 +117,3 @@ function initValidationHintTooltips(root) {
|
|
|
88
117
|
}
|
|
89
118
|
});
|
|
90
119
|
}
|
|
91
|
-
|
|
92
|
-
// get rid of translation_missing tooltips
|
|
93
|
-
$(document).ready(function() {
|
|
94
|
-
$(this).on('mouseover', '.translation_missing', function() {
|
|
95
|
-
$(this).attr('title', '');
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
// Re-bind widgets (tooltips) after Turbo Frame swaps.
|
|
100
|
-
document.addEventListener("turbo:frame-load", function(event) {
|
|
101
|
-
var root = event.target;
|
|
102
|
-
if (!root || !root.querySelectorAll) { return; }
|
|
103
|
-
initInlineFormsWidgets(root);
|
|
104
|
-
});
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
@charset 'utf-8';
|
|
2
2
|
|
|
3
|
+
@use 'sass:meta';
|
|
4
|
+
|
|
3
5
|
@import 'settings/settings';
|
|
4
6
|
|
|
5
7
|
// Match F5 visual proportions: F5 `$row-width` was 62.5rem (1000px); F6
|
|
@@ -58,7 +60,12 @@ $body-font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Roboto, Arial, sans
|
|
|
58
60
|
// Stays @import: see the module-system note in inline_forms.scss.
|
|
59
61
|
@import 'theme';
|
|
60
62
|
|
|
61
|
-
|
|
63
|
+
// Tippy's vendored CSS, inlined. It used to be `@import '…/tippy.css'`,
|
|
64
|
+
// which Dart Sass passes through as a plain CSS @import: the browser then
|
|
65
|
+
// fetched /vendor/assets/stylesheets/tippy.css (resolved next to the compiled
|
|
66
|
+
// stylesheet), a 404 on every page. load-css (not an extension-less @import,
|
|
67
|
+
// deprecated for Dart Sass 3) emits it here, in the same place.
|
|
68
|
+
@include meta.load-css('../../../vendor/assets/stylesheets/tippy');
|
|
62
69
|
|
|
63
70
|
.validation-hints-source[hidden] {
|
|
64
71
|
display: none !important;
|
|
@@ -113,6 +113,19 @@
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
// A top-bar submenu shows as a plain list until Foundation's DropdownMenu
|
|
117
|
+
// marks it `is-dropdown-submenu` (whose own rules then hide it). On the first
|
|
118
|
+
// page `html.no-js` covers that gap (layouts/inline_forms.html.erb), but
|
|
119
|
+
// Foundation removes the class and Turbo Drive never restores it, so after a
|
|
120
|
+
// visit the new body's submenus could flash open until inline_forms.js
|
|
121
|
+
// re-initialised them on turbo:load (most of all from a host layout that
|
|
122
|
+
// still loads the bundle in <body>). Only for menus marked
|
|
123
|
+
// `data-dropdown-menu`: a `data-responsive-menu` turns its submenus into
|
|
124
|
+
// `is-drilldown-submenu` on small screens, which this rule would hide.
|
|
125
|
+
.dropdown.menu[data-dropdown-menu] > li > ul.menu:not(.is-dropdown-submenu) {
|
|
126
|
+
display: none;
|
|
127
|
+
}
|
|
128
|
+
|
|
116
129
|
// Match: model top bar is the wider gold band (height 90px, padded so its
|
|
117
130
|
// usable area is in the lower 45px). Override Foundation 6's default
|
|
118
131
|
// `.top-bar { padding: 0.5rem }` so our 45/90px math holds.
|
|
@@ -394,6 +394,27 @@ module InlineFormsHelper
|
|
|
394
394
|
values
|
|
395
395
|
end
|
|
396
396
|
|
|
397
|
+
# A version or file timestamp: the date with its year
|
|
398
|
+
# (time.formats.inline_forms; rails-i18n's :short has none, so edits years
|
|
399
|
+
# apart read the same), the exact ISO 8601 time on hover.
|
|
400
|
+
def inline_forms_time(time)
|
|
401
|
+
tag.time(inline_forms_time_text(time), datetime: time.iso8601, title: time.iso8601)
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
# The text alone. The gem defines time.formats.inline_forms only in en and
|
|
405
|
+
# nl; in another locale without it (and without i18n fallbacks) a bare
|
|
406
|
+
# l(format: :inline_forms) raises, so the same format is the default. The
|
|
407
|
+
# month names still come from that locale (rails-i18n).
|
|
408
|
+
def inline_forms_time_text(time)
|
|
409
|
+
l(time, format: :inline_forms, default: InlineForms::TIME_FORMAT)
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
# The application's name for the gem's titles and the Devise pages
|
|
413
|
+
# (InlineForms.application_title).
|
|
414
|
+
def inline_forms_application_title
|
|
415
|
+
InlineForms.application_title
|
|
416
|
+
end
|
|
417
|
+
|
|
397
418
|
def version_modified_by(id)
|
|
398
419
|
return "Unknown" if id.blank?
|
|
399
420
|
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
and the contents will be displayed here.
|
|
7
7
|
</p>
|
|
8
8
|
<p>
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
The titles come from the <em>application_name</em> translation; override
|
|
10
|
+
inline_forms.general.application_title, inline_forms.devise.title_for_devise
|
|
11
|
+
or inline_forms.devise.welcome in <em>config/locales</em> to change one.<br />
|
|
11
12
|
</p>
|
|
12
13
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<div class="top-bar-left">
|
|
4
4
|
<ul class="menu">
|
|
5
5
|
<li class="menu-text">
|
|
6
|
-
<h1 style="margin: 0; font-size: inherit;"><a href='/'><%= t('inline_forms.devise.title_for_devise') %> <%= InlineForms::VERSION %></a></h1>
|
|
6
|
+
<h1 style="margin: 0; font-size: inherit;"><a href='/'><%= t('inline_forms.devise.title_for_devise', default: inline_forms_application_title) %> <%= InlineForms::VERSION %></a></h1>
|
|
7
7
|
</li>
|
|
8
8
|
</ul>
|
|
9
9
|
</div>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<div class="top-bar-left">
|
|
4
4
|
<ul class="menu">
|
|
5
5
|
<li class="menu-text">
|
|
6
|
-
<h1 style="margin: 0; font-size: inherit;"><a href='/'><%= t('inline_forms.devise.title_for_devise') %> <%= InlineForms::VERSION %></a></h1>
|
|
6
|
+
<h1 style="margin: 0; font-size: inherit;"><a href='/'><%= t('inline_forms.devise.title_for_devise', default: inline_forms_application_title) %> <%= InlineForms::VERSION %></a></h1>
|
|
7
7
|
</li>
|
|
8
8
|
</ul>
|
|
9
9
|
</div>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<div class="row" id='inline_forms_devise_header_row'>
|
|
6
6
|
<div class="small-11 centered column">
|
|
7
|
-
<h1><%= t('inline_forms.devise.welcome') %></h1>
|
|
7
|
+
<h1><%= t('inline_forms.devise.welcome', default: t('inline_forms.devise.welcome_to', name: inline_forms_application_title)) %></h1>
|
|
8
8
|
</div>
|
|
9
9
|
</div>
|
|
10
10
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<%# Unused by the gem's own devise views; kept for host apps that render it. %>
|
|
2
2
|
<%# Same title source as layouts/inline_forms; Devise 5 dropped %>
|
|
3
3
|
<%# devise_error_messages!, so errors use Devise's own error_messages partial. %>
|
|
4
|
-
<div id="large_title"><%=
|
|
4
|
+
<div id="large_title"><%= inline_forms_application_title %></div>
|
|
5
5
|
<div id="flash_message">
|
|
6
6
|
<% if resource.errors.any? %>
|
|
7
7
|
<%= render "devise/shared/error_messages", resource: resource %>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<%= form_tag request.path, method: :get do %>
|
|
2
2
|
<div class="row collapse">
|
|
3
3
|
<div class="large-1 small-1 columns">
|
|
4
|
-
<%= link_to
|
|
4
|
+
<%= link_to tag.i(class: "fi-x"), request.path, title: t("inline_forms.search.reset"), class: "button expanded inline_forms_model_top_bar_buttons" %>
|
|
5
5
|
</div>
|
|
6
6
|
<div class="large-6 small-6 columns">
|
|
7
|
-
<%= text_field_tag :search, params[:search], placeholder: "
|
|
7
|
+
<%= text_field_tag :search, params[:search], placeholder: t("inline_forms.search.placeholder"), id: "input_search" %>
|
|
8
8
|
</div>
|
|
9
9
|
<div class="large-3 small-3 columns">
|
|
10
|
-
<%= submit_tag "
|
|
10
|
+
<%= submit_tag t("inline_forms.search.submit"), class: "button expanded inline_forms_model_top_bar_buttons" %>
|
|
11
11
|
</div>
|
|
12
12
|
<div class="large-2 small-2 columns">
|
|
13
13
|
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
<%= t("inline_forms.files.event.#{entry[:file_event]}") %>
|
|
24
24
|
</div>
|
|
25
25
|
<div class="small-2 column">
|
|
26
|
-
<%=
|
|
26
|
+
<%= inline_forms_time(entry[:at]) %>
|
|
27
27
|
</div>
|
|
28
28
|
<div class="small-2 column">
|
|
29
29
|
<%= inline_forms_file_user_name(entry[:by]) %>
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
<%= t("inline_forms.view.version_events.#{version.event}", default: version.event) -%><% if entry[:kind] == :rich_text %> <em>(<%= t("inline_forms.view.versions_rich_text") %>)</em><% end %>
|
|
96
96
|
</div>
|
|
97
97
|
<div class="small-2 column">
|
|
98
|
-
<%=
|
|
98
|
+
<%= inline_forms_time(version.created_at) -%>
|
|
99
99
|
</div>
|
|
100
100
|
<div class="small-2 column">
|
|
101
101
|
<%= version_modified_by version.whodunnit -%>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<% elsif @last_sweep.error.present? %>
|
|
15
15
|
<%= t("inline_forms.files.global.sweep_failed", error: @last_sweep.error) %>
|
|
16
16
|
<% else %>
|
|
17
|
-
<%= t("inline_forms.files.global.sweep_last", at:
|
|
17
|
+
<%= t("inline_forms.files.global.sweep_last", at: inline_forms_time_text(@last_sweep.ran_at), count: @last_sweep.purged_count) %>
|
|
18
18
|
<% end %>
|
|
19
19
|
</p>
|
|
20
20
|
|
|
@@ -78,10 +78,10 @@
|
|
|
78
78
|
<span class="inline_forms-file-name"><%= inline_forms_file_entry_name(entry) %></span>
|
|
79
79
|
<span class="inline_forms-file-meta"><%= inline_forms_file_size(entry.byte_size) %> · <%= t("inline_forms.files.reason.#{entry.reason}") %></span>
|
|
80
80
|
</td>
|
|
81
|
-
<td><%= t("inline_forms.files.by_on", user: inline_forms_file_user_name(entry.trashed_by_id), at:
|
|
81
|
+
<td><%= t("inline_forms.files.by_on", user: inline_forms_file_user_name(entry.trashed_by_id), at: inline_forms_time_text(entry.trashed_at)) %></td>
|
|
82
82
|
<td>
|
|
83
|
-
<% if entry.state == :restored %><%= t("inline_forms.files.state_restored", user: inline_forms_file_user_name(entry.restored_by_id), at:
|
|
84
|
-
<% elsif entry.state == :purged %><%= t("inline_forms.files.state_purged", user: inline_forms_file_user_name(entry.purged_by_id), at:
|
|
83
|
+
<% if entry.state == :restored %><%= t("inline_forms.files.state_restored", user: inline_forms_file_user_name(entry.restored_by_id), at: inline_forms_time_text(entry.restored_at)) %>
|
|
84
|
+
<% elsif entry.state == :purged %><%= t("inline_forms.files.state_purged", user: inline_forms_file_user_name(entry.purged_by_id), at: inline_forms_time_text(entry.purged_at)) %>
|
|
85
85
|
<% elsif entry.state == :expired %><%= t("inline_forms.files.state_expired") %>
|
|
86
86
|
<% else %>
|
|
87
87
|
<% if entry.purge_after %><%= t("inline_forms.files.expires_in", count: ((entry.purge_after - Time.current) / 1.day).ceil, date: l(entry.purge_after.to_date)) %><% else %><%= t("inline_forms.files.global.states.trashed") %><% end %>
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
<span class="inline_forms-file-meta">
|
|
42
42
|
<%= inline_forms_file_size(entry.byte_size) %> ·
|
|
43
43
|
<%= t("inline_forms.files.reason.#{entry.reason}") %>
|
|
44
|
-
<%= t("inline_forms.files.by_on", user: inline_forms_file_user_name(entry.trashed_by_id), at:
|
|
44
|
+
<%= t("inline_forms.files.by_on", user: inline_forms_file_user_name(entry.trashed_by_id), at: inline_forms_time_text(entry.trashed_at)) %>
|
|
45
45
|
</span>
|
|
46
46
|
<span class="inline_forms-file-meta">
|
|
47
47
|
<% if entry.state == :restored %>
|
|
48
|
-
<%= t("inline_forms.files.state_restored", user: inline_forms_file_user_name(entry.restored_by_id), at:
|
|
48
|
+
<%= t("inline_forms.files.state_restored", user: inline_forms_file_user_name(entry.restored_by_id), at: inline_forms_time_text(entry.restored_at)) %>
|
|
49
49
|
<% elsif entry.state == :purged %>
|
|
50
|
-
<%= t("inline_forms.files.state_purged", user: inline_forms_file_user_name(entry.purged_by_id), at:
|
|
50
|
+
<%= t("inline_forms.files.state_purged", user: inline_forms_file_user_name(entry.purged_by_id), at: inline_forms_time_text(entry.purged_at)) %>
|
|
51
51
|
<% elsif entry.state == :expired %>
|
|
52
52
|
<%= t("inline_forms.files.state_expired") %>
|
|
53
53
|
<% else %>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>
|
|
7
|
-
<%= t('inline_forms.general.application_title') %> v<%= InlineForms::VERSION %>
|
|
7
|
+
<%= t('inline_forms.general.application_title', default: inline_forms_application_title) %> v<%= InlineForms::VERSION %>
|
|
8
8
|
</title>
|
|
9
9
|
<%= stylesheet_link_tag "application" %>
|
|
10
10
|
<%= stylesheet_link_tag "inline_forms_fonts" %>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="utf-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>
|
|
7
|
-
<%= t('inline_forms.general.application_title') %> v<%= InlineForms::VERSION %>
|
|
7
|
+
<%= t('inline_forms.general.application_title', default: inline_forms_application_title) %> v<%= InlineForms::VERSION %>
|
|
8
8
|
</title>
|
|
9
9
|
<%= stylesheet_link_tag "inline_forms_fonts" %>
|
|
10
10
|
<%= stylesheet_link_tag "inline_forms/devise" %>
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
|
-
|
|
2
|
+
<%# class="no-js": Foundation's CSS hides the top-bar submenus while it is set %>
|
|
3
|
+
<%# and its JS removes it on the first init, so the submenus do not show as %>
|
|
4
|
+
<%# plain lists before then. Turbo Drive never puts it back; after a visit %>
|
|
5
|
+
<%# inline_forms.js initialises the new body on turbo:load, and the %>
|
|
6
|
+
<%# `[data-dropdown-menu]` rule in inline_forms.scss covers any gap. %>
|
|
7
|
+
<html lang="<%= I18n.locale %>" class="no-js">
|
|
3
8
|
<head>
|
|
4
9
|
<meta charset="utf-8" />
|
|
5
10
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
11
|
<%# A missing translation must not reach <title>: a bare t() returns an %>
|
|
7
12
|
<%# html_safe <span class="translation_missing"> that shows up as markup. %>
|
|
8
|
-
<%#
|
|
9
|
-
|
|
10
|
-
<title><%= t('application_name', default: application_name) %> v<%= InlineForms::VERSION %></title>
|
|
13
|
+
<%# inline_forms_application_title always has a plain-text fallback. %>
|
|
14
|
+
<title><%= inline_forms_application_title %> v<%= InlineForms::VERSION %></title>
|
|
11
15
|
<%= stylesheet_link_tag "application" %>
|
|
12
16
|
<%= stylesheet_link_tag "inline_forms_fonts" %>
|
|
13
17
|
<%= stylesheet_link_tag "inline_forms/inline_forms" %>
|
|
@@ -17,6 +21,16 @@
|
|
|
17
21
|
<%# Publishes the CSP nonce (nothing without a nonce generator) for the %>
|
|
18
22
|
<%# scripts Turbo inserts. %>
|
|
19
23
|
<%= csp_meta_tag %>
|
|
24
|
+
<%# In <head>, so Turbo Drive runs them once: it keeps head scripts across %>
|
|
25
|
+
<%# visits (a body script runs again on every visit, with a fresh jQuery), %>
|
|
26
|
+
<%# and appends them, in order, on a visit from a page that lacks them. %>
|
|
27
|
+
<%# Tippy.js (v6) needs Popper.js as a global before its UMD factory runs %>
|
|
28
|
+
<%# (`tippy-bundle.umd.min` only bundles default themes, not Popper itself). %>
|
|
29
|
+
<%# inline_forms.js initialises Foundation on the ready event and on %>
|
|
30
|
+
<%# turbo:load, once per <body>. %>
|
|
31
|
+
<%= javascript_include_tag 'popper.min' %>
|
|
32
|
+
<%= javascript_include_tag 'tippy-bundle.umd.min' %>
|
|
33
|
+
<%= javascript_include_tag 'inline_forms/inline_forms' %>
|
|
20
34
|
</head>
|
|
21
35
|
|
|
22
36
|
<body class="<%= inline_forms_body_theme_class %>">
|
|
@@ -35,11 +49,6 @@
|
|
|
35
49
|
<div id="outer_container">
|
|
36
50
|
<%= yield %>
|
|
37
51
|
</div>
|
|
38
|
-
<%# Tippy.js (v6) needs Popper.js as a global before its UMD factory runs %>
|
|
39
|
-
<%# (`tippy-bundle.umd.min` only bundles default themes, not Popper itself). %>
|
|
40
|
-
<%= javascript_include_tag 'popper.min' %>
|
|
41
|
-
<%= javascript_include_tag 'tippy-bundle.umd.min' %>
|
|
42
|
-
<%= javascript_include_tag 'inline_forms/inline_forms' %>
|
|
43
52
|
<%# Turbo (Hotwire) is loaded as an ES module so it does not collide with %>
|
|
44
53
|
<%# the classic-script Sprockets bundle above. Drive stays at the default %>
|
|
45
54
|
<%# (enabled); inline interactions use `<turbo-frame>` + HTML responses. %>
|
|
@@ -19,14 +19,21 @@ module InlineForms
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
@inline_forms_searchable = true
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"#{connection.quote_table_name(table)}.#{connection.quote_column_name(c)} LIKE :q"
|
|
25
|
-
}.join(" OR ")
|
|
22
|
+
@inline_forms_search_columns = cols
|
|
23
|
+
model = self
|
|
26
24
|
scope :inline_forms_search, ->(q) {
|
|
27
|
-
where(
|
|
25
|
+
where(model.inline_forms_search_clause, q: "%#{sanitize_sql_like(q.to_s)}%")
|
|
28
26
|
}
|
|
29
27
|
end
|
|
28
|
+
|
|
29
|
+
# Built on the first search, not in inline_forms_search_on: quoting
|
|
30
|
+
# needs a database connection, and the class body runs whenever the
|
|
31
|
+
# model loads (eager loading, assets:precompile without a database).
|
|
32
|
+
def inline_forms_search_clause
|
|
33
|
+
@inline_forms_search_clause ||= @inline_forms_search_columns.map { |c|
|
|
34
|
+
"#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(c)} LIKE :q"
|
|
35
|
+
}.join(" OR ")
|
|
36
|
+
end
|
|
30
37
|
end
|
|
31
38
|
end
|
|
32
39
|
end
|
data/lib/inline_forms/version.rb
CHANGED
data/lib/inline_forms.rb
CHANGED
|
@@ -187,6 +187,28 @@ module InlineForms
|
|
|
187
187
|
# programmatically (generator / GUI); the user edits it to real values after.
|
|
188
188
|
PLACEHOLDER_VALUES = { 1 => "one", 2 => "two" }.freeze
|
|
189
189
|
|
|
190
|
+
# Version and file timestamps: time.formats.inline_forms in the gem's en
|
|
191
|
+
# and nl locales, and the default where a locale lacks it.
|
|
192
|
+
TIME_FORMAT = "%d %b %Y %H:%M"
|
|
193
|
+
|
|
194
|
+
# The application's name for the gem's titles and the Devise pages: the
|
|
195
|
+
# host's `application_name` translation, else its
|
|
196
|
+
# ApplicationHelper#application_name (the installer writes both, and the
|
|
197
|
+
# gem's header partial uses the helper), else its Rails module name. The
|
|
198
|
+
# gem's title keys (inline_forms.general.application_title,
|
|
199
|
+
# inline_forms.devise.title_for_devise and .welcome) resolve to this in en
|
|
200
|
+
# and nl unless the host translates them (lib/locales/inline_forms_titles.rb).
|
|
201
|
+
def self.application_title
|
|
202
|
+
I18n.t("application_name", default: application_name_from_helper || Rails.application.class.module_parent_name)
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def self.application_name_from_helper
|
|
206
|
+
return unless defined?(::ApplicationController)
|
|
207
|
+
|
|
208
|
+
helpers = ::ApplicationController.helpers
|
|
209
|
+
helpers.application_name if helpers.respond_to?(:application_name)
|
|
210
|
+
end
|
|
211
|
+
|
|
190
212
|
def self.plain_text_form_element?(form_element)
|
|
191
213
|
PLAIN_TEXT_FORM_ELEMENTS.include?(form_element.to_sym)
|
|
192
214
|
rescue NoMethodError
|
|
@@ -408,7 +430,8 @@ module InlineForms
|
|
|
408
430
|
end
|
|
409
431
|
end
|
|
410
432
|
|
|
411
|
-
|
|
433
|
+
# .rb too: inline_forms_titles.rb holds the title keys as lambdas.
|
|
434
|
+
I18n.load_path << Dir[File.join(File.expand_path(File.dirname(__FILE__) + "/locales"), "*.{yml,rb}")]
|
|
412
435
|
I18n.load_path.flatten!
|
|
413
436
|
end
|
|
414
437
|
end
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
en:
|
|
2
2
|
inline_forms:
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
# The generic list search (inline_forms/_generic_search), shown for
|
|
4
|
+
# models that declare inline_forms_search_on.
|
|
5
|
+
search:
|
|
6
|
+
placeholder: "search..."
|
|
7
|
+
submit: search
|
|
8
|
+
reset: reset
|
|
9
|
+
# general.application_title, devise.title_for_devise and devise.welcome
|
|
10
|
+
# are not defined here: without a host override the views use the
|
|
11
|
+
# host's application_name translation (InlineFormsHelper#inline_forms_application_title).
|
|
5
12
|
devise:
|
|
6
|
-
|
|
7
|
-
welcome: Welcome for Devise
|
|
13
|
+
welcome_to: "Welcome to %{name}!"
|
|
8
14
|
passwords:
|
|
9
15
|
forgot_your_password: Forgot Your Password?
|
|
10
16
|
change_your_password: Change your password, if you want!
|
|
@@ -152,3 +158,8 @@ en:
|
|
|
152
158
|
messages:
|
|
153
159
|
inline_forms_file_too_large: "is too large (maximum %{count} MB)"
|
|
154
160
|
inline_forms_file_missing: "no file chosen"
|
|
161
|
+
# Version and file timestamps (InlineFormsHelper#inline_forms_time and the
|
|
162
|
+
# file trash): rails-i18n's :short has no year.
|
|
163
|
+
time:
|
|
164
|
+
formats:
|
|
165
|
+
inline_forms: "%d %b %Y %H:%M"
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
nl:
|
|
2
2
|
inline_forms:
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
# The generic list search (inline_forms/_generic_search), shown for
|
|
4
|
+
# models that declare inline_forms_search_on.
|
|
5
|
+
search:
|
|
6
|
+
placeholder: "zoeken..."
|
|
7
|
+
submit: zoek
|
|
8
|
+
reset: wissen
|
|
9
|
+
# general.application_title, devise.title_for_devise and devise.welcome
|
|
10
|
+
# are not defined here: without a host override the views use the
|
|
11
|
+
# host's application_name translation (InlineFormsHelper#inline_forms_application_title).
|
|
5
12
|
devise:
|
|
6
|
-
|
|
7
|
-
welcome: Welcome for Devise
|
|
13
|
+
welcome_to: "Welkom bij %{name}!"
|
|
8
14
|
passwords:
|
|
9
15
|
forgot_your_password: Wachtwoord Vergeten?
|
|
10
16
|
change_your_password: Verander wachtwoord, als u wilt!
|
|
@@ -152,3 +158,8 @@ nl:
|
|
|
152
158
|
messages:
|
|
153
159
|
inline_forms_file_too_large: "is te groot (maximaal %{count} MB)"
|
|
154
160
|
inline_forms_file_missing: "geen bestand gekozen"
|
|
161
|
+
# Version and file timestamps (InlineFormsHelper#inline_forms_time and the
|
|
162
|
+
# file trash): rails-i18n's :short has no year.
|
|
163
|
+
time:
|
|
164
|
+
formats:
|
|
165
|
+
inline_forms: "%d %b %Y %H:%M"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# The gem's title keys, resolved to the application's name
|
|
4
|
+
# (InlineForms.application_title) instead of a placeholder. Lambdas, so a
|
|
5
|
+
# host view that calls a key bare gets the real name too. A host translation
|
|
6
|
+
# of the same key still wins: the host's locale files load after the gem's.
|
|
7
|
+
title = ->(_key, **_options) { InlineForms.application_title }
|
|
8
|
+
welcome = ->(_key, **_options) { I18n.t("inline_forms.devise.welcome_to", name: InlineForms.application_title) }
|
|
9
|
+
keys = {
|
|
10
|
+
inline_forms: {
|
|
11
|
+
general: { application_title: title },
|
|
12
|
+
devise: { title_for_devise: title, welcome: welcome }
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
{ en: keys, nl: keys }
|
|
@@ -19,6 +19,8 @@ class LocaleTest < InlineFormsIntegrationTestCase
|
|
|
19
19
|
inline_forms.view.version_events.update inline_forms.view.version_events.destroy
|
|
20
20
|
inline_forms.devise.login common.more common.logout inline_forms.view.create_failed
|
|
21
21
|
inline_forms.files.preview inline_forms.files.download_pdf
|
|
22
|
+
inline_forms.search.placeholder inline_forms.search.submit inline_forms.search.reset
|
|
23
|
+
inline_forms.devise.welcome_to time.formats.inline_forms
|
|
22
24
|
].freeze
|
|
23
25
|
|
|
24
26
|
setup do
|
|
@@ -107,7 +109,90 @@ class LocaleTest < InlineFormsIntegrationTestCase
|
|
|
107
109
|
end
|
|
108
110
|
refute_includes body, "<strong>Event</strong>"
|
|
109
111
|
version = @machine.versions.last
|
|
110
|
-
assert_includes body, ERB::Util.h(I18n.l(version.created_at, format: :
|
|
112
|
+
assert_includes body, ERB::Util.h(I18n.l(version.created_at, format: :inline_forms, locale: :nl))
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# rails-i18n's :short ("%d %b %H:%M") has no year: edits years apart read
|
|
116
|
+
# the same next to Restore.
|
|
117
|
+
test "version timestamps show the year, and the exact time on hover" do
|
|
118
|
+
version = @machine.versions.last
|
|
119
|
+
version.update_columns(created_at: Time.zone.local(2019, 3, 5, 14, 7))
|
|
120
|
+
row = "machine_#{@machine.id}"
|
|
121
|
+
strictly(:nl) do
|
|
122
|
+
get list_versions_machine_path(@machine, update: row), headers: frame_headers(row)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
assert_response :success
|
|
126
|
+
iso = version.reload.created_at.iso8601
|
|
127
|
+
assert_includes response.body, %(<time datetime="#{iso}" title="#{iso}">05 mrt 2019 14:07</time>)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
test "the generic search box is translated" do
|
|
131
|
+
I18n.backend.store_translations(:en, widgets: "widgets")
|
|
132
|
+
I18n.backend.store_translations(:nl, widgets: "widgets")
|
|
133
|
+
{ en: [ "search...", "search", "reset" ], nl: [ "zoeken...", "zoek", "wissen" ] }.each do |locale, (placeholder, submit, reset)|
|
|
134
|
+
strictly(locale) { get widgets_path }
|
|
135
|
+
|
|
136
|
+
assert_response :success
|
|
137
|
+
assert_includes response.body, %(placeholder="#{placeholder}")
|
|
138
|
+
assert_includes response.body, %(value="#{submit}")
|
|
139
|
+
assert_includes response.body, %(title="#{reset}")
|
|
140
|
+
refute_includes response.body, "zoek op naam" if locale == :en
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# The gem shipped "Application Title" / "Title for Devise" / "Welcome for
|
|
145
|
+
# Devise" in en and nl; any locale the host did not override showed them.
|
|
146
|
+
# The keys now resolve to the application's name, also when a host view
|
|
147
|
+
# calls them bare.
|
|
148
|
+
test "the gem's title keys resolve to the application's name" do
|
|
149
|
+
get widgets_path
|
|
150
|
+
I18n.backend.store_translations(:nl, application_name: "Werkplaats")
|
|
151
|
+
strictly(:nl) do
|
|
152
|
+
assert_equal "Werkplaats", I18n.t("inline_forms.general.application_title")
|
|
153
|
+
assert_equal "Werkplaats", I18n.t("inline_forms.devise.title_for_devise")
|
|
154
|
+
assert_equal "Welkom bij Werkplaats!", I18n.t("inline_forms.devise.welcome")
|
|
155
|
+
devise = controller.render_to_string(template: "stats/show", layout: "devise")
|
|
156
|
+
assert_includes devise, "Werkplaats v#{InlineForms::VERSION}"
|
|
157
|
+
top_bar = controller.render_to_string(partial: "devise/sessions/top-bar")
|
|
158
|
+
assert_includes top_bar, "Werkplaats #{InlineForms::VERSION}"
|
|
159
|
+
end
|
|
160
|
+
I18n.with_locale(:en) do
|
|
161
|
+
# No en application_name translation here: the host's
|
|
162
|
+
# ApplicationHelper#application_name.
|
|
163
|
+
assert_equal "Dummy", I18n.t("inline_forms.general.application_title")
|
|
164
|
+
assert_equal "Welcome to Dummy!", I18n.t("inline_forms.devise.welcome")
|
|
165
|
+
assert_includes controller.render_to_string(template: "stats/show", layout: "application"), "Dummy v#{InlineForms::VERSION}"
|
|
166
|
+
end
|
|
167
|
+
ensure
|
|
168
|
+
I18n.backend.reload!
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
test "a host translation of a title key wins" do
|
|
172
|
+
I18n.t("inline_forms.general.application_title") # loads the gem's files first, as a host app does
|
|
173
|
+
I18n.backend.store_translations(:nl, inline_forms: { general: { application_title: "Banko" } })
|
|
174
|
+
|
|
175
|
+
assert_equal "Banko", I18n.t("inline_forms.general.application_title", locale: :nl)
|
|
176
|
+
ensure
|
|
177
|
+
I18n.backend.reload!
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# time.formats.inline_forms is defined in en and nl only; a bare
|
|
181
|
+
# l(format: :inline_forms) raises in any other locale without fallbacks.
|
|
182
|
+
test "version and trash timestamps render in a locale without the gem's format" do
|
|
183
|
+
original = I18n.available_locales
|
|
184
|
+
I18n.available_locales = original + [ :de ]
|
|
185
|
+
months = %w[Jan Feb Mär Apr Mai Jun Jul Aug Sep Okt Nov Dez]
|
|
186
|
+
I18n.backend.store_translations(:de, date: { abbr_month_names: [ nil, *months ] })
|
|
187
|
+
time = Time.zone.local(2019, 3, 5, 14, 7)
|
|
188
|
+
|
|
189
|
+
I18n.with_locale(:de) do
|
|
190
|
+
assert_raises(I18n::MissingTranslationData) { I18n.l(time, format: :inline_forms, raise: true) }
|
|
191
|
+
assert_equal "05 Mär 2019 14:07", ApplicationController.helpers.send(:inline_forms_time_text, time)
|
|
192
|
+
end
|
|
193
|
+
ensure
|
|
194
|
+
I18n.available_locales = original
|
|
195
|
+
I18n.backend.reload!
|
|
111
196
|
end
|
|
112
197
|
|
|
113
198
|
test "the versions list in en keeps its English labels" do
|
|
@@ -62,4 +62,24 @@ class ModelTopBarTest < InlineFormsIntegrationTestCase
|
|
|
62
62
|
refute_includes response.body, "new_button"
|
|
63
63
|
refute_includes response.body, %(id="input_search")
|
|
64
64
|
end
|
|
65
|
+
|
|
66
|
+
# The class body runs whenever the model loads (eager loading,
|
|
67
|
+
# assets:precompile with no database); quoting there needed a connection.
|
|
68
|
+
test "inline_forms_search_on needs no database connection until the search runs" do
|
|
69
|
+
model = Class.new(ApplicationRecord) do
|
|
70
|
+
self.table_name = "widgets"
|
|
71
|
+
def self.name = "OfflineWidget"
|
|
72
|
+
end
|
|
73
|
+
no_db = ->(*) { raise "database touched at declaration" }
|
|
74
|
+
%i[connection lease_connection with_connection].each { |m| model.define_singleton_method(m, &no_db) }
|
|
75
|
+
|
|
76
|
+
model.inline_forms_search_on :name
|
|
77
|
+
|
|
78
|
+
assert model.inline_forms_searchable?
|
|
79
|
+
%i[connection lease_connection with_connection].each { |m| model.singleton_class.remove_method(m) }
|
|
80
|
+
Widget.create!(name: "Gamma")
|
|
81
|
+
assert_equal [ "Gamma" ], model.inline_forms_search("amm").pluck(:name)
|
|
82
|
+
# Built once, on the first search.
|
|
83
|
+
assert_same model.inline_forms_search_clause, model.inline_forms_search_clause
|
|
84
|
+
end
|
|
65
85
|
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../integration_test_helper"
|
|
4
|
+
|
|
5
|
+
# Top-bar submenus after a Turbo Drive visit. The bundle sat in <body>, so
|
|
6
|
+
# Turbo re-ran it on every visit (a fresh jQuery, its own Foundation plugin
|
|
7
|
+
# data), and until that finished the new body's submenus showed as plain
|
|
8
|
+
# lists; StProject, Scouting and Papiamentu each carried the same layout copy
|
|
9
|
+
# to hide them (html.no-js, a turbo:load re-init, a CSS rule). Now the gem
|
|
10
|
+
# loads the bundle in <head>, which Turbo runs once.
|
|
11
|
+
class TurboMenuTest < InlineFormsIntegrationTestCase
|
|
12
|
+
ROOT = File.expand_path("../..", __dir__)
|
|
13
|
+
|
|
14
|
+
def boot_block
|
|
15
|
+
js = File.read(File.join(ROOT, "app/assets/javascripts/inline_forms/inline_forms.js"))
|
|
16
|
+
js[/^if \(!window\.inlineFormsBooted\) \{.*?\n\}\n/m]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
test "the layout starts as no-js and loads the bundle in head" do
|
|
20
|
+
get widgets_path
|
|
21
|
+
|
|
22
|
+
assert_response :success
|
|
23
|
+
assert_match %r{<html lang="en" class="no-js">}, response.body
|
|
24
|
+
head = response.body[%r{<head>.*</head>}m]
|
|
25
|
+
scripts = %w[popper.min tippy-bundle.umd.min inline_forms/inline_forms].map { |name|
|
|
26
|
+
head.index(%r{<script src="[^"]*/#{Regexp.escape(name)}[^"]*\.js"></script>})
|
|
27
|
+
}
|
|
28
|
+
assert scripts.all?, "popper, tippy and inline_forms.js are in <head>"
|
|
29
|
+
assert_equal scripts.sort, scripts, "in that order"
|
|
30
|
+
refute_match %r{<body.*inline_forms/inline_forms[^"]*\.js}m, response.body
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
test "inline_forms.js wires every document listener once, and boots once per body" do
|
|
34
|
+
boot = boot_block
|
|
35
|
+
|
|
36
|
+
assert boot, "the listeners sit behind the once-guard"
|
|
37
|
+
rest = File.read(File.join(ROOT, "app/assets/javascripts/inline_forms/inline_forms.js")).sub(boot, "")
|
|
38
|
+
refute_match(/addEventListener|\$\(document\)|\.ready\(/, rest.gsub(%r{^\s*//.*$}, "").gsub(/el\.addEventListener\("input"/, ""),
|
|
39
|
+
"no document listener outside the guard: a host layout with the bundle in <body> re-runs it on every visit")
|
|
40
|
+
%w[turbo:load turbo:frame-load mouseover].each do |event|
|
|
41
|
+
assert_includes boot, "document.addEventListener(\"#{event}\""
|
|
42
|
+
end
|
|
43
|
+
assert_includes boot, "document.body === inlineFormsBootedBody"
|
|
44
|
+
assert_includes boot, "window.jQuery(document).foundation();"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
test "uninitialised dropdown submenus stay hidden, drilldown menus are left alone" do
|
|
48
|
+
scss = File.read(File.join(ROOT, "app/assets/stylesheets/inline_forms/inline_forms.scss"))
|
|
49
|
+
|
|
50
|
+
assert_match(/^\.dropdown\.menu\[data-dropdown-menu\] > li > ul\.menu:not\(\.is-dropdown-submenu\) \{\n display: none;\n\}/, scss)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Compiled CSS is checked in the example app (example_app_stylesheet_test).
|
|
54
|
+
test "tippy.css is inlined, not left as a plain CSS @import the browser 404s on" do
|
|
55
|
+
scss = File.read(File.join(ROOT, "app/assets/stylesheets/inline_forms/foundation_and_overrides.scss"))
|
|
56
|
+
|
|
57
|
+
refute_match(/^\s*@import\s+['"][^'"]*tippy\.css['"]/, scss)
|
|
58
|
+
assert_includes scss, "@include meta.load-css('../../../vendor/assets/stylesheets/tippy');"
|
|
59
|
+
end
|
|
60
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inline_forms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.1.
|
|
4
|
+
version: 8.1.67
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ace Suares
|
|
@@ -273,6 +273,7 @@ files:
|
|
|
273
273
|
- lib/inline_forms/version.rb
|
|
274
274
|
- lib/locales/inline_forms.en.yml
|
|
275
275
|
- lib/locales/inline_forms.nl.yml
|
|
276
|
+
- lib/locales/inline_forms_titles.rb
|
|
276
277
|
- lib/otherstuff/add_roles.sql
|
|
277
278
|
- lib/otherstuff/mkrole
|
|
278
279
|
- lib/otherstuff/roles_users.sql
|
|
@@ -334,6 +335,7 @@ files:
|
|
|
334
335
|
- test/integration/schema_batch_pipeline_test.rb
|
|
335
336
|
- test/integration/schema_edit_test.rb
|
|
336
337
|
- test/integration/schema_preview_test.rb
|
|
338
|
+
- test/integration/turbo_menu_test.rb
|
|
337
339
|
- test/integration_test_helper.rb
|
|
338
340
|
- test/plain_text_configuration_test.rb
|
|
339
341
|
- test/schema_apply_test.rb
|
|
@@ -424,6 +426,7 @@ test_files:
|
|
|
424
426
|
- test/integration/schema_batch_pipeline_test.rb
|
|
425
427
|
- test/integration/schema_edit_test.rb
|
|
426
428
|
- test/integration/schema_preview_test.rb
|
|
429
|
+
- test/integration/turbo_menu_test.rb
|
|
427
430
|
- test/integration_test_helper.rb
|
|
428
431
|
- test/plain_text_configuration_test.rb
|
|
429
432
|
- test/schema_apply_test.rb
|