kaui 0.16.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/app/assets/javascripts/application.js +1 -1
  4. data/app/assets/javascripts/kaui/kaui.js +78 -1
  5. data/app/assets/stylesheets/bootstrap_and_overrides.css.less +5 -0
  6. data/app/assets/stylesheets/kaui/account.less +20 -0
  7. data/app/assets/stylesheets/kaui/audit.less +38 -0
  8. data/app/assets/stylesheets/kaui/common.less +103 -0
  9. data/app/assets/stylesheets/kaui/datatable.less +19 -0
  10. data/app/assets/stylesheets/kaui/kaui.less +3 -1
  11. data/app/assets/stylesheets/kaui/subscription.less +15 -0
  12. data/app/assets/stylesheets/kaui/tags.less +30 -1
  13. data/app/controllers/kaui/account_custom_fields_controller.rb +24 -0
  14. data/app/controllers/kaui/account_tags_controller.rb +21 -0
  15. data/app/controllers/kaui/accounts_controller.rb +43 -16
  16. data/app/controllers/kaui/admin_tenants_controller.rb +152 -11
  17. data/app/controllers/kaui/audit_logs_controller.rb +93 -0
  18. data/app/controllers/kaui/bundles_controller.rb +15 -3
  19. data/app/controllers/kaui/custom_fields_controller.rb +2 -0
  20. data/app/controllers/kaui/engine_controller_util.rb +14 -0
  21. data/app/controllers/kaui/invoice_items_controller.rb +17 -0
  22. data/app/controllers/kaui/invoices_controller.rb +22 -5
  23. data/app/controllers/kaui/payment_methods_controller.rb +10 -9
  24. data/app/controllers/kaui/subscriptions_controller.rb +54 -7
  25. data/app/controllers/kaui/tag_definitions_controller.rb +1 -0
  26. data/app/helpers/kaui/account_helper.rb +28 -0
  27. data/app/helpers/kaui/object_helper.rb +4 -0
  28. data/app/helpers/kaui/permissions_helper.rb +15 -0
  29. data/app/helpers/kaui/plugin_helper.rb +58 -0
  30. data/app/helpers/kaui/subscription_helper.rb +9 -7
  31. data/app/models/kaui/admin_tenant.rb +20 -6
  32. data/app/models/kaui/catalog.rb +4 -4
  33. data/app/models/kaui/tag.rb +1 -1
  34. data/app/models/kaui/tag_definition.rb +1 -1
  35. data/app/views/kaui/account_custom_fields/index.html.erb +35 -0
  36. data/app/views/kaui/account_tags/index.html.erb +35 -0
  37. data/app/views/kaui/accounts/_account_info.html.erb +5 -0
  38. data/app/views/kaui/accounts/_billing_info.html.erb +1 -1
  39. data/app/views/kaui/accounts/_close_account_modal.html.erb +98 -0
  40. data/app/views/kaui/accounts/index.html.erb +0 -7
  41. data/app/views/kaui/accounts/show.html.erb +4 -0
  42. data/app/views/kaui/admin_tenants/_add_allowed_user_modal.html.erb +64 -0
  43. data/app/views/kaui/admin_tenants/_form_plugin_config.erb +257 -151
  44. data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +133 -48
  45. data/app/views/kaui/admin_tenants/_show_catalog_xml.erb +3 -2
  46. data/app/views/kaui/admin_tenants/show.html.erb +6 -1
  47. data/app/views/kaui/audit_logs/_show_history_modal.html.erb +177 -0
  48. data/app/views/kaui/audit_logs/index.html.erb +52 -0
  49. data/app/views/kaui/bundle_tags/_form_bar.html.erb +4 -2
  50. data/app/views/kaui/bundles/index.html.erb +21 -14
  51. data/app/views/kaui/chargebacks/_form.html.erb +1 -9
  52. data/app/views/kaui/charges/_form.html.erb +2 -10
  53. data/app/views/kaui/credits/_form.html.erb +1 -9
  54. data/app/views/kaui/custom_fields/_form.html.erb +1 -1
  55. data/app/views/kaui/custom_fields/_list_bar.html.erb +1 -1
  56. data/app/views/kaui/invoices/_invoice_table.html.erb +30 -2
  57. data/app/views/kaui/layouts/kaui_account_navbar.html.erb +7 -0
  58. data/app/views/kaui/layouts/kaui_flash.html.erb +13 -2
  59. data/app/views/kaui/payment_methods/_new_creditcard_payment_method.html.erb +11 -11
  60. data/app/views/kaui/payment_methods/_plugin_properties.html.erb +1 -1
  61. data/app/views/kaui/payments/_form.html.erb +1 -9
  62. data/app/views/kaui/refunds/_form.html.erb +4 -6
  63. data/app/views/kaui/subscriptions/_cancel_by_date_modal.html.erb +62 -0
  64. data/app/views/kaui/subscriptions/_form.html.erb +7 -13
  65. data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +50 -11
  66. data/app/views/kaui/subscriptions/new.html.erb +3 -1
  67. data/app/views/kaui/tag_definitions/_form.html.erb +139 -0
  68. data/app/views/kaui/tags/index.html.erb +1 -1
  69. data/app/views/kaui/transactions/_control_plugin_names.html.erb +1 -1
  70. data/config/routes.rb +18 -2
  71. data/db/migrate/20130812155313_devise_create_kaui_users.rb +9 -7
  72. data/db/migrate/20150109214021_create_kaui_tenants.rb +8 -6
  73. data/db/migrate/20150112232813_create_kaui_allowed_users.rb +15 -11
  74. data/lib/kaui/engine.rb +1 -0
  75. data/lib/kaui/version.rb +1 -1
  76. data/test/dummy/config/database.yml +6 -1
  77. data/test/fixtures/SpyCarAdvanced.xml +824 -0
  78. data/test/functional/kaui/account_children_controller_test.rb +1 -1
  79. data/test/functional/kaui/account_custom_fields_controller_test.rb +29 -0
  80. data/test/functional/kaui/account_tags_controller_test.rb +19 -0
  81. data/test/functional/kaui/accounts_controller_test.rb +23 -6
  82. data/test/functional/kaui/admin_controller_test.rb +2 -2
  83. data/test/functional/kaui/admin_tenants_controller_test.rb +76 -5
  84. data/test/functional/kaui/audit_logs_controller_test.rb +71 -0
  85. data/test/functional/kaui/bundles_controller_test.rb +2 -1
  86. data/test/functional/kaui/payments_controller_test.rb +1 -1
  87. data/test/functional/kaui/subscriptions_controller_test.rb +1 -2
  88. data/test/functional/kaui/tag_definitions_controller_test.rb +2 -1
  89. data/test/killbill_test_helper.rb +5 -2
  90. data/test/unit/kaui/admin_tenant_test.rb +100 -0
  91. data/test/unit/kaui/money_helper_test.rb +1 -1
  92. metadata +58 -13
  93. data/app/assets/javascripts/kaui/validation.js +0 -21
  94. data/test/dummy/log/test.log +0 -0
@@ -28,10 +28,10 @@
28
28
  <div id=<%= "div_#{ii.invoice_item_id}" %> class="form-group">
29
29
  <label class="col-sm-2 control-label"></label>
30
30
 
31
- <% bundle = @bundles.find { |bundle| bundle.bundle_id == ii.bundle_id } %>
31
+ <% bundle_result = @bundles.find { |bundle| bundle.bundle_id == ii.bundle_id } %>
32
32
  <div class="col-sm-10">
33
33
  <input type="checkbox" id=<%= "cb_adj_#{ii.invoice_item_id}" %>>
34
- <%= "Item #{index + 1} : #{ii.description} #{"(bundle #{bundle.external_key})" unless bundle.nil?}" %>
34
+ <%= "Item #{index + 1} : #{ii.description} #{"(bundle #{bundle_result.external_key})" unless bundle_result.nil?}" %>
35
35
  <%= text_field_tag "adjustments[#{ii.invoice_item_id}]", index, :id => "tf_adj_#{ii.invoice_item_id}", :value => ii.amount, :class => 'form-control' %>
36
36
  </div>
37
37
  </div>
@@ -42,7 +42,7 @@
42
42
  <div id="div_refund_amount" class="form-group">
43
43
  <%= label_tag :amount, 'Amount', :class => 'col-sm-2 control-label' %>
44
44
  <div class="col-sm-10">
45
- <%= text_field_tag :amount, @payment.purchased_amount, :id => 'refund_amount', :class => 'form-control' %>
45
+ <%= number_field_tag :amount, @payment.purchased_amount, :id => 'refund_amount', :class => 'form-control' %>
46
46
  <p class="help-block">Currency: <%= @invoice.currency %></p>
47
47
  </div>
48
48
  </div>
@@ -184,9 +184,7 @@
184
184
  /*
185
185
  * For refund amount text area, attach handler to disable 'ENTER' and also prevent bad values
186
186
  */
187
- $("#refund_amount").keydown(function(event) {
188
- preventNonNumericValues(event);
189
- }).bind('keypress', function(e) {
187
+ $("#refund_amount").bind('keypress', function(e) {
190
188
  if ((e.keyCode || e.which) == 13) {
191
189
  return false;
192
190
  }
@@ -0,0 +1,62 @@
1
+ <div class="modal fade" id="cancel_subscription_by_date_modal" tabindex="-1" role="dialog">
2
+ <div class="modal-dialog" role="document">
3
+ <div class="modal-content column-block">
4
+ <div>
5
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
6
+ <h1 class="modal-title">Cancel a subscription given a date</h1>
7
+ </div>
8
+ <div class="modal-body">
9
+ <%= form_for :subscription, :url => '' , :method => :delete, :html => {:class => 'form-horizontal', :id => 'cancel_subscription_form'} do |f| %>
10
+ <div class="form-group">
11
+ <%= label_tag :requested_date, 'Date', :class => 'col-sm-2 control-label' %>
12
+ <div class="col-sm-10">
13
+ <%= text_field_tag :requested_date, Date.parse(Time.now.to_s).to_s, :class => 'form-control date-picker' %>
14
+ </div>
15
+ </div>
16
+ <div class="form-group">
17
+ <div class="col-sm-offset-4 col-sm-8">
18
+ <div class="checkbox">
19
+ <%= label_tag :use_requested_date_for_billing do %>
20
+ <input type="checkbox" id="is_requested_date_for_billing">
21
+ Use requested date for billing?
22
+ <input type="hidden" id="use_requested_date_for_billing" name="use_requested_date_for_billing" value="0">
23
+ <% end %>
24
+ </div>
25
+ </div>
26
+ </div>
27
+
28
+ <div class="form-group">
29
+ <div class="col-sm-offset-4 col-sm-10">
30
+ <%= submit_tag 'Save', :class => 'btn btn-default' %>
31
+ </div>
32
+ </div>
33
+ <% end %>
34
+ </div>
35
+ <div class="modal-footer">
36
+ <div class="alert alert-warning">
37
+ <strong>Notice</strong>
38
+ <ul>
39
+ <li>When <span class="label label-default">Use requested date for billing?</span> is checked, then entitlement date and billing date are going to be equal to the requested date.</li>
40
+ <li>When <strong>not</strong> checked, then the entitlement date will be set with requested date, and billing date will default to now.</li>
41
+ </ul>
42
+ </div>
43
+ </div>
44
+ </div><!-- /.modal-content -->
45
+ </div><!-- /.modal-dialog -->
46
+ </div><!-- /.modal -->
47
+
48
+ <%= javascript_tag do %>
49
+ $(document).ready(function() {
50
+
51
+ $('#cancel_subscription_by_date_modal').on('show.bs.modal', function (e) {
52
+ $("#cancel_subscription_form").attr("action", Routes.kaui_engine_subscription_path(e.relatedTarget.dataset['id']));
53
+
54
+ });
55
+
56
+ $('#is_requested_date_for_billing').change(function(e) {
57
+ $('#use_requested_date_for_billing').val($(this).is(':checked') ? 1 : 0);
58
+ });
59
+
60
+ });
61
+
62
+ <% end %>
@@ -5,13 +5,7 @@
5
5
 
6
6
  <% if @subscription.product_category == 'ADD_ON' %>
7
7
  <%= hidden_field_tag :base_product_name, @base_product_name %>
8
- <div class="form-group">
9
- <%= label_tag :plan_name, 'Plan', :class => 'col-sm-2 control-label' %>
10
- <div class="col-sm-10">
11
- <%= select_tag :plan_name, options_for_select(@plans), :class => 'form-control' %>
12
- </div>
13
- </div>
14
- <% else %>
8
+ <% elsif @subscription.product_category == 'BASE' %>
15
9
  <div class="form-group">
16
10
  <%= f.label :external_key, 'Key', :class => 'col-sm-2 control-label' %>
17
11
  <div class="col-sm-10">
@@ -21,13 +15,13 @@
21
15
  </div>
22
16
  </div>
23
17
  </div>
24
- <div class="form-group">
25
- <%= label_tag :plan_name, 'Plan', :class => 'col-sm-2 control-label' %>
26
- <div class="col-sm-10">
27
- <%= select_tag :plan_name, options_for_select(@plans), :class => 'form-control' %>
28
- </div>
29
- </div>
30
18
  <% end %>
19
+ <div class="form-group">
20
+ <%= label_tag :plan_name, 'Plan', :class => 'col-sm-2 control-label' %>
21
+ <div class="col-sm-10">
22
+ <%= select_tag :plan_name, options_for_select(@plans), :class => 'form-control' %>
23
+ </div>
24
+ </div>
31
25
  <div class="form-group">
32
26
  <div class="col-sm-offset-2 col-sm-10">
33
27
  <div class="radio">
@@ -1,24 +1,57 @@
1
1
  <table id="subscriptions_<%= bundle.bundle_id %>" class="table table-condensed mobile-data">
2
2
  <thead>
3
3
  <tr>
4
+ <% unless @available_subscription_tags.blank? && @custom_fields_per_subscription.blank? %>
5
+ <th></th>
6
+ <% end %>
4
7
  <th>Product category</th>
5
8
  <th>Product name</th>
6
9
  <th>Phase type</th>
7
10
  <th>Start date</th>
8
11
  <th>Charged through date</th>
9
- <th>Cancel date</th>
12
+ <th>Cancel information</th>
10
13
  <th>Actions</th>
11
14
  </tr>
12
15
  </thead>
13
16
  <tbody>
14
17
  <% (bundle.subscriptions || []).each do |sub| %>
15
18
  <tr class="<%= is_subscription_cancelled?(sub) ? 'expired' : 'non-expired' %>">
16
- <td><%= humanized_subscription_product_category(sub) %></td>
19
+ <% unless @available_subscription_tags.blank? && @custom_fields_per_subscription.blank? %>
20
+ <td class="inline-row-tag-bar">
21
+ <div class="tag-bar tag-bar-no-border">
22
+ <% unless @available_subscription_tags.blank? %>
23
+ <div class="tag-select" onclick="void(0)">
24
+ <span><i class="fa fa-tag"></i><i class="fa fa-caret-down"></i></span>
25
+
26
+ <div class="tag-select-box">
27
+ <strong>Tag as:</strong>
28
+
29
+ <%= render :partial => 'kaui/bundle_tags/form_bar',
30
+ :locals => {:params => { :bundle_id => bundle.bundle_id},
31
+ :tag_names => (@tags_per_subscription[sub.subscription_id] || []).map { |tag| tag.tag_definition_name },
32
+ :available_tags => @available_subscription_tags,
33
+ :update_tags_path => update_subscriptions_tags_path(sub.subscription_id)
34
+ } %>
35
+ </div>
36
+ </div>
37
+ <% end %>
38
+
39
+ <%= render :partial => 'kaui/custom_fields/list_bar',
40
+ :locals => {:custom_fields => @custom_fields_per_subscription[sub.subscription_id] || []} %>
41
+ </div>
42
+
43
+ </td>
44
+ <% end %>
45
+ <td>
46
+ <span class="subscription-id-popover" data-toggle="popover" data-trigger="hover" title="Subscription ID" data-content="<%= sub.subscription_id %>">
47
+ <%= humanized_subscription_product_category(sub) %>
48
+ </span>
49
+ </td>
17
50
  <td><%= humanized_subscription_full_product_name(sub) %></td>
18
51
  <td><%= humanized_subscription_phase_type(sub) %></td>
19
52
  <td><%= humanized_subscription_start_date(sub, account) %></td>
20
53
  <td><%= humanized_subscription_charged_through_date(sub, account) %></td>
21
- <td><%= humanized_subscription_cancelled_date(sub, account) %></td>
54
+ <td><%= humanized_subscription_cancelled_information(sub, account) %></td>
22
55
  <td class="text-center">
23
56
  <% if is_subscription_future_cancelled?(sub, account) %>
24
57
  <%= link_to 'Reinstate', kaui_engine.reinstate_path(:id => sub.subscription_id), :method => :put, :class => 'btn btn-xs' %>
@@ -37,6 +70,7 @@
37
70
  <li><%= link_to 'Cancel start of term (full credit)', kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'START_OF_TERM'), :method => :delete %></li>
38
71
  <li><%= link_to 'Cancel immediately (partial credit)', kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'IMMEDIATE'), :method => :delete %></li>
39
72
  <li><%= link_to 'Cancel end of term (no credit)', kaui_engine.subscription_path(:id => sub.subscription_id, :policy => 'END_OF_TERM'), :method => :delete %></li>
73
+ <li><%= link_to 'Cancel a subscription given a date', '#cancel_subscription_by_date_modal', data: {toggle: 'modal', id: sub.subscription_id} %></li>
40
74
  </ul>
41
75
  </div>
42
76
  <% end %>
@@ -50,20 +84,25 @@
50
84
  </tbody>
51
85
  </table>
52
86
 
87
+ <%= render :partial => 'kaui/subscriptions/cancel_by_date_modal' %>
88
+
53
89
  <%= javascript_tag do %>
54
90
  $(document).ready(function() {
91
+ $('.subscription-id-popover').popover();
92
+
55
93
  $('#subscriptions_<%= bundle.bundle_id %>').dataTable({
56
94
  "dom": "t",
57
95
  "paging": false,
58
- "order": [[ 3, "asc" ]],
96
+ "order": [[ <%= @available_subscription_tags.blank? && @custom_fields_per_subscription.blank? ? 3 : 4 %>, "asc" ]],
59
97
  "columns": [
60
- null,
61
- null,
62
- null,
63
- null,
64
- null,
65
- null,
66
- { "orderable": false }
98
+ <%= "{ orderable: false }," unless @available_subscription_tags.blank? && @custom_fields_per_subscription.blank? %>
99
+ null,
100
+ null,
101
+ null,
102
+ null,
103
+ null,
104
+ null,
105
+ { "orderable": false }
67
106
  ]
68
107
  });
69
108
  });
@@ -4,8 +4,10 @@
4
4
  <div class="column-block">
5
5
  <% if @subscription.product_category == 'ADD_ON' %>
6
6
  <h1>Add new add-on</h1>
7
+ <% elsif @subscription.product_category == 'STANDALONE' %>
8
+ <h1>Add new standalone subscription</h1>
7
9
  <% else %>
8
- <h1>Add new base subscription</h1>
10
+ <h1>Add new subscription</h1>
9
11
  <% end %>
10
12
 
11
13
  <%= render 'form' %>
@@ -1,6 +1,24 @@
1
1
  <%= form_for @tag_definition, :html => {:class => 'form-horizontal'} do |f| %>
2
2
  <%= f.hidden_field :id %>
3
3
 
4
+ <div class="form-group">
5
+ <%= f.label :object_type, :class => 'col-sm-2 control-label' do %>
6
+ Object type<a class='btn btn-xs tag-definition-add-link' href="javascript:void(0);" onclick="new_object_type();" id="new_object_type">
7
+ <%= '<i class="fa fa-plus-square"></i>'.html_safe %>
8
+ </a>
9
+ <% end %>
10
+ <div class="col-sm-10" id="object_types">
11
+ <% (@tag_definition.applicable_object_types || [:account]).each_with_index do |object_type, index| %>
12
+ <div id="object_type_line_<%= index %>">
13
+ <%= f.select "applicable_object_types[#{index}]", object_types,
14
+ {:selected => object_type, :id => "object_type_#{index}"}, :class => 'form-control tag-definition-select' %>
15
+ <a class='btn btn-xs' href="javascript:void(0);" onclick="delete_object_type(this);" id="delete_object_type_<%= index %>" <%= "style='display: none;'".html_safe if index == 0 %>>
16
+ <%= '<i class="fa fa-times"></i>'.html_safe %>
17
+ </a>
18
+ </div>
19
+ <% end %>
20
+ </div>
21
+ </div>
4
22
  <div class='form-group'>
5
23
  <%= f.label :name, 'Name', :class => 'col-sm-2 control-label' %>
6
24
  <div class='col-sm-10'>
@@ -19,3 +37,124 @@
19
37
  </div>
20
38
  </div>
21
39
  <% end %>
40
+
41
+ <%= javascript_tag do %>
42
+ var all_object_types = [];
43
+
44
+ $( document ).ready(function() {
45
+ initialize();
46
+
47
+ function initialize(){
48
+ all_object_types = $.map($("#object_types>div:last").find("select option"), function(e, i) {
49
+ return $(e).val();
50
+ });
51
+ }
52
+
53
+ $(".tag-definition-select").on("change",function(){ refresh_options(); });
54
+ });
55
+
56
+ function get_used_object_types(){
57
+ var used_object_types = $.map($('#object_types>div'), function(e, i) {
58
+ return $(e).find("select").val();
59
+ });
60
+ return used_object_types;
61
+ }
62
+
63
+ function refresh_options(){
64
+ remove_used_object_types();
65
+ // restore missing types
66
+ var used_object_types = get_used_object_types();
67
+ var available_object_types = all_object_types.filter(function(type){
68
+ return used_object_types.indexOf(type) < 0;
69
+ });
70
+
71
+ $('#object_types>div').each(function(){
72
+ var container = this;
73
+ var object_types = $.map($(container).find("select option"), function(option, i) {
74
+ return $(option).val();
75
+ });
76
+
77
+ $.each(available_object_types, function(idx, type){
78
+ if (object_types.indexOf(type) < 0)
79
+ {
80
+ $(container).find("select").append('<option value="' + type + '">' + type + '</option>');
81
+ }
82
+ });
83
+
84
+ sort_object_types(container);
85
+ });
86
+ }
87
+
88
+ function remove_used_object_types(){
89
+ var used_object_types = get_used_object_types();
90
+ for (var i = 0; i < used_object_types.length; i++){
91
+ $("#object_types>div").each(function(){
92
+ var selected = $(this).find("select").val();
93
+
94
+ if (selected != used_object_types[i])
95
+ {
96
+ $(this).find("select").find("option[value='" + used_object_types[i] + "']").remove();
97
+ }
98
+ });
99
+ }
100
+ }
101
+
102
+ function new_object_type() {
103
+ var used_object_types = get_used_object_types();
104
+ var max_idx = $.map($("[id^=delete_object_type_]"), function(e, i) {
105
+ return e.id.split("delete_object_type_")[1] }
106
+ ).sort(function(a, b) {
107
+ return b - a
108
+ })[0];
109
+
110
+ var row = $("#object_types>div:last").clone(true);
111
+ var row_idx = (parseInt(max_idx) + 1).toString();
112
+ row.attr("id", "object_type_line_" + row_idx);
113
+ row.children("select").attr("id", "object_type_" + row_idx);
114
+
115
+ for (var i = 0; i < used_object_types.length; i++){
116
+ row.children("select").find("option[value='" + used_object_types[i] + "']").remove();
117
+ }
118
+
119
+ row.children("select").attr('name', ($(row.children("select")).attr('name')).replace(max_idx,row_idx));
120
+ row.children("a").attr("id", "delete_object_type_" + row_idx);
121
+ row.children("a").css("display", "inline-block");
122
+
123
+ /* Attach row into dom */
124
+ if (row.children("select").has("option").length > 0){
125
+ row.insertAfter("#object_types>div:last");
126
+ }
127
+
128
+ remove_used_object_types();
129
+
130
+ }
131
+
132
+ function delete_object_type(obj) {
133
+ var idx = obj.id.split("delete_object_type_")[1];
134
+
135
+ if ( idx > 0 ){
136
+ var object_type = $("#object_type_line_" + idx).find("select").val();
137
+ $("#object_type_line_" + idx).remove();
138
+
139
+ $("#object_types>div").each(function(){
140
+ $(this).find("select").append('<option value="' + object_type + '">' + object_type + '</option>');
141
+ sort_object_types(this);
142
+ });
143
+ }
144
+
145
+ }
146
+
147
+ function sort_object_types(e){
148
+ var selected = $(e).find("select").val();
149
+
150
+ var options = $(e).find("select option");
151
+ options.detach().sort(function(a,b) {
152
+ var at = $(a).text();
153
+ var bt = $(b).text();
154
+ return (at > bt)?1:((at < bt)?-1:0);
155
+ });
156
+ options.appendTo($(e).find("select"));
157
+ $(e).find("select").val(selected);
158
+ }
159
+
160
+ <% end %>
@@ -27,7 +27,7 @@
27
27
  <%= javascript_tag do %>
28
28
  $(document).ready(function() {
29
29
  var table = $('#tags-table').DataTable({
30
- "dom": "<'row'r>t<'row'<'col-md-6'i><'col-md-6'p>>",
30
+ "dom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
31
31
  "pagingType": <% if @max_nb_records.nil? -%>"simple"<% else -%>"full_numbers"<% end -%>,
32
32
  "language": {
33
33
  <!-- See DefaultPaginationSqlDaoHelper.java -->
@@ -8,7 +8,7 @@
8
8
  </tr>
9
9
  </thead>
10
10
  <tbody>
11
- <% (@control_plugin_names || ['']).each_with_index do |control_plugin_name, index| %>
11
+ <% (@control_plugin_names ||= ['']).each_with_index do |control_plugin_name, index| %>
12
12
  <tr id="control_plugin_name_<%= index %>" >
13
13
  <td><%= text_field_tag 'control_plugin_names[]', control_plugin_name, class: 'form-control' %></td>
14
14
  <td>
data/config/routes.rb CHANGED
@@ -38,6 +38,7 @@ Kaui::Engine.routes.draw do
38
38
  match '/unlink_to_parent' => 'accounts#unlink_to_parent', :via => :delete, :as => 'unlink_to_parent'
39
39
 
40
40
  scope '/account_tags' do
41
+ match '/' => 'account_tags#index', :via => :get, :as => 'account_tags'
41
42
  match '/edit' => 'account_tags#edit', :via => :get, :as => 'edit_account_tags'
42
43
  match '/edit' => 'account_tags#update', :via => :post, :as => 'update_account_tags'
43
44
  end
@@ -48,13 +49,19 @@ Kaui::Engine.routes.draw do
48
49
  scope '/timeline' do
49
50
  match '/' => 'account_timelines#show', :via => :get, :as => 'account_timeline'
50
51
  end
52
+ scope '/custom_fields' do
53
+ match '/' => 'account_custom_fields#index', :via => :get, :as => 'account_custom_fields'
54
+ end
51
55
  scope '/account_children' do
52
56
  match '/' => 'account_children#index', :via => :get, :as => 'account_children'
53
57
  match '/pagination' => 'account_children#pagination', :via => :get, :as => 'account_children_pagination'
54
58
  end
59
+ scope '/audit_logs' do
60
+ match '/history' => 'audit_logs#history', :via => :get, :as => 'audit_logs_history'
61
+ end
55
62
  end
56
63
  end
57
- resources :accounts, :only => [ :index, :new, :create, :edit, :update, :show ], :param => :account_id do
64
+ resources :accounts, :only => [ :index, :new, :create, :edit, :update, :show, :destroy ], :param => :account_id do
58
65
  member do
59
66
  put :set_default_payment_method
60
67
  delete :delete_payment_method
@@ -74,6 +81,7 @@ Kaui::Engine.routes.draw do
74
81
  resources :refunds, :only => [:new, :create]
75
82
  resources :transactions, :only => [:new, :create]
76
83
  resources :queues, :only => [:index]
84
+ resources :audit_logs, :only => [:index]
77
85
  end
78
86
 
79
87
  scope '/payment_methods' do
@@ -89,6 +97,9 @@ Kaui::Engine.routes.draw do
89
97
  end
90
98
  resources :invoices, :only => [ :index ]
91
99
 
100
+ scope '/invoice_items' do
101
+ match '/:id/tags' => 'invoice_items#update_tags', :via => :post, :as => 'update_invoice_items_tags'
102
+ end
92
103
  resources :invoice_items, :only => [:update, :destroy]
93
104
 
94
105
  scope '/payments' do
@@ -112,6 +123,7 @@ Kaui::Engine.routes.draw do
112
123
  end
113
124
 
114
125
  scope '/subscriptions' do
126
+ match '/:id/tags' => 'subscriptions#update_tags', :via => :post, :as => 'update_subscriptions_tags'
115
127
  match '/:id/edit_bcd' => 'subscriptions#edit_bcd', :via => :get, :as => 'edit_bcd'
116
128
  match '/:id/update_bcd' => 'subscriptions#update_bcd', :via => :put, :as => 'update_bcd'
117
129
  match '/:id/reinstate' => 'subscriptions#reinstate', :via => :put, :as => 'reinstate'
@@ -154,7 +166,6 @@ Kaui::Engine.routes.draw do
154
166
  match '/clock' => 'admin#set_clock', :via => :put, :as => 'admin_set_clock'
155
167
  end
156
168
 
157
- resources :admin_tenants, :only => [ :index, :new, :create, :show ]
158
169
  scope '/admin_tenants' do
159
170
  match '/:id/new_catalog' => 'admin_tenants#new_catalog', :via => :get, :as => 'admin_tenant_new_catalog'
160
171
  match '/:id/delete_catalog' => 'admin_tenants#delete_catalog', :via => :delete, :as => 'admin_tenant_delete_catalog'
@@ -171,7 +182,12 @@ Kaui::Engine.routes.draw do
171
182
  match '/upload_catalog_translation' => 'admin_tenants#upload_catalog_translation', :via => :post, :as => 'admin_tenant_upload_catalog_translation'
172
183
  match '/upload_plugin_config' => 'admin_tenants#upload_plugin_config', :via => :post, :as => 'admin_tenant_upload_plugin_config'
173
184
  match '/remove_allowed_user' => 'admin_tenants#remove_allowed_user', :via => :delete, :as => 'remove_allowed_user'
185
+ match '/add_allowed_user' => 'admin_tenants#add_allowed_user', :via => :put, :as => 'add_allowed_user'
186
+ match '/allowed_users' => 'admin_tenants#allowed_users', :via => :get, :as => 'admin_tenant_allowed_users'
187
+ match '/catalog_by_effective_date' => 'admin_tenants#catalog_by_effective_date', :via => :get, :as => 'catalog_by_effective_date'
188
+ match '/suggest_plugin_name' => 'admin_tenants#suggest_plugin_name', :via => :get, :as => 'suggest_plugin_name'
174
189
  end
190
+ resources :admin_tenants, :only => [ :index, :new, :create, :show ]
175
191
 
176
192
  resources :admin_allowed_users
177
193
  scope '/admin_allowed_users' do
@@ -1,12 +1,14 @@
1
1
  class DeviseCreateKauiUsers < ActiveRecord::Migration[5.0]
2
2
  def change
3
- create_table(:kaui_users) do |t|
4
- # From Kill Bill
5
- t.string :kb_username, :null => false
6
- t.string :kb_session_id, :null => true
7
- t.timestamps
8
- end
3
+ unless table_exists?(:kaui_users)
4
+ create_table(:kaui_users) do |t|
5
+ # From Kill Bill
6
+ t.string :kb_username, :null => false
7
+ t.string :kb_session_id, :null => true
8
+ t.timestamps
9
+ end
9
10
 
10
- add_index :kaui_users, [:kb_username], :unique => true
11
+ add_index :kaui_users, [:kb_username], :unique => true
12
+ end
11
13
  end
12
14
  end
@@ -1,12 +1,14 @@
1
1
  class CreateKauiTenants < ActiveRecord::Migration[5.0]
2
2
  def change
3
- create_table :kaui_tenants do |t|
4
- t.string :name
5
- t.string :kb_tenant_id
6
- t.string :api_key
7
- t.string :encrypted_api_secret
3
+ unless table_exists?(:kaui_tenants)
4
+ create_table :kaui_tenants do |t|
5
+ t.string :name
6
+ t.string :kb_tenant_id
7
+ t.string :api_key
8
+ t.string :encrypted_api_secret
8
9
 
9
- t.timestamps
10
+ t.timestamps
11
+ end
10
12
  end
11
13
  end
12
14
  end
@@ -1,19 +1,23 @@
1
1
  class CreateKauiAllowedUsers < ActiveRecord::Migration[5.0]
2
2
  def change
3
- create_table :kaui_allowed_users do |t|
4
- t.string :kb_username
5
- t.string :description
6
- t.timestamps
3
+ unless table_exists?(:kaui_allowed_users)
4
+ create_table :kaui_allowed_users do |t|
5
+ t.string :kb_username
6
+ t.string :description
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :kaui_allowed_users, [:kb_username], :unique => true
7
11
  end
8
12
 
9
- add_index :kaui_allowed_users, [:kb_username], :unique => true
13
+ unless table_exists?(:kaui_allowed_user_tenants)
14
+ create_table :kaui_allowed_user_tenants do |t|
15
+ t.belongs_to :kaui_allowed_user
16
+ t.belongs_to :kaui_tenant
17
+ t.timestamps null: false
18
+ end
10
19
 
11
- create_table :kaui_allowed_user_tenants do |t|
12
- t.belongs_to :kaui_allowed_user
13
- t.belongs_to :kaui_tenant
14
- t.timestamps null: false
20
+ add_index :kaui_allowed_user_tenants, [:kaui_allowed_user_id, :kaui_tenant_id], :unique => true, :name => 'kaui_allowed_user_tenants_uniq'
15
21
  end
16
-
17
- add_index :kaui_allowed_user_tenants, [:kaui_allowed_user_id, :kaui_tenant_id], :unique => true, :name => 'kaui_allowed_user_tenants_uniq'
18
22
  end
19
23
  end
data/lib/kaui/engine.rb CHANGED
@@ -20,6 +20,7 @@ require 'devise'
20
20
  require 'cancan'
21
21
  require 'country_select'
22
22
  require 'concurrent'
23
+ require 'mustache-js-rails'
23
24
 
24
25
  module Kaui
25
26
  class Engine < ::Rails::Engine
data/lib/kaui/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kaui
2
- VERSION = '0.16.2'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -9,6 +9,11 @@ default: &default
9
9
  timeout: 5000
10
10
  # Work around broken PostgreSQL activerecord-jdbc-adapter on Rails 5
11
11
  insert_returning: false
12
+ # MariaDB (see lib/arjdbc/mysql/connection_methods.rb)
13
+ useSsl: false
14
+ # MySQL
15
+ requireSSL: false
16
+ useSSL: false
12
17
 
13
18
  development:
14
19
  <<: *default
@@ -19,4 +24,4 @@ development:
19
24
  # Do not set this db to the same as development or production.
20
25
  test:
21
26
  <<: *default
22
- database: kaui_test
27
+ database: <%= ENV.fetch('DB_NAME', 'kaui_test') %>