customer_vault 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +2 -2
  3. data/app/assets/images/customer_vault/icons/group-128.png +0 -0
  4. data/app/assets/images/customer_vault/icons/group-16.png +0 -0
  5. data/app/assets/images/customer_vault/icons/group-20.png +0 -0
  6. data/app/assets/images/customer_vault/icons/group-24.png +0 -0
  7. data/app/assets/images/customer_vault/icons/group-256.png +0 -0
  8. data/app/assets/images/customer_vault/icons/group-32.png +0 -0
  9. data/app/assets/images/customer_vault/icons/group-48.png +0 -0
  10. data/app/assets/images/customer_vault/icons/group-512.png +0 -0
  11. data/app/assets/images/customer_vault/icons/group-64.png +0 -0
  12. data/app/assets/stylesheets/customer_vault/{application.css → application.css.scss} +54 -5
  13. data/app/assets/stylesheets/customer_vault/{people.css → individuals.css} +1 -0
  14. data/app/assets/stylesheets/customer_vault/links.css +3 -0
  15. data/app/controllers/customer_vault/corporations_controller.rb +5 -7
  16. data/app/controllers/customer_vault/individuals_controller.rb +61 -0
  17. data/app/controllers/customer_vault/links_controller.rb +53 -0
  18. data/app/controllers/customer_vault/people_controller.rb +5 -54
  19. data/app/helpers/customer_vault/individuals_helper.rb +4 -0
  20. data/app/models/customer_vault/corporation.rb +5 -1
  21. data/app/models/customer_vault/individual.rb +15 -0
  22. data/app/models/customer_vault/link.rb +6 -0
  23. data/app/models/customer_vault/person.rb +13 -2
  24. data/app/views/customer_vault/corporations/_form.html.slim +28 -21
  25. data/app/views/customer_vault/corporations/_list_details.html.slim +29 -0
  26. data/app/views/customer_vault/corporations/_show_details.html.slim +36 -0
  27. data/app/views/customer_vault/corporations/edit.html.slim +22 -7
  28. data/app/views/customer_vault/corporations/new.html.slim +22 -5
  29. data/app/views/customer_vault/corporations/show.html.slim +41 -16
  30. data/app/views/customer_vault/{people → individuals}/_form.html.slim +16 -13
  31. data/app/views/customer_vault/individuals/_list_details.html.slim +39 -0
  32. data/app/views/customer_vault/individuals/_show_details.html.slim +52 -0
  33. data/app/views/customer_vault/individuals/edit.html.slim +23 -0
  34. data/app/views/customer_vault/individuals/new.html.slim +25 -0
  35. data/app/views/customer_vault/individuals/show.html.slim +42 -0
  36. data/app/views/customer_vault/layout/_form_error.html.slim +5 -0
  37. data/app/views/customer_vault/links/_aside.html.slim +4 -0
  38. data/app/views/customer_vault/links/_title.html.slim +3 -0
  39. data/app/views/customer_vault/links/edit.html.slim +30 -0
  40. data/app/views/customer_vault/links/new.html.slim +32 -0
  41. data/app/views/customer_vault/people/_select.html.slim +1 -0
  42. data/app/views/customer_vault/people/index.html.slim +29 -58
  43. data/config/cucumber.yml +8 -0
  44. data/config/routes.rb +7 -3
  45. data/db/migrate/20141016151955_change_people_to_individuals.rb +5 -0
  46. data/db/migrate/20141017085621_add_link.rb +12 -0
  47. data/lib/customer_vault/engine.rb +1 -0
  48. data/lib/customer_vault/version.rb +1 -1
  49. data/lib/tasks/cucumber.rake +65 -0
  50. data/spec/controllers/customer_vault/corporations_controller_spec.rb +3 -9
  51. data/spec/controllers/customer_vault/individuals_controller_spec.rb +156 -0
  52. data/spec/dummy/config/initializers/inflections.rb +1 -1
  53. data/spec/dummy/config/routes.rb +1 -1
  54. data/spec/dummy/db/development.sqlite3 +0 -0
  55. data/spec/dummy/db/migrate/20141013153526_create_dorsale_addresses.dorsale.rb +14 -0
  56. data/spec/dummy/db/migrate/20141014073225_add_polymorphic_fields_to_addresses.dorsale.rb +7 -0
  57. data/spec/dummy/db/schema.rb +24 -2
  58. data/spec/dummy/db/test.sqlite3 +0 -0
  59. data/spec/dummy/log/development.log +22059 -0
  60. data/spec/dummy/log/test.log +35561 -0
  61. data/spec/dummy/tmp/cache/assets/development/sass/8f425af8af5194cec6da5008411d913407b2b024/application.css.scssc +0 -0
  62. data/spec/dummy/tmp/cache/assets/development/sprockets/03c4e7aa08d7d8a9e984a1e4eea01566 +0 -0
  63. data/spec/dummy/tmp/cache/assets/development/sprockets/190ff82deecfbbe385c03ee8f8f3d2bf +0 -0
  64. data/spec/dummy/tmp/cache/assets/development/sprockets/201cb9b3ce55f2f4dea6232ab8220cc3 +0 -0
  65. data/spec/dummy/tmp/cache/assets/development/sprockets/2de61d7dd16d9e661790bc2973cc609a +0 -0
  66. data/spec/dummy/tmp/cache/assets/development/sprockets/34d14962fde7e4fd6e2671844bcfaa78 +0 -0
  67. data/spec/dummy/tmp/cache/assets/development/sprockets/39c67f2e186cde8355bb4533f16da267 +0 -0
  68. data/spec/dummy/tmp/cache/assets/development/sprockets/47170c4182a8457e8d53507ea76fa76b +0 -0
  69. data/spec/dummy/tmp/cache/assets/development/sprockets/471d75c3acc9522efc857f3be05b8375 +0 -0
  70. data/spec/dummy/tmp/cache/assets/development/sprockets/49ff98533b89b4c09d5d1ecb9d45f207 +0 -0
  71. data/spec/dummy/tmp/cache/assets/development/sprockets/4b15ccd40e1d9deecfe3f523edb32a25 +0 -0
  72. data/spec/dummy/tmp/cache/assets/development/sprockets/4cd6d71a32c5da916328bfcfa972bd6c +0 -0
  73. data/spec/dummy/tmp/cache/assets/development/sprockets/5d0e775359a27eb80c837eee1bdd52cb +0 -0
  74. data/spec/dummy/tmp/cache/assets/development/sprockets/6355dea7c574d08602bd4e7e16a4c0d2 +0 -0
  75. data/spec/dummy/tmp/cache/assets/development/sprockets/6847fabb2f2a2ff6011d957adb14a11e +0 -0
  76. data/spec/dummy/tmp/cache/assets/development/sprockets/78ef508640527d1bb135c1077223fb7c +0 -0
  77. data/spec/dummy/tmp/cache/assets/development/sprockets/8e1929049a5ed5974d9bbb22b2c1bbc4 +0 -0
  78. data/spec/dummy/tmp/cache/assets/development/sprockets/92220e9fcf5e0717b9dc27169bf512e9 +0 -0
  79. data/spec/dummy/tmp/cache/assets/development/sprockets/a774486cb0f2787691a7e585e008caea +0 -0
  80. data/spec/dummy/tmp/cache/assets/development/sprockets/aa60fba48cd1c25f138255570918b3db +0 -0
  81. data/spec/dummy/tmp/cache/assets/development/sprockets/ac788eb47a519e5f2837cf9504d74f53 +0 -0
  82. data/spec/dummy/tmp/cache/assets/development/sprockets/ac8cf41eb80a554f4f15e80fa6e1ea58 +0 -0
  83. data/spec/dummy/tmp/cache/assets/development/sprockets/df9e45a4bc905f29f8544c37dc9e9a18 +0 -0
  84. data/spec/dummy/tmp/cache/assets/development/sprockets/e5782a71fc01b88e6ac0c1c963bf7e3e +0 -0
  85. data/spec/dummy/tmp/cache/assets/development/sprockets/f516186931f15a3e5c86af1b1632d256 +0 -0
  86. data/spec/dummy/tmp/cache/assets/development/sprockets/faca8abcf70e21e966cebb74604b729f +0 -0
  87. data/spec/dummy/tmp/cache/assets/test/sass/8f425af8af5194cec6da5008411d913407b2b024/application.css.scssc +0 -0
  88. data/spec/dummy/tmp/cache/assets/test/sprockets/03c4e7aa08d7d8a9e984a1e4eea01566 +0 -0
  89. data/spec/dummy/tmp/cache/assets/test/sprockets/0e2a9601926844c961e7e97d32e775be +0 -0
  90. data/spec/dummy/tmp/cache/assets/test/sprockets/183bdc6b3ba504dc16e7b94a0f38fe06 +0 -0
  91. data/spec/dummy/tmp/cache/assets/test/sprockets/190ff82deecfbbe385c03ee8f8f3d2bf +0 -0
  92. data/spec/dummy/tmp/cache/assets/test/sprockets/1dc5cb7209fcdb172bfcde9c841c19e3 +0 -0
  93. data/spec/dummy/tmp/cache/assets/test/sprockets/201cb9b3ce55f2f4dea6232ab8220cc3 +0 -0
  94. data/spec/dummy/tmp/cache/assets/test/sprockets/2b9d45522b3d1f3105e1c33e325dc6de +0 -0
  95. data/spec/dummy/tmp/cache/assets/test/sprockets/2df425d43fef5663aadfc1bcc3087066 +0 -0
  96. data/spec/dummy/tmp/cache/assets/test/sprockets/2e7625733abd8050be92fe0ca1487fad +0 -0
  97. data/spec/dummy/tmp/cache/assets/test/sprockets/31876fc299b61887fae3e657773d7b15 +0 -0
  98. data/spec/dummy/tmp/cache/assets/test/sprockets/338e8df8f4119a2a48b920613a8026a9 +0 -0
  99. data/spec/dummy/tmp/cache/assets/test/sprockets/34d14962fde7e4fd6e2671844bcfaa78 +0 -0
  100. data/spec/dummy/tmp/cache/assets/test/sprockets/36adb34aba0d7825a4c9a4cf09c33572 +0 -0
  101. data/spec/dummy/tmp/cache/assets/test/sprockets/39c67f2e186cde8355bb4533f16da267 +0 -0
  102. data/spec/dummy/tmp/cache/assets/test/sprockets/40dbaa1db791d7be2279ddd67d33a1c4 +0 -0
  103. data/spec/dummy/tmp/cache/assets/test/sprockets/47170c4182a8457e8d53507ea76fa76b +0 -0
  104. data/spec/dummy/tmp/cache/assets/test/sprockets/471d75c3acc9522efc857f3be05b8375 +0 -0
  105. data/spec/dummy/tmp/cache/assets/test/sprockets/49ff98533b89b4c09d5d1ecb9d45f207 +0 -0
  106. data/spec/dummy/tmp/cache/assets/test/sprockets/4b15ccd40e1d9deecfe3f523edb32a25 +0 -0
  107. data/spec/dummy/tmp/cache/assets/test/sprockets/4cd6d71a32c5da916328bfcfa972bd6c +0 -0
  108. data/spec/dummy/tmp/cache/assets/test/sprockets/4d0235c7b6e465a89ad270537681be7f +0 -0
  109. data/spec/dummy/tmp/cache/assets/test/sprockets/52f82b29641b7e97fabca983410c944d +0 -0
  110. data/spec/dummy/tmp/cache/assets/test/sprockets/5b95ef84d5ea3822d0364f3a6f5fa9ff +0 -0
  111. data/spec/dummy/tmp/cache/assets/test/sprockets/5bc4ad6e6b955197190847aeff8df8bd +0 -0
  112. data/spec/dummy/tmp/cache/assets/test/sprockets/5d0e775359a27eb80c837eee1bdd52cb +0 -0
  113. data/spec/dummy/tmp/cache/assets/test/sprockets/6355dea7c574d08602bd4e7e16a4c0d2 +0 -0
  114. data/spec/dummy/tmp/cache/assets/test/sprockets/67a7734fae2f02d979ee498add75d3eb +0 -0
  115. data/spec/dummy/tmp/cache/assets/test/sprockets/6847fabb2f2a2ff6011d957adb14a11e +0 -0
  116. data/spec/dummy/tmp/cache/assets/test/sprockets/78ef508640527d1bb135c1077223fb7c +0 -0
  117. data/spec/dummy/tmp/cache/assets/test/sprockets/86a049860d05103d78ab689003d6ccb3 +0 -0
  118. data/spec/dummy/tmp/cache/assets/test/sprockets/8e1929049a5ed5974d9bbb22b2c1bbc4 +0 -0
  119. data/spec/dummy/tmp/cache/assets/test/sprockets/92220e9fcf5e0717b9dc27169bf512e9 +0 -0
  120. data/spec/dummy/tmp/cache/assets/test/sprockets/a5c73696137ab9dbdda376c8d7ffa3b9 +0 -0
  121. data/spec/dummy/tmp/cache/assets/test/sprockets/a8e30d24c0bb5789981c4751cd2cdd76 +0 -0
  122. data/spec/dummy/tmp/cache/assets/test/sprockets/ac788eb47a519e5f2837cf9504d74f53 +0 -0
  123. data/spec/dummy/tmp/cache/assets/test/sprockets/ac8cf41eb80a554f4f15e80fa6e1ea58 +0 -0
  124. data/spec/dummy/tmp/cache/assets/test/sprockets/b10f86698e41bfdaafc9fb6bbf5bfbd9 +0 -0
  125. data/spec/dummy/tmp/cache/assets/test/sprockets/c08aad292c2ca4aee63f927a45ba90ef +0 -0
  126. data/spec/dummy/tmp/cache/assets/test/sprockets/c9db74506cdab0aec9f855c956f47726 +0 -0
  127. data/spec/dummy/tmp/cache/assets/test/sprockets/d04aeffd159aa29e71a9770dc8630259 +0 -0
  128. data/spec/dummy/tmp/cache/assets/test/sprockets/db5f1ec4fd27d454a95b2824fff064d1 +0 -0
  129. data/spec/dummy/tmp/cache/assets/test/sprockets/df9e45a4bc905f29f8544c37dc9e9a18 +0 -0
  130. data/spec/dummy/tmp/cache/assets/test/sprockets/e5782a71fc01b88e6ac0c1c963bf7e3e +0 -0
  131. data/spec/dummy/tmp/cache/assets/test/sprockets/f516186931f15a3e5c86af1b1632d256 +0 -0
  132. data/spec/dummy/tmp/cache/assets/test/sprockets/faca8abcf70e21e966cebb74604b729f +0 -0
  133. data/spec/dummy/tmp/capybara/capybara-201410171416122395182759.html +13 -0
  134. data/spec/factories/customer_vault_corporations.rb +4 -4
  135. data/spec/factories/{customer_vault_people.rb → customer_vault_individuals.rb} +1 -1
  136. data/spec/factories/customer_vault_links.rb +9 -0
  137. data/spec/helpers/customer_vault/{people_helper_spec.rb → individuals_helper_spec.rb} +3 -3
  138. data/spec/models/customer_vault/corporation_spec.rb +1 -0
  139. data/spec/models/customer_vault/individual_spec.rb +15 -0
  140. data/spec/models/customer_vault/link_spec.rb +13 -0
  141. data/spec/models/customer_vault/person_spec.rb +28 -6
  142. data/spec/routing/customer_vault/corporations_routing_spec.rb +22 -4
  143. data/spec/routing/customer_vault/individual_routing_spec.rb +54 -0
  144. data/spec/routing/customer_vault/people_routing_spec.rb +1 -26
  145. data/spec/spec_helper.rb +1 -0
  146. data/spec/views/customer_vault/individuals/edit.html.slim_spec.rb +47 -0
  147. data/spec/views/customer_vault/individuals/new.html.slim_spec.rb +47 -0
  148. data/spec/views/customer_vault/{people → individuals}/show.html.slim_spec.rb +2 -3
  149. metadata +226 -49
  150. data/app/assets/images/customer_vault/icons/add_person-128.png +0 -0
  151. data/app/assets/images/customer_vault/icons/add_person-20.png +0 -0
  152. data/app/assets/images/customer_vault/icons/add_person-24.png +0 -0
  153. data/app/assets/images/customer_vault/icons/add_person-256.png +0 -0
  154. data/app/assets/images/customer_vault/icons/add_person-32.png +0 -0
  155. data/app/assets/images/customer_vault/icons/add_person-48.png +0 -0
  156. data/app/assets/images/customer_vault/icons/add_person-512.png +0 -0
  157. data/app/assets/images/customer_vault/icons/add_person-64.png +0 -0
  158. data/app/helpers/customer_vault/people_helper.rb +0 -12
  159. data/app/views/customer_vault/corporations/index.html.slim +0 -27
  160. data/app/views/customer_vault/people/edit.html.slim +0 -21
  161. data/app/views/customer_vault/people/new.html.slim +0 -21
  162. data/app/views/customer_vault/people/show.html.slim +0 -57
  163. data/spec/controllers/customer_vault/people_controller_spec.rb +0 -163
  164. data/spec/views/customer_vault/corporations/index.html.slim_spec.rb +0 -29
  165. data/spec/views/customer_vault/people/edit.html.slim_spec.rb +0 -47
  166. data/spec/views/customer_vault/people/index.html.slim_spec.rb +0 -43
  167. data/spec/views/customer_vault/people/new.html.slim_spec.rb +0 -47
  168. /data/app/assets/images/customer_vault/icons/{people-128.png → individual-128.png} +0 -0
  169. /data/app/assets/images/customer_vault/icons/{people-16.png → individual-16.png} +0 -0
  170. /data/app/assets/images/customer_vault/icons/{people-20.png → individual-20.png} +0 -0
  171. /data/app/assets/images/customer_vault/icons/{people-24.png → individual-24.png} +0 -0
  172. /data/app/assets/images/customer_vault/icons/{people-256.png → individual-256.png} +0 -0
  173. /data/app/assets/images/customer_vault/icons/{people-32.png → individual-32.png} +0 -0
  174. /data/app/assets/images/customer_vault/icons/{people-48.png → individual-48.png} +0 -0
  175. /data/app/assets/images/customer_vault/icons/{people-512.png → individual-512.png} +0 -0
  176. /data/app/assets/images/customer_vault/icons/{people-64.png → individual-64.png} +0 -0
  177. /data/app/assets/javascripts/customer_vault/{people.js → individuals.js} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f27110c2f1b43dbe3fe7020150a83cee45314640
4
- data.tar.gz: 6afc22a00c5e45585e0f8beba1a11dc84fb53678
3
+ metadata.gz: fc3e85456bdc02e187ecc3a94e89513dcb61b97d
4
+ data.tar.gz: 0b2ba661f65d0e20029915b8713e6249f585cb95
5
5
  SHA512:
6
- metadata.gz: 5efcd7fc2cceaa8d6f79181ee6ed254e9fa82201ed2ac343b3e65eede8c59aefa25b2e82401a223e9e01d9fc944cd3f43182eb6b4eaeb36a2589490d8ae04bf3
7
- data.tar.gz: c487cc199edac7c4e16df8a552ddd58d4f99cf4dea499262858a477022028774cc62749f02722231af1793f1c2ea9a5ba7e43fabd9b79b19aacdb197b5585e9c
6
+ metadata.gz: 2754aa412120f956fb81ac807b9f268092260c9467f580f53533f11a6c255eca7a0d3fbc1368d0864625b235f9a9e64ed9d829cc5c13fa75816eca267db4750e
7
+ data.tar.gz: 49428c27c8000292dd99de498a7083d69c7aeccf9896902da7c0cdc5850ecd67680f3e61d3ff637eb9b33e5e64a0ab5aa3e00ae4d65e760bb27df4eda29cec53
data/MIT-LICENSE CHANGED
@@ -1,11 +1,11 @@
1
1
  Copyright 2014 YOURNAME
2
2
 
3
- Permission is hereby granted, free of charge, to any person obtaining
3
+ Permission is hereby granted, free of charge, to any individual obtaining
4
4
  a copy of this software and associated documentation files (the
5
5
  "Software"), to deal in the Software without restriction, including
6
6
  without limitation the rights to use, copy, modify, merge, publish,
7
7
  distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
8
+ permit individuals to whom the Software is furnished to do so, subject to
9
9
  the following conditions:
10
10
 
11
11
  The above copyright notice and this permission notice shall be
@@ -55,13 +55,62 @@
55
55
  font-weight:bold;
56
56
  }
57
57
 
58
- .cadre{
59
- background-color:#F5F5F5;
60
- margin-bottom:1%;
61
- border:1px solid #D8D8D8;
62
- padding:0.5%;
58
+ ul {
59
+ list-style:none;
60
+ padding-left:0;
63
61
  }
64
62
 
63
+ aside.individual, aside.corporation, aside .action, ul li.person{
64
+ background-color:#F5F5F5;
65
+ margin-bottom:1%;
66
+ border:1px solid #D8D8D8;
67
+ padding:0.5%;
68
+ }
69
+
70
+ .individual .last_name {
71
+ margin-left: 10px;
72
+ }
73
+
74
+ .individual .last_name {
75
+ margin-left: 10px;
76
+ }
77
+
78
+ .individual .title, .corporation .title {
79
+ margin-left: 10px;
80
+ &:before {
81
+ content: "/";
82
+ margin-right: 10px;
83
+ }
84
+ }
85
+ .individual, .corporation{
86
+ .actions.edit, .actions.delete{
87
+ margin-left: 10px;
88
+ }
89
+ .actions.delete:before{
90
+ content: "-";
91
+ margin-right: 10px;
92
+ }
93
+ }
94
+ /*
95
+ * Tabs
96
+ */
97
+
98
+ .tab-content {
99
+ border-left: 1px solid #ddd;
100
+ border-right: 1px solid #ddd;
101
+ border-bottom: 1px solid #ddd;
102
+ padding: 10px;
103
+ min-height: 300px;
104
+ }
105
+
106
+ .nav-tabs {
107
+ margin-bottom: 0;
108
+ }
109
+
110
+
111
+ /*
112
+ * Pagination
113
+ */
65
114
  .pagination a, .pagination span.current, .pagination span.gap {
66
115
  float: left;
67
116
  background-image:linear-gradient(#FAFAFA, #D8D8D8);
@@ -2,3 +2,4 @@
2
2
  Place all the styles related to the matching controller here.
3
3
  They will automatically be included in application.css.
4
4
  */
5
+
@@ -0,0 +1,3 @@
1
+ ul.linkable {
2
+ padding: 10px;
3
+ }
@@ -4,11 +4,6 @@ module CustomerVault
4
4
  class CorporationsController < ApplicationController
5
5
  before_action :set_corporation, only: [:show, :edit, :update, :destroy]
6
6
 
7
- # GET /corporations
8
- def index
9
- @corporations = Corporation.all
10
- end
11
-
12
7
  # GET /corporations/1
13
8
  def show
14
9
  end
@@ -16,10 +11,12 @@ module CustomerVault
16
11
  # GET /corporations/new
17
12
  def new
18
13
  @corporation = Corporation.new
14
+ @corporation.build_address
19
15
  end
20
16
 
21
17
  # GET /corporations/1/edit
22
18
  def edit
19
+ @corporation.build_address unless @corporation.address
23
20
  end
24
21
 
25
22
  # POST /corporations
@@ -45,7 +42,7 @@ module CustomerVault
45
42
  # DELETE /corporations/1
46
43
  def destroy
47
44
  @corporation.destroy
48
- redirect_to corporations_url, notice: 'Corporation was successfully destroyed.'
45
+ redirect_to people_url, notice: 'Corporation was successfully destroyed.'
49
46
  end
50
47
 
51
48
  private
@@ -56,7 +53,8 @@ module CustomerVault
56
53
 
57
54
  # Only allow a trusted parameter "white list" through.
58
55
  def corporation_params
59
- params.require(:corporation).permit(:name, :email, :phone, :fax)
56
+ params.require(:corporation).permit(:name, :email, :phone, :fax,
57
+ :address_attributes => [:street, :street_bis, :zip, :city, :country])
60
58
  end
61
59
  end
62
60
  end
@@ -0,0 +1,61 @@
1
+ require_dependency "customer_vault/application_controller"
2
+
3
+ module CustomerVault
4
+ class IndividualsController < ApplicationController
5
+ before_action :set_individual, only: [:show, :edit, :update, :destroy]
6
+
7
+ # GET /individuals/1
8
+ def show
9
+ end
10
+
11
+ # GET /individuals/new
12
+ def new
13
+ @individual = Individual.new
14
+ @individual.build_address
15
+ end
16
+
17
+ # GET /individuals/1/edit
18
+ def edit
19
+ @individual.build_address unless @individual.address
20
+ end
21
+
22
+ # POST /individuals
23
+ def create
24
+ @individual = Individual.new(individual_params)
25
+
26
+ if @individual.save
27
+ redirect_to @individual, notice: 'Individual was successfully created.'
28
+ else
29
+ render action: 'new'
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /individuals/1
34
+ def update
35
+ if @individual.update(individual_params)
36
+ redirect_to @individual, notice: 'Individual was successfully updated.'
37
+ else
38
+ render action: 'edit'
39
+ end
40
+ end
41
+
42
+ # DELETE /individuals/1
43
+ def destroy
44
+ @individual.destroy
45
+ redirect_to people_url, notice: 'Individual was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_individual
51
+ @individual = Individual.find(params[:id])
52
+ end
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def individual_params
56
+ params.require(:individual).permit(:first_name, :last_name, :email, :title,
57
+ :twitter, :www, :context, :phone, :fax, :mobile,
58
+ :address_attributes => [:street, :street_bis, :zip, :city, :country])
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,53 @@
1
+ require_dependency "customer_vault/application_controller"
2
+
3
+ module CustomerVault
4
+ class LinksController < ApplicationController
5
+ before_action :load_linkable, only: [:new, :edit, :create, :update, :destroy]
6
+
7
+ def new
8
+ @link = Link.new
9
+ end
10
+
11
+ def edit
12
+ @link = Link.find(params[:id])
13
+ end
14
+
15
+ def create
16
+ params = link_params
17
+ bob = params[:bob].split("-")
18
+
19
+ @link = Link.new(title: params[:title], alice_id: @person.id, alice_type: @person.class.to_s, bob_id: bob[1], bob_type: bob[0])
20
+
21
+ if @link.save
22
+ redirect_to @person, notice: 'Link was successfully created.'
23
+ else
24
+ render action: 'new'
25
+ end
26
+ end
27
+
28
+ def update
29
+ @link = Link.find(params[:id])
30
+ if @link.update(link_params)
31
+ redirect_to @person, notice: 'Link was successfully updated.'
32
+ else
33
+ render action: 'edit'
34
+ end
35
+ end
36
+
37
+ def destroy
38
+ Link.find(params[:id]).destroy
39
+ redirect_to @person, notice: 'Individual was successfully destroyed.'
40
+ end
41
+
42
+
43
+ private
44
+ def load_linkable
45
+ klass = [Individual, Corporation].detect { |c| params["#{c.name.demodulize.underscore}_id"] }
46
+ @person = klass.find(params["#{klass.name.demodulize.underscore}_id"])
47
+ end
48
+ # Only allow a trusted parameter "white list" through.
49
+ def link_params
50
+ params.require(:link).permit(:bob, :title)
51
+ end
52
+ end
53
+ end
@@ -2,61 +2,12 @@ require_dependency "customer_vault/application_controller"
2
2
 
3
3
  module CustomerVault
4
4
  class PeopleController < ApplicationController
5
- before_action :set_person, only: [:show, :edit, :update, :destroy]
5
+ before_action :set_individual, only: [:show, :edit, :update, :destroy]
6
6
 
7
- # GET /people
7
+ # GET /individuals
8
8
  def index
9
- @people = Person.all
9
+ @people = Person.list
10
+ @people= Kaminari.paginate_array(@people).page(params[:page]).per(8)
10
11
  end
11
-
12
- # GET /people/1
13
- def show
14
- end
15
-
16
- # GET /people/new
17
- def new
18
- @person = Person.new
19
- end
20
-
21
- # GET /people/1/edit
22
- def edit
23
- end
24
-
25
- # POST /people
26
- def create
27
- @person = Person.new(person_params)
28
-
29
- if @person.save
30
- redirect_to @person, notice: 'Person was successfully created.'
31
- else
32
- render action: 'new'
33
- end
34
- end
35
-
36
- # PATCH/PUT /people/1
37
- def update
38
- if @person.update(person_params)
39
- redirect_to @person, notice: 'Person was successfully updated.'
40
- else
41
- render action: 'edit'
42
- end
43
- end
44
-
45
- # DELETE /people/1
46
- def destroy
47
- @person.destroy
48
- redirect_to people_url, notice: 'Person was successfully destroyed.'
49
- end
50
-
51
- private
52
- # Use callbacks to share common setup or constraints between actions.
53
- def set_person
54
- @person = Person.find(params[:id])
55
- end
56
-
57
- # Only allow a trusted parameter "white list" through.
58
- def person_params
59
- params.require(:person).permit(:first_name, :last_name, :email, :title, :twitter, :www, :context, :phone, :fax, :mobile)
60
- end
61
12
  end
62
- end
13
+ end
@@ -0,0 +1,4 @@
1
+ module CustomerVault
2
+ module IndividualsHelper
3
+ end
4
+ end
@@ -1,5 +1,9 @@
1
1
  module CustomerVault
2
- class Corporation < ActiveRecord::Base
2
+ class Corporation < Person
3
+ self.table_name = 'customer_vault_corporations'
4
+
3
5
  validates_presence_of :name
6
+ has_one :address, class_name: 'Dorsale::Address', as: :addressable
7
+ accepts_nested_attributes_for :address, allow_destroy: true
4
8
  end
5
9
  end
@@ -0,0 +1,15 @@
1
+ module CustomerVault
2
+ class Individual < Person
3
+ self.table_name = 'customer_vault_individuals'
4
+
5
+ def name
6
+ [self.first_name, self.last_name].join(' ')
7
+ end
8
+
9
+ validates_presence_of :first_name
10
+ validates_presence_of :last_name
11
+
12
+ has_one :address, class_name: 'Dorsale::Address', as: :addressable
13
+ accepts_nested_attributes_for :address, allow_destroy: true
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ module CustomerVault
2
+ class Link < ActiveRecord::Base
3
+ belongs_to :alice, polymorphic: true
4
+ belongs_to :bob, polymorphic: true
5
+ end
6
+ end
@@ -1,6 +1,17 @@
1
1
  module CustomerVault
2
2
  class Person < ActiveRecord::Base
3
- validates_presence_of :first_name
4
- validates_presence_of :last_name
3
+ self.abstract_class = true
4
+
5
+ def self.list
6
+ individuals = Individual.all
7
+ corporations = Corporation.all
8
+ return (individuals + corporations).sort_by(&:created_at)
9
+ end
10
+
11
+ def links
12
+ a = Link.where(alice_id: self.id, alice_type: self.class).map {|l| {title: l.title, person: l.bob, origin: l}}
13
+ b = Link.where(bob_id: self.id, bob_type: self.class).map {|l| {title: l.title, person: l.alice, origin: l}}
14
+ return a + b
15
+ end
5
16
  end
6
17
  end
@@ -1,21 +1,28 @@
1
- = form_for [customer_vault, @corporation] do |f|
2
- - if @corporation.errors.any?
3
- #error_explanation
4
- h2 = "#{pluralize(@corporation.errors.count, "error")} prohibited this corporation from being saved:"
5
- ul
6
- - @corporation.errors.full_messages.each do |message|
7
- li = message
8
-
9
- .field
10
- = f.label :name
11
- = f.text_field :name
12
- .field
13
- = f.label :email
14
- = f.text_field :email
15
- .field
16
- = f.label :phone
17
- = f.text_field :phone
18
- .field
19
- = f.label :fax
20
- = f.text_field :fax
21
- .actions = f.submit 'Save'
1
+ = form_for [customer_vault, @corporation], html: { class: "form-horizontal"} do |f|
2
+ .form-group
3
+ =f.label "Name" , class:"control-label col-lg-2"
4
+ div class="col-lg-10"
5
+ =f.text_field :name, class:"form-control"
6
+
7
+ .form-group
8
+ =f.label "Email", class:"control-label col-lg-2"
9
+ div class="col-lg-10"
10
+ =f.text_field :email, class:"form-control"
11
+
12
+ .form-group
13
+ =f.label "Phone", class:"control-label col-lg-2"
14
+ div class="col-lg-10"
15
+ =f.text_field :phone, class:"form-control"
16
+
17
+ .form-group
18
+ =f.label "Fax", class:"control-label col-lg-2"
19
+ div class="col-lg-10"
20
+ =f.text_field :fax, class:"form-control"
21
+
22
+ = f.fields_for :address do |address_form|
23
+ = render partial: 'dorsale/addresses/nested_form', :locals => {:f => address_form}
24
+
25
+ .actions
26
+ div class= "cdiv mega-top-buffer"
27
+ = f.submit 'Valider', :class=>"btn btn-success btn-sm", id: 'submit-corporation'
28
+ = link_to 'Retour', customer_vault.people_path, :class=>"btn btn-primary btn-sm"
@@ -0,0 +1,29 @@
1
+ .row.corporation
2
+ .col-lg-1
3
+ =image_tag ('customer_vault/icons/group-48.png')
4
+ =link_to 'Details', [customer_vault, c] , :class=>"btn btn-success btn-xs"
5
+ .col-lg-11
6
+ .row.top-buffer
7
+ .col-lg-12 id='name'
8
+ span.bold.name #{c.name}
9
+ - if defined? link
10
+ = render partial: 'customer_vault/links/title', locals: {link: link, person: person}
11
+ .row
12
+ .col-lg-4 id='email'
13
+ - if c.email?
14
+ span class= 'bold text-muted' Email:&nbsp;
15
+ span class = 'text-muted bold' #{c.email}
16
+ - else
17
+ span class = 'bold invisible' CACHEE
18
+ .col-lg-4 id='phone'
19
+ - if c.phone?
20
+ span class= 'bold text-muted' Phone:&nbsp;
21
+ span #{c.phone}
22
+ - else
23
+ span class= 'bold invisible' CACHEE
24
+ .col-lg-4 id='fax'
25
+ - if c.fax?
26
+ span class= 'bold text-muted' Fax:&nbsp;
27
+ span #{c.fax}
28
+ - else
29
+ span class= 'bold invisible' CACHEE
@@ -0,0 +1,36 @@
1
+ aside.col-lg-12.corporation
2
+ .row
3
+ .col-lg-12.cdiv
4
+ =image_tag ('customer_vault/icons/group-64.png')
5
+ .col-lg-12.cdiv
6
+ span class= "text-muted titre bold" #{corporation.name}
7
+ .row
8
+ .col-lg-12.top-buffer
9
+ - if corporation.name?
10
+ .col-lg-12.cdiv
11
+ .bold.text-muted.cdiv Name
12
+ span #{corporation.name?}
13
+ .col-lg-12.cdiv
14
+ - if corporation.email?
15
+ .bold.text-muted.cdiv Email
16
+ span #{corporation.email}
17
+ .col-lg-12.cdiv
18
+ - if corporation.phone?
19
+ .bold.text-muted.cdiv Phone
20
+ span #{corporation.phone}
21
+ .col-lg-12.cdiv
22
+ - if corporation.fax?
23
+ .bold.text-muted.cdiv Fax
24
+ span #{corporation.fax}
25
+ .col-lg-12.cdiv
26
+ - if corporation.address && !corporation.address.one_line.blank?
27
+ .bold.text-muted.cdiv Address
28
+ span.address #{corporation.address.one_line}
29
+
30
+ .row.mega-top-buffer.bottom-buffer
31
+ .col-lg-4.cdiv
32
+ =link_to 'Editer', customer_vault.edit_corporation_path(corporation), :class=>"btn btn-success btn-sm"
33
+ .col-lg-4.cdiv
34
+ =link_to 'Effacer', [customer_vault, corporation], data: {:confirm => 'Are you sure?'}, :method => :delete, :class=>"btn btn-danger btn-sm"
35
+ .col-lg-4.cdiv
36
+ = link_to 'Retour', customer_vault.people_path, :class=>"btn btn-primary btn-sm"
@@ -1,8 +1,23 @@
1
- h1 Editing corporation
2
-
3
- == render 'form'
4
-
5
- = link_to 'Show', [customer_vault, @corporation]
6
- '|
7
- = link_to 'Back', customer_vault.corporations_path
1
+ .container-fluid
2
+ .div class = "col-lg-12"
3
+ ol.breadcrumb
4
+ li
5
+ = link_to 'Home', '/'
6
+ li
7
+ = link_to 'People', customer_vault.people_path
8
+ li.active Edit #{@corporation.name}
9
+ .col-lg-12
10
+ .col-lg-4
11
+ aside.col-lg-12
12
+ .row
13
+ .col-lg-12.cdiv
14
+ =image_tag ('customer_vault/icons/group-64.png')
15
+ .row
16
+ .col-lg-12.cdiv
17
+ h3.text-muted Edit {@corporation.name}
18
+ - if @corporation.errors.any?
19
+ = render partial: 'customer_vault/layout/form_error', :locals => {:p => @corporation}
20
+ .col-lg-8
21
+ .col-lg-12
22
+ == render 'form'
8
23
 
@@ -1,5 +1,22 @@
1
- h1 New corporation
2
-
3
- == render 'form'
4
-
5
- = link_to 'Back', customer_vault.corporations_path
1
+ .container-fluid
2
+ .col-lg-12
3
+ ol.breadcrumb
4
+ li
5
+ = link_to 'Home', '/'
6
+ li
7
+ = link_to 'People', customer_vault.people_path
8
+ li.active New Corporation
9
+ .col-lg-12
10
+ .col-lg-4
11
+ .aside.col-lg-12
12
+ .row
13
+ .col-lg-12.cdiv
14
+ =image_tag ('customer_vault/icons/group-64.png')
15
+ .row
16
+ .col-lg-12.cdiv
17
+ h3.text-muted New Corporation
18
+ - if @corporation.errors.any?
19
+ = render partial: 'customer_vault/layout/form_error', :locals => {:p => @corporation}
20
+ .col-lg-8
21
+ .col-lg-12
22
+ == render 'form'
@@ -1,18 +1,43 @@
1
- p#notice = notice
1
+ .container-fluid
2
+ .col-lg-12
3
+ ol class="breadcrumb"
4
+ li
5
+ = link_to 'Home', '/'
6
+ li
7
+ = link_to 'People', customer_vault.people_path
8
+ li.active #{@corporation.name}
9
+ .col-lg-12
10
+ .col-lg-4
11
+ = render partial: 'show_details', locals: {corporation: @corporation}
12
+
13
+ .col-lg-8
14
+ .col-lg-12
15
+ ul.nav.nav-tabs role="tablist"
16
+ li.active
17
+ a data-toggle="tab" href="#linkable" role="tab" Links
18
+ li
19
+ a data-toggle="tab" href="#history" role="tab" History
20
+ li
21
+ a data-toggle="tab" href="#todos" role="tab" Todos
22
+
23
+ .tab-content
24
+ #linkable.tab-pane.active
25
+ ul.linkable
26
+ - @corporation.links.each do |link|
27
+ li.person
28
+ - target = link[:person]
29
+ - if target.instance_of? CustomerVault::Individual
30
+ = render partial: 'customer_vault/individuals/list_details', :locals => {:i => target, person: @corporation, link: link[:origin]}
31
+ - if target.instance_of? CustomerVault::Corporation
32
+ = render partial: 'customer_vault/corporations/list_details', :locals => {:c => target, person: @corporation, link: link[:origin]}
33
+
34
+ = link_to 'New link', customer_vault.new_corporation_link_path(@corporation.id), :class=>"btn btn-success", id: 'new-link'
35
+ #history.tab-pane
36
+ p
37
+ ' History is soon to come
38
+ #todos.tab-pane
39
+ p
40
+ ' Todos are soon to come
41
+
2
42
 
3
- p
4
- strong Name:
5
- = @corporation.name
6
- p
7
- strong Email:
8
- = @corporation.email
9
- p
10
- strong Phone:
11
- = @corporation.phone
12
- p
13
- strong Fax:
14
- = @corporation.fax
15
43
 
16
- = link_to 'Edit', customer_vault.edit_corporation_path(@corporation)
17
- '|
18
- = link_to 'Back', customer_vault.corporations_path