dorsale 3.5.1 → 3.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8fd76e9602e5d327405b05c83df5f45a94d0b02
4
- data.tar.gz: 3b7282e1f9d793d5dc0f687603051f816791e488
3
+ metadata.gz: 91e5341eb8cfffe13a70e3a8ee82da977139c0a2
4
+ data.tar.gz: 1f9010dd33f9a3e4ed88e3fea11ce31dd530c36d
5
5
  SHA512:
6
- metadata.gz: 9fc09fc9312276e737bf174326c9abd95199105c81e76fa26e3ed65330d5c0c264e88624db0acf38eaed1b58f79db1917d7fe3bf9021fc14e5687957f1ef4a3e
7
- data.tar.gz: cfcedff1fe60c18667cc417a525a8f2257a72dbe8dca2fc6cd8415c94a4285f7147563b3009b1b1538d59e34f1eee2c72c45905cc75b69d76be1ab2a04fafc8c
6
+ metadata.gz: 7ab4ad3cfed29a2ca2a86fde75db9ddf1a1d2bf038bc64e8b790c5afa3896f59c7f9f6e044eee91aa92513e1cf47c3642cbcd784a0e1a9c38d8e0ec31d7936d6
7
+ data.tar.gz: 8b4980ddc931a658e670d68a7834ef3bf76fd0510a1936e9c5fb292fcc93e8deafd18ca197a993d474b4d61cde6aa0c76c83b45f28063dad89a04d4792876926
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.5.2
4
+
5
+ - Comments improvements
6
+ - Add infos to people context
7
+
3
8
  ## 3.5.1
4
9
 
5
10
  - Add title and date to comments
@@ -16,6 +16,9 @@
16
16
  .comment-fields
17
17
  margin-left: 65px
18
18
 
19
+ input, textarea
20
+ font-size: $font-size-base
21
+
19
22
  .comment-title-field
20
23
  display: inline-block
21
24
  width: calc(100% - 10rem - 0.5rem)
@@ -52,7 +55,8 @@
52
55
  font-size: 80%
53
56
  margin-left: 1.5rem
54
57
 
55
- p.comment-text
58
+ p.comment-text,
59
+ p.comment-text-truncated,
56
60
  margin: 1rem 0 0 65px
57
61
 
58
62
  p.comment-text-truncated + p.comment-text
@@ -7,6 +7,7 @@ module Dorsale::AllHelpers
7
7
  include ::Dorsale::CommentsHelper
8
8
  include ::Dorsale::Alexandrie::AttachmentsHelper
9
9
  include ::Dorsale::BillingMachine::ApplicationHelper
10
+ include ::Dorsale::CustomerVault::ApplicationHelper
10
11
  include ::Dorsale::Flyboy::ApplicationHelper
11
12
  include ::Dorsale::ExpenseGun::ApplicationHelper
12
13
  include ::Dorsale::UsersHelper
@@ -1,10 +1,8 @@
1
1
  module Dorsale::CommentsHelper
2
- def comments_for(commentable, options = {})
3
- comments = policy_scope(::Dorsale::Comment)
4
- .where(commentable: commentable)
5
- .preload(:commentable, :author)
6
-
7
- new_comment = comments.new(author: current_user)
2
+ def comments_for(commentable, comments = nil)
3
+ comments = ::Dorsale::Comment.where(commentable: commentable) if comments.nil?
4
+ comments = policy_scope(comments).preload(:commentable, :author)
5
+ new_comment = policy_scope(comments).new(commentable: commentable, author: current_user)
8
6
 
9
7
  render(
10
8
  :partial => "dorsale/comments/comments",
@@ -15,7 +13,24 @@ module Dorsale::CommentsHelper
15
13
  )
16
14
  end
17
15
 
18
- def truncate_comment_text?
19
- controller_name == "people" && action_name == "activity"
16
+ def truncate_comments_in_this_page?
17
+ controller_name == "people"
18
+ end
19
+
20
+ def truncate_comment_text(comment)
21
+ text = comment.text.to_s
22
+ truncated = false
23
+
24
+ if text.to_s.count("\n") > 3
25
+ text = text.split("\n")[0, 3].join("\n")
26
+ truncated = true
27
+ end
28
+
29
+ if text.to_s.length > 300
30
+ text = truncate(text, length: 200)
31
+ truncated = true
32
+ end
33
+
34
+ text2html(text) if truncated
20
35
  end
21
36
  end
@@ -13,4 +13,30 @@ module Dorsale::CustomerVault::ApplicationHelper
13
13
  [Dorsale::CustomerVault::Individual.t, "Dorsale::CustomerVault::Individual"],
14
14
  ]
15
15
  end
16
+
17
+ def person_address_blank?(person)
18
+ [
19
+ person.address.street,
20
+ person.address.street_bis,
21
+ person.address.zip,
22
+ person.address.city,
23
+ person.address.country,
24
+ ].all?(&:blank?)
25
+ end
26
+
27
+ def person_social_blank?(person)
28
+ [
29
+ person.skype,
30
+ person.www,
31
+ person.twitter,
32
+ person.facebook,
33
+ person.linkedin,
34
+ person.viadeo,
35
+ person.try(:societe_com),
36
+ ].all?(&:blank?)
37
+ end
38
+
39
+ def person_related_people_blank?(person)
40
+ person.individuals.empty?
41
+ end
16
42
  end
@@ -9,7 +9,7 @@ class Dorsale::Comment < ::Dorsale::ApplicationRecord
9
9
 
10
10
  default_scope -> {
11
11
  all
12
- .order(date: :desc, created_at: :desc)
12
+ .order(created_at: :desc, id: :desc)
13
13
  .preload(:author)
14
14
  }
15
15
 
@@ -5,6 +5,10 @@ class Dorsale::CustomerVault::Corporation < Dorsale::CustomerVault::Person
5
5
  validates :corporation_name, presence: true
6
6
  has_many :individuals
7
7
 
8
+ def self_and_related_comments
9
+ ::Dorsale::Comment.where(commentable: [self] + individuals)
10
+ end
11
+
8
12
  def name
9
13
  corporation_name
10
14
  end
@@ -6,6 +6,10 @@ class Dorsale::CustomerVault::Individual < Dorsale::CustomerVault::Person
6
6
  validates :last_name, presence: true
7
7
  belongs_to :corporation
8
8
 
9
+ def self_and_related_comments
10
+ comments
11
+ end
12
+
9
13
  def name
10
14
  [self.last_name, self.first_name].join(", ")
11
15
  end
@@ -20,7 +20,7 @@ class Dorsale::CustomerVault::Person < ::Dorsale::ApplicationRecord
20
20
 
21
21
  acts_as_taggable
22
22
 
23
- has_many :comments, -> { order(created_at: :desc, id: :desc) }, class_name: ::Dorsale::Comment, as: :commentable, dependent: :destroy
23
+ has_many :comments, class_name: ::Dorsale::Comment, as: :commentable, dependent: :destroy
24
24
  has_one :address, class_name: ::Dorsale::Address, as: :addressable, inverse_of: :addressable, dependent: :destroy
25
25
  has_many :tasks, class_name: ::Dorsale::Flyboy::Task, as: :taskable, dependent: :destroy
26
26
  has_many :invoices, class_name: ::Dorsale::BillingMachine::Invoice, as: :customer
@@ -30,9 +30,9 @@
30
30
  span.comment-author
31
31
  = comment.author.to_s
32
32
 
33
- - if truncate_comment_text? && comment.text.length > 300
33
+ - if truncate_comments_in_this_page? && text = truncate_comment_text(comment)
34
34
  p.comment-text-truncated
35
- = truncate(comment.text, length: 200)
35
+ = text
36
36
  = " "
37
37
  a.comment-show_more href="#"
38
38
  = ta(:show_more)
@@ -9,11 +9,10 @@
9
9
 
10
10
  .context-body
11
11
  p.text-center = avatar_img(person)
12
- = render "dorsale/customer_vault/people/context_general", person: person
13
- hr
14
- = render "dorsale/customer_vault/people/context_address", person: person
15
- hr
16
- = render 'dorsale/customer_vault/people/context_social', person: person
12
+ = render "dorsale/customer_vault/people/context_general", person: person
13
+ = render "dorsale/customer_vault/people/context_related_people", person: person
14
+ = render "dorsale/customer_vault/people/context_address", person: person
15
+ = render 'dorsale/customer_vault/people/context_social', person: person
17
16
 
18
17
  .context-footer
19
18
  = actions_for(person)
@@ -1,6 +1,8 @@
1
- - address = person.address
2
- = info address, :street
3
- = info address, :street_bis
4
- = info address, :city
5
- = info address, :zip
6
- = info address, :country
1
+ .sub-context class=("blank" if person_address_blank?(person))
2
+ hr
3
+ - address = person.address
4
+ = info address, :street
5
+ = info address, :street_bis
6
+ = info address, :city
7
+ = info address, :zip
8
+ = info address, :country
@@ -1,5 +1,11 @@
1
- = info person, :tags, tags(person)
2
- = info person, :email, helper: :email_link
3
- = info person, :phone, helper: :tel_link
4
- = info person, :mobile, helper: :tel_link
5
- = info person, :fax, helper: :tel_link
1
+ .sub-context
2
+ = info person, :tags, tags(person)
3
+
4
+ - if person.individual?
5
+ = info person, :corporation, helper: :link_to_object
6
+ = info person, :title
7
+
8
+ = info person, :email, helper: :email_link
9
+ = info person, :phone, helper: :tel_link
10
+ = info person, :mobile, helper: :tel_link
11
+ = info person, :fax, helper: :tel_link
@@ -0,0 +1,5 @@
1
+ - return unless person.corporation?
2
+
3
+ .sub-context class=("blank" if person_related_people_blank?(person))
4
+ hr
5
+ = info person, :individuals, person.individuals.map { |i| link_to_object(i) }.join(tag(:br)).html_safe
@@ -1,6 +1,11 @@
1
- = info person, :skype, helper: :email_link
2
- = info person, :www, helper: :web_link
3
- = info person, :twitter, helper: :web_link
4
- = info person, :facebook, helper: :web_link
5
- = info person, :linkedin, helper: :web_link
6
- = info person, :viadeo, helper: :web_link
1
+ .sub-context class=("blank" if person_social_blank?(person))
2
+ hr
3
+ = info person, :skype, helper: :email_link
4
+ = info person, :www, helper: :web_link
5
+ = info person, :twitter, helper: :web_link
6
+ = info person, :facebook, helper: :web_link
7
+ = info person, :linkedin, helper: :web_link
8
+ = info person, :viadeo, helper: :web_link
9
+
10
+ - if person.corporation?
11
+ = info person, :societe_com, helper: :web_link
@@ -1,5 +1,5 @@
1
1
  - content_for :page_body
2
- = comments_for(@person)
2
+ = comments_for(@person, @person.self_and_related_comments)
3
3
 
4
4
  - if @person.try(:context).present?
5
5
  .panel.panel-default: .panel-body = text2html(@person.context)
@@ -67,6 +67,8 @@ en:
67
67
  legal_form: "Legal form"
68
68
  count: "Number of people"
69
69
  person_type: "Type"
70
+ title: "Title"
71
+ individuals: "Individuals"
70
72
  dorsale/customer_vault/individual:
71
73
  <<: *customer_vault_person_attributes
72
74
  dorsale/customer_vault/corporation:
@@ -68,6 +68,7 @@ fr:
68
68
  count: "Nombre de contacts"
69
69
  person_type: "Type"
70
70
  title: "Fonction"
71
+ individuals: "Individus"
71
72
  dorsale/customer_vault/individual:
72
73
  <<: *customer_vault_person_attributes
73
74
  dorsale/customer_vault/corporation:
@@ -1,3 +1,3 @@
1
1
  module Dorsale
2
- VERSION = "3.5.1"
2
+ VERSION = "3.5.2"
3
3
  end
@@ -24,7 +24,16 @@ RSpec.describe ::Dorsale::CustomerVault::Person, type: :model do
24
24
  expect { link.reload }.to raise_error(ActiveRecord::RecordNotFound)
25
25
  end
26
26
  end
27
-
28
27
  end # describe '#links'
29
28
 
29
+ it "should return self_and_related_comments" do
30
+ corporation = create(:customer_vault_corporation)
31
+ individual = create(:customer_vault_individual, corporation: corporation)
32
+ corporation_comment = create(:dorsale_comment, commentable: corporation)
33
+ individual_comment = create(:dorsale_comment, commentable: individual)
34
+
35
+ expect(corporation.self_and_related_comments).to contain_exactly(corporation_comment, individual_comment)
36
+ expect(individual.self_and_related_comments).to contain_exactly(individual_comment)
37
+ end
38
+
30
39
  end
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.5.1
4
+ version: 3.5.2
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-04-07 00:00:00.000000000 Z
11
+ date: 2017-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -703,6 +703,7 @@ files:
703
703
  - app/views/dorsale/customer_vault/people/_context.html.slim
704
704
  - app/views/dorsale/customer_vault/people/_context_address.html.slim
705
705
  - app/views/dorsale/customer_vault/people/_context_general.html.slim
706
+ - app/views/dorsale/customer_vault/people/_context_related_people.slim
706
707
  - app/views/dorsale/customer_vault/people/_context_social.html.slim
707
708
  - app/views/dorsale/customer_vault/people/_data_context.html.slim
708
709
  - app/views/dorsale/customer_vault/people/_filters.html.slim