lato_spaces 3.1.21 → 3.1.23

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: be2bfe1d12ffd6a6776ed821ba3a87faa2ffa65f54172c6c6bd4c0f4b75369c6
4
- data.tar.gz: 198d5f7525775d514fb1d32ab02d9eb0568d6dc0732bb2a8b96798a4db4aff2a
3
+ metadata.gz: 962be7a6c98c4e07eb3b02e4e4c7747de019863f60ef35246855a0db34d25475
4
+ data.tar.gz: b6196760168336ebf3817fb12977b0b44f1ea7aae546ae46b7cbd52c8ad2e231
5
5
  SHA512:
6
- metadata.gz: 3980b1cb0f1061b1438c93e3ca4af49bc89da9d6cfb0d925a1bda773276434ede52a77ea16a9c0dc8b5c54893cc4d5824845ef923da7e5da1be791dd8ec118b1
7
- data.tar.gz: 1d12290c939338e0ead2a475991e091166fb005dc6fdf70acce97ccff654de32ce6a4a0476d9fe084189e2bb8865d385a1633094ae3191a55120ba5811e658d3
6
+ metadata.gz: e8e60a1a44ec88200bf32f67b0b32877777e8fbabcfd664021ae473170d0d5673a3ac6dbe49777e71fa288b24f61f02b77228020479118c92de17318d47752fa
7
+ data.tar.gz: 4f568b5532fce79862f4161a03cc02cd9f86f5d8b9bc7b2b872cd0633eb53fcbb2402d7946b4660cc73b4af89d4d11d1f95f223103116aa5bc00c3b56b13b01f
@@ -9,6 +9,22 @@ module LatoSpaces
9
9
  def index
10
10
  @memberships = LatoSpaces::Membership.where(lato_user_id: @session.user_id).order(created_at: :desc)
11
11
  @groups = LatoSpaces::Group.joins(:lato_spaces_memberships).where(lato_spaces_memberships: { lato_user_id: @session.user_id }).order(name: :asc)
12
+
13
+ if LatoSpaces.config.setgroup_auto_after_login_if_single && LatoSpaces.config.setgroup_redirect_path && @session.get(:spaces_group_id).blank? && @groups.size == 1
14
+ group_id = @groups.first&.id
15
+ if group_id && session_group_create(group_id)
16
+ redirect_to Rails.application.routes.url_helpers.send(LatoSpaces.config.setgroup_redirect_path)
17
+ return
18
+ end
19
+ end
20
+
21
+ if LatoSpaces.config.setgroup_auto_after_login && LatoSpaces.config.setgroup_redirect_path && @session.get(:spaces_group_id).blank?
22
+ group_id = @groups.first&.id
23
+ if group_id && session_group_create(group_id)
24
+ redirect_to Rails.application.routes.url_helpers.send(LatoSpaces.config.setgroup_redirect_path)
25
+ return
26
+ end
27
+ end
12
28
  end
13
29
 
14
30
  def setgroup
@@ -12,16 +12,22 @@ module LatoSpaces::AssociableRequired
12
12
  # Hooks
13
13
  ##
14
14
 
15
- after_create do
16
- lato_spaces_associations.create!(lato_spaces_group_id: lato_spaces_group_id)
15
+ after_create_commit do
16
+ unless lato_spaces_associations.create(lato_spaces_group_id: lato_spaces_group_id)
17
+ Rails.logger.error "Failed to create LatoSpaces association for #{self.class.name} with ID #{id} and group ID #{lato_spaces_group_id}"
18
+ end
17
19
  end
18
20
 
19
21
  # External hooks
20
22
  ##
21
23
 
22
24
  # listen LatoSpaces::Association destroy event to destroy item
23
- LatoSpaces::Association.after_destroy do |association|
24
- association.item&.destroy!
25
+ LatoSpaces::Association.after_destroy_commit do |association|
26
+ if association.item
27
+ unless association.item.destroy
28
+ Rails.logger.error "Failed to destroy #{association.item.class.name} with ID #{association.item_id} after LatoSpaces association destruction"
29
+ end
30
+ end
25
31
  end
26
32
  end
27
33
  end
@@ -7,6 +7,14 @@ module LatoSpaces
7
7
  # Path of the redirect after set group.
8
8
  attr_accessor :setgroup_redirect_path
9
9
 
10
+ # Auto-select first group after login.
11
+ # NOTE: Requires to set `setgroup_redirect_path` to work properly.
12
+ attr_accessor :setgroup_auto_after_login
13
+
14
+ # Auto-select first group after login only if user has a single group.
15
+ # NOTE: Requires to set `setgroup_redirect_path` to work properly.
16
+ attr_accessor :setgroup_auto_after_login_if_single
17
+
10
18
  # Icon of the group (bootstrap icon).
11
19
  attr_accessor :group_icon
12
20
 
@@ -16,10 +24,10 @@ module LatoSpaces
16
24
  # Params of the membership.
17
25
  attr_accessor :membership_params
18
26
 
19
- # Permit creation of groups for users.
27
+ # Permit creation of groups for users (not admins).
20
28
  attr_accessor :permit_group_creation
21
29
 
22
- # Permit management of groups for users.
30
+ # Permit management of groups for users (not admins).
23
31
  attr_accessor :permit_group_management
24
32
 
25
33
  # Permit users to choose a preferred group.
@@ -27,6 +35,8 @@ module LatoSpaces
27
35
 
28
36
  def initialize
29
37
  @setgroup_redirect_path = nil
38
+ @setgroup_auto_after_login = false
39
+ @setgroup_auto_after_login_if_single = false
30
40
  @group_icon = 'bi bi-people-fill'
31
41
  @group_params = %i[name]
32
42
  @membership_params = %i[email]
@@ -1,3 +1,3 @@
1
1
  module LatoSpaces
2
- VERSION = "3.1.21"
2
+ VERSION = "3.1.23"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lato_spaces
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.21
4
+ version: 3.1.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-04-03 00:00:00.000000000 Z
11
+ date: 2025-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails