dorsale 3.4.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -2
  3. data/app/assets/javascripts/dorsale/common/upload.coffee +25 -0
  4. data/app/assets/javascripts/dorsale/dependencies.coffee +1 -0
  5. data/app/assets/stylesheets/dorsale/all.sass +0 -1
  6. data/app/assets/stylesheets/dorsale/common.sass +0 -4
  7. data/app/assets/stylesheets/dorsale/dependencies.sass +2 -1
  8. data/app/controllers/dorsale/application_controller.rb +2 -2
  9. data/app/controllers/dorsale/flyboy/tasks_controller.rb +3 -3
  10. data/app/filters/dorsale/billing_machine/small_data/filter_for_invoices.rb +5 -5
  11. data/app/filters/dorsale/billing_machine/small_data/filter_for_quotations.rb +5 -5
  12. data/app/filters/dorsale/billing_machine/small_data/filter_strategy_by_customer.rb +1 -1
  13. data/app/filters/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb +1 -1
  14. data/app/filters/dorsale/billing_machine/small_data/filter_strategy_by_state.rb +1 -1
  15. data/app/filters/dorsale/customer_vault/small_data/filter_for_people.rb +3 -3
  16. data/app/filters/dorsale/expense_gun/small_data/filter_for_expenses.rb +3 -3
  17. data/app/filters/dorsale/flyboy/small_data/filter_for_tasks.rb +2 -2
  18. data/app/filters/dorsale/flyboy/small_data/filter_strategy_by_done.rb +1 -1
  19. data/app/helpers/dorsale/all_helpers.rb +2 -10
  20. data/app/helpers/dorsale/flyboy/application_helper.rb +2 -2
  21. data/app/models/dorsale/application_record.rb +7 -9
  22. data/app/models/dorsale/customer_vault/person.rb +1 -1
  23. data/app/models/dorsale/flyboy/task.rb +1 -1
  24. data/app/views/dorsale/billing_machine/invoices/_filters.html.slim +2 -2
  25. data/app/views/dorsale/billing_machine/invoices/_show_actions.html.slim +2 -2
  26. data/app/views/dorsale/billing_machine/invoices/index.xlsx.ruby +1 -1
  27. data/app/views/dorsale/billing_machine/quotations/_filters.html.slim +2 -2
  28. data/app/views/dorsale/billing_machine/quotations/_show_actions.html.slim +1 -1
  29. data/app/views/dorsale/customer_vault/people/index.xlsx.ruby +1 -1
  30. data/app/views/dorsale/expense_gun/expenses/_show_actions.html.slim +4 -4
  31. data/app/views/dorsale/flyboy/tasks/index.xlsx.ruby +1 -1
  32. data/config/locales/dorsale.en.yml +11 -1
  33. data/config/locales/dorsale.fr.yml +10 -0
  34. data/config/routes.rb +0 -6
  35. data/lib/dorsale/engine.rb +4 -1
  36. data/lib/dorsale/version.rb +1 -1
  37. metadata +17 -69
  38. data/app/assets/javascripts/dorsale/common/forms.coffee +0 -58
  39. data/app/assets/javascripts/dorsale/common/modals.coffee +0 -126
  40. data/app/assets/stylesheets/dorsale/common/filters.sass +0 -43
  41. data/app/assets/stylesheets/dorsale/common/flash.sass +0 -6
  42. data/app/assets/stylesheets/dorsale/common/modals.sass +0 -45
  43. data/app/assets/stylesheets/dorsale/common/pagination.sass +0 -8
  44. data/app/assets/stylesheets/dorsale/print.sass +0 -74
  45. data/app/controllers/concerns/dorsale/back_url_concern.rb +0 -18
  46. data/app/controllers/dorsale/small_data/filters_controller.rb +0 -36
  47. data/app/filters/dorsale/small_data/filter.rb +0 -68
  48. data/app/filters/dorsale/small_data/filter_strategy.rb +0 -5
  49. data/app/filters/dorsale/small_data/filter_strategy_by_date.rb +0 -6
  50. data/app/filters/dorsale/small_data/filter_strategy_by_date_begin.rb +0 -6
  51. data/app/filters/dorsale/small_data/filter_strategy_by_date_end.rb +0 -6
  52. data/app/filters/dorsale/small_data/filter_strategy_by_key_value.rb +0 -16
  53. data/app/filters/dorsale/small_data/filter_strategy_by_tags.rb +0 -11
  54. data/app/filters/dorsale/small_data/filter_strategy_by_time_period.rb +0 -37
  55. data/app/helpers/dorsale/bootstrap_helper.rb +0 -6
  56. data/app/helpers/dorsale/button_helper.rb +0 -161
  57. data/app/helpers/dorsale/filters_helper.rb +0 -68
  58. data/app/helpers/dorsale/form_helper.rb +0 -49
  59. data/app/helpers/dorsale/link_helper.rb +0 -52
  60. data/app/helpers/dorsale/pagination_helper.rb +0 -6
  61. data/app/helpers/dorsale/routes_helper.rb +0 -20
  62. data/app/helpers/dorsale/sorting_helper.rb +0 -48
  63. data/app/helpers/dorsale/text_helper.rb +0 -121
  64. data/app/libs/dorsale/sortable_uuid_generator.rb +0 -11
  65. data/app/models/concerns/dorsale/active_record_uuid_concern.rb +0 -15
  66. data/app/models/concerns/dorsale/default_values_concern.rb +0 -13
  67. data/app/models/concerns/dorsale/model_i18n.rb +0 -25
  68. data/app/models/concerns/dorsale/model_to_s.rb +0 -9
  69. data/app/models/concerns/dorsale/polymorphic_id.rb +0 -34
  70. data/app/models/concerns/dorsale/search.rb +0 -30
  71. data/app/models/dorsale/small_data.rb +0 -2
  72. data/app/serializers/dorsale/serializers.rb +0 -2
  73. data/app/serializers/dorsale/serializers/base.rb +0 -17
  74. data/app/serializers/dorsale/serializers/xlsx.rb +0 -36
  75. data/app/views/dorsale/search/_form.html.slim +0 -6
  76. data/config/locales/common.en.yml +0 -210
  77. data/config/locales/common.fr.yml +0 -220
  78. data/lib/dorsale/active_record_comma_type_cast.rb +0 -12
  79. data/lib/dorsale/core_and_rails_ext.rb +0 -3
  80. data/lib/dorsale/form_back_url.rb +0 -18
  81. data/spec/controllers/dorsale/small_data/filters_controller_spec.rb +0 -60
  82. data/spec/filters/dorsale/small_data/filter_spec.rb +0 -39
  83. data/spec/helpers/dorsale/form_helper_spec.rb +0 -11
  84. data/spec/helpers/dorsale/link_helper_spec.rb +0 -31
  85. data/spec/helpers/dorsale/sorting_helper_spec.rb +0 -74
  86. data/spec/helpers/dorsale/text_helper_spec.rb +0 -123
  87. data/spec/libs/dorsale/active_record_comma_type_cast_spec.rb +0 -44
  88. data/spec/libs/dorsale/polymorphic_id_spec.rb +0 -30
  89. data/spec/libs/dorsale/sortable_uuid_generator_spec.rb +0 -29
  90. data/spec/models/concerns/dorsale/model_i18n_spec.rb +0 -21
  91. data/spec/routing/dorsale/small_data_routing_spec.rb +0 -15
  92. data/spec/serializers/dorsale/serializers/xlsx_spec.rb +0 -33
@@ -1,12 +0,0 @@
1
- module Dorsale::ActiveRecordCommaTypeCast
2
- def cast_value(value)
3
- if value.is_a?(String)
4
- super value.gsub(",", ".").gsub(/[^-0-9\.]/, "")
5
- else
6
- super value
7
- end
8
- end
9
- end
10
-
11
- ActiveRecord::Type::Decimal.send(:prepend, Dorsale::ActiveRecordCommaTypeCast)
12
- ActiveRecord::Type::Float.send(:prepend, Dorsale::ActiveRecordCommaTypeCast)
@@ -1,3 +0,0 @@
1
- require "dorsale/file_loader"
2
- require "dorsale/active_record_comma_type_cast"
3
- require "dorsale/form_back_url"
@@ -1,18 +0,0 @@
1
- module Dorsale::FormBackUrl
2
- def back_url_tag
3
- tag(:input,
4
- :type => "hidden",
5
- :name => "back_url",
6
- :value => (params[:back_url] || request.referer),
7
- )
8
- end
9
-
10
- def form_tag_with_body(html_options, content)
11
- output = form_tag_html(html_options)
12
- output.safe_concat(back_url_tag)
13
- output << content
14
- output.safe_concat("</form>")
15
- end
16
- end
17
-
18
- ActionView::Helpers::FormTagHelper.send(:prepend, Dorsale::FormBackUrl)
@@ -1,60 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Dorsale::SmallData::FiltersController, type: :controller do
4
- routes { Dorsale::Engine.routes }
5
-
6
- let(:user) { create(:user) }
7
-
8
- before(:each) { sign_in(user) }
9
-
10
- let(:filters) { {key: "value"} }
11
-
12
- before(:each) do
13
- request.env["HTTP_REFERER"] = "where_i_came_from"
14
- end
15
-
16
- describe "create" do
17
- let(:action) {
18
- post :create, params: {filters: filters}
19
- }
20
-
21
- it "should redirect to refferer" do
22
- action
23
- expect(response).to redirect_to "where_i_came_from"
24
- end
25
-
26
- it "should redirect to call back url if defined" do
27
- post :create, params: {filters: {key: "value"}, form_url: "xxx"}
28
- expect(response).to redirect_to "xxx"
29
- end
30
-
31
- it "should store the filter in cookie" do
32
- action
33
- expect(response.cookies["filters"]).to eq(filters.to_json)
34
- end
35
-
36
- it "should merge filters with previous filters" do
37
- action
38
- post :create, params: {filters: {other_key: "value2"}}
39
- expect(response.cookies["filters"]).to eq({key: "value", other_key: "value2"}.to_json)
40
- end
41
- end
42
-
43
- describe "form_url" do
44
- it "should reset page" do
45
- post :create, params: {filters: {}, form_url: "/dorsale/flyboy/tasks"}
46
- expect(response).to redirect_to "/dorsale/flyboy/tasks"
47
-
48
- post :create, params: {filters: {}, form_url: "/dorsale/flyboy/tasks?&sort=term&page=3"}
49
- expect(response).to redirect_to "/dorsale/flyboy/tasks?&sort=term"
50
-
51
- post :create, params: {filters: {}, form_url: "/dorsale/flyboy/tasks?&sort=term&page=3&a=b"}
52
- expect(response).to redirect_to "/dorsale/flyboy/tasks?&sort=term&a=b"
53
-
54
- post :create, params: {filters: {}, form_url: "/dorsale/flyboy/tasks?page=3&a=b"}
55
- expect(response).to redirect_to "/dorsale/flyboy/tasks?a=b"
56
- end
57
- end
58
-
59
- end
60
-
@@ -1,39 +0,0 @@
1
- require "rails_helper"
2
-
3
- module Dorsale
4
- describe SmallData::Filter do
5
- let(:jar) { {} }
6
- let(:filter) { {"name" => "bidule"} }
7
- let(:f) { Dorsale::SmallData::Filter.new(jar) }
8
-
9
- describe "write" do
10
- it "should write the provided hash as json in the jar" do
11
- f.write(filter)
12
- expect(jar["filters"]).to eq filter.to_json
13
- end
14
- end
15
-
16
- describe "read" do
17
- it "should read stored filters" do
18
- f.write(filter)
19
- expect(f.read).to eq(filter)
20
- end
21
-
22
- it "should return empty hash by default" do
23
- expect(f.read).to eq({})
24
- end
25
-
26
- it "should return empty hash on invalid json" do
27
- jar["filters"] = "i am invalid"
28
- expect(f.read).to eq({})
29
- end
30
- end
31
-
32
- it "should set/get values" do
33
- filter = Dorsale::CustomerVault::SmallData::FilterForPeople.new({})
34
- filter.person_type = "truc"
35
- expect(filter.person_type).to eq "truc"
36
- end
37
-
38
- end
39
- end
@@ -1,11 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe Dorsale::FormHelper, type: :helper do
4
- describe "form_buttons" do
5
- it "should not return full url" do
6
- html = form_buttons(back_url: "http://example.org/abc")
7
- expect(html).to include "/abc"
8
- expect(html).to_not include "://"
9
- end
10
- end
11
- end
@@ -1,31 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe Dorsale::LinkHelper, type: :helper do
4
- it "web_link" do
5
- expect(web_link("")).to be nil
6
- expect(web_link(nil)).to be nil
7
- expect(web_link("google.fr")).to eq %(<a href="http://google.fr">google.fr</a>)
8
- expect(web_link("http://google.fr")).to eq %(<a href="http://google.fr">http://google.fr</a>)
9
- end
10
-
11
- it "tel_link" do
12
- expect(tel_link("")).to be nil
13
- expect(tel_link(nil)).to be nil
14
- expect(tel_link("123")).to eq %(<a href="tel:123">123</a>)
15
- expect(tel_link("+ 33 6")).to eq %(<a href="tel:+336">+ 33 6</a>)
16
- end
17
-
18
- it "email_link" do
19
- expect(email_link("")).to be nil
20
- expect(email_link(nil)).to be nil
21
- expect(email_link("aaa@bbb.com")).to eq %(<a href="mailto:aaa@bbb.com">aaa@bbb.com</a>)
22
- end
23
-
24
- it "twitter_link" do
25
- expect(twitter_link("")).to be nil
26
- expect(twitter_link(nil)).to be nil
27
- expect(twitter_link("BenoitMC")).to eq %(<a href="https://twitter.com/BenoitMC">BenoitMC</a>)
28
- expect(twitter_link("twitter.com/BenoitMC")).to eq %(<a href="https://twitter.com/BenoitMC">twitter.com/BenoitMC</a>)
29
- expect(twitter_link("http://twitter.com/BenoitMC")).to eq %(<a href="http://twitter.com/BenoitMC">http://twitter.com/BenoitMC</a>)
30
- end
31
- end
@@ -1,74 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe Dorsale::SortingHelper, type: :helper do
4
- describe "#sortable_column" do
5
- let(:params) {{
6
- :controller => "home",
7
- :action => "home",
8
- }}
9
-
10
- it "current sort is nil" do
11
- link = sortable_column("text", :col)
12
- expect(link).to eq %(<a class="sort" href="/?sort=col">text</a>)
13
- end
14
-
15
- it "current sort is col" do
16
- params.merge!(sort: "col")
17
- link = sortable_column("text", :col)
18
- expect(link).to eq %(<a class="sort asc" href="/?sort=-col">text ↓</a>)
19
- end
20
-
21
- it "current sort is -col" do
22
- params.merge!(sort: "-col")
23
- link = sortable_column("text", :col)
24
- expect(link).to eq %(<a class="sort desc" href="/?sort=col">text ↑</a>)
25
- end
26
-
27
- it "current sort is other" do
28
- params.merge!(sort: "other")
29
- link = sortable_column("text", :col)
30
- expect(link).to eq %(<a class="sort" href="/?sort=col">text</a>)
31
- end
32
-
33
- it "current sort is -other" do
34
- params.merge!(sort: "-other")
35
- link = sortable_column("text", :col)
36
- expect(link).to eq %(<a class="sort" href="/?sort=col">text</a>)
37
- end
38
-
39
- it "should raise on invalid column type" do
40
- # old handles_sortable_columns syntax
41
- expect {
42
- sortable_column("text", {column: "col"})
43
- }.to raise_error ArgumentError
44
- end
45
- end # describe "#sortable_column"
46
-
47
- describe "#sortable_column_order" do
48
- attr_reader :params
49
-
50
- it "should parse asc column" do
51
- @params = {sort: "col"}
52
- expect(sortable_column_order).to eq ["col", :asc]
53
- end
54
-
55
- it "should parse desc column" do
56
- @params = {sort: "-col"}
57
- expect(sortable_column_order).to eq ["col", :desc]
58
- end
59
-
60
- it "should parse nil" do
61
- @params = {}
62
- expect(sortable_column_order).to eq [nil, nil]
63
- end
64
-
65
- it "should accept block" do
66
- @params = {sort: "-col"}
67
-
68
- sortable_column_order do |column, order|
69
- expect(column).to eq "col"
70
- expect(order).to eq :desc
71
- end
72
- end
73
- end # describe "#sortable_column_order"
74
- end
@@ -1,123 +0,0 @@
1
- require 'rails_helper'
2
-
3
- describe Dorsale::TextHelper, type: :helper do
4
- it "hours" do
5
- expect(hours(nil)).to be nil
6
- expect(hours(1)).to eq "1,00 heure"
7
- expect(hours(3)).to eq "3,00 heures"
8
- expect(hours(3.5)).to eq "3,50 heures"
9
- expect(hours(3.123)).to eq "3,12 heures"
10
- end
11
-
12
- it "number" do
13
- expect(number(nil)).to be nil
14
- expect(number(1)).to eq "1"
15
- expect(number(1.2)).to eq "1,20"
16
- expect(number(1.234)).to eq "1,23"
17
- expect(number(123456.789)).to eq "123 456,79"
18
- end
19
-
20
- it "percentage" do
21
- expect(percentage(nil)).to be nil
22
- expect(percentage(1)).to eq "1\u00A0%"
23
- expect(percentage(1.123)).to eq "1,12\u00A0%"
24
- end
25
-
26
- it "euros" do
27
- expect(euros(nil)).to be nil
28
- expect(euros(1)).to eq "1\u00A0€"
29
- expect(euros(1.123)).to eq "1,12\u00A0€"
30
- end
31
-
32
- it "date" do
33
- expect(date(nil)).to be nil
34
- expect(date(Date.parse("2012-12-21"))).to eq "21/12/2012"
35
- end
36
-
37
- it "text2html" do
38
- expect(text2html(nil)).to be nil
39
- expect(text2html(" \n")).to be nil
40
- expect(text2html("hello\nworld")).to eq "hello<br />world"
41
- expect(text2html("hello\r\nworld")).to eq "hello<br />world"
42
- expect(text2html("\n\nhello\nworld\n\n\n")).to eq "hello<br />world"
43
- expect(text2html("<b>hello</b> world")).to eq "hello world"
44
- end
45
-
46
- it "should work with module calls" do
47
- expect(Dorsale::AllHelpers.number(1.2)).to eq "1,20"
48
- end
49
-
50
- describe "#info" do
51
- let(:quotation_line) {
52
- l = create(:billing_machine_quotation_line,
53
- :unit => "abc",
54
- :quantity => 1000.17,
55
- )
56
-
57
- def l.date; Date.parse("2015-01-25"); end
58
- def l.time; Time.parse("2015-01-25 17:09:23"); end
59
- def l.paid?; true end
60
- l
61
- }
62
-
63
- it "should work with strings" do
64
- expect(info quotation_line, :unit).to eq %(<div class="info"><strong class="info-label">Unité</strong><span class="info-separator"> : </span><span class="info-value quotation_line-unit">abc</span></div>)
65
- end
66
-
67
- it "should accept other tags" do
68
- expect(info quotation_line, :unit, nil, tag: :p).to eq %(<p class="info"><strong class="info-label">Unité</strong><span class="info-separator"> : </span><span class="info-value quotation_line-unit">abc</span></p>)
69
- end
70
-
71
- it "should accept custom separator" do
72
- expect(info quotation_line, :unit, separator: "->").to eq %(<div class="info"><strong class="info-label">Unité</strong><span class="info-separator">-&gt;</span><span class="info-value quotation_line-unit">abc</span></div>)
73
- end
74
-
75
- it "should accept nested values" do
76
- expect(info quotation_line.quotation, :state).to eq %(<div class="info"><strong class="info-label">État</strong><span class="info-separator"> : </span><span class="info-value quotation-state">En attente</span></div>)
77
- end
78
-
79
- it "should override value" do
80
- expect(info quotation_line, :unit, "zzzzz").to include "zzzzz"
81
- end
82
-
83
- it "should work with floats" do
84
- expect(info quotation_line, :quantity).to include "1 000,17"
85
- end
86
-
87
- it "should work with date" do
88
- expect(info quotation_line, :date).to include "25/01/2015"
89
- end
90
-
91
- it "should work with time" do
92
- expect(info quotation_line, :time).to include "25/01/2015 à 17:09"
93
- end
94
-
95
- it "should work with booleans" do
96
- expect(info quotation_line, :paid?).to include "Oui"
97
- end
98
-
99
- it "should accept helper" do
100
- expect(info quotation_line, :quantity, helper: :euros).to include "1\u00A0000,17\u00A0€"
101
- end
102
-
103
- it "should work with class" do
104
- expect(info Dorsale::CustomerVault::Person, :count, 123).to eq %(<div class="info"><strong class="info-label">Nombre de contacts</strong><span class="info-separator"> : </span><span class="info-value person-count">123</span></div>)
105
- end
106
-
107
- it "should accept default value" do
108
- quotation_line.unit = nil
109
- expect(info quotation_line, :unit, default: "hello").to eq %(<div class="info"><strong class="info-label">Unité</strong><span class="info-separator"> : </span><span class="info-value quotation_line-unit">hello</span></div>)
110
- end
111
-
112
- it "should accept :hide as default value" do
113
- quotation_line.unit = nil
114
- expect(info quotation_line, :unit, default: :hide).to eq nil
115
- end
116
-
117
- it "should hide on blank strings" do
118
- quotation_line.unit = " \n"
119
- expect(info quotation_line, :unit, default: :hide).to eq nil
120
- end
121
- end
122
-
123
- end
@@ -1,44 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Dorsale::ActiveRecordCommaTypeCast, type: :model do
4
- let(:line) { create(:billing_machine_invoice_line) }
5
-
6
- it "should accept , as decimal separator" do
7
- line.update!(quantity: "12,34")
8
- expect(line.reload.quantity).to eq 12.34
9
- end
10
-
11
- it "should accept . as decimal separator" do
12
- line.update!(quantity: "12.34")
13
- expect(line.reload.quantity).to eq 12.34
14
- end
15
-
16
- it "should accept space as group separator" do
17
- line.update!(quantity: "123 456,78")
18
- expect(line.reload.quantity).to eq 123456.78
19
-
20
- line.update!(quantity: "123 456.78")
21
- expect(line.reload.quantity).to eq 123456.78
22
- end
23
-
24
- it "should accept nbsp as group separator" do
25
- line.update!(quantity: "123 456,78")
26
- expect(line.reload.quantity).to eq 123456.78
27
-
28
- line.update!(quantity: "123 456.78")
29
- expect(line.reload.quantity).to eq 123456.78
30
- end
31
-
32
- it "should accept negative numbers" do
33
- line.update!(quantity: "-12,34")
34
- expect(line.reload.quantity).to eq -12.34
35
-
36
- line.update!(quantity: "-12.34")
37
- expect(line.reload.quantity).to eq -12.34
38
- end
39
-
40
- it "should accept trailing chars" do
41
- line.update!(quantity: "abc 12.34 def")
42
- expect(line.reload.quantity).to eq 12.34
43
- end
44
- end
@@ -1,30 +0,0 @@
1
- require "rails_helper"
2
-
3
- RSpec.describe Dorsale::PolymorphicId do
4
- it "should return guid" do
5
- task = create(:flyboy_task)
6
- expect(task.id).to be_present
7
- expect(task.guid).to eq "Dorsale::Flyboy::Task-#{task.id}"
8
- end
9
-
10
- it "should return guid" do
11
- corporation = create(:customer_vault_corporation)
12
- task = build(:flyboy_task, taskable: nil)
13
-
14
- expect(task.taskable).to be_nil
15
- expect(task.taskable_id).to be_nil
16
- expect(task.taskable_type).to be_nil
17
-
18
- task.taskable_guid = corporation.guid
19
-
20
- expect(task.taskable).to eq corporation
21
- expect(task.taskable_id).to eq corporation.id
22
- expect(task.taskable_type).to eq "Dorsale::CustomerVault::Person"
23
- end
24
-
25
- it "should return base_class in guid" do
26
- corporation = create(:customer_vault_corporation)
27
- expect(corporation.guid).to eq "Dorsale::CustomerVault::Person-#{corporation.id}"
28
- end
29
-
30
- end