moduler 0.5.0 → 0.6.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/assets/builds/moduler/tailwind.css +50 -1
- data/app/assets/javascripts/moduler/controllers/attachments_controller.js +30 -0
- data/app/assets/javascripts/moduler/controllers/dependent_select_controller.js +19 -0
- data/app/assets/javascripts/moduler/controllers/select_all_controller.js +15 -0
- data/app/components/moduler/filter_component.html.erb +9 -1
- data/app/components/moduler/filter_component.rb +12 -0
- data/app/components/moduler/form/attachments_component.html.erb +32 -0
- data/app/components/moduler/form/attachments_component.rb +28 -0
- data/app/components/moduler/form/checkboxes_component.html.erb +19 -0
- data/app/components/moduler/form/checkboxes_component.rb +13 -0
- data/app/components/moduler/form/select_component.html.erb +1 -1
- data/app/components/moduler/form/select_component.rb +5 -0
- data/app/components/moduler/form/wysiwyg_component.rb +1 -1
- data/app/controllers/concerns/moduler/authentication.rb +1 -1
- data/app/controllers/concerns/moduler/restrict_administrator_access.rb +32 -0
- data/app/controllers/moduler/administration/application_controller.rb +1 -0
- data/app/controllers/moduler/administration/articles_controller.rb +1 -1
- data/app/controllers/moduler/administration/emails/deliveries_controller.rb +42 -0
- data/app/controllers/moduler/administration/emails_controller.rb +68 -0
- data/app/controllers/moduler/administration/memberships_controller.rb +62 -0
- data/app/controllers/moduler/administration/organizations_controller.rb +51 -0
- data/app/controllers/moduler/administration/preferences_controller.rb +57 -0
- data/app/controllers/moduler/administration/roles_controller.rb +56 -0
- data/app/controllers/moduler/administration/users_controller.rb +2 -2
- data/app/controllers/moduler/application_controller.rb +2 -1
- data/app/controllers/moduler/articles_controller.rb +3 -2
- data/app/controllers/moduler/profile/sent_emails_controller.rb +18 -0
- data/app/controllers/moduler/profile/sessions/revocation_controller.rb +1 -0
- data/app/controllers/moduler/profile/sessions_controller.rb +1 -0
- data/app/controllers/moduler/profile_controller.rb +4 -1
- data/app/controllers/moduler/sessions_controller.rb +1 -0
- data/app/controllers/moduler/users_controller.rb +2 -0
- data/app/filters/email_delivery_filter.rb +35 -0
- data/app/filters/organization_query_filter.rb +23 -0
- data/app/jobs/moduler/email_delivery_job.rb +14 -0
- data/app/lib/moduler/form_builder.rb +17 -3
- data/app/mailers/moduler/application_mailer.rb +27 -1
- data/app/mailers/moduler/email_mailer.rb +14 -0
- data/app/models/moduler/article.rb +2 -0
- data/app/models/moduler/email.rb +59 -0
- data/app/models/moduler/membership.rb +25 -0
- data/app/models/moduler/organization.rb +13 -0
- data/app/models/moduler/preference.rb +44 -0
- data/app/models/moduler/role.rb +26 -0
- data/app/models/moduler/sent_email.rb +13 -0
- data/app/models/moduler/user.rb +13 -1
- data/app/models/moduler/user_email.rb +15 -0
- data/app/policies/moduler/administration/email_policy.rb +26 -0
- data/app/policies/moduler/administration/membership_policy.rb +29 -0
- data/app/policies/moduler/administration/organization_policy.rb +25 -0
- data/app/policies/moduler/administration/preference_policy.rb +29 -0
- data/app/policies/moduler/administration/role_policy.rb +25 -0
- data/app/views/layouts/moduler/mailer.html.erb +30 -0
- data/app/views/layouts/moduler/mailer.text.erb +1 -0
- data/app/views/moduler/administration/articles/_article.html.erb +2 -0
- data/app/views/moduler/administration/articles/_form.html.erb +1 -0
- data/app/views/moduler/administration/emails/_email.html.erb +33 -0
- data/app/views/moduler/administration/emails/_form.html.erb +23 -0
- data/app/views/moduler/administration/emails/deliveries/new.html.erb +58 -0
- data/app/views/moduler/administration/emails/edit.html.erb +1 -0
- data/app/views/moduler/administration/emails/index.html.erb +13 -0
- data/app/views/moduler/administration/emails/new.html.erb +1 -0
- data/app/views/moduler/administration/memberships/_form.html.erb +38 -0
- data/app/views/moduler/administration/memberships/_membership.html.erb +23 -0
- data/app/views/moduler/administration/memberships/edit.html.erb +1 -0
- data/app/views/moduler/administration/memberships/index.html.erb +14 -0
- data/app/views/moduler/administration/memberships/new.html.erb +1 -0
- data/app/views/moduler/administration/organizations/_form.html.erb +13 -0
- data/app/views/moduler/administration/organizations/_organization.html.erb +23 -0
- data/app/views/moduler/administration/organizations/edit.html.erb +1 -0
- data/app/views/moduler/administration/organizations/index.html.erb +13 -0
- data/app/views/moduler/administration/organizations/new.html.erb +1 -0
- data/app/views/moduler/administration/preferences/_form.html.erb +16 -0
- data/app/views/moduler/administration/preferences/_preference.html.erb +24 -0
- data/app/views/moduler/administration/preferences/edit.html.erb +1 -0
- data/app/views/moduler/administration/preferences/index.html.erb +13 -0
- data/app/views/moduler/administration/preferences/new.html.erb +1 -0
- data/app/views/moduler/administration/roles/_form.html.erb +24 -0
- data/app/views/moduler/administration/roles/_role.html.erb +15 -0
- data/app/views/moduler/administration/roles/edit.html.erb +1 -0
- data/app/views/moduler/administration/roles/index.html.erb +14 -0
- data/app/views/moduler/administration/roles/new.html.erb +1 -0
- data/app/views/moduler/administration/users/_user.html.erb +4 -0
- data/app/views/moduler/administration/users/edit.html.erb +1 -0
- data/app/views/moduler/administration/users/new.html.erb +1 -0
- data/app/views/moduler/common/_header.html.erb +2 -7
- data/app/views/moduler/common/administration/_sidebar.html.erb +9 -0
- data/app/views/moduler/common/profile/_sidebar.html.erb +1 -0
- data/app/views/moduler/email_mailer/custom.html.erb +3 -0
- data/app/views/moduler/email_mailer/custom.text.erb +1 -0
- data/app/views/moduler/profile/edit.html.erb +1 -0
- data/app/views/moduler/profile/sent_emails/index.html.erb +26 -0
- data/config/locales/moduler/administration/articles/en.yml +5 -0
- data/config/locales/moduler/administration/emails/en.yml +75 -0
- data/config/locales/moduler/administration/memberships/en.yml +35 -0
- data/config/locales/moduler/administration/organizations/en.yml +26 -0
- data/config/locales/moduler/administration/preferences/en.yml +44 -0
- data/config/locales/moduler/administration/roles/en.yml +32 -0
- data/config/locales/moduler/administration/users/en.yml +6 -1
- data/config/locales/moduler/common/en.yml +6 -1
- data/config/locales/moduler/components/en.yml +5 -0
- data/config/locales/moduler/models/en.yml +8 -0
- data/config/locales/moduler/profile/en.yml +2 -0
- data/config/locales/moduler/profile/sent_emails/en.yml +11 -0
- data/config/routes.rb +10 -0
- data/db/migrate/20261111113522_create_moduler_organizations.rb +11 -0
- data/db/migrate/20261111150000_create_moduler_roles.rb +13 -0
- data/db/migrate/20261111160000_create_moduler_memberships.rb +13 -0
- data/db/migrate/20261111180000_add_name_to_moduler_users.rb +5 -0
- data/db/migrate/20261111190000_add_status_to_moduler_articles.rb +8 -0
- data/db/migrate/20261111200000_create_moduler_preferences.rb +13 -0
- data/db/migrate/20261111210000_create_moduler_emails.rb +15 -0
- data/db/migrate/20261111210001_create_moduler_user_emails.rb +13 -0
- data/db/migrate/20261111210002_create_moduler_sent_emails.rb +12 -0
- data/lib/moduler/configuration.rb +6 -0
- data/lib/moduler/version.rb +1 -1
- metadata +80 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 81844153b9bf050ad6dcd61506cb7f4c899fc319a2e24e9f7d419de203522c0e
|
|
4
|
+
data.tar.gz: 89ec8cc74bfaed32d389e447773ed65249d442097d045984d7f142ba6c5ed4a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cab1f5b5af985d380606853e560f2f25b22697cca35220e61d689880db48760f679d373257a34eb1169b4df03b16cd682016ed86a8be60fe7f448bf39658013d
|
|
7
|
+
data.tar.gz: 0256ba167de24fc8f243003cbee2ad8862c9f154fd5a7bd769792c3a29a3ee33447e4482980d7be92c9ae1e4b36db7ad6c650f4362971d207096627aa216b63b
|
|
@@ -54,7 +54,6 @@
|
|
|
54
54
|
--text-xl: 1.25rem;
|
|
55
55
|
--text-xl--line-height: calc(1.75 / 1.25);
|
|
56
56
|
--text-2xl: 1.5rem;
|
|
57
|
-
--text-2xl--line-height: calc(2 / 1.5);
|
|
58
57
|
--font-weight-medium: 500;
|
|
59
58
|
--font-weight-semibold: 600;
|
|
60
59
|
--font-weight-bold: 700;
|
|
@@ -254,6 +253,9 @@
|
|
|
254
253
|
.-mx-4 {
|
|
255
254
|
margin-inline: calc(var(--spacing) * -4);
|
|
256
255
|
}
|
|
256
|
+
.mx-1 {
|
|
257
|
+
margin-inline: calc(var(--spacing) * 1);
|
|
258
|
+
}
|
|
257
259
|
.mx-auto {
|
|
258
260
|
margin-inline: auto;
|
|
259
261
|
}
|
|
@@ -960,6 +962,9 @@
|
|
|
960
962
|
.w-full {
|
|
961
963
|
width: 100%;
|
|
962
964
|
}
|
|
965
|
+
.w-px {
|
|
966
|
+
width: 1px;
|
|
967
|
+
}
|
|
963
968
|
.max-w-2xl {
|
|
964
969
|
max-width: var(--container-2xl);
|
|
965
970
|
}
|
|
@@ -987,6 +992,9 @@
|
|
|
987
992
|
.shrink-0 {
|
|
988
993
|
flex-shrink: 0;
|
|
989
994
|
}
|
|
995
|
+
.border-collapse {
|
|
996
|
+
border-collapse: collapse;
|
|
997
|
+
}
|
|
990
998
|
.translate-x-2 {
|
|
991
999
|
--tw-translate-x: calc(var(--spacing) * 2);
|
|
992
1000
|
translate: var(--tw-translate-x) var(--tw-translate-y);
|
|
@@ -1030,6 +1038,13 @@
|
|
|
1030
1038
|
.gap-4 {
|
|
1031
1039
|
gap: calc(var(--spacing) * 4);
|
|
1032
1040
|
}
|
|
1041
|
+
.space-y-2 {
|
|
1042
|
+
:where(& > :not(:last-child)) {
|
|
1043
|
+
--tw-space-y-reverse: 0;
|
|
1044
|
+
margin-block-start: calc(calc(var(--spacing) * 2) * var(--tw-space-y-reverse));
|
|
1045
|
+
margin-block-end: calc(calc(var(--spacing) * 2) * calc(1 - var(--tw-space-y-reverse)));
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1033
1048
|
.space-y-4 {
|
|
1034
1049
|
:where(& > :not(:last-child)) {
|
|
1035
1050
|
--tw-space-y-reverse: 0;
|
|
@@ -1070,6 +1085,9 @@
|
|
|
1070
1085
|
border-color: var(--color-slate-100);
|
|
1071
1086
|
}
|
|
1072
1087
|
}
|
|
1088
|
+
.self-stretch {
|
|
1089
|
+
align-self: stretch;
|
|
1090
|
+
}
|
|
1073
1091
|
.truncate {
|
|
1074
1092
|
overflow: hidden;
|
|
1075
1093
|
text-overflow: ellipsis;
|
|
@@ -1155,6 +1173,9 @@
|
|
|
1155
1173
|
.bg-emerald-50 {
|
|
1156
1174
|
background-color: var(--color-emerald-50);
|
|
1157
1175
|
}
|
|
1176
|
+
.bg-gray-200 {
|
|
1177
|
+
background-color: var(--color-gray-200);
|
|
1178
|
+
}
|
|
1158
1179
|
.bg-green-100 {
|
|
1159
1180
|
background-color: var(--color-green-100);
|
|
1160
1181
|
}
|
|
@@ -1233,12 +1254,18 @@
|
|
|
1233
1254
|
.pt-6 {
|
|
1234
1255
|
padding-top: calc(var(--spacing) * 6);
|
|
1235
1256
|
}
|
|
1257
|
+
.pr-10 {
|
|
1258
|
+
padding-right: calc(var(--spacing) * 10);
|
|
1259
|
+
}
|
|
1236
1260
|
.pb-4 {
|
|
1237
1261
|
padding-bottom: calc(var(--spacing) * 4);
|
|
1238
1262
|
}
|
|
1239
1263
|
.pb-6 {
|
|
1240
1264
|
padding-bottom: calc(var(--spacing) * 6);
|
|
1241
1265
|
}
|
|
1266
|
+
.pl-3 {
|
|
1267
|
+
padding-left: calc(var(--spacing) * 3);
|
|
1268
|
+
}
|
|
1242
1269
|
.text-center {
|
|
1243
1270
|
text-align: center;
|
|
1244
1271
|
}
|
|
@@ -1349,6 +1376,9 @@
|
|
|
1349
1376
|
.italic {
|
|
1350
1377
|
font-style: italic;
|
|
1351
1378
|
}
|
|
1379
|
+
.underline {
|
|
1380
|
+
text-decoration-line: underline;
|
|
1381
|
+
}
|
|
1352
1382
|
.accent-custom {
|
|
1353
1383
|
accent-color: var(--color-custom);
|
|
1354
1384
|
}
|
|
@@ -1449,6 +1479,10 @@
|
|
|
1449
1479
|
--tw-prose-invert-th-borders: oklch(44.6% 0.043 257.281);
|
|
1450
1480
|
--tw-prose-invert-td-borders: oklch(37.2% 0.044 257.287);
|
|
1451
1481
|
}
|
|
1482
|
+
.select-all {
|
|
1483
|
+
-webkit-user-select: all;
|
|
1484
|
+
user-select: all;
|
|
1485
|
+
}
|
|
1452
1486
|
.ring-inset {
|
|
1453
1487
|
--tw-ring-inset: inset;
|
|
1454
1488
|
}
|
|
@@ -1754,16 +1788,31 @@
|
|
|
1754
1788
|
margin-inline: calc(var(--spacing) * 0);
|
|
1755
1789
|
}
|
|
1756
1790
|
}
|
|
1791
|
+
.md\:my-2 {
|
|
1792
|
+
@media (width >= 48rem) {
|
|
1793
|
+
margin-block: calc(var(--spacing) * 2);
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1757
1796
|
.md\:mt-8 {
|
|
1758
1797
|
@media (width >= 48rem) {
|
|
1759
1798
|
margin-top: calc(var(--spacing) * 8);
|
|
1760
1799
|
}
|
|
1761
1800
|
}
|
|
1801
|
+
.md\:h-px {
|
|
1802
|
+
@media (width >= 48rem) {
|
|
1803
|
+
height: 1px;
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1762
1806
|
.md\:w-1\/8 {
|
|
1763
1807
|
@media (width >= 48rem) {
|
|
1764
1808
|
width: calc(1 / 8 * 100%);
|
|
1765
1809
|
}
|
|
1766
1810
|
}
|
|
1811
|
+
.md\:w-auto {
|
|
1812
|
+
@media (width >= 48rem) {
|
|
1813
|
+
width: auto;
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1767
1816
|
.md\:shrink-0 {
|
|
1768
1817
|
@media (width >= 48rem) {
|
|
1769
1818
|
flex-shrink: 0;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// Rows of attached and new files (Moduler::Form::AttachmentsComponent).
|
|
4
|
+
// Adding a row opens the file picker of its new file field; removing an
|
|
5
|
+
// attached file's row submits its id for removal when the form is saved.
|
|
6
|
+
export default class extends Controller {
|
|
7
|
+
static targets = ["list", "template"]
|
|
8
|
+
static values = { removeFieldName: String }
|
|
9
|
+
|
|
10
|
+
add() {
|
|
11
|
+
const row = this.templateTarget.content.firstElementChild.cloneNode(true)
|
|
12
|
+
this.listTarget.append(row)
|
|
13
|
+
row.querySelector("input[type=file]")?.click()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
remove(event) {
|
|
17
|
+
const row = event.target.closest("li")
|
|
18
|
+
const attachmentId = row.dataset.attachmentId
|
|
19
|
+
|
|
20
|
+
if (attachmentId) {
|
|
21
|
+
const input = document.createElement("input")
|
|
22
|
+
input.type = "hidden"
|
|
23
|
+
input.name = this.removeFieldNameValue
|
|
24
|
+
input.value = attachmentId
|
|
25
|
+
this.element.append(input)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
row.remove()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// Repopulates the dependent select with the choices for the value chosen in
|
|
4
|
+
// the source select, e.g. the roles of the chosen organization.
|
|
5
|
+
//
|
|
6
|
+
// options value: { "<source value>": [[label, value], ...] }
|
|
7
|
+
export default class extends Controller {
|
|
8
|
+
static targets = ["source", "dependent"]
|
|
9
|
+
static values = { options: Object }
|
|
10
|
+
|
|
11
|
+
update() {
|
|
12
|
+
const choices = this.optionsValue[this.sourceTarget.value] || []
|
|
13
|
+
const blank = this.dependentTarget.querySelector("option[value='']")
|
|
14
|
+
const options = choices.map(([label, value]) => new Option(label, value))
|
|
15
|
+
|
|
16
|
+
this.dependentTarget.replaceChildren(...(blank ? [blank] : []), ...options)
|
|
17
|
+
this.dependentTarget.value = ""
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
// A checkbox that checks or unchecks all child checkboxes, and is checked
|
|
4
|
+
// itself when all of them are.
|
|
5
|
+
export default class extends Controller {
|
|
6
|
+
static targets = ["parent", "child"]
|
|
7
|
+
|
|
8
|
+
toggleChildren() {
|
|
9
|
+
this.childTargets.forEach((child) => { child.checked = this.parentTarget.checked })
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
toggleParent() {
|
|
13
|
+
this.parentTarget.checked = this.childTargets.length > 0 && this.childTargets.every((child) => child.checked)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -4,9 +4,17 @@
|
|
|
4
4
|
class: "w-full rounded-md border border-slate-300 px-3 text-sm text-slate-900 placeholder:text-slate-400 focus:border-slate-900 focus:outline-none focus:ring-1 focus:ring-slate-900" %>
|
|
5
5
|
</div>
|
|
6
6
|
|
|
7
|
+
<% selects.each do |select| %>
|
|
8
|
+
<div class="min-w-48">
|
|
9
|
+
<%= form.select select[:name], select[:choices], { include_blank: select.fetch(:prompt, true) },
|
|
10
|
+
"aria-label": select[:prompt],
|
|
11
|
+
class: "w-full rounded-md border border-slate-300 bg-white pl-3 pr-10 text-sm text-slate-900 focus:border-slate-900 focus:outline-none focus:ring-1 focus:ring-slate-900" %>
|
|
12
|
+
</div>
|
|
13
|
+
<% end %>
|
|
14
|
+
|
|
7
15
|
<%= form.submit t("moduler.components.filter.action.filter"),
|
|
8
16
|
class: "cursor-pointer whitespace-nowrap rounded-md bg-white px-3 py-2 text-sm/6 font-semibold text-custom ring-1 ring-inset ring-slate-300 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-custom" %>
|
|
9
|
-
<% if
|
|
17
|
+
<% if filtered? %>
|
|
10
18
|
<%= link_to t("moduler.components.filter.action.clear"), @url, class: "flex h-10 items-center text-sm text-slate-500 hover:text-slate-900" %>
|
|
11
19
|
<% end %>
|
|
12
20
|
<% end %>
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
module Moduler
|
|
4
4
|
class FilterComponent < ViewComponent::Base
|
|
5
|
+
# options:
|
|
6
|
+
# placeholder: placeholder of the query field
|
|
7
|
+
# selects: additional select fields, each a hash with
|
|
8
|
+
# name (filter attribute), choices ([label, value] pairs) and prompt (label of the empty choice)
|
|
5
9
|
def initialize(filter, url, options = {})
|
|
6
10
|
@filter = filter
|
|
7
11
|
@url = url
|
|
@@ -11,5 +15,13 @@ module Moduler
|
|
|
11
15
|
def placeholder
|
|
12
16
|
@options.fetch(:placeholder) { t("moduler.components.filter.placeholder.query") }
|
|
13
17
|
end
|
|
18
|
+
|
|
19
|
+
def selects
|
|
20
|
+
@options.fetch(:selects, [])
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def filtered?
|
|
24
|
+
@filter.query.present? || selects.any? { |select| @filter.public_send(select[:name]).present? }
|
|
25
|
+
end
|
|
14
26
|
end
|
|
15
27
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<div class="mt-2" data-controller="attachments" data-attachments-remove-field-name-value="<%= remove_field_name %>">
|
|
2
|
+
<% if @options.key?(:label) %>
|
|
3
|
+
<p class="block text-sm text-slate-500"><%= @options[:label] %></p>
|
|
4
|
+
<% end %>
|
|
5
|
+
|
|
6
|
+
<ul class="mt-2 space-y-2" data-attachments-target="list">
|
|
7
|
+
<% attached.each do |attachment| %>
|
|
8
|
+
<li class="flex items-center justify-between gap-3 rounded-md border border-slate-200 px-3 py-2" data-attachment-id="<%= attachment.id %>">
|
|
9
|
+
<%= link_to attachment.filename, helpers.main_app.rails_blob_path(attachment, disposition: "attachment"), class: "truncate text-sm text-gray-900 hover:underline" %>
|
|
10
|
+
<button type="button" data-action="attachments#remove" class="shrink-0 cursor-pointer text-sm text-slate-500 hover:text-red-600"><%= t("moduler.components.form.attachments.action.remove") %></button>
|
|
11
|
+
</li>
|
|
12
|
+
<% end %>
|
|
13
|
+
</ul>
|
|
14
|
+
|
|
15
|
+
<template data-attachments-target="template">
|
|
16
|
+
<li class="flex items-center justify-between gap-3 rounded-md border border-slate-200 px-3 py-2">
|
|
17
|
+
<input type="file" name="<%= field_name %>" class="block w-full text-sm text-gray-900 file:mr-3 file:rounded-md file:border-0 file:bg-white file:px-3 file:py-1.5 file:text-sm file:font-semibold file:text-gray-900 file:shadow-xs file:ring-1 file:ring-inset file:ring-gray-300 hover:file:bg-gray-50">
|
|
18
|
+
<button type="button" data-action="attachments#remove" class="shrink-0 cursor-pointer text-sm text-slate-500 hover:text-red-600"><%= t("moduler.components.form.attachments.action.remove") %></button>
|
|
19
|
+
</li>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<button type="button" data-action="attachments#add" class="mt-2 cursor-pointer rounded-md bg-white px-2.5 py-1 text-sm font-medium text-slate-600 shadow-sm ring-1 ring-inset ring-slate-300 hover:bg-slate-50 hover:text-slate-900">
|
|
23
|
+
<%= t("moduler.components.form.attachments.action.add") %>
|
|
24
|
+
</button>
|
|
25
|
+
|
|
26
|
+
<% if @options.key?(:description) %>
|
|
27
|
+
<p class="mt-1 text-xs text-gray-400"><%= @options[:description] %></p>
|
|
28
|
+
<% end %>
|
|
29
|
+
<% if @form.error?(@name) %>
|
|
30
|
+
<%= @form.error(@name, class: "text-red-500 text-sm mt-1") %>
|
|
31
|
+
<% end %>
|
|
32
|
+
</div>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Moduler
|
|
4
|
+
# Files of a has_many_attached association, one row per file. Rows of new
|
|
5
|
+
# files are added with a button, and each row (new or attached) can be
|
|
6
|
+
# removed. Attached files marked for removal are submitted as
|
|
7
|
+
# remove_<name singular>_ids[] (e.g. remove_attachment_ids[]) and removed
|
|
8
|
+
# by the controller when the form is saved.
|
|
9
|
+
class Form::AttachmentsComponent < ViewComponent::Base
|
|
10
|
+
def initialize(form, name, options = {})
|
|
11
|
+
@form = form
|
|
12
|
+
@name = name
|
|
13
|
+
@options = options
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def attached
|
|
17
|
+
@form.object.public_send(@name).select(&:persisted?)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def field_name
|
|
21
|
+
"#{@form.object_name}[#{@name}][]"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def remove_field_name
|
|
25
|
+
"#{@form.object_name}[remove_#{@name.to_s.singularize}_ids][]"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<fieldset class="mt-2">
|
|
2
|
+
<% if @options.key?(:label) %>
|
|
3
|
+
<legend class="block text-sm text-slate-500"><%= @options[:label] %></legend>
|
|
4
|
+
<% end %>
|
|
5
|
+
<div class="mt-2 space-y-2">
|
|
6
|
+
<%= @form.collection_check_boxes @name, @choices, :last, :first do |choice| %>
|
|
7
|
+
<div class="flex items-center gap-3">
|
|
8
|
+
<%= choice.check_box(class: "h-4 w-4 shrink-0 cursor-pointer rounded border-gray-300 accent-custom") %>
|
|
9
|
+
<%= choice.label(class: "cursor-pointer text-sm text-gray-900") %>
|
|
10
|
+
</div>
|
|
11
|
+
<% end %>
|
|
12
|
+
</div>
|
|
13
|
+
<% if @options.key?(:description) %>
|
|
14
|
+
<p class="mt-1 text-xs text-gray-400"><%= @options[:description] %></p>
|
|
15
|
+
<% end %>
|
|
16
|
+
<% if @form.error?(@name) %>
|
|
17
|
+
<%= @form.error(@name, class: "text-red-500 text-sm mt-1") %>
|
|
18
|
+
<% end %>
|
|
19
|
+
</fieldset>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Moduler
|
|
4
|
+
class Form::CheckboxesComponent < ViewComponent::Base
|
|
5
|
+
# choices: array of [label, value] pairs
|
|
6
|
+
def initialize(form, name, choices, options = {})
|
|
7
|
+
@form = form
|
|
8
|
+
@name = name
|
|
9
|
+
@choices = choices
|
|
10
|
+
@options = options
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<%= @form.label @name, @options[:label], class: "block text-sm text-slate-500" %>
|
|
4
4
|
<% end %>
|
|
5
5
|
<div class="mt-2">
|
|
6
|
-
<%= @form.select @name, @choices, { include_blank: @options[:include_blank] }, class: "block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-custom sm:text-sm/6" %>
|
|
6
|
+
<%= @form.select @name, @choices, { include_blank: @options[:include_blank] }, data: data, class: "block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-custom sm:text-sm/6" %>
|
|
7
7
|
</div>
|
|
8
8
|
<% if @options.key?(:description) %>
|
|
9
9
|
<p class="mt-1 text-xs text-gray-400"><%= @options[:description] %></p>
|
|
@@ -54,7 +54,7 @@ module Moduler
|
|
|
54
54
|
|
|
55
55
|
data.merge(
|
|
56
56
|
wysiwyg_direct_upload_url_value: helpers.main_app.rails_direct_uploads_path,
|
|
57
|
-
wysiwyg_blob_url_value: helpers.main_app.
|
|
57
|
+
wysiwyg_blob_url_value: helpers.main_app.rails_service_blob_url(":signed_id", ":filename"),
|
|
58
58
|
wysiwyg_attachments_field_name_value: attachments_field_name
|
|
59
59
|
)
|
|
60
60
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Moduler
|
|
2
|
+
# Keeps administrators out of the application: they are redirected to the
|
|
3
|
+
# administration area. Controllers administrators may use (the
|
|
4
|
+
# administration area, the profile, signing in and out, public pages) opt
|
|
5
|
+
# out with +allow_administrator_access+.
|
|
6
|
+
module RestrictAdministratorAccess
|
|
7
|
+
extend ActiveSupport::Concern
|
|
8
|
+
|
|
9
|
+
included do
|
|
10
|
+
before_action :restrict_administrator_access
|
|
11
|
+
helper_method :current_home_path
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class_methods do
|
|
15
|
+
def allow_administrator_access(**options)
|
|
16
|
+
skip_before_action :restrict_administrator_access, **options
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
# The home page of the signed-in user: the administration area for
|
|
23
|
+
# administrators, the application for everyone else.
|
|
24
|
+
def current_home_path
|
|
25
|
+
Current.user&.administrator? ? moduler.administration_root_path : moduler.root_path
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def restrict_administrator_access
|
|
29
|
+
redirect_to moduler.administration_root_path if Current.user&.administrator?
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -46,7 +46,7 @@ module Moduler
|
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def permitted_parameters
|
|
49
|
-
params.expect(article: [ :path, :title, :description, :keywords, :content, images: [] ])
|
|
49
|
+
params.expect(article: [ :status, :path, :title, :description, :keywords, :content, images: [] ])
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def permitted_filter_parameters
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Moduler
|
|
2
|
+
module Administration
|
|
3
|
+
module Emails
|
|
4
|
+
# Sending an email to users chosen from a filterable list.
|
|
5
|
+
class DeliveriesController < ApplicationController
|
|
6
|
+
before_action :set_email
|
|
7
|
+
|
|
8
|
+
def new
|
|
9
|
+
@filter, @users = EmailDeliveryFilter.new(candidates, permitted_filter_parameters).call
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def create
|
|
13
|
+
queued = @email.deliver_to(User.where(id: Array(params[:user_ids])))
|
|
14
|
+
|
|
15
|
+
redirect_to moduler.new_administration_email_delivery_path(@email), notice: t(".notice", count: queued)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def set_email
|
|
21
|
+
@email = Email.find(params[:email_id])
|
|
22
|
+
authorize(@email, :deliver?, policy_class: EmailPolicy)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Users with the id and sent_at of their queued email, if any.
|
|
26
|
+
def candidates
|
|
27
|
+
User
|
|
28
|
+
.joins(User.sanitize_sql_array([
|
|
29
|
+
"LEFT JOIN moduler_user_emails ON moduler_user_emails.moduler_user_id = moduler_users.id AND moduler_user_emails.moduler_email_id = ?",
|
|
30
|
+
@email.id
|
|
31
|
+
]))
|
|
32
|
+
.select("moduler_users.*", "moduler_user_emails.id AS user_email_id", "moduler_user_emails.sent_at AS user_email_sent_at")
|
|
33
|
+
.order(:email_address)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def permitted_filter_parameters
|
|
37
|
+
(params.permit(filter: %i[ query role sent per_page ])[:filter] || {}).merge(params.permit(:page))
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
module Moduler
|
|
2
|
+
module Administration
|
|
3
|
+
class EmailsController < ApplicationController
|
|
4
|
+
before_action -> { authorize([ :moduler, :administration, :email ]) }
|
|
5
|
+
before_action :set_email, only: %i[ edit update destroy ]
|
|
6
|
+
|
|
7
|
+
def index
|
|
8
|
+
@filter, @emails = QueryFilter.new(Email, permitted_filter_parameters).call
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def new
|
|
12
|
+
@email = Email.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def create
|
|
16
|
+
@email = Email.new(permitted_parameters.except(:remove_attachment_ids))
|
|
17
|
+
|
|
18
|
+
if @email.save
|
|
19
|
+
redirect_to moduler.administration_emails_path, notice: t(".notice")
|
|
20
|
+
else
|
|
21
|
+
render :new, status: :unprocessable_entity
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def edit; end
|
|
26
|
+
|
|
27
|
+
# New attachments are added to the existing ones, and the attachments
|
|
28
|
+
# marked for removal are removed, once the email is saved.
|
|
29
|
+
def update
|
|
30
|
+
parameters = permitted_parameters
|
|
31
|
+
attachments = parameters.delete(:attachments)
|
|
32
|
+
remove_attachment_ids = parameters.delete(:remove_attachment_ids)
|
|
33
|
+
|
|
34
|
+
if @email.update(parameters)
|
|
35
|
+
@email.attachments.attach(attachments) if attachments.present?
|
|
36
|
+
@email.attachments_attachments.where(id: remove_attachment_ids).find_each(&:purge) if remove_attachment_ids.present?
|
|
37
|
+
|
|
38
|
+
redirect_to moduler.administration_emails_path, notice: t(".notice")
|
|
39
|
+
else
|
|
40
|
+
render :edit, status: :unprocessable_entity
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def destroy
|
|
45
|
+
@email.destroy!
|
|
46
|
+
|
|
47
|
+
redirect_to moduler.administration_emails_path, status: :see_other, notice: t(".notice")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
private
|
|
51
|
+
|
|
52
|
+
def set_email
|
|
53
|
+
@email = Email.find(params[:id])
|
|
54
|
+
authorize(@email, policy_class: EmailPolicy)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def permitted_parameters
|
|
58
|
+
params.expect(email: [ :subject, :sender, :kind, :event, :body, attachments: [], images: [], remove_attachment_ids: [] ]).tap do |parameters|
|
|
59
|
+
parameters[:attachments] = Array(parameters[:attachments]).compact_blank if parameters.key?(:attachments)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def permitted_filter_parameters
|
|
64
|
+
(params.permit(filter: %i[ query ])[:filter] || {}).merge(params.permit(:page))
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
module Moduler
|
|
2
|
+
module Administration
|
|
3
|
+
class MembershipsController < ApplicationController
|
|
4
|
+
before_action -> { authorize([ :moduler, :administration, :membership ]) }
|
|
5
|
+
before_action :set_membership, only: %i[ edit update destroy ]
|
|
6
|
+
|
|
7
|
+
def index
|
|
8
|
+
@filter, @memberships = OrganizationQueryFilter.new(Membership.includes(:user, :organization, :role), permitted_filter_parameters).call
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def new
|
|
12
|
+
@membership = Membership.new(moduler_organization_id: params[:organization_id])
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def create
|
|
16
|
+
@membership = Membership.new(permitted_parameters)
|
|
17
|
+
|
|
18
|
+
if @membership.save
|
|
19
|
+
redirect_to moduler.administration_memberships_path, notice: t(".notice")
|
|
20
|
+
else
|
|
21
|
+
render :new, status: :unprocessable_entity
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def edit; end
|
|
26
|
+
|
|
27
|
+
def update
|
|
28
|
+
if @membership.update(permitted_update_parameters)
|
|
29
|
+
redirect_to moduler.administration_memberships_path, notice: t(".notice")
|
|
30
|
+
else
|
|
31
|
+
render :edit, status: :unprocessable_entity
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def destroy
|
|
36
|
+
@membership.destroy!
|
|
37
|
+
|
|
38
|
+
redirect_to moduler.administration_memberships_path, status: :see_other, notice: t(".notice")
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def set_membership
|
|
44
|
+
@membership = Membership.find(params[:id])
|
|
45
|
+
authorize(@membership, policy_class: MembershipPolicy)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def permitted_parameters
|
|
49
|
+
params.expect(membership: %i[ moduler_organization_id moduler_user_id moduler_role_id ])
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# The organization and user of a membership cannot be changed, only the role.
|
|
53
|
+
def permitted_update_parameters
|
|
54
|
+
params.expect(membership: %i[ moduler_role_id ])
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def permitted_filter_parameters
|
|
58
|
+
(params.permit(filter: %i[ query organization_id ])[:filter] || {}).merge(params.permit(:page))
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|