dorsale 3.1.7 → 3.2.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 (157) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/app/assets/javascripts/dorsale/common/comments.coffee +18 -20
  4. data/app/assets/javascripts/dorsale/common/datepicker.coffee +1 -1
  5. data/app/assets/javascripts/dorsale/common/forms.coffee +1 -1
  6. data/app/assets/javascripts/dorsale/common/modals.coffee +1 -1
  7. data/app/assets/javascripts/dorsale/common/tabs_loader.coffee +1 -1
  8. data/app/assets/javascripts/dorsale/common/tags.coffee +1 -1
  9. data/app/assets/javascripts/dorsale/common/tooltips.coffee +1 -1
  10. data/app/assets/javascripts/dorsale/dependencies.coffee +2 -0
  11. data/app/assets/javascripts/dorsale/engines/billing_machine.coffee +1 -1
  12. data/app/assets/stylesheets/dorsale/all.sass +1 -1
  13. data/app/assets/stylesheets/dorsale/common/comments.sass +1 -1
  14. data/app/assets/stylesheets/dorsale/common/filters.sass +16 -1
  15. data/app/assets/stylesheets/dorsale/common/styles.sass +3 -0
  16. data/app/assets/stylesheets/dorsale/engines/customer_vault.sass +2 -2
  17. data/app/assets/stylesheets/dorsale/engines/expense_gun.sass +3 -0
  18. data/app/assets/stylesheets/dorsale/engines/flyboy.sass +4 -0
  19. data/app/assets/stylesheets/dorsale/print.sass +73 -0
  20. data/app/controllers/dorsale/alexandrie/attachments_controller.rb +0 -4
  21. data/app/controllers/dorsale/application_controller.rb +12 -0
  22. data/app/controllers/dorsale/billing_machine/application_controller.rb +0 -5
  23. data/app/controllers/dorsale/billing_machine/id_cards_controller.rb +0 -4
  24. data/app/controllers/dorsale/billing_machine/invoices_controller.rb +0 -4
  25. data/app/controllers/dorsale/billing_machine/payment_terms_controller.rb +0 -4
  26. data/app/controllers/dorsale/billing_machine/quotations_controller.rb +0 -4
  27. data/app/controllers/dorsale/comments_controller.rb +30 -55
  28. data/app/controllers/dorsale/customer_vault/links_controller.rb +5 -5
  29. data/app/controllers/dorsale/customer_vault/people_controller.rb +9 -11
  30. data/app/controllers/dorsale/expense_gun/categories_controller.rb +0 -4
  31. data/app/controllers/dorsale/expense_gun/expenses_controller.rb +1 -5
  32. data/app/controllers/dorsale/flyboy/folders_controller.rb +0 -4
  33. data/app/controllers/dorsale/flyboy/tasks_controller.rb +0 -4
  34. data/app/controllers/dorsale/users_controller.rb +7 -11
  35. data/app/filters/dorsale/billing_machine/small_data/filter_strategy_by_customer.rb +1 -1
  36. data/app/filters/dorsale/flyboy/small_data/filter_for_tasks.rb +1 -1
  37. data/app/helpers/dorsale/all_helpers.rb +1 -0
  38. data/app/helpers/dorsale/billing_machine/application_helper.rb +23 -0
  39. data/app/helpers/dorsale/comments_helper.rb +14 -2
  40. data/app/helpers/dorsale/flyboy/application_helper.rb +4 -0
  41. data/app/helpers/dorsale/text_helper.rb +12 -7
  42. data/app/libs/dorsale/sortable_uuid_generator.rb +11 -0
  43. data/app/mailers/dorsale/billing_machine/invoice_mailer.rb +2 -4
  44. data/app/models/concerns/dorsale/active_record_uuid_concern.rb +15 -0
  45. data/app/models/concerns/dorsale/default_values_concern.rb +13 -0
  46. data/app/models/dorsale/alexandrie/attachment.rb +3 -3
  47. data/app/models/dorsale/application_record.rb +11 -0
  48. data/app/models/dorsale/billing_machine/invoice.rb +13 -13
  49. data/app/models/dorsale/billing_machine/invoice_line.rb +3 -9
  50. data/app/models/dorsale/billing_machine/quotation.rb +6 -12
  51. data/app/models/dorsale/billing_machine/quotation_line.rb +3 -8
  52. data/app/models/dorsale/customer_vault/person.rb +5 -4
  53. data/app/models/dorsale/expense_gun/expense.rb +3 -4
  54. data/app/models/dorsale/expense_gun/expense_line.rb +4 -5
  55. data/app/models/dorsale/flyboy/folder.rb +2 -3
  56. data/app/models/dorsale/flyboy/task.rb +5 -6
  57. data/app/models/dorsale/flyboy/task_comment.rb +3 -8
  58. data/app/models/dorsale/users/active.rb +1 -1
  59. data/app/policies/dorsale/billing_machine/invoice_policy_helper.rb +5 -0
  60. data/app/policies/dorsale/comment_policy_helper.rb +21 -0
  61. data/app/serializers/dorsale/serializers/xlsx.rb +13 -2
  62. data/app/views/dorsale/billing_machine/invoices/_details.html.slim +1 -1
  63. data/app/views/dorsale/billing_machine/invoices/_filters.html.slim +1 -1
  64. data/app/views/dorsale/billing_machine/invoices/_form.html.slim +1 -1
  65. data/app/views/dorsale/billing_machine/invoices/_header_infos.html.slim +9 -4
  66. data/app/views/dorsale/billing_machine/invoices/_list.html.slim +3 -2
  67. data/app/views/dorsale/billing_machine/invoices/email.html.slim +6 -0
  68. data/app/views/dorsale/billing_machine/invoices/index.html.slim +1 -1
  69. data/app/views/dorsale/billing_machine/invoices/index.xlsx.ruby +41 -0
  70. data/app/views/dorsale/billing_machine/quotations/_filters.html.slim +1 -1
  71. data/app/views/dorsale/billing_machine/quotations/_list.html.slim +4 -3
  72. data/app/views/dorsale/comments/_comment.html.slim +2 -2
  73. data/app/views/dorsale/comments/_comments.html.slim +5 -0
  74. data/app/views/dorsale/comments/_form.html.slim +5 -6
  75. data/app/views/dorsale/comments/_list.html.slim +1 -1
  76. data/app/views/dorsale/comments/edit.html.slim +1 -1
  77. data/app/views/dorsale/customer_vault/links/edit.html.slim +13 -17
  78. data/app/views/dorsale/customer_vault/links/index.html.slim +10 -0
  79. data/app/views/dorsale/customer_vault/links/new.html.slim +10 -14
  80. data/app/views/dorsale/customer_vault/people/_actions.html.slim +2 -2
  81. data/app/views/dorsale/customer_vault/people/_data_context.html.slim +1 -1
  82. data/app/views/dorsale/customer_vault/people/_index_tabs.html.slim +2 -2
  83. data/app/views/dorsale/customer_vault/people/_show_layout.html.slim +10 -0
  84. data/app/views/dorsale/customer_vault/people/_tabs.html.slim +24 -0
  85. data/app/views/dorsale/customer_vault/people/activity.slim +2 -3
  86. data/app/views/dorsale/customer_vault/people/edit.html.slim +1 -0
  87. data/app/views/dorsale/customer_vault/people/index.html.slim +2 -2
  88. data/app/views/dorsale/customer_vault/people/index.xlsx.ruby +49 -0
  89. data/app/views/dorsale/customer_vault/people/invoices.html.slim +5 -0
  90. data/app/views/dorsale/customer_vault/people/show.html.slim +5 -26
  91. data/app/views/dorsale/customer_vault/people/tasks.html.slim +4 -0
  92. data/app/views/dorsale/expense_gun/categories/_list.html.slim +4 -1
  93. data/app/views/dorsale/expense_gun/expenses/_list.html.slim +1 -1
  94. data/app/views/dorsale/expense_gun/expenses/show.html.slim +3 -3
  95. data/app/views/dorsale/flyboy/_filters.html.slim +3 -0
  96. data/app/views/dorsale/flyboy/folders/_form.html.slim +3 -1
  97. data/app/views/dorsale/flyboy/folders/_list.html.slim +2 -2
  98. data/app/views/dorsale/flyboy/task_comments/_list.html.slim +2 -2
  99. data/app/views/dorsale/flyboy/tasks/_form.html.slim +4 -1
  100. data/app/views/dorsale/flyboy/tasks/_list.html.slim +1 -1
  101. data/app/views/dorsale/flyboy/tasks/_summary_list.html.slim +6 -5
  102. data/app/views/dorsale/flyboy/tasks/index.html.slim +2 -4
  103. data/app/views/dorsale/flyboy/tasks/index.xlsx.ruby +23 -0
  104. data/app/views/dorsale/flyboy/tasks/summary.html.slim +0 -2
  105. data/config/locales/common.en.yml +2 -0
  106. data/config/locales/common.fr.yml +2 -0
  107. data/config/locales/customer_vault.en.yml +0 -6
  108. data/config/locales/customer_vault.fr.yml +0 -6
  109. data/config/locales/flyboy.en.yml +2 -0
  110. data/config/locales/flyboy.fr.yml +2 -0
  111. data/config/routes.rb +7 -2
  112. data/db/migrate/20161118071317_dorsale_add_missing_indexes.rb +25 -0
  113. data/features/billing_machine_invoices.feature +4 -2
  114. data/features/customer_vault_invoices.feature +10 -0
  115. data/features/customer_vault_tasks.feature +1 -1
  116. data/features/flyboy_tasks.feature +3 -15
  117. data/features/step_definitions/billing_machine_invoices_steps.rb +2 -6
  118. data/features/step_definitions/billing_machine_quotations_steps.rb +5 -5
  119. data/features/step_definitions/common_steps.rb +7 -1
  120. data/features/step_definitions/customer_vault_corporations_steps.rb +7 -7
  121. data/features/step_definitions/customer_vault_filters_steps.rb +3 -3
  122. data/features/step_definitions/customer_vault_individuals_steps.rb +1 -1
  123. data/features/step_definitions/customer_vault_invoices_steps.rb +7 -0
  124. data/features/step_definitions/customer_vault_links_steps.rb +5 -3
  125. data/features/step_definitions/customer_vault_people_steps.rb +1 -1
  126. data/features/step_definitions/customer_vault_search_steps.rb +4 -4
  127. data/features/step_definitions/customer_vault_tasks_steps.rb +6 -16
  128. data/features/step_definitions/expense_gun_expenses_steps.rb +2 -2
  129. data/features/step_definitions/flyboy_folders_steps.rb +5 -5
  130. data/features/step_definitions/flyboy_tasks_steps.rb +5 -29
  131. data/lib/dorsale/engine.rb +6 -1
  132. data/lib/dorsale/polymorphic_id.rb +1 -1
  133. data/lib/dorsale/version.rb +1 -1
  134. data/spec/controllers/dorsale/billing_machine/invoices_controller_spec.rb +3 -4
  135. data/spec/controllers/dorsale/comments_controller_spec.rb +3 -3
  136. data/spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb +10 -0
  137. data/spec/controllers/dorsale/flyboy/tasks_controller_spec.rb +1 -13
  138. data/spec/factories/dorsale_comments.rb +3 -3
  139. data/spec/helpers/dorsale/text_helper_spec.rb +15 -0
  140. data/spec/{lib → libs}/active_record_comma_type_cast_spec.rb +0 -0
  141. data/spec/{lib → libs/dorsale}/polymorphic_id_spec.rb +0 -0
  142. data/spec/libs/dorsale/sortable_uuid_generator_spec.rb +29 -0
  143. data/spec/rails_helper.rb +2 -0
  144. data/spec/routing/dorsale/customer_vault/people_routing_spec.rb +15 -0
  145. metadata +54 -18
  146. data/app/pdfs/dorsale/flyboy/roadmap.rb +0 -47
  147. data/app/views/dorsale/billing_machine/invoices/index.csv.ruby +0 -46
  148. data/app/views/dorsale/comments/_loader.html.slim +0 -5
  149. data/app/views/dorsale/comments/index.html.slim +0 -11
  150. data/app/views/dorsale/customer_vault/people/_activity_tab.html.slim +0 -4
  151. data/app/views/dorsale/customer_vault/people/_comment.html.slim +0 -1
  152. data/app/views/dorsale/customer_vault/people/_links_tab.html.slim +0 -7
  153. data/app/views/dorsale/customer_vault/people/_tasks_tab.html.slim +0 -1
  154. data/app/views/dorsale/customer_vault/people/index.xls.slim +0 -24
  155. data/app/views/dorsale/flyboy/tasks/index.csv.ruby +0 -24
  156. data/app/views/dorsale/flyboy/tasks/index.pdf.ruby +0 -6
  157. data/app/views/dorsale/flyboy/tasks/index.xls.erb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e8255c9d6c9efa78f99a3914f3ca347456faa10
4
- data.tar.gz: c4bea5ce3821ec79e4fb8ff96fce60869cb49e2e
3
+ metadata.gz: 3238d078981accff66147d5fb412740e482a115f
4
+ data.tar.gz: bb228e445bec72569f5083bd8ea6322702ba8ebd
5
5
  SHA512:
6
- metadata.gz: 66c316f9221bf01e9b47a8dccc5da0512b3e374c765cf11595104db3189e068df578814219bb2895fecb1b0cdebd13e28395a5161d5362c7b1887f7464340987
7
- data.tar.gz: 4a5e092869742218f94c4bcbc126c63f644d41a0dbf130a7370cecddbbaa3e2c27457069ebdacab833d6f1e041190a613a6fd0d7b4a689bd2003365b46ee3626
6
+ metadata.gz: 45e05fc44b6d74b7f44becd523c8dd7c7d306a82479adf5e86e7c9a677dc2285ab8cd9b56a2d1f2f405427014dc21a0d959192659c5f797ce5bc0c0ac5979b6c
7
+ data.tar.gz: 5ffd84a943253a3e8fdb99a5adad1286e62299106b62f604074f6ff6e745f0efaf2879dba8266d5540b73438fb1bec7990e3991d19a26957d382c353a17c5779
data/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.2.0
4
+
5
+ - Add print CSS
6
+ - UUID friendly
7
+ - Add missing indexes
8
+ - Add `:default` option to `info` helper
9
+ - Refactor
10
+ - Add nilify_blanks gem
11
+ - Add invoices chart
12
+ - CustomerVault improvements + add invoices tab
13
+ - Comments improvements
14
+ - Remove tasks PDF and CSV export (XLSX still present)
15
+ - Convert CSV exports to XLSX
16
+ - XLSX Serializer improvements
17
+
3
18
  ## 3.1.7
4
19
 
5
20
  - Filters changes : get/set are now private
@@ -1,28 +1,22 @@
1
1
  window.dorsaleComments =
2
- load: ->
3
- $("#dorsale-comments").map ->
4
- container = $(this)
5
- url = this.dataset.url
6
-
7
- $.ajax
8
- url: url
9
- success: (data) ->
10
- container.html(data)
11
- dorsaleComments.setupCreateForm()
12
- dorsaleComments.setupEditButtons()
13
- dorsaleComments.setupDeleteButtons()
14
-
15
- reload: ->
16
- dorsaleComments.load()
2
+ setup: ->
3
+ dorsaleComments.setupCreateForm()
4
+ dorsaleComments.setupEditForm()
5
+ dorsaleComments.setupEditButtons()
6
+ dorsaleComments.setupDeleteButtons()
17
7
 
18
8
  setupCreateForm: ->
19
- $("#dorsale-comments form[id*=new]").on("ajax:success", dorsaleComments.reload)
9
+ $("#dorsale-comments").on "ajax:success", "form[id*=new]", (e, data) ->
10
+ if data.length
11
+ $(this).find("textarea").val("")
12
+ $("#dorsale-comments-list").prepend(data)
20
13
 
21
14
  setupEditForm: ->
22
- $("#dorsale-comments form[id*=edit]").on("ajax:success", dorsaleComments.reload)
15
+ $("#dorsale-comments-list").on "ajax:success", "form[id*=edit]", (e, data) ->
16
+ $(this).replaceWith(data)
23
17
 
24
18
  setupEditButtons: ->
25
- $("#dorsale-comments [href$=edit]").click ->
19
+ $("#dorsale-comments-list").on "click", "[href$=edit]", ->
26
20
  container = $(this).parents(".comment")
27
21
  url = this.href
28
22
 
@@ -30,9 +24,13 @@ window.dorsaleComments =
30
24
  url: url
31
25
  success: (data) ->
32
26
  container.replaceWith(data)
33
- dorsaleComments.setupEditForm()
34
27
 
35
28
  return false
36
29
 
37
30
  setupDeleteButtons: ->
38
- $("#dorsale-comments [data-method=delete]").on("ajax:success", dorsaleComments.reload)
31
+ $("#dorsale-comments-list").on "ajax:success", "[data-method=delete]", ->
32
+ $(this).parents(".comment").fadeOut ->
33
+ $(this).remove()
34
+
35
+ $(document).on "turbolinks:load", ->
36
+ dorsaleComments.setup()
@@ -16,5 +16,5 @@ window.setupDatepickers = ->
16
16
  todayBtn: "linked"
17
17
  autoclose: true
18
18
 
19
- $(document).on "ready turbolinks:load page:load", ->
19
+ $(document).on "turbolinks:load", ->
20
20
  setupDatepickers()
@@ -24,7 +24,7 @@ window.setupUploadInputs = (scope = document) ->
24
24
  label.html(label_value)
25
25
  input.change()
26
26
 
27
- $(document).on "ready turbolinks:load page:load", ->
27
+ $(document).on "turbolinks:load", ->
28
28
  $("button.reset").click ->
29
29
  form = $(this).parents("form")
30
30
 
@@ -122,5 +122,5 @@ window.modal =
122
122
  .on("submit", modal._callbacks.forms)
123
123
 
124
124
 
125
- $(document).on "ready turbolinks:load page:load modal:open", ->
125
+ $(document).on "turbolinks:load modal:open", ->
126
126
  modal.setup()
@@ -1,4 +1,4 @@
1
- $(document).on "ready turbolinks:load page:load", ->
1
+ $(document).on "turbolinks:load", ->
2
2
  if window.location.hash
3
3
  activeTab = $('[href="' + window.location.hash + '"]')
4
4
  activeTab && activeTab.tab('show')
@@ -1,4 +1,4 @@
1
- $(document).on "ready turbolinks:load page:load", ->
1
+ $(document).on "turbolinks:load", ->
2
2
  $("form:not([action*=filters]) select[multiple][name*=tag]").not(".select2-hidden-accessible").map ->
3
3
  placeholder = $(this).attr("placeholder")
4
4
 
@@ -1,3 +1,3 @@
1
- $(document).on "ready turbolinks:load page:load", ->
1
+ $(document).on "turbolinks:load", ->
2
2
  $(".title-tooltip").map ->
3
3
  $(this).tooltip(html: this.title)
@@ -9,3 +9,5 @@
9
9
  //= require select2_locale_fr
10
10
  //= require bootstrap-datepicker/core
11
11
  //= require bootstrap-datepicker/locales/bootstrap-datepicker.fr
12
+ //= require Chart.bundle
13
+ //= require chartkick
@@ -15,7 +15,7 @@ window.num2str = (num) ->
15
15
  num = parseFloat(num)
16
16
  accounting.formatNumber(num)
17
17
 
18
- $(document).on "ready turbolinks:load page:load cocoon:after-insert", ->
18
+ $(document).on "turbolinks:load cocoon:after-insert", ->
19
19
  $("#billing_machine-form input.number").keyup ->
20
20
  total_excluding_taxes = 0.0
21
21
 
@@ -1,4 +1,4 @@
1
1
  @import dorsale/dependencies
2
2
  @import dorsale/common
3
3
  @import dorsale/engines
4
-
4
+ @import dorsale/print
@@ -1,4 +1,4 @@
1
- #comments-list
1
+ #dorsale-comments-list
2
2
  margin: 1em 0
3
3
 
4
4
  .comment
@@ -2,13 +2,16 @@
2
2
  @extend .well
3
3
  padding: 8px
4
4
  box-shadow: none
5
+ display: flex
5
6
 
6
7
  select,
7
8
  button,
8
9
  input,
9
10
  .form-control,
10
11
  .select2-container,
12
+ .btn + .btn,
11
13
  margin: 0 5px 0 0
14
+ max-width: 15em
12
15
 
13
16
  .form-group
14
17
  display: inline-block
@@ -16,13 +19,25 @@
16
19
  padding: 0
17
20
  margin: 0
18
21
 
19
- .form-control
22
+ .form-control,
23
+ @extend .input-sm
20
24
  display: inline-block
21
25
  width: auto
22
26
 
27
+ .btn
28
+ @extend .btn-sm
29
+
23
30
  input[id*=date]
24
31
  width: 8em
25
32
 
26
33
  .select2-container
27
34
  display: inline-block !important
28
35
  width: 30em !important
36
+ height: 30px !important
37
+
38
+ .select2-selection
39
+ height: 28px !important
40
+ min-height: 0 !important
41
+
42
+ .select2-selection__choice
43
+ margin-top: 3px !important
@@ -21,6 +21,9 @@
21
21
  .fa
22
22
  @extend .fa-fw
23
23
 
24
+ button .fa
25
+ width: auto
26
+
24
27
  img
25
28
  max-width: 100%
26
29
 
@@ -12,8 +12,8 @@
12
12
  .infos-container
13
13
  width: auto
14
14
 
15
- .person-tab-content
16
- padding: 1em 0
15
+ #person-tabs
16
+ margin-bottom: 1em
17
17
 
18
18
  .index-tabs-container
19
19
  position: relative
@@ -10,3 +10,6 @@
10
10
 
11
11
  > .col-md-4
12
12
  width: 33.33%
13
+
14
+ .attachments-panel
15
+ display: none
@@ -65,3 +65,7 @@
65
65
  td.task-term,
66
66
  th.task-term,
67
67
  text-align: right
68
+
69
+ @media print
70
+ #new_task_comment_tr
71
+ display: none
@@ -0,0 +1,73 @@
1
+ @media print
2
+ html,
3
+ body,
4
+ #body,
5
+ #main,
6
+ #context,
7
+ #context-main,
8
+ .row,
9
+ div[class^=col],
10
+ thead *,
11
+ tfoot *,
12
+ th,
13
+ margin: 0 !important
14
+ padding: 0 !important
15
+ font-size: 11px !important
16
+ float: none !important
17
+ width: auto !important
18
+ height: auto !important
19
+
20
+ .panel-title,
21
+ .context-header,
22
+ thead *,
23
+ tfoot *,
24
+ th,
25
+ font-size: 12px !important
26
+ line-height: 12px !important
27
+
28
+ h1
29
+ font-size: 2em
30
+
31
+ .filters,
32
+ form.search,
33
+ .input-group-addon,
34
+ .btn,
35
+ .actions,
36
+ .actions + hr,
37
+ .navbar,
38
+ .nav,
39
+ .nav-tabs,
40
+ a[href]:after,
41
+ display: none !important
42
+
43
+ .panel,
44
+ .table,
45
+ .list-group,
46
+ .well,
47
+ hr,
48
+ p,
49
+ margin: 1em 0 !important
50
+
51
+ .panel table,
52
+ .well p,
53
+ td p,
54
+ margin: 0 !important
55
+
56
+ .well,
57
+ padding: 0.5em !important
58
+
59
+ .panel-heading,
60
+ .panel-title,
61
+ .panel-body,
62
+ .panel-footer,
63
+ .context-header,
64
+ .context-body,
65
+ .context-footer,
66
+ .list-group-item,
67
+ thead tr > *,
68
+ tfoot tr > *,
69
+ padding: 0.5em !important
70
+ margin: 0 !important
71
+
72
+ .panel-heading .panel-title,
73
+ padding: 0 !important
@@ -70,10 +70,6 @@ class Dorsale::Alexandrie::AttachmentsController < ::Dorsale::ApplicationControl
70
70
  ::Dorsale::Alexandrie::Attachment
71
71
  end
72
72
 
73
- def scope
74
- policy_scope(model)
75
- end
76
-
77
73
  def set_objects
78
74
  @attachment = scope.find(params[:id])
79
75
  end
@@ -13,4 +13,16 @@ class Dorsale::ApplicationController < ::ApplicationController
13
13
  end
14
14
  }
15
15
 
16
+ def model
17
+ raise NotImplementedError
18
+ end
19
+
20
+ helper_method :model
21
+
22
+ def scope
23
+ policy_scope(model)
24
+ end
25
+
26
+ helper_method :scope
27
+
16
28
  end
@@ -7,12 +7,7 @@ class Dorsale::BillingMachine::ApplicationController < ::Dorsale::ApplicationCon
7
7
  raise "#euros is not available in BillingMachine, please use #bm_currency instead"
8
8
  end
9
9
 
10
- def bm_currency(n)
11
- DH.currency(n, ::Dorsale::BillingMachine.default_currency)
12
- end
13
-
14
10
  helper_method :euros
15
- helper_method :bm_currency
16
11
 
17
12
  def set_common_variables
18
13
  @payment_terms ||= policy_scope(::Dorsale::BillingMachine::PaymentTerm)
@@ -51,10 +51,6 @@ class Dorsale::BillingMachine::IdCardsController < ::Dorsale::BillingMachine::Ap
51
51
  ::Dorsale::BillingMachine::IdCard
52
52
  end
53
53
 
54
- def scope
55
- policy_scope(model)
56
- end
57
-
58
54
  def back_url
59
55
  url_for(action: :index, id: nil)
60
56
  end
@@ -140,10 +140,6 @@ class Dorsale::BillingMachine::InvoicesController < ::Dorsale::BillingMachine::A
140
140
  ::Dorsale::BillingMachine::Invoice
141
141
  end
142
142
 
143
- def scope
144
- policy_scope(model)
145
- end
146
-
147
143
  def default_back_url
148
144
  if @invoice
149
145
  url_for(action: :show, id: @invoice.to_param)
@@ -51,10 +51,6 @@ class Dorsale::BillingMachine::PaymentTermsController < ::Dorsale::BillingMachin
51
51
  ::Dorsale::BillingMachine::PaymentTerm
52
52
  end
53
53
 
54
- def scope
55
- policy_scope(model)
56
- end
57
-
58
54
  def back_url
59
55
  url_for(action: :index, id: nil)
60
56
  end
@@ -113,10 +113,6 @@ class Dorsale::BillingMachine::QuotationsController < ::Dorsale::BillingMachine:
113
113
  ::Dorsale::BillingMachine::Quotation
114
114
  end
115
115
 
116
- def scope
117
- policy_scope(model)
118
- end
119
-
120
116
  def default_back_url
121
117
  if @quotation
122
118
  url_for(action: :show, id: @quotation.to_param)
@@ -7,29 +7,16 @@ class Dorsale::CommentsController < ::Dorsale::ApplicationController
7
7
 
8
8
  layout false
9
9
 
10
- def index
11
- @comment = scope.new(comment_params_for_create)
12
- @commentable = @comment.commentable
13
- @comments = scope
14
- .where(commentable: @commentable)
15
- .preload(:commentable, :author)
16
-
17
- authorize @commentable, :read?
18
- end
19
-
20
10
  def create
21
11
  @comment ||= scope.new(comment_params_for_create)
22
- @commentable = @comment.commentable
23
12
 
24
13
  authorize @comment, :create?
25
14
 
26
15
  if @comment.save
27
- flash[:success] = t("messages.comments.create_ok")
16
+ render_comment
28
17
  else
29
- flash[:danger] = t("messages.comments.create_error")
18
+ render_nothing
30
19
  end
31
-
32
- render_or_redirect
33
20
  end
34
21
 
35
22
  def edit
@@ -40,37 +27,39 @@ class Dorsale::CommentsController < ::Dorsale::ApplicationController
40
27
  authorize @comment, :update?
41
28
 
42
29
  if @comment.update(comment_params_for_update)
43
- flash[:notice] = t("messages.comments.update_ok")
30
+ render_comment
44
31
  else
45
- flash[:alert] = t("messages.comments.update_error")
32
+ render_form
46
33
  end
47
-
48
- render_or_redirect
49
34
  end
50
35
 
51
36
  def destroy
52
37
  authorize @comment, :delete?
53
38
 
54
- if @comment.destroy
55
- flash[:notice] = t("messages.comments.delete_ok")
56
- else
57
- flash[:alert] = t("messages.comments.delete_error")
58
- end
39
+ @comment.destroy
59
40
 
60
- render_or_redirect
41
+ render_nothing
61
42
  end
62
43
 
63
44
  private
64
45
 
65
- def back_url
66
- [
67
- params[:form_url],
68
- request.referer,
69
- (main_app.root_path rescue "/"),
70
- ].select(&:present?).first
46
+ def render_comment
47
+ if request.xhr?
48
+ render partial: "comment", locals: {comment: @comment}
49
+ else
50
+ redirect_to back_url
51
+ end
71
52
  end
72
53
 
73
- def render_or_redirect
54
+ def render_form
55
+ if request.xhr?
56
+ render partial: "form", locals: {comment: @comment}
57
+ else
58
+ redirect_to back_url
59
+ end
60
+ end
61
+
62
+ def render_nothing
74
63
  if request.xhr?
75
64
  head :ok
76
65
  else
@@ -78,12 +67,16 @@ class Dorsale::CommentsController < ::Dorsale::ApplicationController
78
67
  end
79
68
  end
80
69
 
81
- def model
82
- ::Dorsale::Comment
70
+ def back_url
71
+ [
72
+ params[:form_url],
73
+ request.referer,
74
+ (main_app.root_path rescue "/"),
75
+ ].select(&:present?).first
83
76
  end
84
77
 
85
- def scope
86
- policy_scope(model)
78
+ def model
79
+ ::Dorsale::Comment
87
80
  end
88
81
 
89
82
  def set_objects
@@ -109,28 +102,10 @@ class Dorsale::CommentsController < ::Dorsale::ApplicationController
109
102
  end
110
103
 
111
104
  def comment_params_for_create
112
- comment_params.merge(
113
- :author => current_user,
114
- :commentable => find_commentable,
115
- )
105
+ comment_params.merge(author: current_user)
116
106
  end
117
107
 
118
108
  def comment_params_for_update
119
109
  comment_params
120
110
  end
121
-
122
- def commentable_type
123
- params[:commentable_type] || @comment.commentable_type
124
- end
125
-
126
- def commentable_id
127
- params[:commentable_id] || @comment.commentable_id
128
- end
129
-
130
- def find_commentable
131
- commentable_type.to_s.constantize.find(commentable_id)
132
- rescue NameError
133
- raise ActiveRecord::RecordNotFound
134
- end
135
-
136
111
  end