lesli 5.0.22 → 5.0.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 +4 -4
- data/Rakefile +1 -2
- data/app/assets/config/lesli_manifest.js +2 -2
- data/app/assets/images/lesli/brand/register-background.jpg +0 -0
- data/app/assets/stylesheets/lesli/application.css +1 -0
- data/app/controllers/lesli/abouts_controller.rb +12 -13
- data/app/controllers/lesli/application_controller.rb +1 -42
- data/app/controllers/lesli/application_lesli_controller.rb +8 -1
- data/app/controllers/lesli/apps_controller.rb +25 -0
- data/app/controllers/lesli/items/actions_controller.rb +122 -0
- data/app/{models/lesli/item/activity.rb → controllers/lesli/items/activities_controller.rb} +2 -2
- data/app/controllers/lesli/items/discussions_controller.rb +93 -0
- data/app/controllers/lesli/{system_controllers_controller.rb → resources_controller.rb} +3 -3
- data/app/controllers/lesli/shared/dashboards_controller.rb +11 -279
- data/app/helpers/lesli/customization_helper.rb +3 -3
- data/app/helpers/lesli/html_helper.rb +114 -2
- data/app/helpers/lesli/navigation_helper.rb +8 -25
- data/app/helpers/lesli/system_helper.rb +21 -4
- data/app/helpers/lesli/turbo_helper.rb +19 -2
- data/app/interfaces/lesli/requester_interface.rb +2 -29
- data/app/interfaces/lesli/responder_interface.rb +121 -61
- data/app/models/concerns/lesli/account_initializer.rb +13 -13
- data/{lib/rspec/factories/lesli_account.rb → app/models/concerns/lesli/account_logs.rb} +23 -9
- data/app/models/concerns/lesli/user_extensions.rb +33 -51
- data/app/models/lesli/account.rb +6 -5
- data/app/models/lesli/application_lesli_record.rb +14 -0
- data/app/models/lesli/items/action.rb +15 -0
- data/app/models/lesli/items/activity.rb +50 -0
- data/app/models/lesli/items/discussion.rb +15 -0
- data/app/models/lesli/{user/journal.rb → resource.rb} +9 -4
- data/app/models/lesli/role.rb +2 -17
- data/app/models/lesli/shared/dashboard.rb +1 -0
- data/app/models/lesli/user.rb +23 -77
- data/app/services/lesli/application_lesli_service.rb +21 -4
- data/app/{operators/lesli/controller_operator.rb → services/lesli/resource_service.rb} +92 -23
- data/app/services/lesli/role_service.rb +15 -9
- data/app/services/lesli/user_service.rb +28 -27
- data/app/views/lesli/apps/show.html.erb +1 -1
- data/app/views/lesli/errors/not_found.html.erb +1 -1
- data/app/views/lesli/errors/unauthorized.html.erb +9 -11
- data/app/views/lesli/layouts/application-devise.html.erb +5 -5
- data/app/views/lesli/layouts/application-lesli.html.erb +8 -7
- data/app/views/lesli/layouts/application-public.html.erb +4 -4
- data/app/views/lesli/layouts/mailer.html.erb +1 -1
- data/app/views/lesli/partials/{_application-analytics.html.erb → _application-lesli-analytics.html.erb} +14 -3
- data/app/views/lesli/partials/{_application-lesli-css.html.erb → _application-lesli-assets.html.erb} +8 -4
- data/app/views/lesli/partials/{_application-head.html.erb → _application-lesli-head.html.erb} +2 -2
- data/app/views/lesli/partials/_application-lesli-header.html.erb +6 -6
- data/app/views/lesli/partials/_application-lesli-navigation.html.erb +3 -6
- data/app/views/lesli/partials/_application-lesli-notifications.html.erb +0 -1
- data/app/views/lesli/partials/turbo/_redirection.html.erb +5 -0
- data/app/views/lesli/shared/dashboards/{_show.html.erb → edit.html.erb} +3 -3
- data/app/views/lesli/shared/dashboards/{_edit.html.erb → show.html.erb} +3 -3
- data/config/brakeman.yml +55 -0
- data/config/importmap.rb +0 -3
- data/config/initializers/devise.rb +1 -2
- data/config/initializers/lesli.rb +27 -14
- data/config/initializers/lesli_migration_helpers.rb +0 -5
- data/config/locales/translations.en.yml +6 -2
- data/config/locales/translations.es.yml +5 -2
- data/config/locales/translations.fr.yml +1 -4
- data/config/locales/translations.it.yml +5 -2
- data/config/locales/translations.pt.yml +1 -4
- data/config/routes.rb +4 -6
- data/db/migrate/v1/{0000000310_create_lesli_users.rb → 0000000210_create_lesli_users.rb} +4 -0
- data/db/migrate/v1/{0000000210_create_lesli_roles.rb → 0000000310_create_lesli_roles.rb} +6 -0
- data/db/migrate/v1/{0000100110_create_lesli_system_controllers.rb → 0000000410_create_lesli_resources.rb} +8 -5
- data/db/seed/users.rb +1 -1
- data/db/seed/xyz.rb +3 -1
- data/lib/generators/lesli/spec/spec_generator.rb +0 -3
- data/lib/generators/lesli/view/view_generator.rb +0 -3
- data/lib/lesli/configuration.rb +1 -1
- data/{app/lib → lib}/lesli/courier.rb +40 -7
- data/lib/lesli/engine.rb +1 -1
- data/lib/lesli/{routing.rb → router.rb} +3 -2
- data/lib/lesli/version.rb +2 -2
- data/lib/lesli.rb +3 -2
- data/lib/migrate/common.rb +2 -0
- data/lib/migrate/items/action_structure.rb +2 -1
- data/lib/migrate/items/activity_structure.rb +12 -2
- data/lib/migrate/items/discussion_structure.rb +1 -1
- data/lib/scss/_apps.scss +1 -0
- data/lib/tasks/lesli/db.rake +5 -5
- data/lib/tasks/lesli/{controllers.rake → resources.rake} +4 -4
- data/lib/tasks/lesli_tasks.rake +13 -1
- data/lib/test/config.rb +111 -0
- data/{db/migrate/v1/0000130210_create_lesli_user_roles.rb → lib/test/helpers/response_integration_helper.rb} +12 -9
- data/{db/migrate/v1/0000100210_create_lesli_system_controller_actions.rb → lib/test/lesli.rb} +28 -9
- data/readme.md +61 -68
- metadata +37 -87
- data/app/helpers/lesli/assets_helper.rb +0 -74
- data/app/helpers/lesli/general_helper.rb +0 -96
- data/app/mailers/lesli/devise_mailer.rb +0 -67
- data/app/models/concerns/lesli/has_activities.rb +0 -29
- data/app/models/concerns/lesli/user_activities.rb +0 -165
- data/app/models/concerns/lesli/user_security.rb +0 -220
- data/app/models/lesli/account/detail.rb +0 -37
- data/app/models/lesli/account/log.rb +0 -57
- data/app/models/lesli/account/request.rb +0 -37
- data/app/models/lesli/descriptor/privilege.rb +0 -39
- data/app/models/lesli/descriptor.rb +0 -57
- data/app/models/lesli/role/action.rb +0 -73
- data/app/models/lesli/role/privilege.rb +0 -38
- data/app/models/lesli/system_controller/action.rb +0 -37
- data/app/models/lesli/system_controller.rb +0 -104
- data/app/models/lesli/user/activity.rb +0 -5
- data/app/models/lesli/user/detail.rb +0 -55
- data/app/models/lesli/user/request.rb +0 -38
- data/app/models/lesli/user/role.rb +0 -39
- data/app/models/lesli/user/session.rb +0 -79
- data/app/models/lesli/user/setting.rb +0 -46
- data/app/operators/lesli/role_operator.rb +0 -153
- data/app/services/lesli/role/action_service.rb +0 -75
- data/app/services/lesli/user/session_service.rb +0 -78
- data/app/validators/lesli/application_lesli_validator.rb +0 -67
- data/app/validators/lesli/users_validator.rb +0 -217
- data/app/views/lesli/emails/user_mailer/invitation.html.erb +0 -23
- data/app/views/lesli/partials/_application-lesli-annoouncements.html.erb +0 -49
- data/app/views/lesli/partials/_application-lesli-javascript.html.erb +0 -46
- data/app/views/lesli/wrappers/_application-devise-simple.erb +0 -59
- data/app/views/lesli/wrappers/_application-devise.html.erb +0 -76
- data/db/migrate/v1/0000110210_create_lesli_account_details.rb +0 -70
- data/db/migrate/v1/0000110310_create_lesli_account_settings.rb +0 -37
- data/db/migrate/v1/0000110410_create_lesli_account_activities.rb +0 -37
- data/db/migrate/v1/0000120210_create_lesli_role_actions.rb +0 -45
- data/db/migrate/v1/0000120310_create_lesli_role_privileges.rb +0 -45
- data/db/migrate/v1/0000130310_create_lesli_user_sessions.rb +0 -56
- data/db/migrate/v1/0000130410_create_lesli_user_activities.rb +0 -37
- data/db/migrate2/0000100510_create_lesli_account_locations.rb +0 -64
- data/db/migrate2/0000100610_create_lesli_account_currencies.rb +0 -48
- data/lib/assets/javascripts/lesli/i18n_js +0 -1095
- data/lib/migrate/shared/dashboard_structure.rb +0 -54
- data/lib/migrate/shared/setting_structure.rb +0 -20
- data/lib/rspec/config/spec_coverage.rb +0 -95
- data/lib/rspec/factories/lesli_role.rb +0 -62
- data/lib/rspec/factories/lesli_user.rb +0 -64
- data/lib/rspec/fixtures/files/lesli-icon.png +0 -0
- data/lib/rspec/fixtures/files/test_file_1.docx +0 -0
- data/lib/rspec/helpers/lesli_helper.rb +0 -65
- data/lib/rspec/helpers/rails_helper.rb +0 -134
- data/lib/rspec/helpers/response_request_helper.rb +0 -214
- data/lib/rspec/helpers/response_service_helper.rb +0 -66
- data/lib/rspec/helpers/spec_helper.rb +0 -99
- data/lib/rspec/lesli_api_tester.rb +0 -133
- data/lib/rspec/lesli_service_tester.rb +0 -46
- data/lib/rspec/testers/controller.rb +0 -63
- data/lib/rspec/testers/model.rb +0 -36
- data/lib/rspec/testers/request.rb +0 -93
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd0c72054c9e183cd20bb799ce466d3e7726a169a27d25c74f629dd18456a756
|
|
4
|
+
data.tar.gz: 4a06f9ec53949acea25626f80a57c2f7a200949847c1588263ed501b4e8958e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4cb0333bce69463e0b9d5a5087fb132176b8e8824f1d743788325cf42d4b3accb076fb9e6b47336a7601569b7914a052bf19cc98350e28eb9e473e1b93b286f6
|
|
7
|
+
data.tar.gz: 52b5932c2c4467fe81cbf7c882be73127f8d8ad55df48f837b79b38bbbee00d6a64cc5a52c4be72d6551434264b8fe3197eb29bddb60775e5b024f61e1fb09c2
|
data/Rakefile
CHANGED
|
@@ -30,13 +30,13 @@ Building a better future, one line of code at a time.
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
// · Engine
|
|
33
|
+
// · Engine images
|
|
34
34
|
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
35
35
|
//= link_tree ../images/lesli .png
|
|
36
36
|
//= link_tree ../images/lesli .jpg
|
|
37
37
|
//= link_tree ../images/lesli .svg
|
|
38
38
|
|
|
39
|
-
// ·
|
|
39
|
+
// · Engine styles and scripts
|
|
40
40
|
// · ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~ ~·~
|
|
41
41
|
//= link lesli/application.css
|
|
42
42
|
//= link lesli/application.js
|
|
Binary file
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Lesli
|
|
4
4
|
|
|
5
|
-
Copyright (c)
|
|
5
|
+
Copyright (c) 2025, Lesli Technologies, S. A.
|
|
6
6
|
|
|
7
7
|
This program is free software: you can redistribute it and/or modify
|
|
8
8
|
it under the terms of the GNU General Public License as published by
|
|
@@ -19,7 +19,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
19
19
|
|
|
20
20
|
Lesli · Ruby on Rails SaaS Development Framework.
|
|
21
21
|
|
|
22
|
-
Made with ♥ by
|
|
22
|
+
Made with ♥ by LesliTech
|
|
23
23
|
Building a better future, one line of code at a time.
|
|
24
24
|
|
|
25
25
|
@contact hello@lesli.tech
|
|
@@ -37,21 +37,20 @@ module Lesli
|
|
|
37
37
|
skip_before_action :authenticate_request, only: [:welcome] if defined?(LesliShield)
|
|
38
38
|
skip_before_action :authorize_request, only: [:welcome] if defined?(LesliShield)
|
|
39
39
|
|
|
40
|
-
# def status
|
|
41
|
-
# respond_with_successful({ :Lesli => "Ruby on Rails SaaS Development Framework." })
|
|
42
|
-
# end
|
|
43
|
-
|
|
44
40
|
def welcome
|
|
41
|
+
# renders the welcome page
|
|
45
42
|
end
|
|
46
43
|
|
|
44
|
+
def up
|
|
45
|
+
# renders the health check page
|
|
46
|
+
end
|
|
47
|
+
|
|
47
48
|
# GET /status
|
|
48
49
|
def show
|
|
49
50
|
respond_to do |format|
|
|
50
51
|
format.html {}
|
|
51
|
-
format.json
|
|
52
|
-
|
|
53
|
-
# get installed engines
|
|
54
|
-
@lesli_engines = LesliSystem.engines.map { |engine, engine_info|
|
|
52
|
+
format.json do
|
|
53
|
+
lesli_engines = LesliSystem.engines.map do |engine, engine_info|
|
|
55
54
|
{
|
|
56
55
|
:name => engine_info[:name],
|
|
57
56
|
:code => engine_info[:code],
|
|
@@ -60,9 +59,9 @@ module Lesli
|
|
|
60
59
|
:version => engine_info[:version],
|
|
61
60
|
:description => engine_info[:description]
|
|
62
61
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
end
|
|
63
|
+
respond_with_json(lesli_engines)
|
|
64
|
+
end
|
|
66
65
|
end
|
|
67
66
|
end
|
|
68
67
|
end
|
|
@@ -34,7 +34,7 @@ module Lesli
|
|
|
34
34
|
class ApplicationController < ActionController::Base
|
|
35
35
|
layout "lesli/layouts/application-public"
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
protect_from_forgery with: :exception
|
|
38
38
|
|
|
39
39
|
attr_reader :query
|
|
40
40
|
attr_reader :engine_path
|
|
@@ -46,47 +46,6 @@ module Lesli
|
|
|
46
46
|
}
|
|
47
47
|
end
|
|
48
48
|
|
|
49
|
-
# Meta-programming to define flash setter methods dynamically
|
|
50
|
-
# success("Everything worked!")
|
|
51
|
-
# danger("Oops, there was an error.")
|
|
52
|
-
# info("Just an informational message.")
|
|
53
|
-
# warning("This is a warning.")
|
|
54
|
-
[:success, :danger, :warning, :info].each do |flash_type|
|
|
55
|
-
define_method(flash_type) do |message|
|
|
56
|
-
flash[flash_type] = message
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def language
|
|
61
|
-
|
|
62
|
-
# check if param locale was sent by the user
|
|
63
|
-
unless params[:locale].blank?
|
|
64
|
-
|
|
65
|
-
locale = params[:locale].to_sym
|
|
66
|
-
|
|
67
|
-
# check if locale requested is valid
|
|
68
|
-
if I18n.available_locales.include?(locale)
|
|
69
|
-
|
|
70
|
-
# save requested locale in session
|
|
71
|
-
# this will be used in application_controller#switch_locale
|
|
72
|
-
session[:locale] = locale
|
|
73
|
-
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
I18n.locale = locale
|
|
79
|
-
|
|
80
|
-
redirect_back(fallback_location: request.referer)
|
|
81
|
-
|
|
82
|
-
# This code is not really executed
|
|
83
|
-
# respond_with_successful({
|
|
84
|
-
# locale: I18n.locale,
|
|
85
|
-
# default_locale: I18n.default_locale,
|
|
86
|
-
# available_locales: I18n.available_locales
|
|
87
|
-
# })
|
|
88
|
-
end
|
|
89
|
-
|
|
90
49
|
# # Set the user language based on url configuration or browser/os default language (ready for public pages)
|
|
91
50
|
# def set_locale
|
|
92
51
|
# # language defined in the http header request
|
|
@@ -42,7 +42,6 @@ module Lesli
|
|
|
42
42
|
|
|
43
43
|
protect_from_forgery with: :exception
|
|
44
44
|
|
|
45
|
-
before_action :set_path
|
|
46
45
|
before_action :set_locale
|
|
47
46
|
before_action :authenticate_request if defined?(LesliShield)
|
|
48
47
|
before_action :authorize_request if defined?(LesliShield)
|
|
@@ -56,5 +55,13 @@ module Lesli
|
|
|
56
55
|
rescue_from ActionController::ParameterMissing do |_e|
|
|
57
56
|
respond_with_error("Missing params")
|
|
58
57
|
end
|
|
58
|
+
|
|
59
|
+
def log(payload)
|
|
60
|
+
payload[:engine] = self.class.module_parent
|
|
61
|
+
payload[:source] = self.class.name
|
|
62
|
+
payload[:action] = action_name
|
|
63
|
+
payload[:session_id] = session[:user_session_id]
|
|
64
|
+
current_user.log(**payload)
|
|
65
|
+
end
|
|
59
66
|
end
|
|
60
67
|
end
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
module Lesli
|
|
2
2
|
class AppsController < ApplicationLesliController
|
|
3
|
+
|
|
3
4
|
def show
|
|
5
|
+
# renders the engine selector view
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def language
|
|
9
|
+
|
|
10
|
+
# check if param locale was sent by the user
|
|
11
|
+
unless params[:locale].blank?
|
|
12
|
+
|
|
13
|
+
locale = params[:locale].to_sym
|
|
14
|
+
|
|
15
|
+
# check if locale requested is valid
|
|
16
|
+
if I18n.available_locales.include?(locale)
|
|
17
|
+
|
|
18
|
+
# save requested locale in session
|
|
19
|
+
# this will be used in application_controller#switch_locale
|
|
20
|
+
session[:locale] = locale
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
I18n.locale = locale
|
|
27
|
+
|
|
28
|
+
redirect_back(fallback_location: request.referer)
|
|
4
29
|
end
|
|
5
30
|
end
|
|
6
31
|
end
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
|
|
33
|
+
module Lesli
|
|
34
|
+
module Items
|
|
35
|
+
class ActionsController < ApplicationLesliController
|
|
36
|
+
before_action :set_action, only: [:create, :update]
|
|
37
|
+
|
|
38
|
+
def create
|
|
39
|
+
action = @parent_resource.actions.new({
|
|
40
|
+
title: action_params['title'],
|
|
41
|
+
done: action_params['done'] || false,
|
|
42
|
+
user_id: current_user.id
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
if action.save
|
|
46
|
+
respond_with_lesli(:turbo => [
|
|
47
|
+
stream_notification_success("Action created"),
|
|
48
|
+
stream_actions_component()
|
|
49
|
+
])
|
|
50
|
+
else
|
|
51
|
+
respond_with_lesli(
|
|
52
|
+
:turbo => stream_notification_danger(action.errors.full_messages)
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def update
|
|
58
|
+
|
|
59
|
+
@resource.done = true
|
|
60
|
+
@resource.save
|
|
61
|
+
|
|
62
|
+
respond_with_lesli(:turbo => [
|
|
63
|
+
stream_notification_success("Action updated"),
|
|
64
|
+
stream_actions_component()
|
|
65
|
+
])
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
private
|
|
69
|
+
|
|
70
|
+
def stream_actions_component
|
|
71
|
+
turbo_stream.update("#{@action_parent_object}-actions") do
|
|
72
|
+
LesliView::Items::Actions.new(
|
|
73
|
+
@parent_resource,
|
|
74
|
+
path_to_create:public_send(@action_path_string, @parent_resource),
|
|
75
|
+
path_to_update:->(action) {
|
|
76
|
+
public_send(@action_update_path_string, @parent_resource, action)
|
|
77
|
+
}
|
|
78
|
+
).render_in(view_context)
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def set_action
|
|
83
|
+
|
|
84
|
+
# Get the item model class, example: LesliSupport::Ticket::Discussion
|
|
85
|
+
@action_model = self.class.name.gsub("Controller","").singularize.constantize
|
|
86
|
+
|
|
87
|
+
# Get the parent model class, example: LesliSupport::Ticket
|
|
88
|
+
@action_model_parent = @action_model.reflect_on_association(:item).klass
|
|
89
|
+
|
|
90
|
+
# Get the row owner name, example: from LesliSupport::Ticket gets ticket
|
|
91
|
+
@action_parent_object = "#{@action_model_parent.name.demodulize.underscore}"
|
|
92
|
+
|
|
93
|
+
# Get the parent associations id, example: ticket_id
|
|
94
|
+
@action_model_parent_id = "#{@action_parent_object}_id"
|
|
95
|
+
|
|
96
|
+
# Get the local path method, example: ticket_discussions_path
|
|
97
|
+
@action_path_string = "#{@action_parent_object}_actions_path"
|
|
98
|
+
|
|
99
|
+
# Get the local path method, example: ticket_discussion_path
|
|
100
|
+
@action_update_path_string = "#{@action_parent_object}_action_path"
|
|
101
|
+
|
|
102
|
+
# Get the parent resource
|
|
103
|
+
@parent_resource = @action_model_parent.find_by_id(
|
|
104
|
+
params[@action_model_parent_id.to_sym]
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
@resource = @parent_resource.actions.find(params[:id]) if params[:id]
|
|
108
|
+
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def action_params
|
|
112
|
+
# Get the params key, example: ticket_action
|
|
113
|
+
action_model_param_key = @action_model.model_name.param_key
|
|
114
|
+
params.require(action_model_param_key.to_sym).permit(
|
|
115
|
+
:title,
|
|
116
|
+
:done,
|
|
117
|
+
@action_model_parent_id
|
|
118
|
+
)
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
|
|
33
|
+
module Lesli
|
|
34
|
+
module Items
|
|
35
|
+
class DiscussionsController < ApplicationLesliController
|
|
36
|
+
before_action :set_discussion, only: [:create]
|
|
37
|
+
|
|
38
|
+
def create
|
|
39
|
+
discussion = @parent_resource.discussions.new({
|
|
40
|
+
message: discussion_params[:message],
|
|
41
|
+
user_id: current_user.id
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
if discussion.save
|
|
45
|
+
respond_with_lesli(:turbo => [
|
|
46
|
+
stream_notification_success("Comment created"),
|
|
47
|
+
turbo_stream.update("#{@discussion_parent_object}-discussions") do
|
|
48
|
+
LesliView::Items::Discussions.new(@parent_resource, public_send(@discussion_path_string, @parent_resource)).render_in(view_context)
|
|
49
|
+
end
|
|
50
|
+
])
|
|
51
|
+
else
|
|
52
|
+
respond_with_lesli(
|
|
53
|
+
:turbo => stream_notification_danger(discussion.errors.full_messages)
|
|
54
|
+
)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
private
|
|
59
|
+
|
|
60
|
+
def set_discussion
|
|
61
|
+
|
|
62
|
+
# Get the item model class, example: LesliSupport::Ticket::Discussion
|
|
63
|
+
@discussion_model = self.class.name.gsub("Controller","").singularize.constantize
|
|
64
|
+
|
|
65
|
+
# Get the parent model class, example: LesliSupport::Ticket
|
|
66
|
+
@discussion_model_parent = @discussion_model.reflect_on_association(:item).klass
|
|
67
|
+
|
|
68
|
+
# Get the row owner name, example: from LesliSupport::Ticket gets ticket
|
|
69
|
+
@discussion_parent_object = "#{@discussion_model_parent.name.demodulize.underscore}"
|
|
70
|
+
|
|
71
|
+
# Get the parent associations id, example: ticket_id
|
|
72
|
+
@discussion_model_parent_id = "#{@discussion_parent_object}_id"
|
|
73
|
+
|
|
74
|
+
# Get the local path method, example: ticket_discussions_path
|
|
75
|
+
@discussion_path_string = "#{@discussion_parent_object}_discussions_path"
|
|
76
|
+
|
|
77
|
+
# Get the parent resource
|
|
78
|
+
@parent_resource = @discussion_model_parent.find_by_id(
|
|
79
|
+
params[@discussion_model_parent_id.to_sym]
|
|
80
|
+
)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def discussion_params
|
|
84
|
+
# Get the params key, example: ticket_discussion
|
|
85
|
+
discussion_model_param_key = @discussion_model.model_name.param_key
|
|
86
|
+
params.require(discussion_model_param_key.to_sym).permit(
|
|
87
|
+
:message,
|
|
88
|
+
@discussion_model_parent_id
|
|
89
|
+
)
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Lesli
|
|
4
4
|
|
|
5
|
-
Copyright (c)
|
|
5
|
+
Copyright (c) 2026, Lesli Technologies, S. A.
|
|
6
6
|
|
|
7
7
|
This program is free software: you can redistribute it and/or modify
|
|
8
8
|
it under the terms of the GNU General Public License as published by
|
|
@@ -19,7 +19,7 @@ along with this program. If not, see http://www.gnu.org/licenses/.
|
|
|
19
19
|
|
|
20
20
|
Lesli · Ruby on Rails SaaS Development Framework.
|
|
21
21
|
|
|
22
|
-
Made with ♥ by
|
|
22
|
+
Made with ♥ by LesliTech
|
|
23
23
|
Building a better future, one line of code at a time.
|
|
24
24
|
|
|
25
25
|
@contact hello@lesli.tech
|
|
@@ -31,7 +31,7 @@ Building a better future, one line of code at a time.
|
|
|
31
31
|
=end
|
|
32
32
|
|
|
33
33
|
module Lesli
|
|
34
|
-
class
|
|
34
|
+
class ResourcesController < ApplicationLesliController
|
|
35
35
|
before_action :set_system_controller, only: [:show, :update, :destroy]
|
|
36
36
|
|
|
37
37
|
# GET /system_controllers
|