lato_spaces 3.1.13 → 3.1.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/lato_spaces/application_controller.rb +15 -0
- data/app/models/concerns/lato_spaces/associable_required.rb +1 -1
- data/app/models/lato_spaces/membership.rb +9 -0
- data/app/views/lato_spaces/application/index.html.erb +8 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20231215220127_add_preferred_to_lato_spaces_membership.rb +5 -0
- data/lib/lato_spaces/config.rb +4 -0
- data/lib/lato_spaces/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9da28e9c32f14cffd625de68cb55fa7e46583e71f946e650eea34ca503bc74fa
|
4
|
+
data.tar.gz: c4d82e9ab8da5e591122208cd594c85836c9e99293856dd14b456fc41acabf3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d2cdb9a0fadd1e570dc8b60d86fa4c2b8dd4e9d9447e6a9768ee0262e59b77deb459f063decac09ae51ffd9b90752f5a58609d37269e3cdaa1c931ed8c1ed6c
|
7
|
+
data.tar.gz: 288980d9592b0d6c75b4ccfbd7b896a3ca5b306a126d20b0c051bb46af1e997f70183f262a3f998d9cbe11e483cb5106735ae90040c142c6b084d9b024184484
|
@@ -7,6 +7,7 @@ module LatoSpaces
|
|
7
7
|
before_action { active_sidebar(:lato_spaces); active_navbar(:lato_spaces) }
|
8
8
|
|
9
9
|
def index
|
10
|
+
@memberships = LatoSpaces::Membership.where(lato_user_id: @session.user_id).order(created_at: :desc)
|
10
11
|
@groups = LatoSpaces::Group.joins(:lato_spaces_memberships).where(lato_spaces_memberships: { lato_user_id: @session.user_id }).order(name: :asc)
|
11
12
|
end
|
12
13
|
|
@@ -24,6 +25,20 @@ module LatoSpaces
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
def setpreferred
|
29
|
+
membership = LatoSpaces::Membership.find_by(lato_user_id: @session.user_id, lato_spaces_group_id: params[:id])
|
30
|
+
|
31
|
+
respond_to do |format|
|
32
|
+
if membership&.set_preferred
|
33
|
+
format.html { redirect_to lato_spaces.root_path }
|
34
|
+
format.json { render json: {} }
|
35
|
+
else
|
36
|
+
format.html { redirect_to lato_spaces.root_path, alert: 'Error on changing preferred group.' }
|
37
|
+
format.json { render json: { error: 'Error on changing preferred group.' }, status: :unprocessable_entity }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
27
42
|
protected
|
28
43
|
|
29
44
|
def authenticate_lato_spaces_admin
|
@@ -78,6 +78,15 @@ module LatoSpaces
|
|
78
78
|
# Operations
|
79
79
|
##
|
80
80
|
|
81
|
+
def set_preferred
|
82
|
+
ActiveRecord::Base.transaction do
|
83
|
+
LatoSpaces::Membership.where(lato_user_id: lato_user_id).update_all(preferred: false)
|
84
|
+
update!(preferred: true)
|
85
|
+
end
|
86
|
+
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
81
90
|
def send_invite
|
82
91
|
if lato_invitation.blank? || lato_user.present?
|
83
92
|
errors.add(:base, 'This user is already a member of this space.')
|
@@ -6,6 +6,7 @@
|
|
6
6
|
<div class="row">
|
7
7
|
<% @groups.each do |group| %>
|
8
8
|
<% is_selected = @session.get(:spaces_group_id)&.to_i == group.id %>
|
9
|
+
<% is_preferred = @memberships.find { |m| m.lato_spaces_group_id == group.id }&.preferred %>
|
9
10
|
|
10
11
|
<div class="col col-12 col-lg-6 col-lg-4 col-xl-3 mb-3">
|
11
12
|
<div class="card h-100 border border-4 <%= is_selected ? 'border-success' : 'border-light' %>">
|
@@ -21,6 +22,13 @@
|
|
21
22
|
<i class="bi bi-gear"></i>
|
22
23
|
<% end %>
|
23
24
|
<% end %>
|
25
|
+
|
26
|
+
<% if LatoSpaces.config.permit_group_preferred %>
|
27
|
+
<%= link_to lato_spaces.setpreferred_path(group), class: "btn btn-#{is_preferred ? 'warning' : 'light'} ms-1 me-1", data: { turbo_method: :post } do %>
|
28
|
+
<i class="bi bi-star<%= is_preferred ? '-fill' : '' %>"></i>
|
29
|
+
<% end %>
|
30
|
+
<% end %>
|
31
|
+
|
24
32
|
<%= link_to lato_spaces.setgroup_path(group), class: "btn btn-#{is_selected ? 'success' : 'primary'} ms-1", data: { turbo_method: :post } do %>
|
25
33
|
<i class="bi bi-check-circle<%= is_selected ? '-fill' : '' %>"></i>
|
26
34
|
<% end %>
|
data/config/routes.rb
CHANGED
data/lib/lato_spaces/config.rb
CHANGED
@@ -18,6 +18,9 @@ module LatoSpaces
|
|
18
18
|
|
19
19
|
# Permit management of groups for users.
|
20
20
|
attr_accessor :permit_group_management
|
21
|
+
|
22
|
+
# Permit users to choose a preferred group.
|
23
|
+
attr_accessor :permit_group_preferred
|
21
24
|
|
22
25
|
def initialize
|
23
26
|
@setgroup_redirect_path = nil
|
@@ -25,6 +28,7 @@ module LatoSpaces
|
|
25
28
|
@group_params = %i[name]
|
26
29
|
@permit_group_creation = false
|
27
30
|
@permit_group_management = false
|
31
|
+
@permit_group_preferred = false
|
28
32
|
end
|
29
33
|
end
|
30
34
|
end
|
data/lib/lato_spaces/version.rb
CHANGED
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.
|
4
|
+
version: 3.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregorio Galante
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- db/migrate/20231102082229_create_lato_spaces_groups.rb
|
84
84
|
- db/migrate/20231102082236_create_lato_spaces_memberships.rb
|
85
85
|
- db/migrate/20231129183145_create_lato_spaces_associations.rb
|
86
|
+
- db/migrate/20231215220127_add_preferred_to_lato_spaces_membership.rb
|
86
87
|
- lib/lato_spaces.rb
|
87
88
|
- lib/lato_spaces/config.rb
|
88
89
|
- lib/lato_spaces/engine.rb
|
@@ -109,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
110
|
- !ruby/object:Gem::Version
|
110
111
|
version: '0'
|
111
112
|
requirements: []
|
112
|
-
rubygems_version: 3.4.
|
113
|
+
rubygems_version: 3.4.10
|
113
114
|
signing_key:
|
114
115
|
specification_version: 4
|
115
116
|
summary: Summary of LatoSpaces.
|