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
@@ -0,0 +1,58 @@
1
+ module Kaui
2
+ module PluginHelper
3
+ # including plugin that are installed
4
+ def plugin_repository
5
+ plugins = []
6
+ plugin_repository = Kaui::AdminTenant::get_plugin_repository
7
+ installed_plugins = installed_plugins()
8
+
9
+ plugin_repository.each_pair do |key, info|
10
+ found_plugin = installed_plugins.reject! { |p| p.plugin_key.eql?(key.to_s) }
11
+ plugins << {
12
+ plugin_key: plugin_key(key.to_s, info),
13
+ plugin_name: plugin_name(key.to_s, info),
14
+ plugin_type: info[:type],
15
+ installed: !found_plugin.nil?
16
+ }
17
+ end
18
+
19
+ installed_plugins.each do |plugin|
20
+ plugins << {
21
+ plugin_key: plugin.plugin_key,
22
+ plugin_name: plugin.plugin_name,
23
+ plugin_type: nil,
24
+ installed: true
25
+ }
26
+ end
27
+
28
+ plugins.sort! { |a,b| a[:plugin_key] <=> b[:plugin_key] && b[:installed].to_s <=> a[:installed].to_s }
29
+ plugins
30
+ end
31
+
32
+ private
33
+
34
+ def plugin_name(key, info)
35
+ if info[:artifact_id].nil?
36
+ "killbill-#{key}"
37
+ else
38
+ "killbill-#{info[:artifact_id].gsub('killbill-','').gsub('-plugin','')}"
39
+ end
40
+ end
41
+
42
+ def plugin_key(key, info)
43
+ # hack:: replace paypal key with paypal_express, to set configuration and allow the ui to find the right configuration inputs
44
+ if key.eql?('paypal')
45
+ 'paypal_express'
46
+ else
47
+ "#{key}"
48
+ end
49
+ end
50
+
51
+ def installed_plugins
52
+ nodes_info = KillBillClient::Model::NodesInfo.nodes_info(Kaui.current_tenant_user_options(current_user, session)) || []
53
+ plugins_info = nodes_info.first.plugins_info || []
54
+
55
+ plugins_info.select { |plugin| !plugin.version.nil?}
56
+ end
57
+ end
58
+ end
@@ -99,12 +99,7 @@ module Kaui
99
99
  if !sub.present? or !sub.cancelled_date.present? or !account.present? or !account.time_zone.present?
100
100
  nil
101
101
  else
102
- cancelled_date = format_date(sub.cancelled_date, account.time_zone).html_safe
103
- if Time.parse(sub.cancelled_date) > current_time(account.time_zone)
104
- 'Pending cancellation on ' + cancelled_date
105
- else
106
- 'Canceled on ' + cancelled_date
107
- end
102
+ "Entitlement date: #{format_date(sub.cancelled_date, account.time_zone)}"
108
103
  end
109
104
  end
110
105
 
@@ -120,10 +115,17 @@ module Kaui
120
115
  if !sub.present? or !sub.billing_end_date.present? or !account.present? or !account.time_zone.present?
121
116
  nil
122
117
  else
123
- format_date(sub.billing_end_date, account.time_zone).html_safe
118
+ "Billing date: #{format_date(sub.billing_end_date, account.time_zone)}"
124
119
  end
125
120
  end
126
121
 
122
+ def humanized_subscription_cancelled_information(sub, account)
123
+ if !sub.present? or !sub.cancelled_date.present? or !account.present? or !account.time_zone.present?
124
+ nil
125
+ else
126
+ "#{humanized_subscription_cancelled_date(sub, account)}<br/>#{humanized_subscription_billing_end_date(sub, account)}".html_safe
127
+ end
128
+ end
127
129
 
128
130
  def humanized_time_unit(time_unit)
129
131
  time_unit.downcase.capitalize
@@ -63,6 +63,8 @@ class Kaui::AdminTenant < KillBillClient::Model::Tenant
63
63
 
64
64
  # Extract killbill key for oss plugins based on convention 'killbill-KEY'
65
65
  plugin_key = killbill_key.gsub(/killbill-/, '') if killbill_key.start_with?('killbill-')
66
+ # hack:: rewrite key, to allow the ui to find the right configuration inputs
67
+ plugin_key = rewrite_plugin_key(plugin_key)
66
68
  # If such key exists, lookup in plugin directory
67
69
  plugin_repo_entry = plugin_directory[plugin_key.to_sym] unless plugin_key.nil?
68
70
  # Extract plugin_type based on plugin_directory entry if exists
@@ -88,11 +90,11 @@ class Kaui::AdminTenant < KillBillClient::Model::Tenant
88
90
  end
89
91
 
90
92
  # Serialize the whole thing a as string of the form:
91
- # plugin_key1::key1=value1,key2=value2,..;plugin_key2::...
93
+ # plugin_key1::key1=value1|key2=value2|..;plugin_key2::...
92
94
  tenant_config.map do |plugin_key, props|
93
95
  serialized_props = props.inject("") do |s, (k, v)|
94
96
  e="#{k.to_s}=#{v.to_s}";
95
- s == "" ? s="#{e}" : s="#{s},#{e}";
97
+ s == "" ? s="#{e}" : s="#{s}|#{e}";
96
98
  s
97
99
  end
98
100
  "#{plugin_key}::#{serialized_props}"
@@ -101,16 +103,16 @@ class Kaui::AdminTenant < KillBillClient::Model::Tenant
101
103
  end
102
104
 
103
105
 
104
- def format_plugin_config(plugin_name, plugin_type, props)
106
+ def format_plugin_config(plugin_key, plugin_type, props)
105
107
  return nil unless props.present?
106
108
  if plugin_type == 'ruby'
107
109
  require 'yaml'
108
110
  hsh = {}
109
- hsh[plugin_name.to_sym] = {}
111
+ hsh[plugin_key.to_sym] = {}
110
112
  props.each do |k,v|
111
- hsh[plugin_name.to_sym][k.to_sym] = v.to_sym
113
+ hsh[plugin_key.to_sym][k.to_sym] = v.to_sym
112
114
  end
113
- hsh[plugin_name.to_sym]
115
+ hsh[plugin_key.to_sym]
114
116
  hsh.to_yaml
115
117
  elsif plugin_type == 'java'
116
118
  res = ""
@@ -122,5 +124,17 @@ class Kaui::AdminTenant < KillBillClient::Model::Tenant
122
124
  props['raw_config']
123
125
  end
124
126
  end
127
+
128
+ # hack when the plugin name after killbill is not the same as the plugin key, this mainly affects ruby plugin configuration,
129
+ # as it use the key to retrieve the configuration.
130
+ def rewrite_plugin_key(plugin_key)
131
+ if plugin_key.start_with?('paypal')
132
+ 'paypal_express'
133
+ elsif plugin_key.start_with?('firstdata')
134
+ 'firstdata_e4'
135
+ else
136
+ "#{plugin_key}"
137
+ end
138
+ end
125
139
  end
126
140
  end
@@ -4,9 +4,9 @@ class Kaui::Catalog < KillBillClient::Model::Catalog
4
4
 
5
5
  class << self
6
6
 
7
- def get_catalog_json(latest, options)
7
+ def get_catalog_json(latest, requested_date, options)
8
8
 
9
- catalogs = KillBillClient::Model::Catalog.get_tenant_catalog('json', nil, options)
9
+ catalogs = KillBillClient::Model::Catalog.get_tenant_catalog('json', requested_date, options)
10
10
  return catalogs.length > 0 ? catalogs[catalogs.length - 1] : nil if latest
11
11
 
12
12
  # Order by latest
@@ -36,9 +36,9 @@ class Kaui::Catalog < KillBillClient::Model::Catalog
36
36
  end
37
37
 
38
38
 
39
- def get_catalog_xml(options)
39
+ def get_catalog_xml(requested_date, options)
40
40
 
41
- catalog_xml = KillBillClient::Model::Catalog.get_tenant_catalog('xml', nil, options)
41
+ catalog_xml = KillBillClient::Model::Catalog.get_tenant_catalog('xml', requested_date, options)
42
42
 
43
43
  parsed_catalog = parse_catalog_xml(catalog_xml)
44
44
 
@@ -9,7 +9,7 @@ class Kaui::Tag < KillBillClient::Model::Tag
9
9
  end
10
10
 
11
11
  class << self
12
- [:account, :bundle].each do |model|
12
+ [:account, :bundle, :subscription].each do |model|
13
13
  define_method "all_for_#{model.to_s}" do |model_id, included_deleted, audit, options|
14
14
  instance = Kaui.const_get(model.to_s.camelize).new("#{model.to_s}_id".to_sym => model_id)
15
15
  instance.tags(included_deleted, audit, options)
@@ -23,7 +23,7 @@ class Kaui::TagDefinition < KillBillClient::Model::TagDefinition
23
23
 
24
24
  ALL_OBJECT_TYPES.each do |object_type|
25
25
  define_singleton_method "all_for_#{object_type.downcase}" do |options_for_klient|
26
- (self.all('NONE', options_for_klient).delete_if { |tag_definition| !tag_definition.applicable_object_types.include? object_type }).sort
26
+ (self.all('NONE', options_for_klient).delete_if { |tag_definition| !tag_definition.applicable_object_types.include? object_type || tag_definition.is_control_tag }).sort
27
27
  end
28
28
  end
29
29
 
@@ -0,0 +1,35 @@
1
+ <div class="search">
2
+
3
+ <div class="column-block">
4
+
5
+ <h1>Custom Fields</h1>
6
+ <input type="hidden" id="custom-fields" value="<%= @custom_fields_json %>">
7
+ <table id="custom_fields-table" class="table table-condensed mobile-data">
8
+ <thead>
9
+ <tr>
10
+ <th>Object ID</th>
11
+ <th>Object type</th>
12
+ <th>Name</th>
13
+ <th>Value</th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <tr>
18
+ <td colspan="1" class="dataTables_empty">Loading data from server</td>
19
+ </tr>
20
+ </tbody>
21
+ </table>
22
+
23
+ </div>
24
+
25
+ </div>
26
+
27
+ <%= javascript_tag do %>
28
+ $(document).ready(function() {
29
+ var customFields = JSON.parse($("#custom-fields").val());
30
+ $('#custom_fields-table').DataTable({
31
+ "dom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
32
+ data: customFields
33
+ });
34
+ });
35
+ <% end %>
@@ -0,0 +1,35 @@
1
+ <div class="search">
2
+
3
+ <div class="column-block">
4
+
5
+ <h1>Tags</h1>
6
+ <input type="hidden" id="tags" value="<%= @tags_json %>">
7
+ <table id="tags-table" class="table table-condensed mobile-data">
8
+ <thead>
9
+ <tr>
10
+ <th>Tag ID</th>
11
+ <th>Object ID</th>
12
+ <th>Object type</th>
13
+ <th>Tag definition name</th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <tr>
18
+ <td colspan="1" class="dataTables_empty">Loading data from server</td>
19
+ </tr>
20
+ </tbody>
21
+ </table>
22
+
23
+ </div>
24
+
25
+ </div>
26
+
27
+ <%= javascript_tag do %>
28
+ $(document).ready(function() {
29
+ var tags = JSON.parse($("#tags").val());
30
+ $('#tags-table').DataTable({
31
+ "dom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
32
+ data: tags
33
+ });
34
+ });
35
+ <% end %>
@@ -13,6 +13,11 @@
13
13
  kaui_engine.account_children_path(@account.account_id),
14
14
  :class => 'btn btn-xs' %>
15
15
  <% end %>
16
+ <% if can_close_account? && !account_closed? %>
17
+ <%= link_to('<i class="fa fa-times"></i>Close'.html_safe, '#closeAccountModal',
18
+ :class => 'btn btn-xs text-danger',
19
+ data: {toggle: 'modal', name: @account.name || '(not set)', account_id: @account.account_id}) %>
20
+ <% end %>
16
21
  <% unless @account.parent_account_id.nil? %>
17
22
  <span class="label label-info account-child-label">Child</span>
18
23
  <% end %>
@@ -33,7 +33,7 @@
33
33
 
34
34
  <div class="row">
35
35
  <div class="fix-position">
36
- <table class="transparent">
36
+ <table class="transparent" <%= billing_info_margin.html_safe %>>
37
37
  <tr>
38
38
  <th>Account balance</th>
39
39
  <td>
@@ -0,0 +1,98 @@
1
+ <div class="modal fade" id="closeAccountModal" 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">Close account</h1>
7
+ </div>
8
+ <div class="modal-body">
9
+ <%= form_for :close, :url => '' , :method => :delete, :html => {:class => 'form-horizontal', :id => 'account-close-form'} do |f| %>
10
+ <div class='form-group'>
11
+ <%= f.label :name, 'Name', :class => 'col-sm-4 control-label' %>
12
+ <div class="col-sm-8">
13
+ <%= f.text_field :name, :class => 'form-control', :readonly => true %>
14
+ </div>
15
+ </div>
16
+ <div class='form-group'>
17
+ <%= f.label :account_id, 'Account id', :class => 'col-sm-4 control-label' %>
18
+ <div class="col-sm-8">
19
+ <%= f.text_field :account_id, :class => 'form-control', :readonly => true %>
20
+ </div>
21
+ </div>
22
+ <div class="form-group">
23
+ <div class="col-sm-offset-4 col-sm-8">
24
+ <div class="row">
25
+ <div class="col-sm-3">
26
+ <label class="switch">
27
+ <input name="options[]" id="cancelAllSubscriptions" type="checkbox" value="cancel_all_subscriptions">
28
+ <span class="slider round"></span>
29
+ </label>
30
+ </div>
31
+ <label class="col-sm-8 capitalize">Cancel all subscriptions.</label>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <div class="form-group">
36
+ <div class="col-sm-offset-4 col-sm-8">
37
+ <div class="row">
38
+ <div class="col-sm-3">
39
+ <label class="switch">
40
+ <input name="options[]" id="writeoffUnpaidInvoices" type="checkbox" value="writeoff_unpaid_invoices">
41
+ <span class="slider round"></span>
42
+ </label>
43
+ </div>
44
+ <label class="col-sm-8 capitalize">Write off unpaid invoices.</label>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ <div class="form-group">
49
+ <div class="col-sm-offset-4 col-sm-8">
50
+ <div class="row">
51
+ <div class="col-sm-3">
52
+ <label class="switch">
53
+ <input name="options[]" id="itemAdjustUnpaidInvoices" type="checkbox" value="item_adjust_unpaid_invoices">
54
+ <span class="slider round"></span>
55
+ </label>
56
+ </div>
57
+ <label class="col-sm-8 capitalize">Item adjust unpaid invoices.</label>
58
+ </div>
59
+ </div>
60
+ </div>
61
+
62
+ <div class="form-group">
63
+ <div class="col-sm-offset-4 col-sm-8">
64
+ <%= submit_tag 'Close', :class => 'btn btn-danger' %>
65
+ </div>
66
+ </div>
67
+ <% end %>
68
+ </div>
69
+ </div><!-- /.modal-content -->
70
+ </div><!-- /.modal-dialog -->
71
+ </div><!-- /.modal -->
72
+
73
+ <%= javascript_tag do %>
74
+ $(document).ready(function() {
75
+
76
+ $('#closeAccountModal').on('show.bs.modal', function (e) {
77
+ $("#close_account_id").val(e.relatedTarget.dataset['accountId']);
78
+ $("#close_name").val(e.relatedTarget.dataset['name']);
79
+
80
+ // reset toggles
81
+ var options = $("#closeAccountModal").find('input[type="checkbox"]');
82
+ $.each( options, function( index, elem ) {
83
+ $(elem).prop('checked',false);
84
+ });
85
+
86
+ $("#account-close-form").attr("action", Routes.kaui_engine_account_path(e.relatedTarget.dataset['accountId']));
87
+
88
+ });
89
+
90
+ $('#writeoffUnpaidInvoices').change(function(){
91
+ $("#itemAdjustUnpaidInvoices").prop("checked",!$(this).prop("checked"));
92
+ });
93
+
94
+ $('#itemAdjustUnpaidInvoices').change(function(){
95
+ $("#writeoffUnpaidInvoices").prop("checked",!$(this).prop("checked"));
96
+ });
97
+ });
98
+ <% end %>
@@ -49,13 +49,6 @@ $(document).ready(function() {
49
49
  "serverSide": true,
50
50
  "search": {"search": "<%= @search_query %>"},
51
51
  "ajax": "<%= accounts_pagination_path(:ordering => @ordering, :format => :json) %>",
52
- "rowCallback": function( row, data, index ) {
53
- if ( data[0] == 1 ) {
54
- $('td:eq(0)', row).html( '<span class="label label-info account-child-label">Child</span>' );
55
- }else{
56
- $('td:eq(0)', row).html('')
57
- }
58
- },
59
52
  "columnDefs": [
60
53
  { "orderable": false, "targets": 0, "createdCell": function (td, cellData, rowData, row, col) {
61
54
  $(td).css('padding-left', '20px');
@@ -10,6 +10,10 @@
10
10
  <%= render :partial => 'kenui/email_notifications/configure_events_modal' %>
11
11
  <% end %>
12
12
 
13
+ <% if can_close_account? %>
14
+ <%= render :partial => 'close_account_modal' %>
15
+ <% end %>
16
+
13
17
  <%= javascript_tag do %>
14
18
  function disableLinks() {
15
19
  $('a.btn.disabled').click(function (e) {
@@ -0,0 +1,64 @@
1
+ <div class="modal fade" id="addAllowedUserModal" 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">Add allowed user</h1>
7
+ </div>
8
+ <div class="modal-body">
9
+ <%= form_for :allowed_user, :url => add_allowed_user_path, :method => :put, :html => {:class => 'form-horizontal', :id => 'tenantAllowedUserForm'} do |f| %>
10
+ <div class='form-group'>
11
+ <%= f.label :kb_username, 'User name', :class => 'col-sm-4 control-label' %>
12
+ <div class="col-sm-8">
13
+ <%= f.text_field :kb_username, :class => 'form-control', :required => true %>
14
+ </div>
15
+ </div>
16
+ <input type="hidden" name="tenant_id" value="<%= @tenant.id %>" />
17
+ <div class="form-group">
18
+ <div class="col-sm-offset-4 col-sm-10">
19
+ <%= submit_tag 'Add', :class => 'btn btn-default' %>
20
+ </div>
21
+ </div>
22
+ <% end %>
23
+ </div>
24
+ </div><!-- /.modal-content -->
25
+ </div><!-- /.modal-dialog -->
26
+ </div><!-- /.modal -->
27
+
28
+ <%= javascript_tag do %>
29
+ $(document).ready(function() {
30
+ function loadAllowedUser() {
31
+ $.ajax(
32
+ {
33
+ url: Routes.kaui_engine_admin_tenant_allowed_users_path(),
34
+ type: "GET",
35
+ dataType: "json",
36
+ data: {tenant_id: <%= @tenant.id %>},
37
+ success: function(data) {
38
+ var availableAllowedUser = [];
39
+ for (var i=0; i < data.length ; i++) {
40
+ availableAllowedUser.push(data[i].kb_username);
41
+ }
42
+
43
+ $( "#allowed_user_kb_username" ).autocomplete({
44
+ source: availableAllowedUser,
45
+ appendTo: "#tenantAllowedUserForm",
46
+ classes: {
47
+ "ui-autocomplete": "autocomplete-allowed-user"
48
+ },
49
+ });
50
+
51
+ }
52
+ });
53
+ }
54
+
55
+ $('#addAllowedUserModal').on('show.bs.modal', function (e) {
56
+ // reset field
57
+ $( "#allowed_user_kb_username" ).val('');
58
+
59
+ });
60
+
61
+ loadAllowedUser();
62
+
63
+ });
64
+ <% end %>