lesli_support 0.1.0 → 1.1.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 (135) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/lesli_support/support-logo.svg +1 -9
  3. data/app/assets/javascripts/lesli_support/application.js +1 -4998
  4. data/app/assets/stylesheets/lesli_support/application.css +3 -3
  5. data/app/controllers/lesli_support/catalog/items_controller.rb +60 -0
  6. data/app/controllers/lesli_support/item/discussions_controller.rb +6 -0
  7. data/app/controllers/lesli_support/item/tasks_controller.rb +6 -0
  8. data/app/controllers/lesli_support/ticket/activities_controller.rb +60 -0
  9. data/app/controllers/lesli_support/ticket/discussions_controller.rb +1 -2
  10. data/app/controllers/lesli_support/tickets_controller.rb +37 -56
  11. data/app/helpers/lesli_support/{options_helper.rb → catalog/items_helper.rb} +1 -1
  12. data/app/helpers/lesli_support/ticket/activities_helper.rb +4 -0
  13. data/app/models/lesli_support/account.rb +5 -8
  14. data/app/models/lesli_support/catalog/item.rb +4 -0
  15. data/app/models/lesli_support/catalog.rb +3 -12
  16. data/app/models/lesli_support/dashboard.rb +6 -10
  17. data/app/models/lesli_support/item/activity.rb +4 -0
  18. data/app/models/lesli_support/item/discussion.rb +6 -0
  19. data/app/models/lesli_support/item/task.rb +6 -0
  20. data/app/models/lesli_support/ticket/activity.rb +4 -0
  21. data/app/models/lesli_support/ticket/discussion.rb +3 -4
  22. data/app/models/lesli_support/ticket.rb +66 -7
  23. data/app/services/lesli_support/ticket_service.rb +37 -55
  24. data/app/views/lesli_support/catalog/items/_form.html.erb +17 -0
  25. data/app/views/lesli_support/catalog/items/_item.html.erb +2 -0
  26. data/app/views/lesli_support/catalog/items/edit.html.erb +12 -0
  27. data/app/views/lesli_support/catalog/items/index.html.erb +16 -0
  28. data/app/views/lesli_support/catalog/items/new.html.erb +11 -0
  29. data/app/views/lesli_support/catalog/items/show.html.erb +10 -0
  30. data/app/views/lesli_support/dashboards/_component-latest-tickets.html.erb +34 -0
  31. data/app/views/lesli_support/dashboards/_component-tickets-by-category.html.erb +17 -0
  32. data/app/views/lesli_support/dashboards/_component-tickets-created.html.erb +10 -0
  33. data/app/views/lesli_support/dashboards/_component-tickets-open.html.erb +5 -0
  34. data/app/views/lesli_support/tickets/_form.html.erb +27 -0
  35. data/app/views/lesli_support/tickets/index.html.erb +35 -4
  36. data/app/views/lesli_support/tickets/new.html.erb +31 -14
  37. data/app/views/lesli_support/tickets/show.html.erb +30 -15
  38. data/config/locales/translations.en.yml +1 -42
  39. data/config/locales/translations.es.yml +1 -42
  40. data/config/locales/translations.fr.yml +1 -42
  41. data/config/locales/translations.it.yml +1 -42
  42. data/config/locales/translations.pt.yml +1 -42
  43. data/config/routes.rb +5 -25
  44. data/db/migrate/v1/0702000110_create_lesli_support_accounts.rb +10 -8
  45. data/db/migrate/v1/0702002010_create_lesli_support_catalogs.rb +37 -0
  46. data/db/migrate/v1/0702100110_create_lesli_support_slas.rb +2 -6
  47. data/db/migrate/v1/0702110110_create_lesli_support_tickets.rb +18 -49
  48. data/db/seed/development.rb +43 -22
  49. data/db/seed/production.rb +7 -2
  50. data/db/seed/seeds.json +64 -0
  51. data/db/seed/test.rb +2 -2
  52. data/db/seeds.rb +6 -13
  53. data/db/{migrate/v1/0702000210_create_lesli_support_account_settings.rb → tables/0010009010_create_feedbacks.rb} +21 -11
  54. data/db/{migrate/v1 → tables}/0702010110_create_lesli_support_catalog_workspaces.rb +7 -7
  55. data/db/{migrate/v1 → tables}/0702010210_create_lesli_support_catalog_types.rb +6 -6
  56. data/db/{migrate/v1 → tables}/0702010310_create_lesli_support_catalog_categories.rb +7 -7
  57. data/db/{migrate/v1 → tables}/0702010410_create_lesli_support_catalog_priorities.rb +7 -7
  58. data/lib/lesli_support/version.rb +2 -2
  59. data/readme.md +77 -25
  60. metadata +37 -91
  61. data/app/controllers/lesli_support/catalog_categories_controller.rb +0 -60
  62. data/app/controllers/lesli_support/catalog_priorities_controller.rb +0 -60
  63. data/app/controllers/lesli_support/catalog_types_controller.rb +0 -60
  64. data/app/controllers/lesli_support/catalog_workspaces_controller.rb +0 -60
  65. data/app/controllers/lesli_support/dashboard/components_controller.rb +0 -92
  66. data/app/controllers/lesli_support/options_controller.rb +0 -23
  67. data/app/helpers/lesli_support/catalog_categories_helper.rb +0 -4
  68. data/app/helpers/lesli_support/catalog_priorities_helper.rb +0 -4
  69. data/app/helpers/lesli_support/catalog_types_helper.rb +0 -4
  70. data/app/helpers/lesli_support/catalog_workspaces_helper.rb +0 -4
  71. data/app/models/lesli_support/catalog_category.rb +0 -5
  72. data/app/models/lesli_support/catalog_priority.rb +0 -5
  73. data/app/models/lesli_support/catalog_type.rb +0 -5
  74. data/app/models/lesli_support/catalog_workspace.rb +0 -5
  75. data/app/models/lesli_support/dashboard/component.rb +0 -18
  76. data/app/models/lesli_support/option.rb +0 -4
  77. data/app/views/layouts/lesli_support/application.html.erb +0 -15
  78. data/app/views/lesli_support/catalog_categories/_catalog_category.html.erb +0 -2
  79. data/app/views/lesli_support/catalog_categories/_form.html.erb +0 -17
  80. data/app/views/lesli_support/catalog_categories/edit.html.erb +0 -10
  81. data/app/views/lesli_support/catalog_categories/index.html.erb +0 -14
  82. data/app/views/lesli_support/catalog_categories/new.html.erb +0 -9
  83. data/app/views/lesli_support/catalog_categories/show.html.erb +0 -10
  84. data/app/views/lesli_support/catalog_priorities/_catalog_priority.html.erb +0 -2
  85. data/app/views/lesli_support/catalog_priorities/_form.html.erb +0 -17
  86. data/app/views/lesli_support/catalog_priorities/edit.html.erb +0 -10
  87. data/app/views/lesli_support/catalog_priorities/index.html.erb +0 -14
  88. data/app/views/lesli_support/catalog_priorities/new.html.erb +0 -9
  89. data/app/views/lesli_support/catalog_priorities/show.html.erb +0 -10
  90. data/app/views/lesli_support/catalog_types/_catalog_type.html.erb +0 -2
  91. data/app/views/lesli_support/catalog_types/_form.html.erb +0 -17
  92. data/app/views/lesli_support/catalog_types/edit.html.erb +0 -10
  93. data/app/views/lesli_support/catalog_types/index.html.erb +0 -14
  94. data/app/views/lesli_support/catalog_types/new.html.erb +0 -9
  95. data/app/views/lesli_support/catalog_types/show.html.erb +0 -10
  96. data/app/views/lesli_support/catalog_workspaces/_catalog_workspace.html.erb +0 -2
  97. data/app/views/lesli_support/catalog_workspaces/_form.html.erb +0 -17
  98. data/app/views/lesli_support/catalog_workspaces/edit.html.erb +0 -10
  99. data/app/views/lesli_support/catalog_workspaces/index.html.erb +0 -14
  100. data/app/views/lesli_support/catalog_workspaces/new.html.erb +0 -9
  101. data/app/views/lesli_support/catalog_workspaces/show.html.erb +0 -10
  102. data/app/views/lesli_support/dashboards/edit.html.erb +0 -1
  103. data/app/views/lesli_support/dashboards/index.html.erb +0 -1
  104. data/app/views/lesli_support/dashboards/new.html.erb +0 -1
  105. data/app/views/lesli_support/dashboards/show.html.erb +0 -1
  106. data/app/views/lesli_support/options/_form.html.erb +0 -17
  107. data/app/views/lesli_support/options/_option.html.erb +0 -2
  108. data/app/views/lesli_support/options/edit.html.erb +0 -10
  109. data/app/views/lesli_support/options/index.html.erb +0 -14
  110. data/app/views/lesli_support/options/new.html.erb +0 -9
  111. data/app/views/lesli_support/options/show.html.erb +0 -10
  112. data/app/views/lesli_support/ticket/discussions/_discussion.html.erb +0 -2
  113. data/app/views/lesli_support/ticket/discussions/_form.html.erb +0 -17
  114. data/app/views/lesli_support/ticket/discussions/edit.html.erb +0 -10
  115. data/app/views/lesli_support/ticket/discussions/index.html.erb +0 -14
  116. data/app/views/lesli_support/ticket/discussions/new.html.erb +0 -9
  117. data/app/views/lesli_support/ticket/discussions/show.html.erb +0 -10
  118. data/app/views/lesli_support/tickets/edit.html.erb +0 -20
  119. data/db/migrate/v1/0702050110_create_lesli_support_dashboards.rb +0 -50
  120. data/db/migrate/v1/0702050210_create_lesli_support_dashboard_components.rb +0 -50
  121. data/db/migrate/v1/0702110510_create_lesli_support_ticket_discussions.rb +0 -52
  122. data/lib/scss/application.scss +0 -11
  123. data/lib/vue/application.js +0 -93
  124. data/lib/vue/apps/dashboard/components/engine-version.vue +0 -71
  125. data/lib/vue/apps/dashboard/components/my-tasks.vue +0 -77
  126. data/lib/vue/apps/tickets/components/assignments.vue +0 -93
  127. data/lib/vue/apps/tickets/components/form.vue +0 -305
  128. data/lib/vue/apps/tickets/components/internal-comments.vue +0 -107
  129. data/lib/vue/apps/tickets/components/sla-info.vue +0 -115
  130. data/lib/vue/apps/tickets/index.vue +0 -145
  131. data/lib/vue/apps/tickets/new.vue +0 -78
  132. data/lib/vue/apps/tickets/show.vue +0 -183
  133. data/lib/vue/stores/tickets.js +0 -276
  134. data/lib/vue/stores/translations.json +0 -272
  135. /data/app/views/lesli_support/partials/{_engine-navigation.html.erb → _navigation.html.erb} +0 -0
@@ -1,6 +1,6 @@
1
- /*!***********************************************************************************************************************************************************!*\
2
- !*** css ./node_modules/css-loader/dist/cjs.js??clonedRuleSet-39.use[1]!./node_modules/sass-loader/dist/cjs.js!../LesliSupport/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!../LesliSupport/lib/scss/application.scss ***!
3
+ \**************************************************************************************************************************************************************/
4
4
  .lesli-support-tickets .lesli-form > fieldset {
5
5
  padding: 3rem 6rem;
6
6
  }
@@ -0,0 +1,60 @@
1
+ module LesliSupport
2
+ class Catalog::ItemsController < ApplicationController
3
+ before_action :set_catalog_item, only: %i[ show edit update destroy ]
4
+
5
+ # GET /catalog/items
6
+ def index
7
+ @catalog_items = Catalog::Item.all
8
+ end
9
+
10
+ # GET /catalog/items/1
11
+ def show
12
+ end
13
+
14
+ # GET /catalog/items/new
15
+ def new
16
+ @catalog_item = Catalog::Item.new
17
+ end
18
+
19
+ # GET /catalog/items/1/edit
20
+ def edit
21
+ end
22
+
23
+ # POST /catalog/items
24
+ def create
25
+ @catalog_item = Catalog::Item.new(catalog_item_params)
26
+
27
+ if @catalog_item.save
28
+ redirect_to @catalog_item, notice: "Item was successfully created."
29
+ else
30
+ render :new, status: :unprocessable_entity
31
+ end
32
+ end
33
+
34
+ # PATCH/PUT /catalog/items/1
35
+ def update
36
+ if @catalog_item.update(catalog_item_params)
37
+ redirect_to @catalog_item, notice: "Item was successfully updated.", status: :see_other
38
+ else
39
+ render :edit, status: :unprocessable_entity
40
+ end
41
+ end
42
+
43
+ # DELETE /catalog/items/1
44
+ def destroy
45
+ @catalog_item.destroy!
46
+ redirect_to catalog_items_url, notice: "Item was successfully destroyed.", status: :see_other
47
+ end
48
+
49
+ private
50
+ # Use callbacks to share common setup or constraints between actions.
51
+ def set_catalog_item
52
+ @catalog_item = Catalog::Item.find(params[:id])
53
+ end
54
+
55
+ # Only allow a list of trusted parameters through.
56
+ def catalog_item_params
57
+ params.fetch(:catalog_item, {})
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,6 @@
1
+ module LesliSupport
2
+ module Item
3
+ class DiscussionsController < Lesli::Item::DiscussionsController
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module LesliSupport
2
+ module Item
3
+ class TasksController < Lesli::Item::TasksController
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,60 @@
1
+ module LesliSupport
2
+ class Ticket::ActivitiesController < ApplicationController
3
+ before_action :set_ticket_activity, only: %i[ show edit update destroy ]
4
+
5
+ # GET /ticket/activities
6
+ def index
7
+ @ticket_activities = Ticket::Activity.all
8
+ end
9
+
10
+ # GET /ticket/activities/1
11
+ def show
12
+ end
13
+
14
+ # GET /ticket/activities/new
15
+ def new
16
+ @ticket_activity = Ticket::Activity.new
17
+ end
18
+
19
+ # GET /ticket/activities/1/edit
20
+ def edit
21
+ end
22
+
23
+ # POST /ticket/activities
24
+ def create
25
+ @ticket_activity = Ticket::Activity.new(ticket_activity_params)
26
+
27
+ if @ticket_activity.save
28
+ redirect_to @ticket_activity, notice: "Activity was successfully created."
29
+ else
30
+ render :new, status: :unprocessable_entity
31
+ end
32
+ end
33
+
34
+ # PATCH/PUT /ticket/activities/1
35
+ def update
36
+ if @ticket_activity.update(ticket_activity_params)
37
+ redirect_to @ticket_activity, notice: "Activity was successfully updated.", status: :see_other
38
+ else
39
+ render :edit, status: :unprocessable_entity
40
+ end
41
+ end
42
+
43
+ # DELETE /ticket/activities/1
44
+ def destroy
45
+ @ticket_activity.destroy!
46
+ redirect_to ticket_activities_path, notice: "Activity was successfully destroyed.", status: :see_other
47
+ end
48
+
49
+ private
50
+ # Use callbacks to share common setup or constraints between actions.
51
+ def set_ticket_activity
52
+ @ticket_activity = Ticket::Activity.find(params.expect(:id))
53
+ end
54
+
55
+ # Only allow a list of trusted parameters through.
56
+ def ticket_activity_params
57
+ params.fetch(:ticket_activity, {})
58
+ end
59
+ end
60
+ end
@@ -1,5 +1,4 @@
1
1
  module LesliSupport
2
- class Ticket::DiscussionsController < ApplicationController
3
- include Lesli::Interfaces::Controllers::Discussions
2
+ class Ticket::DiscussionsController < Lesli::Items::DiscussionsController
4
3
  end
5
4
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Lesli
4
4
 
5
- Copyright (c) 2023, Lesli Technologies, S. A.
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 https://www.lesli.tech
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
@@ -35,25 +35,15 @@ module LesliSupport
35
35
  before_action :set_ticket, only: [:show, :update, :destroy, :images]
36
36
 
37
37
  def index
38
- respond_to do |format|
39
- format.html { }
40
- format.json do
41
- #respond_with_successful(TicketService.new(current_user, query).index)
42
- respond_with_pagination(TicketService.new(current_user, query).index)
43
- end
44
- end
38
+ @tickets = respond_with_pagination(TicketService.new(current_user, query).index)
45
39
  end
46
40
 
47
41
  def show
48
- respond_to do |format|
49
- format.html { }
50
- format.json do
51
- respond_with_successful(@ticket.show)
52
- end
53
- end
42
+ @ticket = @ticket.show
54
43
  end
55
44
 
56
45
  def new
46
+ @ticket = Ticket.new
57
47
  end
58
48
 
59
49
  def edit
@@ -62,38 +52,36 @@ module LesliSupport
62
52
  def create
63
53
  ticket = TicketService.new(current_user, query).create(ticket_params)
64
54
 
55
+ @ticket = ticket.result
65
56
  if ticket.successful?
66
- respond_with_successful(ticket.result)
67
- else
68
- respond_with_error(ticket.errors)
57
+ success('ticket creado de forma exitosass')
58
+ respond_with_lesli(
59
+ #:html => redirect_to(ticket_path(@ticket.id)),
60
+ :turbo => stream_redirection(ticket_path(@ticket.id))
61
+ )
62
+ else
63
+ respond_with_lesli(
64
+ :turbo => ticket.errors_as_sentence
65
+ )
69
66
  end
70
67
  end
71
68
 
72
69
  def update
73
70
 
74
- respond_with_successful(@ticket.update(ticket_params))
75
-
76
- # return respond_with_not_found unless @ticket
77
- # return respond_with_unauthorized unless @ticket.is_editable_by?(current_user, bypass_status: true)
78
-
79
- # # When the ticket is closed, the only available field for update is the status
80
- # update_params = ticket_params
81
- # if ["completed_successfully", "completed_unsuccessfully"].include? @ticket.status&.status_type
82
- # update_params = completed_ticket_params
83
- # end
84
-
85
- # if @ticket.check_workflow_transitions(current_user, update_params)
86
- # ticket_update_response = TicketServices.update(current_user, @ticket, update_params)
87
-
88
- # @ticket = ticket_update_response.payload
89
- # if ticket_update_response.successful?
90
- # respond_with_successful(@ticket.show(current_user, @query))
91
- # else
92
- # respond_with_error(@ticket.errors.full_messages.to_sentence)
93
- # end
94
- # else
95
- # respond_with_error(@ticket.errors.full_messages.to_sentence)
96
- # end
71
+ if @ticket.update(ticket_params)
72
+ # log(
73
+ # subject: @invite,
74
+ # description: "Ticket updated successfully"
75
+ # )
76
+ respond_with_lesli(
77
+ :turbo => stream_notification_success("Ticket updated successfully")
78
+ )
79
+ else
80
+ respond_with_lesli(
81
+ :turbo => stream_notification_danger(@ticket.errors)
82
+ #:turbo => stream_notification_danger(@ticket.errors.full_messages.to_sentence)
83
+ )
84
+ end
97
85
  end
98
86
 
99
87
  def destroy
@@ -135,19 +123,17 @@ module LesliSupport
135
123
  private
136
124
 
137
125
  def set_ticket
138
- ticket_id = params[:id] unless params[:id].blank?
139
- ticket_id = params[:ticket_id] unless params[:ticket_id].blank?
140
- @ticket = TicketService.new(current_user, query).find(ticket_id)
126
+ @ticket = TicketService.new(current_user, query).find(id:params[:id])
141
127
  return respond_with_not_found unless @ticket.found?
142
128
  end
143
129
 
144
130
  def ticket_params
145
131
  params.require(:ticket).permit(
146
- :catalog_type_id,
147
- #:catalog_source_id,
148
- :catalog_category_id,
149
- :catalog_priority_id,
150
- :catalog_workspace_id,
132
+ :type_id,
133
+ #:source_id,
134
+ :category_id,
135
+ :priority_id,
136
+ :workspace_id,
151
137
 
152
138
  :subject,
153
139
  :description,
@@ -156,13 +142,8 @@ module LesliSupport
156
142
  :deadline,
157
143
  :started_at,
158
144
  :completed_at,
159
- :hours_worked
160
- )
161
- end
162
-
163
- def completed_ticket_params
164
- params.require(:ticket).permit(
165
- :cloud_help_workflow_statuses_id
145
+ :hours_worked,
146
+ :owner_id
166
147
  )
167
148
  end
168
149
  end
@@ -1,4 +1,4 @@
1
1
  module LesliSupport
2
- module OptionsHelper
2
+ module Catalog::ItemsHelper
3
3
  end
4
4
  end
@@ -0,0 +1,4 @@
1
+ module LesliSupport
2
+ module Ticket::ActivitiesHelper
3
+ end
4
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Lesli
4
4
 
5
- Copyright (c) 2023, Lesli Technologies, S. A.
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 https://www.lesli.tech
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
@@ -33,16 +33,13 @@ Building a better future, one line of code at a time.
33
33
  module LesliSupport
34
34
  class Account < ApplicationRecord
35
35
  belongs_to :account, class_name: "Lesli::Account"
36
- has_many :catalog_workspaces
37
- has_many :catalog_types
38
- has_many :catalog_categories
39
- has_many :catalog_priorities
36
+ has_many :dashboards
37
+ has_many :catalogs, class_name: "Catalog"
40
38
  has_many :tickets
41
-
39
+
42
40
  after_create :initialize_account
43
41
 
44
42
  def initialize_account
45
- Dashboard.initialize_dashboard(self)
46
43
  end
47
44
  end
48
45
  end
@@ -0,0 +1,4 @@
1
+ module LesliSupport
2
+ class Catalog::Item < ApplicationRecord
3
+ end
4
+ end
@@ -1,15 +1,6 @@
1
1
  module LesliSupport
2
- class Catalog < ApplicationRecord
3
- has_ancestry
4
- belongs_to :parent, class_name: "Catalog", optional: true
5
-
6
- after_save :catalog_option_order
7
-
8
- def catalog_option_order
9
- return if self.parent_id.nil?
10
- return unless self.order.nil?
11
- self.order = self.id
12
- self.save!
13
- end
2
+ class Catalog < Lesli::Shared::Catalog
3
+ belongs_to :account
4
+ has_many :items
14
5
  end
15
6
  end
@@ -1,15 +1,11 @@
1
1
 
2
2
  module LesliSupport
3
3
  class Dashboard < Lesli::Shared::Dashboard
4
- self.table_name = "lesli_support_dashboards"
5
-
6
- belongs_to :account
7
-
8
- has_many :components, inverse_of: :dashboard, autosave: true, dependent: :destroy
9
- accepts_nested_attributes_for :components, allow_destroy: true
10
-
11
- def self.initialize_dashboard(account)
12
- super(self, account, [])
13
- end
4
+ COMPONENTS = [
5
+ :tickets_created,
6
+ :tickets_by_category,
7
+ :tickets_open,
8
+ {:latest_tickets => { size: 8, position: 1 }},
9
+ ]
14
10
  end
15
11
  end
@@ -0,0 +1,4 @@
1
+ module LesliSupport
2
+ class Item::Activity < Lesli::Item::Activity
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module LesliSupport
2
+ module Item
3
+ class Discussion < Lesli::Item::Discussion
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module LesliSupport
2
+ module Item
3
+ class Task < Lesli::Item::Task
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ module LesliSupport
2
+ class Ticket::Activity < ApplicationRecord
3
+ end
4
+ end
@@ -1,7 +1,6 @@
1
1
  module LesliSupport
2
- class Ticket::Discussion < Lesli::CloudObject::Discussion
3
- belongs_to :cloud_object, class_name: "LesliSupport::Ticket", foreign_key: "ticket_id"
4
- belongs_to :parent, class_name: "Discussion", optional: true
5
- has_many :children, class_name: "Discussion", foreign_key: "parent_id"
2
+ class Ticket::Discussion < Lesli::Items::Discussion
3
+ belongs_to :item, class_name: "LesliSupport::Ticket", foreign_key: "ticket_id"
4
+ belongs_to :user, class_name: "Lesli::User"
6
5
  end
7
6
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Lesli
4
4
 
5
- Copyright (c) 2023, Lesli Technologies, S. A.
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 https://www.lesli.tech
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
@@ -33,12 +33,71 @@ Building a better future, one line of code at a time.
33
33
  module LesliSupport
34
34
  class Ticket < Lesli::ApplicationLesliRecord
35
35
  belongs_to :account
36
+ belongs_to :owner, class_name: "Lesli::User"
36
37
  belongs_to :user, class_name: "Lesli::User"
37
- belongs_to :creator, class_name: "Lesli::User"
38
38
 
39
- belongs_to :catalog_workspace, optional: true
40
- belongs_to :catalog_type, optional: true
41
- belongs_to :catalog_category, optional: true
42
- belongs_to :catalog_priority, optional: true
39
+ # Catalogs
40
+ belongs_to :type, optional: true, class_name: "Catalog::Item"
41
+ belongs_to :category, optional: true, class_name: "Catalog::Item"
42
+ belongs_to :priority, optional: true, class_name: "Catalog::Item"
43
+
44
+ # Items
45
+ include Lesli::Item::Tasks
46
+ include Lesli::Item::Activities
47
+ include Lesli::Item::Discussions
48
+ #has_many :discussions, class_name: "LesliSupport::Item::Discussion"
49
+
50
+ # include Lesli::Items::Attachments
51
+ # include Lesli::Items::Subscribers
52
+
53
+ # Hooks
54
+ before_create :before_create_ticket
55
+ after_save :after_save_activities
56
+
57
+ private
58
+
59
+ def before_create_ticket
60
+ prefix = Lesli.config.support.dig(:prefix)
61
+ self.subject = self.subject.titleize
62
+ self.uid ||= loop do
63
+ candidate = generate_resource_uid(prefix:prefix)
64
+ break candidate unless Ticket.exists?(uid: candidate)
65
+ end
66
+ end
67
+
68
+ def after_save_activities
69
+
70
+ if self.saved_change_to_owner_id?
71
+ self.activities_create(
72
+ description: "Agent assigned #{self.owner.name}",
73
+ activity_code: :owner_id,
74
+ metadata: { owner_id: self.owner.id }
75
+ )
76
+ end
77
+
78
+ if self.saved_change_to_type_id?
79
+ self.activities_create(
80
+ description: "Ticket type updated to #{self.type.name}",
81
+ activity_code: :type_id,
82
+ metadata: { type_id: self.type.id }
83
+ )
84
+ end
85
+
86
+ if self.saved_change_to_category_id?
87
+ self.activities_create(
88
+ description: "Ticket category updated to #{self.category.name}",
89
+ activity_code: :category_id,
90
+ metadata: { category_id: self.category.id }
91
+ )
92
+ end
93
+
94
+ if self.saved_change_to_priority_id?
95
+ self.activities_create(
96
+ description: "Ticket priority updated to #{self.priority.name}",
97
+ activity_code: :priority_id,
98
+ metadata: { priority_id: self.priority.id }
99
+ )
100
+ end
101
+ end
43
102
  end
44
103
  end