moduler 0.6.0 → 0.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81844153b9bf050ad6dcd61506cb7f4c899fc319a2e24e9f7d419de203522c0e
4
- data.tar.gz: 89ec8cc74bfaed32d389e447773ed65249d442097d045984d7f142ba6c5ed4a4
3
+ metadata.gz: 48b04e1bddcad684cb26f044713db46a9b049c4f6a7ceaa0f0f5e60211dd085e
4
+ data.tar.gz: c01f94740262115c801c293abeeacec41a53c4e6fa17bcba1a8c8bd5899d3439
5
5
  SHA512:
6
- metadata.gz: cab1f5b5af985d380606853e560f2f25b22697cca35220e61d689880db48760f679d373257a34eb1169b4df03b16cd682016ed86a8be60fe7f448bf39658013d
7
- data.tar.gz: 0256ba167de24fc8f243003cbee2ad8862c9f154fd5a7bd769792c3a29a3ee33447e4482980d7be92c9ae1e4b36db7ad6c650f4362971d207096627aa216b63b
6
+ metadata.gz: 4889b74712446a913cb1ec858ddb37a85cec01bd55769ba45d648250b01f0308e1f8a38e303d99a612f65d2cac105609fbc5db1d219686d80ba65376ec8f6eeb
7
+ data.tar.gz: a09513f54e837d8b7cf0f70a32ee9171b55c05bc2428ab5a71422bdbfe41428364f5bb384205e321c73bb20340b097f4e74fa74b05f36bb74c36ca61c47c1304
@@ -54,6 +54,7 @@
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);
57
58
  --font-weight-medium: 500;
58
59
  --font-weight-semibold: 600;
59
60
  --font-weight-bold: 700;
@@ -232,6 +233,9 @@
232
233
  .inset-0 {
233
234
  inset: calc(var(--spacing) * 0);
234
235
  }
236
+ .inset-x-2 {
237
+ inset-inline: calc(var(--spacing) * 2);
238
+ }
235
239
  .start {
236
240
  inset-inline-start: var(--spacing);
237
241
  }
@@ -244,6 +248,9 @@
244
248
  .right-4 {
245
249
  right: calc(var(--spacing) * 4);
246
250
  }
251
+ .z-10 {
252
+ z-index: 10;
253
+ }
247
254
  .z-50 {
248
255
  z-index: 50;
249
256
  }
@@ -930,6 +937,10 @@
930
937
  .table {
931
938
  display: table;
932
939
  }
940
+ .size-4 {
941
+ width: calc(var(--spacing) * 4);
942
+ height: calc(var(--spacing) * 4);
943
+ }
933
944
  .size-5 {
934
945
  width: calc(var(--spacing) * 5);
935
946
  height: calc(var(--spacing) * 5);
@@ -947,6 +958,9 @@
947
958
  .h-16 {
948
959
  height: calc(var(--spacing) * 16);
949
960
  }
961
+ .max-h-72 {
962
+ max-height: calc(var(--spacing) * 72);
963
+ }
950
964
  .min-h-9 {
951
965
  min-height: calc(var(--spacing) * 9);
952
966
  }
@@ -1002,6 +1016,9 @@
1002
1016
  .cursor-pointer {
1003
1017
  cursor: pointer;
1004
1018
  }
1019
+ .list-none {
1020
+ list-style-type: none;
1021
+ }
1005
1022
  .flex-col {
1006
1023
  flex-direction: column;
1007
1024
  }
@@ -1096,6 +1113,9 @@
1096
1113
  .overflow-x-auto {
1097
1114
  overflow-x: auto;
1098
1115
  }
1116
+ .overflow-y-auto {
1117
+ overflow-y: auto;
1118
+ }
1099
1119
  .rounded {
1100
1120
  border-radius: 0.25rem;
1101
1121
  }
@@ -1212,6 +1232,9 @@
1212
1232
  .bg-yellow-100 {
1213
1233
  background-color: var(--color-yellow-100);
1214
1234
  }
1235
+ .p-1 {
1236
+ padding: calc(var(--spacing) * 1);
1237
+ }
1215
1238
  .p-2 {
1216
1239
  padding: calc(var(--spacing) * 2);
1217
1240
  }
@@ -1257,6 +1280,9 @@
1257
1280
  .pr-10 {
1258
1281
  padding-right: calc(var(--spacing) * 10);
1259
1282
  }
1283
+ .pb-0 {
1284
+ padding-bottom: calc(var(--spacing) * 0);
1285
+ }
1260
1286
  .pb-4 {
1261
1287
  padding-bottom: calc(var(--spacing) * 4);
1262
1288
  }
@@ -1437,6 +1463,11 @@
1437
1463
  transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
1438
1464
  transition-duration: var(--tw-duration, var(--default-transition-duration));
1439
1465
  }
1466
+ .transition-transform {
1467
+ transition-property: transform, translate, scale, rotate;
1468
+ transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
1469
+ transition-duration: var(--tw-duration, var(--default-transition-duration));
1470
+ }
1440
1471
  .duration-200 {
1441
1472
  --tw-duration: 200ms;
1442
1473
  transition-duration: 200ms;
@@ -1486,6 +1517,11 @@
1486
1517
  .ring-inset {
1487
1518
  --tw-ring-inset: inset;
1488
1519
  }
1520
+ .group-open\:rotate-180 {
1521
+ &:is(:where(.group):is([open], :popover-open, :open) *) {
1522
+ rotate: 180deg;
1523
+ }
1524
+ }
1489
1525
  .group-hover\:text-custom {
1490
1526
  &:is(:where(.group):hover *) {
1491
1527
  @media (hover: hover) {
@@ -1855,6 +1891,11 @@
1855
1891
  padding-right: calc(var(--spacing) * 6);
1856
1892
  }
1857
1893
  }
1894
+ .md\:pb-2 {
1895
+ @media (width >= 48rem) {
1896
+ padding-bottom: calc(var(--spacing) * 2);
1897
+ }
1898
+ }
1858
1899
  .md\:pl-0 {
1859
1900
  @media (width >= 48rem) {
1860
1901
  padding-left: calc(var(--spacing) * 0);
@@ -1895,6 +1936,11 @@
1895
1936
  max-width: var(--container-5xl);
1896
1937
  }
1897
1938
  }
1939
+ .\[\&\:\:-webkit-details-marker\]\:hidden {
1940
+ &::-webkit-details-marker {
1941
+ display: none;
1942
+ }
1943
+ }
1898
1944
  }
1899
1945
  .prose-100 {
1900
1946
  max-width: 100%;
@@ -0,0 +1,12 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ // Closes a <details> dropdown on a click outside it or on Escape.
4
+ export default class extends Controller {
5
+ closeOnOutsideClick(event) {
6
+ if (!this.element.contains(event.target)) this.close()
7
+ }
8
+
9
+ close() {
10
+ this.element.open = false
11
+ }
12
+ }
@@ -0,0 +1,29 @@
1
+ module Moduler
2
+ # Scopes a controller to the organization in the URL
3
+ # (+/organizations/:organization_id/...+), available as
4
+ # +Current.organization+ and the +current_organization+ helper. The
5
+ # organization is looked up among the signed-in user's organizations; for
6
+ # any other organization (for example after the user was removed from it)
7
+ # the user is redirected to the home page to choose another one. Keeping the
8
+ # organization in the URL lets every browser tab work in a different
9
+ # organization.
10
+ module OrganizationScoped
11
+ extend ActiveSupport::Concern
12
+
13
+ included do
14
+ before_action :set_current_organization
15
+ end
16
+
17
+ private
18
+
19
+ def set_current_organization
20
+ Current.organization = Current.user.organizations.find_by(id: organization_id_param)
21
+
22
+ redirect_to moduler.root_path, alert: t("moduler.flash.organization_not_found") unless Current.organization
23
+ end
24
+
25
+ def organization_id_param
26
+ params[:organization_id]
27
+ end
28
+ end
29
+ end
@@ -9,7 +9,7 @@ module Moduler
9
9
 
10
10
  rescue_from Pundit::NotAuthorizedError, with: :not_authorized
11
11
 
12
- helper_method :current_user
12
+ helper_method :current_user, :current_organization
13
13
 
14
14
  private
15
15
 
@@ -17,6 +17,10 @@ module Moduler
17
17
  Current.user
18
18
  end
19
19
 
20
+ def current_organization
21
+ Current.organization
22
+ end
23
+
20
24
  def not_authorized
21
25
  redirect_to current_home_path, alert: t("moduler.flash.not_authorized")
22
26
  end
@@ -1,5 +1,7 @@
1
1
  module Moduler
2
2
  class HomeController < ApplicationController
3
- def index; end
3
+ def index
4
+ @memberships = Current.user.memberships.includes(:organization, :role).order("moduler_organizations.name")
5
+ end
4
6
  end
5
7
  end
@@ -0,0 +1,13 @@
1
+ module Moduler
2
+ class OrganizationsController < ApplicationController
3
+ include OrganizationScoped
4
+
5
+ def show; end
6
+
7
+ private
8
+
9
+ def organization_id_param
10
+ params[:id]
11
+ end
12
+ end
13
+ end
@@ -1,6 +1,6 @@
1
1
  module Moduler
2
2
  class Current < ActiveSupport::CurrentAttributes
3
- attribute :session
3
+ attribute :session, :organization
4
4
  delegate :user, to: :session, allow_nil: true
5
5
  end
6
6
  end
@@ -0,0 +1,29 @@
1
+ <details class="group relative p-2 pb-0 md:pb-2" data-controller="dropdown" data-action="click@window->dropdown#closeOnOutsideClick keydown.esc@window->dropdown#close">
2
+ <summary class="flex cursor-pointer list-none items-center justify-between gap-2 rounded-md border border-gray-200 px-3 py-2 text-sm hover:bg-slate-50 [&::-webkit-details-marker]:hidden" aria-label="<%= t(".label") %>">
3
+ <span class="min-w-0">
4
+ <span class="block text-xs text-slate-500"><%= t(".label") %></span>
5
+ <span class="block truncate font-medium text-gray-900"><%= current_organization.name %></span>
6
+ </span>
7
+ <svg class="size-4 shrink-0 text-slate-400 transition-transform group-open:rotate-180" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
8
+ <path fill-rule="evenodd" d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
9
+ </svg>
10
+ </summary>
11
+
12
+ <ul id="organization_switcher" class="absolute inset-x-2 z-10 mt-1 max-h-72 overflow-y-auto rounded-md border border-gray-200 bg-white p-1 text-sm shadow-lg">
13
+ <% current_user.organizations.order(:name).each do |organization| %>
14
+ <li>
15
+ <% if organization == current_organization %>
16
+ <span class="flex items-center justify-between gap-2 rounded-md bg-slate-100 px-3 py-2 font-medium text-gray-900" aria-current="true">
17
+ <span class="truncate"><%= organization.name %></span>
18
+ <svg class="size-4 shrink-0" viewBox="0 0 20 20" fill="currentColor" role="img" aria-label="<%= t(".current") %>">
19
+ <path fill-rule="evenodd" d="M16.704 4.153a.75.75 0 0 1 .143 1.052l-8 10.5a.75.75 0 0 1-1.127.075l-4.5-4.5a.75.75 0 0 1 1.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 0 1 1.05-.143Z" clip-rule="evenodd" />
20
+ </svg>
21
+ </span>
22
+ <% else %>
23
+ <%= link_to organization.name, moduler.organization_path(organization),
24
+ class: "block truncate rounded-md px-3 py-2 text-slate-500 hover:bg-slate-50 hover:text-gray-900" %>
25
+ <% end %>
26
+ </li>
27
+ <% end %>
28
+ </ul>
29
+ </details>
@@ -1,7 +1,10 @@
1
1
  <aside class="-mx-4 border-b border-gray-200 px-2 md:mx-0 md:w-1/8 md:shrink-0 md:border-b-0 md:border-r md:px-0">
2
+ <%= render "moduler/common/organization_switcher" %>
3
+
2
4
  <nav class="flex gap-1 overflow-x-auto md:flex-col text-sm p-2">
5
+ <%= render(Moduler::SidebarActionComponent.new(t(".action.dashboard"), moduler.organization_path(current_organization), "moduler/organizations")) %>
3
6
  <% Array(Moduler.configuration.dig(:resources)).each do |resource| %>
4
- <%= render(Moduler::SidebarActionComponent.new(t(".action.#{resource}"), moduler.url_for([resource.to_sym]), "moduler/#{resource}")) %>
7
+ <%= render(Moduler::SidebarActionComponent.new(t(".action.#{resource}"), moduler.url_for([current_organization, resource.to_sym]), "moduler/#{resource}")) %>
5
8
  <% end %>
6
9
  </nav>
7
10
  </aside>
@@ -1,6 +1,24 @@
1
- <main class="mx-auto flex w-full flex-1 max-w-[120rem] flex-col gap-4 px-4 md:flex-row md:gap-8 md:pl-0 md:pr-6">
2
- <%= render "moduler/common/sidebar" %>
3
-
4
- <div class="flex min-w-0 flex-1 flex-col pb-4 md:mt-8">
1
+ <main class="mx-auto flex w-full max-w-2xl flex-1 flex-col px-4 py-8">
2
+ <div class="mb-6">
3
+ <h1 class="text-base font-semibold text-gray-900"><%= t(".title", name: current_user.display_name) %></h1>
4
+ <p class="mt-1 text-sm text-slate-500"><%= t(@memberships.any? ? ".description" : ".empty") %></p>
5
5
  </div>
6
+
7
+ <% if @memberships.any? %>
8
+ <ul id="organizations" class="divide-y divide-gray-200 rounded-md border border-gray-200 bg-white">
9
+ <% @memberships.each do |membership| %>
10
+ <li id="<%= dom_id(membership.organization) %>">
11
+ <%= link_to moduler.organization_path(membership.organization), class: "flex items-center justify-between gap-3 px-4 py-4 hover:bg-slate-50 sm:px-5" do %>
12
+ <span class="min-w-0">
13
+ <span class="block truncate text-sm font-medium text-gray-900"><%= membership.organization.name %></span>
14
+ <span class="mt-1 block text-xs text-slate-400"><%= membership.role.name %></span>
15
+ </span>
16
+ <svg class="size-4 shrink-0 text-slate-400" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
17
+ <path fill-rule="evenodd" d="M8.22 5.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.75.75 0 0 1-1.06-1.06L11.94 10 8.22 6.28a.75.75 0 0 1 0-1.06Z" clip-rule="evenodd" />
18
+ </svg>
19
+ <% end %>
20
+ </li>
21
+ <% end %>
22
+ </ul>
23
+ <% end %>
6
24
  </main>
@@ -0,0 +1,7 @@
1
+ <main class="mx-auto flex w-full flex-1 max-w-[120rem] flex-col gap-4 px-4 md:flex-row md:gap-8 md:pl-0 md:pr-6">
2
+ <%= render "moduler/common/sidebar" %>
3
+
4
+ <div class="flex min-w-0 flex-1 flex-col pb-4 md:mt-8">
5
+ <%= render(Moduler::PageHeaderComponent.new(current_organization.name)) %>
6
+ </div>
7
+ </main>
@@ -13,6 +13,12 @@ en:
13
13
  organizations: Organizations
14
14
  roles: Roles
15
15
  memberships: Members
16
+ organization_switcher:
17
+ label: Organization
18
+ current: Current organization
19
+ sidebar:
20
+ action:
21
+ dashboard: Dashboard
16
22
  profile:
17
23
  sidebar:
18
24
  action:
@@ -2,3 +2,4 @@ en:
2
2
  moduler:
3
3
  flash:
4
4
  not_authorized: You are not authorized to perform this action.
5
+ organization_not_found: You don't have access to this organization.
@@ -0,0 +1,7 @@
1
+ en:
2
+ moduler:
3
+ home:
4
+ index:
5
+ title: "Welcome, %{name}"
6
+ description: Choose an organization to continue.
7
+ empty: You don't belong to any organization yet. Ask an administrator to add you to one.
data/config/routes.rb CHANGED
@@ -6,6 +6,8 @@ Moduler::Engine.routes.draw do
6
6
 
7
7
  resource :document_acceptance, only: %i[ new create ]
8
8
 
9
+ resources :organizations, only: :show
10
+
9
11
  resource :profile, only: %i[ edit update ], controller: :profile
10
12
  namespace :profile do
11
13
  namespace :sessions do
@@ -1,3 +1,3 @@
1
1
  module Moduler
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moduler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomasz Kowalewski
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-11-11 00:00:00.000000000 Z
10
+ date: 2026-11-12 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rails
@@ -221,6 +221,7 @@ files:
221
221
  - app/assets/javascripts/moduler/application.js
222
222
  - app/assets/javascripts/moduler/controllers/attachments_controller.js
223
223
  - app/assets/javascripts/moduler/controllers/dependent_select_controller.js
224
+ - app/assets/javascripts/moduler/controllers/dropdown_controller.js
224
225
  - app/assets/javascripts/moduler/controllers/flash_controller.js
225
226
  - app/assets/javascripts/moduler/controllers/select_all_controller.js
226
227
  - app/assets/javascripts/moduler/controllers/wysiwyg_controller.js
@@ -270,6 +271,7 @@ files:
270
271
  - app/components/moduler/sidebar_action_component.html.erb
271
272
  - app/components/moduler/sidebar_action_component.rb
272
273
  - app/controllers/concerns/moduler/authentication.rb
274
+ - app/controllers/concerns/moduler/organization_scoped.rb
273
275
  - app/controllers/concerns/moduler/require_document_acceptance.rb
274
276
  - app/controllers/concerns/moduler/restrict_administrator_access.rb
275
277
  - app/controllers/moduler/administration/application_controller.rb
@@ -288,6 +290,7 @@ files:
288
290
  - app/controllers/moduler/articles_controller.rb
289
291
  - app/controllers/moduler/document_acceptances_controller.rb
290
292
  - app/controllers/moduler/home_controller.rb
293
+ - app/controllers/moduler/organizations_controller.rb
291
294
  - app/controllers/moduler/profile/sent_emails_controller.rb
292
295
  - app/controllers/moduler/profile/sessions/revocation_controller.rb
293
296
  - app/controllers/moduler/profile/sessions_controller.rb
@@ -388,6 +391,7 @@ files:
388
391
  - app/views/moduler/articles/show.html.erb
389
392
  - app/views/moduler/common/_flash.html.erb
390
393
  - app/views/moduler/common/_header.html.erb
394
+ - app/views/moduler/common/_organization_switcher.html.erb
391
395
  - app/views/moduler/common/_sidebar.html.erb
392
396
  - app/views/moduler/common/administration/_sidebar.html.erb
393
397
  - app/views/moduler/common/profile/_sidebar.html.erb
@@ -395,6 +399,7 @@ files:
395
399
  - app/views/moduler/email_mailer/custom.html.erb
396
400
  - app/views/moduler/email_mailer/custom.text.erb
397
401
  - app/views/moduler/home/index.html.erb
402
+ - app/views/moduler/organizations/show.html.erb
398
403
  - app/views/moduler/profile/edit.html.erb
399
404
  - app/views/moduler/profile/sent_emails/index.html.erb
400
405
  - app/views/moduler/profile/sessions/_session.html.erb
@@ -416,6 +421,7 @@ files:
416
421
  - config/locales/moduler/components/en.yml
417
422
  - config/locales/moduler/document_acceptances/en.yml
418
423
  - config/locales/moduler/en.yml
424
+ - config/locales/moduler/home/en.yml
419
425
  - config/locales/moduler/models/en.yml
420
426
  - config/locales/moduler/profile/en.yml
421
427
  - config/locales/moduler/profile/sent_emails/en.yml