lesli_bell 0.2.0 → 1.0.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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/lesli_bell/application.js +1 -4337
  3. data/app/assets/stylesheets/lesli_bell/application.css +3 -3
  4. data/app/controllers/lesli_bell/announcements_controller.rb +16 -1
  5. data/app/controllers/lesli_bell/dashboards_controller.rb +26 -49
  6. data/app/controllers/lesli_bell/notifications_controller.rb +7 -12
  7. data/app/models/lesli_bell/announcement/user.rb +6 -0
  8. data/app/models/lesli_bell/announcement.rb +12 -2
  9. data/app/models/lesli_bell/dashboard.rb +38 -2
  10. data/app/models/lesli_bell/notification.rb +15 -16
  11. data/app/services/lesli_bell/announcement_service.rb +84 -0
  12. data/app/services/lesli_bell/notification_service.rb +46 -51
  13. data/app/views/lesli_bell/announcements/index.html.erb +30 -11
  14. data/app/views/lesli_bell/dashboards/edit.html.erb +30 -7
  15. data/app/views/lesli_bell/dashboards/show.html.erb +33 -1
  16. data/app/views/lesli_bell/notifications/index.html.erb +65 -1
  17. data/app/views/lesli_bell/partials/{_engine-navigation.html.erb → _navigation.html.erb} +1 -1
  18. data/config/locales/translations.en.yml +1 -26
  19. data/config/locales/translations.es.yml +1 -26
  20. data/config/locales/translations.fr.yml +1 -26
  21. data/config/locales/translations.it.yml +1 -26
  22. data/config/locales/translations.pt.yml +1 -26
  23. data/config/routes.rb +3 -4
  24. data/db/migrate/v1.0/0308000110_create_lesli_bell_accounts.rb +1 -6
  25. data/db/migrate/v1.0/0308003010_create_lesli_bell_dashboards.rb +37 -0
  26. data/db/migrate/v1.0/0308100110_create_lesli_bell_notifications.rb +0 -2
  27. data/db/migrate/v1.0/0308110110_create_lesli_bell_announcements.rb +2 -2
  28. data/db/migrate/v1.0/0308110310_create_lesli_bell_announcement_users.rb +6 -7
  29. data/db/seed/announcements.rb +47 -0
  30. data/db/seed/notifications.rb +53 -0
  31. data/db/seed/seeds.json +36 -0
  32. data/db/seeds.rb +7 -12
  33. data/lib/lesli_bell/version.rb +2 -2
  34. data/lib/vue/application.js +6 -6
  35. data/lib/vue/apps/announcements/index.vue +49 -28
  36. data/lib/vue/apps/notifications/index.vue +4 -8
  37. data/lib/vue/stores/announcement.js +36 -31
  38. data/lib/vue/stores/translations.json +55 -15
  39. data/readme.md +31 -17
  40. metadata +10 -27
  41. data/app/views/lesli_bell/announcements/_announcement.html.erb +0 -2
  42. data/app/views/lesli_bell/announcements/_form.html.erb +0 -17
  43. data/app/views/lesli_bell/dashboards/_dashboard.html.erb +0 -2
  44. data/app/views/lesli_bell/dashboards/_form.html.erb +0 -17
  45. data/app/views/lesli_bell/dashboards/index.html.erb +0 -14
  46. data/app/views/lesli_bell/dashboards/new.html.erb +0 -9
  47. data/db/seed/development.rb +0 -59
  48. data/db/seed/production.rb +0 -0
  49. data/db/seed/test.rb +0 -0
@@ -1,4 +1,4 @@
1
- /*!********************************************************************************************************************************************************!*\
2
- !*** css ./node_modules/css-loader/dist/cjs.js??clonedRuleSet-19.use[1]!./node_modules/sass-loader/dist/cjs.js!../LesliBell/lib/scss/application.scss ***!
3
- \********************************************************************************************************************************************************/
1
+ /*!***********************************************************************************************************************************************************!*\
2
+ !*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./node_modules/sass-loader/dist/cjs.js!../LesliBell/lib/scss/application.scss ***!
3
+ \***********************************************************************************************************************************************************/
4
4
 
@@ -2,9 +2,24 @@ module LesliBell
2
2
  class AnnouncementsController < ApplicationController
3
3
  before_action :set_announcement, only: %i[ show edit update destroy ]
4
4
 
5
+ # GET /announcements/list
6
+ def list
7
+ respond_to do |format|
8
+ format.html { }
9
+ format.json {
10
+ respond_with_pagination(AnnouncementService.new(current_user, query).list)
11
+ }
12
+ end
13
+ end
14
+
5
15
  # GET /announcements
6
16
  def index
7
- @announcements = Announcement.all
17
+ respond_to do |format|
18
+ format.html { }
19
+ format.json {
20
+ respond_with_pagination(AnnouncementService.new(current_user, query).index)
21
+ }
22
+ end
8
23
  end
9
24
 
10
25
  # GET /announcements/1
@@ -1,59 +1,36 @@
1
- module LesliBell
2
- class DashboardsController < ApplicationController
3
- #before_action :set_dashboard, only: %i[ show edit update destroy ]
1
+ =begin
4
2
 
5
- # GET /dashboards
6
- def index
7
- end
3
+ Lesli
8
4
 
9
- # GET /dashboards/1
10
- def show
11
- end
5
+ Copyright (c) 2025, Lesli Technologies, S. A.
12
6
 
13
- # GET /dashboards/new
14
- def new
15
- @dashboard = Dashboard.new
16
- end
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
17
11
 
18
- # GET /dashboards/1/edit
19
- def edit
20
- end
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
21
16
 
22
- # POST /dashboards
23
- def create
24
- @dashboard = Dashboard.new(dashboard_params)
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
25
19
 
26
- if @dashboard.save
27
- redirect_to @dashboard, notice: "Dashboard was successfully created."
28
- else
29
- render :new, status: :unprocessable_entity
30
- end
31
- end
20
+ Lesli · Ruby on Rails SaaS Development Framework.
32
21
 
33
- # PATCH/PUT /dashboards/1
34
- def update
35
- if @dashboard.update(dashboard_params)
36
- redirect_to @dashboard, notice: "Dashboard was successfully updated.", status: :see_other
37
- else
38
- render :edit, status: :unprocessable_entity
39
- end
40
- end
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
41
24
 
42
- # DELETE /dashboards/1
43
- def destroy
44
- @dashboard.destroy
45
- redirect_to dashboards_url, notice: "Dashboard was successfully destroyed.", status: :see_other
46
- end
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
47
32
 
48
- private
49
- # Use callbacks to share common setup or constraints between actions.
50
- def set_dashboard
51
- @dashboard = Dashboard.find(params[:id])
52
- end
53
-
54
- # Only allow a list of trusted parameters through.
55
- def dashboard_params
56
- params.fetch(:dashboard, {})
57
- end
58
- end
33
+ module LesliBell
34
+ class DashboardsController < Lesli::Shared::DashboardsController
35
+ end
59
36
  end
@@ -4,12 +4,7 @@ module LesliBell
4
4
 
5
5
  # GET /notifications
6
6
  def index
7
- respond_to do |format|
8
- format.html { }
9
- format.json {
10
- respond_with_pagination(NotificationService.new(current_user, query).index)
11
- }
12
- end
7
+ @notifications = respond_as_pagination(NotificationService.new(current_user, query).index)
13
8
  end
14
9
 
15
10
  # GET /notifications/1
@@ -37,11 +32,9 @@ module LesliBell
37
32
 
38
33
  # PATCH/PUT /notifications/1
39
34
  def update
40
- if @notification.update(notification_params)
41
- redirect_to @notification, notice: "Notification was successfully updated.", status: :see_other
42
- else
43
- render :edit, status: :unprocessable_entity
44
- end
35
+ NotificationService.new(current_user).read(params[:id])
36
+ @notifications = respond_as_pagination(NotificationService.new(current_user, query).index)
37
+ render :index
45
38
  end
46
39
 
47
40
  # DELETE /notifications/1
@@ -58,7 +51,9 @@ module LesliBell
58
51
 
59
52
  # Only allow a list of trusted parameters through.
60
53
  def notification_params
61
- params.fetch(:notification, {})
54
+ params.require(:notification).permit(
55
+ :id
56
+ )
62
57
  end
63
58
  end
64
59
  end
@@ -0,0 +1,6 @@
1
+ module LesliBell
2
+ class Announcement::User < ApplicationRecord
3
+ belongs_to :announcement #, class_name: "CloudBell::Announcement", foreign_key: "cloud_bell_announcements_id", optional: false
4
+ #belongs_to :user, class_name: "Lesli::User", foreign_key: "users_id"
5
+ end
6
+ end
@@ -1,4 +1,14 @@
1
1
  module LesliBell
2
- class Announcement < ApplicationRecord
3
- end
2
+ class Announcement < ApplicationRecord
3
+ belongs_to :account, class_name: "LesliBell::Account"
4
+ belongs_to :user, class_name: "::Lesli::User"
5
+ has_many :users #, class_name: "::Lesli::User"
6
+
7
+ enum category: {
8
+ :info => 'info',
9
+ :danger => 'danger',
10
+ :warning => 'warning',
11
+ :success => 'success'
12
+ }
13
+ end
4
14
  end
@@ -1,4 +1,40 @@
1
+ =begin
2
+
3
+ Lesli
4
+
5
+ Copyright (c) 2025, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ =end
32
+
1
33
  module LesliBell
2
- class Dashboard < ApplicationRecord
3
- end
34
+ class Dashboard < Lesli::Shared::Dashboard
35
+ self.table_name = "lesli_bell_dashboards"
36
+ belongs_to :account
37
+
38
+ COMPONENTS = %i[]
39
+ end
4
40
  end
@@ -3,26 +3,25 @@ module LesliBell
3
3
  belongs_to :account, class_name: "LesliBell::Account"
4
4
  belongs_to :user, class_name: "::Lesli::User"
5
5
 
6
-
7
- enum category: {
8
- info: "info",
9
- danger: "danger",
10
- warning: "warning",
11
- success: "success"
6
+ enum :category, {
7
+ :info => 'info',
8
+ :danger => 'danger',
9
+ :warning => 'warning',
10
+ :success => 'success'
12
11
  }
13
12
 
14
- enum channel: {
15
- push: "push", # webpush & mobilepush
16
- email: "email", # notification sent by email only
17
- webpush: "webpush", # notification for web interface only
18
- mobilepush: "mobilepush", # notification for mobile only
19
- mobiledialog: "mobiledialog", # open a dialog in the main app screen
13
+ enum :channel, {
14
+ :web => 'web', # notification for web interface only
15
+ :push => 'push', # webpush & mobilepush
16
+ :email => 'email', # notification sent by email only
17
+ :dialog => 'dialog', # open a dialog in the main app screen
18
+ :mobile => 'mobile' # notification for mobile only
20
19
  }
21
20
 
22
- enum status: {
23
- read: "read",
24
- sent: "sent",
25
- created: "created"
21
+ enum :status, {
22
+ :created => 'created',
23
+ :sent => 'sent',
24
+ :read => 'read'
26
25
  }
27
26
  end
28
27
  end
@@ -0,0 +1,84 @@
1
+ module LesliBell
2
+ class AnnouncementService < Lesli::ApplicationLesliService
3
+
4
+ def list
5
+
6
+ # NOTE: the query must be created in this specific order, if not ActiveRecord creates weird sql
7
+ # due the OR statement we are usign to get the announcements with a path
8
+
9
+ # Get all the announcements for the current user
10
+ announcements = current_user.account.bell.announcements
11
+
12
+ # joining to the announcement_users table, to see if the users already mark the announcement as read
13
+ announcements = announcements.left_joins(:users)
14
+
15
+ # get the announcements without a specific path (global announcements)
16
+ announcements = announcements.where(path: nil)
17
+
18
+ # get the announcements with a specific path (to show only in a specific page)
19
+ #announcements = announcements.or(Announcement.where("path = ?", filters[:base_path])) if params.dig(:f, :base_path)
20
+
21
+ # get the announcements with a start date greater than or equal to current date and with expiration date less or equal than current date
22
+ # announcements = announcements.where("start_at <= '#{Date.now.end_of_day}' or start_at is NULL")
23
+ # .where("cloud_bell_announcements.end_at >= '#{LC::Date.now.beginning_of_day}' or end_at is NULL")
24
+
25
+ # get the announcements that are not marked as read by the user
26
+ announcements = announcements.where(users: { id: nil })
27
+
28
+ announcements.select(
29
+ :id,
30
+ :name,
31
+ :category,
32
+ :message,
33
+ :can_be_closed,
34
+ :start_at,
35
+ :end_at,
36
+ :path
37
+ ).page(query[:pagination][:page])
38
+ .per(query[:pagination][:perPage])
39
+ .order(:start_at)
40
+ end
41
+
42
+ def index
43
+
44
+ # work with all notifications
45
+ announcements = current_user.account.bell
46
+ .announcements
47
+ .order(:start_at)
48
+
49
+ # add pagination
50
+ announcements
51
+ .page(query[:pagination][:page])
52
+ .per(query[:pagination][:perPage])
53
+ .order(:updated_at)
54
+ end
55
+
56
+ def create(
57
+ announcements_params,
58
+ send_to_role_ids:nil,
59
+ send_to_user_ids:nil,
60
+ send_to_user_emails:nil
61
+ )
62
+
63
+ users = []
64
+
65
+ unless Announcement.categories.key?(announcements_params[:category])
66
+ announcements_params[:category] = :info
67
+ end
68
+
69
+ announcements_params[:user_id] = current_user.id
70
+
71
+ announcement = current_user.account.bell.announcements.create!(announcements_params)
72
+
73
+ self.resource = announcement
74
+
75
+ self
76
+ end
77
+
78
+ def read id
79
+ noti = current_user.account.bell.notifications.where(:id => id, :user => current_user)
80
+ noti.update(:status => :read)
81
+ self
82
+ end
83
+ end
84
+ end
@@ -1,6 +1,18 @@
1
1
  module LesliBell
2
2
  class NotificationService < Lesli::ApplicationLesliService
3
3
 
4
+ def count
5
+ current_user.account.bell.notifications
6
+ .where(:user => current_user)
7
+ .where(status: nil)
8
+ .or(
9
+ current_user.account.bell.notifications
10
+ .where(user: current_user)
11
+ .where.not(status: 'read')
12
+ )
13
+ .count
14
+ end
15
+
4
16
  def index only_own_notifications=true
5
17
 
6
18
  notifications = []
@@ -22,66 +34,49 @@ module LesliBell
22
34
  .order(:updated_at)
23
35
 
24
36
  return notifications
37
+ end
25
38
 
26
- # LC::Response.pagination(
27
- # notifications.current_page,
28
- # notifications.total_pages,
29
- # notifications.total_count,
30
- # notifications.length,
31
- # notifications.map do |notification|
32
- # {
33
- # id: notification[:id],
34
- # url: notification[:url],
35
- # body: notification[:body],
36
- # subject: notification[:subject],
37
- # category: notification[:category],
38
- # created_at: LC::Date.distance_to_words(notification[:created_at]),
39
- # status: notification[:status],
40
- # }
41
- # end
42
- # )
43
-
39
+ def create_for_me notification_params
40
+ self.create(notification_params, send_to_user_ids: [current_user.id])
44
41
  end
45
42
 
46
43
  def create(
47
- subject,
48
- url:nil,
49
- body:nil,
50
- media:nil,
51
- payload:nil,
52
- channel:nil,
53
- category:nil,
54
- user_receiver_id:nil,
55
- notification_type:nil,
56
- role_receiver_names:nil,
57
- user_receiver_emails:nil
44
+ notification_params,
45
+ send_to_role_ids:nil,
46
+ send_to_user_ids:nil,
47
+ send_to_user_emails:nil
58
48
  )
59
49
 
60
- # validate that the notifications has a valid category
61
- category = 'info' if not ['info', 'danger', 'warning', 'success'].include?(category)
62
-
63
- # set push (web and mobile) notifications as default channel
64
- channel = 'push' unless channel
65
-
66
- # base notification data
67
- notification_params = {
68
- url: url,
69
- body: body,
70
- media: media,
71
- payload: payload,
72
- channel: channel,
73
- subject: subject,
74
- category: category,
75
- notification_type: notification_type,
76
- status: 'created',
77
- user: current_user
78
- }
79
-
50
+ users = []
51
+ notifications = []
52
+
53
+ unless Notification.categories.key?(notification_params[:category])
54
+ notification_params[:category] = :info
55
+ end
56
+
57
+ unless Notification.channels.key?(notification_params[:channel])
58
+ notification_params[:channel] = :web
59
+ end
60
+
61
+ send_to_user_ids.each do |user|
62
+ notifications.push({
63
+ **notification_params,
64
+ user_id: user,
65
+ })
66
+ end
67
+
80
68
  # "bulk insert" all the notifications
81
- notifications = current_user.account.bell.notifications.create([notification_params])
69
+ current_user.account.bell.notifications.create!(notifications)
82
70
 
83
- return { id: notifications.map(&:id) }
71
+ self.resource = { id: notifications.map{ |n| n[:user_id] } }
84
72
 
73
+ self
85
74
  end
75
+
76
+ def read id
77
+ noti = current_user.account.bell.notifications.where(:id => id, :user => current_user)
78
+ noti.update(:status => :read)
79
+ self
80
+ end
86
81
  end
87
82
  end
@@ -1,14 +1,33 @@
1
- <p style="color: green"><%= notice %></p>
1
+ <%#
2
2
 
3
- <h1>Announcements</h1>
3
+ Lesli
4
4
 
5
- <div id="announcements">
6
- <% @announcements.each do |announcement| %>
7
- <%= render announcement %>
8
- <p>
9
- <%= link_to "Show this announcement", announcement %>
10
- </p>
11
- <% end %>
12
- </div>
5
+ Copyright (c) 2023, Lesli Technologies, S. A.
13
6
 
14
- <%= link_to "New announcement", new_announcement_path %>
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ %>
32
+
33
+ <router-view></router-view>
@@ -1,10 +1,33 @@
1
- <h1>Editing dashboard</h1>
1
+ <%#
2
2
 
3
- <%= render "form", dashboard: @dashboard %>
3
+ Lesli
4
4
 
5
- <br>
5
+ Copyright (c) 2025, Lesli Technologies, S. A.
6
6
 
7
- <div>
8
- <%= link_to "Show this dashboard", @dashboard %> |
9
- <%= link_to "Back to dashboards", dashboards_path %>
10
- </div>
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ %>
32
+
33
+ <%= render("/lesli/shared/dashboards/edit") %>
@@ -1 +1,33 @@
1
- <router-view></router-view>
1
+ <%#
2
+
3
+ Lesli
4
+
5
+ Copyright (c) 2025, Lesli Technologies, S. A.
6
+
7
+ This program is free software: you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License as published by
9
+ the Free Software Foundation, either version 3 of the License, or
10
+ (at your option) any later version.
11
+
12
+ This program is distributed in the hope that it will be useful,
13
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ GNU General Public License for more details.
16
+
17
+ You should have received a copy of the GNU General Public License
18
+ along with this program. If not, see http://www.gnu.org/licenses/.
19
+
20
+ Lesli · Ruby on Rails SaaS Development Framework.
21
+
22
+ Made with ♥ by LesliTech
23
+ Building a better future, one line of code at a time.
24
+
25
+ @contact hello@lesli.tech
26
+ @website https://www.lesli.tech
27
+ @license GPLv3 http://www.gnu.org/licenses/gpl-3.0.en.html
28
+
29
+ // · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
30
+ // ·
31
+ %>
32
+
33
+ <%= render("/lesli/shared/dashboards/show") %>
@@ -30,4 +30,68 @@ Building a better future, one line of code at a time.
30
30
  // ·
31
31
  %>
32
32
 
33
- <router-view></router-view>
33
+ <style>
34
+ .notification.is-danger.is-light {
35
+ border: 2px solid hsl(var(--bulma-notification-h), var(--bulma-notification-s), var(--bulma-notification-color-l))
36
+ }
37
+
38
+ .notification.is-warning.is-light {
39
+ border: 2px solid hsl(var(--bulma-notification-h), var(--bulma-notification-s), var(--bulma-notification-color-l));
40
+ }
41
+
42
+ .notification.is-success.is-light {
43
+ border: 2px solid hsl(var(--bulma-notification-h), var(--bulma-notification-s), var(--bulma-notification-color-l));
44
+ }
45
+
46
+ .notification.is-info.is-light {
47
+ border: 2px solid hsl(var(--bulma-notification-h), var(--bulma-notification-s), var(--bulma-notification-color-l));
48
+ }
49
+ </style>
50
+
51
+ <%= render(LesliView::Layout::Container.new("lesli-bell-notifications-index")) do %>
52
+
53
+ <%= render(LesliView::Components::Header.new("Notifications")) do %>
54
+ <%= render(LesliView::Elements::Button.new("mark all as read", icon:"check", solid: true)) %>
55
+ <% end %>
56
+
57
+ <%= render(LesliView::Components::Toolbar.new) %>
58
+
59
+ <% if @notifications.size == 0 %>
60
+ <%= render(LesliView::Elements::Empty.new) %>
61
+ <% else %>
62
+ <section class="notifications">
63
+ <% @notifications[:records].each do |notification| %>
64
+ <div class="notification is-<%= notification[:category] %> is-light mb-2">
65
+
66
+ <!-- Close button -->
67
+ <%= button_to(
68
+ notification_path(notification[:id]),
69
+ method: :put,
70
+ class: "button is-small is-#{notification[:category]}",
71
+ form: { class: "delete" }) do %>
72
+ <span class="icon">
73
+ <span class="material-icons">close</span>
74
+ </span>
75
+ <% end %>
76
+
77
+ <!-- Notification subject -->
78
+ <strong><%= notification[:subject] %></strong>
79
+
80
+ <!-- Notification body (optional) -->
81
+ <% if notification[:body].present? %>
82
+ <p><%= notification[:body] %></p>
83
+ <% end %>
84
+
85
+ <!-- Notification URL (optional) -->
86
+ <% if notification[:url].present? %>
87
+ <p>
88
+ <a href="<%= notification[:url] %>" target="_blank" rel="noopener noreferrer">
89
+ <%= notification[:url] %>
90
+ </a>
91
+ </p>
92
+ <% end %>
93
+ </div>
94
+ <% end %>
95
+ </section>
96
+ <% end %>
97
+ <% end %>