dorsale 3.7.8 → 3.8.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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/app/assets/javascripts/dorsale/common/comments.coffee +1 -1
  4. data/app/assets/stylesheets/dorsale/common/comments.sass +12 -9
  5. data/app/assets/stylesheets/dorsale/common/tables.sass +3 -0
  6. data/app/controllers/dorsale/customer_vault/events_controller.rb +82 -0
  7. data/app/controllers/dorsale/flyboy/tasks_controller.rb +1 -1
  8. data/app/controllers/dorsale/users_controller.rb +1 -1
  9. data/app/helpers/dorsale/comments_helper.rb +2 -2
  10. data/app/helpers/dorsale/customer_vault/application_helper.rb +11 -0
  11. data/app/models/dorsale/customer_vault/event.rb +12 -8
  12. data/app/models/dorsale/customer_vault/person.rb +0 -18
  13. data/app/models/dorsale/users/active.rb +2 -0
  14. data/app/policies/dorsale/customer_vault/event_policy_helper.rb +3 -0
  15. data/app/views/dorsale/billing_machine/invoices/_list.html.slim +6 -0
  16. data/app/views/dorsale/billing_machine/quotations/_list.html.slim +6 -0
  17. data/app/views/dorsale/comments/_comment.html.slim +1 -1
  18. data/app/views/dorsale/comments/_form.html.slim +5 -4
  19. data/app/views/dorsale/customer_vault/events/_action_comment.html.slim +47 -0
  20. data/app/views/dorsale/customer_vault/events/_action_other.html.slim +24 -0
  21. data/app/views/dorsale/customer_vault/events/_event.html.slim +4 -24
  22. data/app/views/dorsale/customer_vault/events/_form.html.slim +32 -0
  23. data/app/views/dorsale/customer_vault/events/_list.html.slim +1 -4
  24. data/app/views/dorsale/customer_vault/events/edit.html.slim +1 -0
  25. data/app/views/dorsale/customer_vault/people/_index_actions.html.slim +2 -2
  26. data/app/views/dorsale/customer_vault/people/show.html.slim +1 -1
  27. data/app/views/dorsale/users/_list.html.slim +2 -1
  28. data/app/views/dorsale/users/index.html.slim +16 -0
  29. data/config/locales/customer_vault.en.yml +5 -0
  30. data/config/locales/customer_vault.fr.yml +5 -0
  31. data/config/routes.rb +1 -1
  32. data/db/migrate/20171023080507_migrate_people_comments_to_events.rb +22 -0
  33. data/db/migrate/20171023133219_customer_vault_events_add_contact_type.rb +5 -0
  34. data/features/customer_vault_corporations.feature +6 -6
  35. data/features/step_definitions/customer_vault_corporations_steps.rb +19 -19
  36. data/features/step_definitions/customer_vault_people_steps.rb +2 -2
  37. data/lib/dorsale/version.rb +1 -1
  38. data/spec/controllers/dorsale/comments_controller_spec.rb +0 -27
  39. data/spec/factories/customer_vault_event.rb +6 -0
  40. data/spec/factories/dorsale_comments.rb +0 -6
  41. data/spec/models/dorsale/comment_spec.rb +0 -7
  42. data/spec/models/dorsale/customer_vault/event_spec.rb +1 -7
  43. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecb41bb191b0f0774874ccda3e131cb20eea812c
4
- data.tar.gz: c6dd41119b5126fbff10a4cd72224139cc15dde3
3
+ metadata.gz: 2cd9ee349fdefbfd043c9e528bc07e4f5be23c67
4
+ data.tar.gz: 1727d591ba6fe8a39da75b00adc47c6d1821c7ae
5
5
  SHA512:
6
- metadata.gz: 3a5363b33345add30d2dc9e89aed9e4570b92b807f663da687cd3333f35436ad0a66cab48f6f6adbf86aed106192503ee941c710708c89b32c3bfbfc72ab743d
7
- data.tar.gz: c78f2865a7de1834dd91396a0246c7c6c168564abe73ccce52dff0917c0141652b02f1269745d29719782f5149f546bd5dec0a0fd370bff180794da9dd085337
6
+ metadata.gz: 43382375849075fec61442b60ba94f676da7831588a1c66f4223504d747ff25fdfd3bdd53ad3c0a94521f2e3db1d67507a3d60df7cadfe827bbc32a100f6afba
7
+ data.tar.gz: 8e0c1a438c2fc23caab0da8dea58d584ffc4a6411fee720fc467806c7b53f313b28c2405d548398648e4ac9e767f2ed03e872e710cf142bf68c4d4c04d4cfd61
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Next version
4
4
 
5
+ ## 3.8.0
6
+
7
+ - Move CV comments to events
8
+ - Add CV event contact type
9
+ - Various fixes
10
+
5
11
  ## 3.7.8
6
12
 
7
13
  - Person build address improvement
@@ -9,7 +9,7 @@ window.dorsaleComments =
9
9
  setupCreateForm: ->
10
10
  $(document).on "ajax:success", "form#new-dorsale-comment", (e, data) ->
11
11
  if data.length
12
- $(this).find("#comment_title, #comment_text").val("")
12
+ $(this).find("input[id$=title], textarea[id$=text]").val("")
13
13
  $(".dorsale-comments-list").prepend(data)
14
14
 
15
15
  setupEditForm: ->
@@ -19,17 +19,20 @@
19
19
  input, textarea
20
20
  font-size: $font-size-base
21
21
 
22
- .comment-title-field
23
- display: inline-block
24
- width: calc(100% - 10rem - 0.5rem)
25
- margin-right: 0.5rem
22
+ .comment-infos-fields
23
+ display: flex
26
24
 
27
- .comment-date-field
28
- display: inline-block
29
- width: 10rem
25
+ > div + div
26
+ margin-left: 5px
30
27
 
31
- input
32
- text-align: center
28
+ .comment-title-field
29
+ flex: 1
30
+
31
+ .comment-contact_type-field
32
+ width: 8rem
33
+
34
+ .comment-date-field
35
+ width: 10rem
33
36
 
34
37
  .comment-text-field
35
38
  margin-top: 0.5rem
@@ -23,3 +23,6 @@ td[class*="count"],
23
23
  td[class*="total"],
24
24
  td[class*="amount"],
25
25
  text-align: right
26
+
27
+ tr.inactive
28
+ background-color: #F5A9A9
@@ -1,4 +1,8 @@
1
1
  class Dorsale::CustomerVault::EventsController < ::Dorsale::CustomerVault::ApplicationController
2
+ before_action :set_objects
3
+
4
+ layout -> { action_name == "index" ? nil : false }
5
+
2
6
  def index
3
7
  authorize model, :list?
4
8
 
@@ -10,9 +14,87 @@ class Dorsale::CustomerVault::EventsController < ::Dorsale::CustomerVault::Appli
10
14
  @events = @events.page(params[:page]).per(50)
11
15
  end
12
16
 
17
+ def create
18
+ @event ||= scope.new(event_params_for_create)
19
+
20
+ authorize @event, :create?
21
+
22
+ if @event.save
23
+ render_event
24
+ else
25
+ render_nothing
26
+ end
27
+ end
28
+
29
+ def edit
30
+ authorize @event, :update?
31
+ end
32
+
33
+ def update
34
+ authorize @event, :update?
35
+
36
+ if @event.update(event_params_for_update)
37
+ render_event
38
+ else
39
+ render_form
40
+ end
41
+ end
42
+
43
+ def destroy
44
+ authorize @event, :delete?
45
+
46
+ @event.destroy!
47
+
48
+ render_nothing
49
+ end
50
+
13
51
  private
14
52
 
15
53
  def model
16
54
  Dorsale::CustomerVault::Event
17
55
  end
56
+
57
+ def set_objects
58
+ @event = scope.find(params[:id]) if params.key?(:id)
59
+ end
60
+
61
+ def render_event
62
+ render partial: "event", locals: {event: @event}
63
+ end
64
+
65
+ def render_form
66
+ render partial: "form", locals: {event: @event}
67
+ end
68
+
69
+ def render_nothing
70
+ head :ok
71
+ end
72
+
73
+ def permitted_params
74
+ safe_params = [
75
+ :action,
76
+ :title,
77
+ :contact_type,
78
+ :date,
79
+ :text,
80
+ ]
81
+
82
+ if params[:action] == "create"
83
+ safe_params << :person_id
84
+ end
85
+
86
+ safe_params
87
+ end
88
+
89
+ def common_event_params
90
+ params.fetch(:event, {}).permit(permitted_params)
91
+ end
92
+
93
+ def event_params_for_create
94
+ common_event_params.merge(author: current_user)
95
+ end
96
+
97
+ def event_params_for_update
98
+ common_event_params
99
+ end
18
100
  end
@@ -189,7 +189,7 @@ class Dorsale::Flyboy::TasksController < ::Dorsale::Flyboy::ApplicationControlle
189
189
  end
190
190
 
191
191
  def set_owners
192
- @owners ||= policy_scope(User).all
192
+ @owners ||= policy_scope(User).actives
193
193
  end
194
194
 
195
195
  def permitted_params
@@ -8,7 +8,7 @@ class Dorsale::UsersController < ::Dorsale::ApplicationController
8
8
  def index
9
9
  authorize User, :list?
10
10
 
11
- @users ||= scope.all
11
+ @users ||= scope.all.order(is_active: :desc)
12
12
  end
13
13
 
14
14
  def new
@@ -20,8 +20,8 @@ module Dorsale::CommentsHelper
20
20
  params[:controller].include?("customer_vault")
21
21
  end
22
22
 
23
- def truncate_comment_text(comment)
24
- text = comment.text.to_s
23
+ def truncate_comment_text(text)
24
+ text = text.to_s
25
25
  truncated = false
26
26
 
27
27
  if text.to_s.count("\n") > 3
@@ -46,4 +46,15 @@ module Dorsale::CustomerVault::ApplicationHelper
46
46
  [model.t("action.#{action}"), action]
47
47
  end
48
48
  end
49
+
50
+ def customer_vault_event_contact_types_for_filter_select
51
+ model = Dorsale::CustomerVault::Event
52
+ model::CONTACT_TYPES.map do |contact_type|
53
+ [model.t("contact_type.#{contact_type}"), contact_type]
54
+ end
55
+ end
56
+
57
+ def new_event_for(person)
58
+ policy_scope(Dorsale::CustomerVault::Event).new(person: person, author: current_user)
59
+ end
49
60
  end
@@ -1,23 +1,27 @@
1
1
  class Dorsale::CustomerVault::Event < ::Dorsale::ApplicationRecord
2
2
  self.table_name = :dorsale_customer_vault_events
3
3
 
4
- ACTIONS = %w(create update comment)
4
+ ACTIONS = %w(create update comment)
5
+ CONTACT_TYPES = %w(contact r1 r2)
5
6
 
6
7
  belongs_to :author, class_name: User
7
8
  belongs_to :person, class_name: Dorsale::CustomerVault::Person
8
- belongs_to :comment, class_name: Dorsale::Comment
9
9
 
10
- validates :person, presence: true
11
- validates :action, presence: true, inclusion: {in: proc {ACTIONS} }
12
- validates :comment, presence: true, if: proc { action == "comment" }
10
+ validates :person, presence: true
11
+ validates :date, presence: true
12
+ validates :text, presence: true
13
+ validates :action, presence: true, inclusion: {in: proc {ACTIONS} }
14
+ validates :contact_type, allow_blank: true, inclusion: {in: proc {CONTACT_TYPES} }
13
15
 
14
16
  default_scope -> {
15
17
  all
16
18
  .order(created_at: :desc, id: :desc)
17
- .preload(:author, :person, :comment)
19
+ .preload(:author, :person)
18
20
  }
19
21
 
20
- def date
21
- created_at.try(:to_date)
22
+ private
23
+
24
+ def assign_default_values
25
+ assign_default :date, Date.current
22
26
  end
23
27
  end
@@ -72,22 +72,4 @@ class Dorsale::CustomerVault::Person < ::Dorsale::ApplicationRecord
72
72
  def destroy_links
73
73
  links.each(&:destroy!)
74
74
  end
75
-
76
- def receive_comment_notification(comment, action)
77
- scope = Pundit.policy_scope!(comment.author, ::Dorsale::CustomerVault::Event)
78
-
79
- if action == :create
80
- scope.create!(
81
- :author => comment.author,
82
- :person => self,
83
- :comment => comment,
84
- :action => "comment",
85
- )
86
- end
87
-
88
- if action == :delete
89
- scope.where(comment: comment).destroy_all
90
- end
91
- end
92
-
93
75
  end
@@ -3,6 +3,8 @@ module Dorsale::Users::Active
3
3
  user_model.class_eval do
4
4
  validates :is_active, inclusion: {in: [true, false]}
5
5
 
6
+ scope :actives, -> { where(is_active: true) }
7
+
6
8
  def initialize(*)
7
9
  super
8
10
  self.is_active = true if is_active.nil?
@@ -1,5 +1,8 @@
1
1
  module Dorsale::CustomerVault::EventPolicyHelper
2
2
  POLICY_METHODS = [
3
3
  :list?,
4
+ :create?,
5
+ :update?,
6
+ :delete?,
4
7
  ]
5
8
  end
@@ -10,6 +10,9 @@ table.default.invoices
10
10
  th
11
11
  = ::Dorsale::BillingMachine::Invoice.t(:customer)
12
12
 
13
+ th
14
+ = ::Dorsale::BillingMachine::Invoice.t(:label)
15
+
13
16
  th
14
17
  = ::Dorsale::BillingMachine::Invoice.t(:total_excluding_taxes)
15
18
 
@@ -31,6 +34,9 @@ table.default.invoices
31
34
  td.customer_name
32
35
  = link_to_object(invoice.customer)
33
36
 
37
+ td.invoice_label
38
+ = invoice.label
39
+
34
40
  td.total_excluding_taxes
35
41
  = bm_currency invoice.total_excluding_taxes
36
42
 
@@ -10,6 +10,9 @@ table.default.quotations
10
10
  th
11
11
  = ::Dorsale::BillingMachine::Quotation.t(:customer)
12
12
 
13
+ th
14
+ = ::Dorsale::BillingMachine::Quotation.t(:label)
15
+
13
16
  th
14
17
  = ::Dorsale::BillingMachine::Quotation.t(:total_excluding_taxes)
15
18
 
@@ -34,6 +37,9 @@ table.default.quotations
34
37
  td.customer_name
35
38
  = link_to_object(quotation.customer)
36
39
 
40
+ td.quotation_label
41
+ = quotation.label
42
+
37
43
  td.total_excluding_taxes
38
44
  = bm_currency quotation.total_excluding_taxes
39
45
 
@@ -30,7 +30,7 @@
30
30
  span.comment-author
31
31
  = comment.author.to_s
32
32
 
33
- - if truncate_comments_in_this_page? && text = truncate_comment_text(comment)
33
+ - if truncate_comments_in_this_page? && text = truncate_comment_text(comment.text)
34
34
  p.comment-text-truncated
35
35
  = text
36
36
  = " "
@@ -12,11 +12,12 @@
12
12
  = image_tag default_avatar_url, class: "avatar"
13
13
 
14
14
  .comment-fields
15
- .comment-title-field
16
- = f.text_field :title, class: "form-control input-sm", placeholder: f.object.t(:title)
15
+ .comment-infos-fields
16
+ .comment-title-field
17
+ = f.text_field :title, class: "form-control input-sm", placeholder: f.object.t(:title)
17
18
 
18
- .comment-date-field
19
- = f.text_field :date, class: "form-control input-sm", placeholder: f.object.t(:date)
19
+ .comment-date-field
20
+ = f.text_field :date, class: "form-control input-sm", placeholder: f.object.t(:date)
20
21
 
21
22
  .comment-text-field
22
23
  = f.text_area :text, rows: 3, class: "form-control input-sm", placeholder: f.object.t(:text)
@@ -0,0 +1,47 @@
1
+ .comment id="comment#{event.id}"
2
+ - if event.author.try(:avatar_url).present?
3
+ = image_tag event.author.avatar_url, class: "avatar"
4
+ - else
5
+ = image_tag default_avatar_url, class: "avatar"
6
+
7
+ p.comment-actions
8
+ - if policy(event).update?
9
+ = icon_link_to :pencil, t("actions.edit"), dorsale.edit_customer_vault_event_path(event), class: "edit-dorsale-comment"
10
+
11
+ - if policy(event).delete?
12
+ = icon_link_to :trash, t("actions.delete"), dorsale.customer_vault_event_path(event), class: "delete-dorsale-comment", method: :delete, remote: true, data: {confirm: t("actions.confirm")}
13
+
14
+ p.comment-infos
15
+ span.comment-commentable-container
16
+ span.comment-commentable = link_to_object(event.person)
17
+ span.comment-separator = " - "
18
+
19
+ - if event.title.present?
20
+ span.title-container
21
+ strong.title = event.title
22
+ span.separator = " - "
23
+
24
+ - if event.contact_type.present?
25
+ span.contact_type-container
26
+ strong.contact_type = event.tv(:contact_type)
27
+ span.separator = " - "
28
+
29
+ span.comment-date
30
+ = date(event.date)
31
+
32
+ = " "
33
+ = event.t(:written_by)
34
+ = " "
35
+ span.comment-author
36
+ = event.author.to_s
37
+
38
+ - if truncate_comments_in_this_page? && text = truncate_comment_text(event.text)
39
+ p.comment-text-truncated
40
+ = text
41
+ = " "
42
+ a.comment-show_more href="#"
43
+ = ta(:show_more)
44
+
45
+ p.comment-text = text2html(event.text)
46
+
47
+ .clearfix
@@ -0,0 +1,24 @@
1
+ .event id="event#{event.id}"
2
+ - if event.author.try(:avatar_url).present?
3
+ = image_tag event.author.avatar_url, class: "avatar"
4
+ - else
5
+ = image_tag default_avatar_url, class: "avatar"
6
+
7
+ p.event-infos
8
+ span.event-person-container
9
+ span.event-person = link_to_object(event.person)
10
+ span.event-separator = " - "
11
+
12
+ span.event-date
13
+ = date(event.date)
14
+
15
+ - if event.author
16
+ = " "
17
+ = event.t(:authored_by)
18
+ = " "
19
+ span.event-author
20
+ = event.author.to_s
21
+
22
+ p.event-text = text2html(event.text)
23
+
24
+ .clearfix
@@ -1,24 +1,4 @@
1
- .event id="event#{event.id}"
2
- - if event.author.try(:avatar_url).present?
3
- = image_tag event.author.avatar_url, class: "avatar"
4
- - else
5
- = image_tag default_avatar_url, class: "avatar"
6
-
7
- p.event-infos
8
- span.event-person-container
9
- span.event-person = link_to_object(event.person)
10
- span.event-separator = " - "
11
-
12
- span.event-date
13
- = date(event.date)
14
-
15
- - if event.author
16
- = " "
17
- = event.t(:authored_by)
18
- = " "
19
- span.event-author
20
- = event.author.to_s
21
-
22
- p.event-text = text2html(event.text)
23
-
24
- .clearfix
1
+ - if event.action == "comment"
2
+ = render "dorsale/customer_vault/events/action_comment", event: event
3
+ - else
4
+ = render "dorsale/customer_vault/events/action_other", event: event
@@ -0,0 +1,32 @@
1
+ - id = "new-dorsale-comment" if event.new_record?
2
+ - id = "edit-dorsale-comment" if event.persisted?
3
+
4
+ = simple_form_for [dorsale, event], remote: true, as: :event, html: {id: id} do |f|
5
+ = f.hidden_field :person_id
6
+ = f.hidden_field :action, value: (f.object.action.presence || "comment")
7
+
8
+ .comment
9
+ - if event.author.try(:avatar_url).present?
10
+ = image_tag event.author.avatar_url, class: "avatar"
11
+ - else
12
+ = image_tag default_avatar_url, class: "avatar"
13
+
14
+ .comment-fields
15
+ .comment-infos-fields
16
+ .comment-title-field
17
+ = f.text_field :title, class: "form-control input-sm", placeholder: f.object.t(:title)
18
+
19
+ .comment-contact_type-field
20
+ = f.select :contact_type, customer_vault_event_contact_types_for_filter_select, {include_blank: true}, class: "form-control input-sm"
21
+
22
+ .comment-date-field
23
+ = f.text_field :date, class: "form-control input-sm", placeholder: f.object.t(:date)
24
+
25
+
26
+ .comment-text-field
27
+ = f.text_area :text, rows: 3, class: "form-control input-sm", placeholder: f.object.t(:text)
28
+
29
+ .comment-submit
30
+ input type="submit" value=t("actions.send") class="btn btn-success btn-xs"
31
+
32
+ .clearfix
@@ -1,6 +1,3 @@
1
1
  .dorsale-events-list.dorsale-comments-list
2
2
  - events.each do |event|
3
- - if event.comment
4
- = render "dorsale/comments/comment", comment: event.comment
5
- - else
6
- = render "dorsale/customer_vault/events/event", event: event
3
+ = render "dorsale/customer_vault/events/event", event: event
@@ -0,0 +1 @@
1
+ = render "dorsale/customer_vault/events/form", event: @event
@@ -1,6 +1,6 @@
1
1
  - if policy(::Dorsale::CustomerVault::Person).create?
2
- = create_button dorsale.new_customer_vault_individual_path, action: :new_individual
3
- = create_button dorsale.new_customer_vault_corporation_path, action: :new_corporation
2
+ = create_button dorsale.new_customer_vault_individual_path, action: :new_individual, icon: "user-plus"
3
+ = create_button dorsale.new_customer_vault_corporation_path, action: :new_corporation, icon: "users"
4
4
 
5
5
  - if @people_without_pagination && policy(model).export?
6
6
  = export_button url_for(format: :xlsx), download: "#{model.ts}.xlsx"
@@ -1,5 +1,5 @@
1
1
  - content_for :page_body
2
- = render "dorsale/comments/form", comment: new_comment_for(@person)
2
+ = render "dorsale/customer_vault/events/form", event: new_event_for(@person)
3
3
  = render "dorsale/customer_vault/events/list", events: @person.self_and_related_events
4
4
 
5
5
  - if @person.try(:context).present?
@@ -8,7 +8,8 @@ table#users-list.default
8
8
 
9
9
  tbody
10
10
  - users.each do |user|
11
- tr.user
11
+ - active_class = user.is_active? ? "active" : "inactive hidden"
12
+ tr.user class=active_class
12
13
  td.user-avatar
13
14
  = avatar_img(user)
14
15
 
@@ -10,4 +10,20 @@
10
10
  - content_for :table
11
11
  = render "dorsale/users/list", users: @users
12
12
 
13
+ - content_for :page_footer
14
+ .text-center = link_to "Afficher les inactifs", "#", class: "show_inactives_link"
15
+
13
16
  = render_dorsale_page
17
+
18
+ coffee:
19
+ $(document).on "turbolinks:load", ->
20
+ show_text = "Afficher les inactifs"
21
+ hide_text = "Masquer les inactifs"
22
+ $(".show_inactives_link").click (event)->
23
+ event.preventDefault()
24
+ if $(this).text() == hide_text
25
+ $(".user.inactive").addClass("hidden")
26
+ $(this).text(show_text)
27
+ else
28
+ $(".user.inactive").removeClass("hidden")
29
+ $(this).text(hide_text)
@@ -111,10 +111,15 @@ en:
111
111
  person: "Person"
112
112
  authored_by: "by"
113
113
  all_actions: "All types"
114
+ contact_type: "Contact type"
114
115
  dorsale/customer_vault/event/action:
115
116
  create: "Create"
116
117
  update: "Update"
117
118
  comment: "Comment"
119
+ dorsale/customer_vault/event/contact_type:
120
+ contact: "Contact"
121
+ r1: "R1"
122
+ r2: "R2"
118
123
  dorsale/customer_vault/event/text:
119
124
  create: "Creation of the person"
120
125
  update: "Update person informations"
@@ -110,10 +110,15 @@ fr:
110
110
  person: "Personne"
111
111
  authored_by: "par"
112
112
  all_actions: "Tous les types"
113
+ contact_type: "Type de contact"
113
114
  dorsale/customer_vault/event/action:
114
115
  create: "Création"
115
116
  update: "Modification"
116
117
  comment: "Commentaire"
118
+ dorsale/customer_vault/event/contact_type:
119
+ contact: "Contact"
120
+ r1: "R1"
121
+ r2: "R2"
117
122
  dorsale/customer_vault/event/text:
118
123
  create: "Création de la personne"
119
124
  update: "Mise à jour des informations de la personne"
@@ -58,7 +58,7 @@ Dorsale::Engine.routes.draw do
58
58
  resources :activity_types, except: [:destroy, :show]
59
59
  resources :origins, except: [:destroy, :show]
60
60
 
61
- resources :events, only: [:index]
61
+ resources :events, only: [:index, :create, :edit, :update, :destroy]
62
62
 
63
63
  resources :people do
64
64
  resources :links
@@ -0,0 +1,22 @@
1
+ class MigratePeopleCommentsToEvents < ActiveRecord::Migration[5.0]
2
+ class Event < ::Dorsale::ApplicationRecord
3
+ self.table_name = :dorsale_customer_vault_events
4
+
5
+ belongs_to :comment, class_name: Dorsale::Comment
6
+ end
7
+
8
+ def change
9
+ add_column :dorsale_customer_vault_events, :title, :string
10
+ add_column :dorsale_customer_vault_events, :date, :date
11
+
12
+ Event.where(action: "comment").each do |event|
13
+ event.title = event.comment.title
14
+ event.text = event.comment.text
15
+ event.date = event.comment.date
16
+ event.save!
17
+ event.comment.destroy!
18
+ end
19
+
20
+ remove_column :dorsale_customer_vault_events, :comment_id
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ class CustomerVaultEventsAddContactType < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :dorsale_customer_vault_events, :contact_type, :string
4
+ end
5
+ end
@@ -53,25 +53,25 @@ Feature: Manage corporations
53
53
  Scenario: Add a comment to a corporation
54
54
  Given an existing corporation
55
55
  When I go on this corporation
56
- And I add a comment
56
+ And I add a comment on the person
57
57
  Then I am on the corporation page
58
- And I see my new comment
58
+ And I see my new comment on the person
59
59
 
60
60
  Scenario: Update comment on a corporation
61
61
  Given an existing corporation
62
62
  And an existing comment on this corporation
63
63
  When I go on this corporation
64
- And I update the comment
64
+ And I update the comment on the person
65
65
  Then I am on the corporation page
66
- And I see my updated comment
66
+ And I see my updated comment on the person
67
67
 
68
68
  Scenario: Delete comment on a corporation
69
69
  Given an existing corporation
70
70
  And an existing comment on this corporation
71
71
  When I go on this corporation
72
- And I delete the comment
72
+ And I delete the comment on the person
73
73
  Then I am on the corporation page
74
- And I see do not see my comment
74
+ And I see do not see my comment on the person
75
75
 
76
76
  Scenario: People activity
77
77
  Given an existing individual with recent comments
@@ -65,54 +65,54 @@ When(/^I go on this corporation$/) do
65
65
  visit dorsale.customer_vault_corporation_path(@corporation)
66
66
  end
67
67
 
68
- When(/^I add a comment$/) do
69
- @comments_count = Dorsale::Comment.count
70
- fill_in "comment_text", with: "MyNewComment"
68
+ When(/^I add a comment on the person$/) do
69
+ @events_count = Dorsale::CustomerVault::Event.count
70
+ fill_in "event_text", with: "MyNewComment"
71
71
  find("[type=submit]").click
72
72
  end
73
73
 
74
- Then(/^I see my new comment$/) do
75
- expect(Dorsale::Comment.count).to eq(@comments_count + 1)
74
+ Then(/^I see my new comment on the person$/) do
75
+ expect(Dorsale::CustomerVault::Event.count).to eq(@events_count + 1)
76
76
 
77
77
  expect(find("p.comment-text")).to have_content "MyNewComment"
78
78
  end
79
79
 
80
80
  Given(/^an existing comment on this corporation$/) do
81
- @comment = create(:dorsale_comment, commentable: @corporation)
81
+ @event = create(:customer_vault_event_comment, person: @corporation)
82
82
  end
83
83
 
84
- When(/^I update the comment$/) do
84
+ When(/^I update the comment on the person$/) do
85
85
  find(".comment [href*=edit]").click
86
86
  within "form[id*=edit]" do
87
- fill_in :comment_text, with: "MyUpdatedComment"
87
+ fill_in :event_text, with: "MyUpdatedComment"
88
88
  find("[type=submit]").click
89
89
  end
90
90
  end
91
91
 
92
- Then(/^I see my updated comment$/) do
92
+ Then(/^I see my updated comment on the person$/) do
93
93
  expect(find("p.comment-text")).to have_content "MyUpdatedComment"
94
94
  end
95
95
 
96
- When(/^I delete the comment$/) do
97
- @comments_count = Dorsale::Comment.count
96
+ When(/^I delete the comment on the person$/) do
97
+ @events_count = Dorsale::CustomerVault::Event.count
98
98
  find(".comment [data-method*=delete]").click
99
99
  end
100
100
 
101
- Then(/^I see do not see my comment$/) do
102
- expect(Dorsale::Comment.count).to eq(@comments_count - 1)
103
- expect(page).to have_no_content @comment.text
101
+ Then(/^I see do not see my comment on the person$/) do
102
+ expect(Dorsale::CustomerVault::Event.count).to eq(@events_count - 1)
103
+ expect(page).to have_no_content @event.text
104
104
  end
105
105
 
106
106
  Given(/^an existing individual with recent comments$/) do
107
107
  @individual = create(:customer_vault_individual)
108
- create(:dorsale_comment, commentable: @individual, text: "individual-comment-1")
109
- create(:dorsale_comment, commentable: @individual, text: "individual-comment-2")
108
+ create(:customer_vault_event_comment, person: @individual, text: "individual-comment-1")
109
+ create(:customer_vault_event_comment, person: @individual, text: "individual-comment-2")
110
110
  end
111
111
 
112
112
  Given(/^an existing corporation with recent comments$/) do
113
113
  @corporation = create(:customer_vault_corporation)
114
- create(:dorsale_comment, commentable: @corporation, text: "corporation-comment-1")
115
- create(:dorsale_comment, commentable: @corporation, text: "corporation-comment-2")
114
+ create(:customer_vault_event_comment, person: @corporation, text: "corporation-comment-1")
115
+ create(:customer_vault_event_comment, person: @corporation, text: "corporation-comment-2")
116
116
  end
117
117
 
118
118
  When(/^I go on the people activity$/) do
@@ -130,7 +130,7 @@ Given(/^an existing corporation with (\d+) comments$/) do |n|
130
130
  step "an existing corporation"
131
131
 
132
132
  n.to_i.times do
133
- create(:dorsale_comment, commentable: @corporation)
133
+ create(:customer_vault_event_comment, person: @corporation)
134
134
  end
135
135
  end
136
136
 
@@ -7,7 +7,7 @@ Then(/^the file is downloaded$/) do
7
7
  end
8
8
 
9
9
  Given(/^a very long comment on this person$/) do
10
- @comment = create(:dorsale_comment, commentable: @person, text: Faker::Lorem.paragraph(10))
10
+ @comment = create(:customer_vault_event_comment, person: @person, text: Faker::Lorem.paragraph(10))
11
11
  end
12
12
 
13
13
  Then(/^I see the truncated comment$/) do
@@ -21,5 +21,5 @@ Then(/^I see the full comment$/) do
21
21
  end
22
22
 
23
23
  Given(/^a short comment on this person$/) do
24
- @comment = create(:dorsale_comment, commentable: @person, text: "i am short")
24
+ @comment = create(:customer_vault_event_comment, person: @person, text: "i am short")
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module Dorsale
2
- VERSION = "3.7.8"
2
+ VERSION = "3.8.0"
3
3
  end
@@ -29,20 +29,6 @@ describe Dorsale::CommentsController, type: :controller do
29
29
  post :create, params: valid_params
30
30
  expect(response).to redirect_to("/")
31
31
  end
32
-
33
- describe "on person" do
34
- it "should create an event" do
35
- expect {
36
- post :create, params: valid_params
37
- }.to change(Dorsale::CustomerVault::Event, :count).by(1)
38
-
39
- event = Dorsale::CustomerVault::Event.last_created
40
- expect(event.author).to eq user
41
- expect(event.person).to eq commentable
42
- expect(event.comment).to eq Dorsale::Comment.last_created
43
- expect(event.action).to eq "comment"
44
- end
45
- end # describe "on person"
46
32
  end
47
33
 
48
34
  describe "update" do
@@ -60,18 +46,5 @@ describe Dorsale::CommentsController, type: :controller do
60
46
  delete :destroy, params: {id: comment, back_url: "/"}
61
47
  expect(response).to redirect_to("/")
62
48
  end
63
-
64
- describe "on person" do
65
- it "should delete event" do
66
- person = create(:customer_vault_corporation)
67
- comment = create(:dorsale_comment, commentable: person)
68
- event = create(:customer_vault_event, person: person, comment: comment, action: "comment")
69
-
70
- delete :destroy, params: {id: comment}
71
-
72
- expect { comment.reload }.to raise_error(ActiveRecord::RecordNotFound)
73
- expect { event.reload }.to raise_error(ActiveRecord::RecordNotFound)
74
- end
75
- end # describe "on person"
76
49
  end
77
50
  end
@@ -3,5 +3,11 @@ FactoryGirl.define do
3
3
  author { build(:user) }
4
4
  person { build(:customer_vault_corporation) }
5
5
  action { "create" }
6
+ text { "Création de la personne" }
7
+ end
8
+
9
+ factory :customer_vault_event_comment, parent: :customer_vault_event do
10
+ action { "comment" }
11
+ text { "Je suis un commentaire" }
6
12
  end
7
13
  end
@@ -3,11 +3,5 @@ FactoryGirl.define do
3
3
  commentable { create(:customer_vault_corporation) }
4
4
  author { create(:user) }
5
5
  text { Faker::Lorem.paragraph }
6
-
7
- after(:create) do |comment|
8
- if comment.commentable.is_a?(Dorsale::CustomerVault::Person)
9
- comment.commentable.receive_comment_notification(comment, :create)
10
- end
11
- end
12
6
  end
13
7
  end
@@ -15,13 +15,6 @@ RSpec.describe Dorsale::Comment, type: :model do
15
15
  it "should have a valid factory" do
16
16
  expect(create(:dorsale_comment)).to be_valid
17
17
  end
18
-
19
- it "should create an event if commentable is a person" do
20
- person = create(:customer_vault_corporation)
21
- expect {
22
- comment = create(:dorsale_comment, commentable: person)
23
- }.to change(Dorsale::CustomerVault::Event, :count).by(1)
24
- end
25
18
  end # describe "factories"
26
19
 
27
20
  describe "default values" do
@@ -3,18 +3,12 @@ require 'rails_helper'
3
3
  RSpec.describe ::Dorsale::CustomerVault::Event, type: :model do
4
4
  it { is_expected.to belong_to :author }
5
5
  it { is_expected.to belong_to :person }
6
- it { is_expected.to belong_to :comment }
7
6
 
8
7
  it { is_expected.to validate_presence_of :person }
9
8
  it { is_expected.to validate_presence_of :action }
10
9
 
11
10
  it { is_expected.to_not validate_presence_of :author }
12
- it { is_expected.to_not validate_presence_of :comment }
13
-
14
- it "should validate comment if action is comment" do
15
- event = described_class.new(action: "comment")
16
- expect(event).to validate_presence_of :comment
17
- end
11
+ it { is_expected.to_not validate_presence_of :contact_type }
18
12
 
19
13
  it "should have a valid factory" do
20
14
  event = create(:customer_vault_event)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorsale
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.8
4
+ version: 3.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - agilidée
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-12 00:00:00.000000000 Z
11
+ date: 2017-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -716,9 +716,13 @@ files:
716
716
  - app/views/dorsale/customer_vault/activity_types/index.html.slim
717
717
  - app/views/dorsale/customer_vault/activity_types/new.html.slim
718
718
  - app/views/dorsale/customer_vault/corporations/_context.html.slim
719
+ - app/views/dorsale/customer_vault/events/_action_comment.html.slim
720
+ - app/views/dorsale/customer_vault/events/_action_other.html.slim
719
721
  - app/views/dorsale/customer_vault/events/_event.html.slim
720
722
  - app/views/dorsale/customer_vault/events/_filters.html.slim
723
+ - app/views/dorsale/customer_vault/events/_form.html.slim
721
724
  - app/views/dorsale/customer_vault/events/_list.html.slim
725
+ - app/views/dorsale/customer_vault/events/edit.html.slim
722
726
  - app/views/dorsale/customer_vault/events/index.html.slim
723
727
  - app/views/dorsale/customer_vault/individuals/_context.html.slim
724
728
  - app/views/dorsale/customer_vault/links/edit.html.slim
@@ -855,6 +859,8 @@ files:
855
859
  - db/migrate/20170427083541_remove_useless_polymorphic_belongs_to.rb
856
860
  - db/migrate/20170427093507_add_origin_and_activity_type_to_customer_vault_people.rb
857
861
  - db/migrate/20170915070538_dorsale_customer_vault_events_add_text.rb
862
+ - db/migrate/20171023080507_migrate_people_comments_to_events.rb
863
+ - db/migrate/20171023133219_customer_vault_events_add_contact_type.rb
858
864
  - features/access.feature
859
865
  - features/billing_machine_id_cards.feature
860
866
  - features/billing_machine_invoices.feature