lato_spaces 3.1.12 → 3.1.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f12e83b0826f21aecfc89708b32d15a34bea7c5d6618c443861114200e15688b
4
- data.tar.gz: bd43cb9d3e0f498189b55f64753a3f4fd0a0bb5adf42bf48fae656da8e861e3d
3
+ metadata.gz: d80fe5ed332a254476c5acc18325b22ee09c530134c6a1abb8b0d233917d19cd
4
+ data.tar.gz: 719dc9bfde39bce04240db5e1b97d473ab1f0f7584efe92b247d68884a15fbd8
5
5
  SHA512:
6
- metadata.gz: 21a35591b29ddcc5ff66049b79138ae0fd2992b5c4e50e79fb5cb1023681e0dd41823b8cc1ca47df2e985909cefcf4aa0c1bfb27e39175a15aa022e5f2365763
7
- data.tar.gz: cbef94da69e3eb4f9eaa3807706d35a457f5c9ba32e41f67ea04c2b83a532656994ab3303d0d789c5449e6f0fb983670eefe5195707d14c264b39d00fcb0cf48
6
+ metadata.gz: c2adf07563efb795fa4aa868f212ecfb7dbfa4729080a3e0ac820aa3600f06a3c9e5e86212be0cceb18f34a633491ebe252f9b7078c308b556a10c90f2409ab1
7
+ data.tar.gz: 310292be92d8431b694fb263feb0a66f03d01e3a8c8d3291d3505a234fce9ba4c9050171bb764ddb0b4af87aedcbfd38473e6bf2cbb0f8cb1e48f27b19b22dc4
@@ -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
@@ -4,7 +4,7 @@ module LatoSpaces
4
4
 
5
5
  def lato_spaces_group_actions(group)
6
6
  content_tag(:div, class: 'btn-group btn-group-sm') do
7
- concat link_to('View', lato_spaces.groups_show_path(group), class: 'btn btn-primary')
7
+ concat link_to(I18n.t('lato_spaces.cta_view'), lato_spaces.groups_show_path(group), class: 'btn btn-primary')
8
8
  end
9
9
  end
10
10
  end
@@ -17,9 +17,9 @@ module LatoSpaces
17
17
  def lato_spaces_membership_actions(membership)
18
18
  content_tag(:div, class: 'btn-group btn-group-sm') do
19
19
  if membership.lato_invitation
20
- concat link_to('Resend', lato_spaces.memberships_send_invite_action_path(membership), class: 'btn btn-primary', data: { turbo_confirm: 'Are you sure?', turbo_method: :post })
20
+ concat link_to(I18n.t('lato_spaces.cta_resend'), lato_spaces.memberships_send_invite_action_path(membership), class: 'btn btn-primary', data: { turbo_confirm: 'Are you sure?', turbo_method: :post })
21
21
  end
22
- concat link_to('Delete', lato_spaces.memberships_destroy_action_path(membership), class: 'btn btn-danger', data: { turbo_confirm: 'Are you sure?', turbo_method: :delete })
22
+ concat link_to(I18n.t('lato_spaces.cta_delete'), lato_spaces.memberships_destroy_action_path(membership), class: 'btn btn-danger', data: { turbo_confirm: 'Are you sure?', turbo_method: :delete })
23
23
  end
24
24
  end
25
25
  end
@@ -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 %>
@@ -11,7 +11,7 @@
11
11
  <%= render 'layouts/lato_spaces/group-form-extra_content', form: form %>
12
12
 
13
13
  <div class="d-flex justify-content-end">
14
- <%= lato_form_submit form, group.persisted? ? 'Update' : 'Confirm', class: %w[btn-success] %>
14
+ <%= lato_form_submit form, group.persisted? ? I18n.t('lato_spaces.cta_update') : I18n.t('lato_spaces.cta_confirm'), class: %w[btn-success] %>
15
15
  </div>
16
16
  <% end %>
17
17
  <% end %>
@@ -7,8 +7,8 @@
7
7
  <div class="card-header d-flex justify-content-between align-items-center">
8
8
  <h2 class="fs-4 mb-0"><%= I18n.t('lato_spaces.group_informations') %></h2>
9
9
  <div class="btn-group btn-group-sm" role="group">
10
- <%= link_to 'Edit', lato_spaces.groups_update_path(@group), class: 'btn btn-primary', data: { lato_action_target: 'trigger', turbo_frame: dom_id(@group, 'form'), action_title: I18n.t('lato_spaces.edit_group') } %>
11
- <%= link_to 'Delete', lato_spaces.groups_destroy_action_path(@group), class: 'btn btn-danger', data: { turbo_confirm: 'Are you sure?', turbo_method: :delete } %>
10
+ <%= link_to I18n.t('lato_spaces.cta_edit'), lato_spaces.groups_update_path(@group), class: 'btn btn-primary', data: { lato_action_target: 'trigger', turbo_frame: dom_id(@group, 'form'), action_title: I18n.t('lato_spaces.edit_group') } %>
11
+ <%= link_to I18n.t('lato_spaces.cta_delete'), lato_spaces.groups_destroy_action_path(@group), class: 'btn btn-danger', data: { turbo_confirm: 'Are you sure?', turbo_method: :delete } %>
12
12
  </div>
13
13
  </div>
14
14
  <div class="card-body">
@@ -26,7 +26,7 @@
26
26
  create: {
27
27
  path: lato_spaces.memberships_create_path(@group),
28
28
  icon: 'bi bi-plus',
29
- data: { lato_action_target: 'trigger', turbo_frame: dom_id(LatoSpaces::Membership.new, 'form'), action_title: 'New membership' }
29
+ data: { lato_action_target: 'trigger', turbo_frame: dom_id(LatoSpaces::Membership.new, 'form'), action_title: I18n.t('lato_spaces.new_membership') }
30
30
  }
31
31
  }
32
32
  %>
@@ -9,7 +9,7 @@
9
9
  </div>
10
10
 
11
11
  <div class="d-flex justify-content-end">
12
- <%= lato_form_submit form, 'Confirm', class: %w[btn-success] %>
12
+ <%= lato_form_submit form, I18n.t('lato_spaces.cta_confirm'), class: %w[btn-success] %>
13
13
  </div>
14
14
  <% end %>
15
15
  <% end %>
@@ -1,6 +1,6 @@
1
- <%= lato_page_head 'New membership', [
1
+ <%= lato_page_head I18n.t('lato_spaces.new_membership'), [
2
2
  { label: I18n.t('lato_spaces.spaces'), path: lato_spaces.root_path },
3
- { label: 'Groups', path: lato_spaces.groups_path },
3
+ { label: I18n.t('lato_spaces.groups'), path: lato_spaces.groups_path },
4
4
  { label: @group.name, path: lato_spaces.groups_show_path(@group) }
5
5
  ] %>
6
6
 
@@ -11,6 +11,13 @@ en:
11
11
  group_members: Group members
12
12
  group_informations: Group informations
13
13
  cta_new_group: Create new group
14
+ cta_view: View
15
+ cta_confirm: Confirm
16
+ cta_update: Update
17
+ cta_edit: Edit
18
+ cta_delete: Delete
19
+ cta_resend: Resend
20
+ new_membership: New membership
14
21
  activerecord:
15
22
  attributes:
16
23
  lato_spaces/membership:
@@ -0,0 +1,28 @@
1
+ it:
2
+ lato_spaces:
3
+ space: Space
4
+ spaces: Spaces
5
+ group: Gruppo
6
+ groups: Gruppi
7
+ welcome: Ciao <b>%{user}</b>!<b> Seleziona il gruppo</b> con cui vuoi lavorare.
8
+ cta_manage_groups: Gestisci gruppi
9
+ new_group: Nuovo gruppo
10
+ edit_group: Modifica gruppo
11
+ group_members: Membri del gruppo
12
+ group_informations: Informazioni del gruppo
13
+ cta_new_group: Crea nuovo gruppo
14
+ cta_view: Visualizza
15
+ cta_confirm: Conferma
16
+ cta_update: Aggiorna
17
+ cta_edit: Modifica
18
+ cta_delete: Cancella
19
+ cta_resend: Reinvia
20
+ new_membership: Nuova iscrizione
21
+ activerecord:
22
+ attributes:
23
+ lato_spaces/group:
24
+ name: Nome
25
+ actions: Azioni
26
+ lato_spaces/membership:
27
+ user_infos: Utente
28
+ actions: Azioni
data/config/routes.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  LatoSpaces::Engine.routes.draw do
2
2
  root 'application#index'
3
3
  post 'setgroup/:id', to: 'application#setgroup', as: :setgroup
4
+ post 'setpreferred/:id', to: 'application#setpreferred', as: :setpreferred
4
5
 
5
6
  scope :groups do
6
7
  get '', to: 'groups#index', as: :groups
@@ -0,0 +1,5 @@
1
+ class AddPreferredToLatoSpacesMembership < ActiveRecord::Migration[7.1]
2
+ def change
3
+ add_column :lato_spaces_memberships, :preferred, :boolean, default: false
4
+ end
5
+ end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module LatoSpaces
2
- VERSION = "3.1.12"
2
+ VERSION = "3.1.14"
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.12
4
+ version: 3.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregorio Galante
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-09 00:00:00.000000000 Z
11
+ date: 2023-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -77,11 +77,13 @@ files:
77
77
  - app/views/layouts/lato_spaces/_group-form-extra_content.html.erb
78
78
  - app/views/layouts/lato_spaces/_group-informations_content.html.erb
79
79
  - config/locales/en.yml
80
+ - config/locales/it.yml
80
81
  - config/routes.rb
81
82
  - db/migrate/20231101082505_add_lato_spaces_admin_to_lato_user.rb
82
83
  - db/migrate/20231102082229_create_lato_spaces_groups.rb
83
84
  - db/migrate/20231102082236_create_lato_spaces_memberships.rb
84
85
  - db/migrate/20231129183145_create_lato_spaces_associations.rb
86
+ - db/migrate/20231215220127_add_preferred_to_lato_spaces_membership.rb
85
87
  - lib/lato_spaces.rb
86
88
  - lib/lato_spaces/config.rb
87
89
  - lib/lato_spaces/engine.rb