kaui 1.4.0 → 2.0.3
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.
- checksums.yaml +4 -4
- data/README.md +24 -1
- data/app/assets/javascripts/kaui/kaui.js +8 -2
- data/app/assets/stylesheets/kaui/common.less +44 -1
- data/app/controllers/kaui/admin_tenants_controller.rb +77 -106
- data/app/controllers/kaui/audit_logs_controller.rb +23 -1
- data/app/controllers/kaui/charges_controller.rb +1 -1
- data/app/controllers/kaui/credits_controller.rb +5 -5
- data/app/controllers/kaui/home_controller.rb +2 -2
- data/app/controllers/kaui/invoice_items_controller.rb +1 -1
- data/app/controllers/kaui/invoices_controller.rb +6 -4
- data/app/controllers/kaui/payment_methods_controller.rb +9 -3
- data/app/controllers/kaui/payments_controller.rb +1 -1
- data/app/controllers/kaui/refunds_controller.rb +2 -2
- data/app/controllers/kaui/sessions_controller.rb +6 -0
- data/app/controllers/kaui/subscriptions_controller.rb +29 -5
- data/app/helpers/kaui/payment_method_helper.rb +5 -3
- data/app/helpers/kaui/plugin_helper.rb +9 -48
- data/app/helpers/kaui/subscription_helper.rb +5 -4
- data/app/models/kaui/admin_tenant.rb +8 -84
- data/app/models/kaui/catalog.rb +14 -2
- data/app/views/kaui/account_emails/_form.html.erb +1 -1
- data/app/views/kaui/accounts/_form.html.erb +1 -1
- data/app/views/kaui/admin_tenants/_form_plugin_config.erb +48 -240
- data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +6 -6
- data/app/views/kaui/admin_tenants/new_catalog.html.erb +16 -15
- data/app/views/kaui/bundles/index.html.erb +1 -1
- data/app/views/kaui/chargebacks/_form.html.erb +1 -1
- data/app/views/kaui/charges/_form.html.erb +1 -1
- data/app/views/kaui/credits/_form.html.erb +2 -2
- data/app/views/kaui/invoices/show.html.erb +0 -1
- data/app/views/kaui/payments/_form.html.erb +1 -1
- data/app/views/kaui/payments/_payment_table.html.erb +2 -2
- data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
- data/app/views/kaui/subscriptions/_form.html.erb +16 -4
- data/config/routes.rb +1 -1
- data/lib/kaui/version.rb +1 -1
- data/test/dummy/config/initializers/cookies_serializer.rb +1 -1
- data/test/functional/kaui/admin_tenants_controller_test.rb +2 -22
- data/test/functional/kaui/credits_controller_test.rb +3 -3
- data/test/functional/kaui/home_controller_test.rb +5 -5
- data/test/functional/kaui/subscriptions_controller_test.rb +1 -1
- data/test/killbill_test_helper.rb +6 -6
- data/test/unit/helpers/kaui/payment_method_helper_test.rb +17 -0
- data/test/unit/kaui/admin_tenant_test.rb +10 -47
- metadata +8 -6
@@ -2,7 +2,7 @@
|
|
2
2
|
<div class='form-group'>
|
3
3
|
<%= f.label :email, 'Email', :class => 'col-sm-2 control-label' %>
|
4
4
|
<div class="col-sm-10">
|
5
|
-
<%= f.
|
5
|
+
<%= f.email_field :email, :class => 'form-control', :required => true %>
|
6
6
|
</div>
|
7
7
|
</div>
|
8
8
|
<div class="form-group">
|
@@ -38,7 +38,7 @@
|
|
38
38
|
<div class="form-group">
|
39
39
|
<%= f.label :email, 'Email', :class => 'col-sm-3 control-label' %>
|
40
40
|
<div class="col-sm-9">
|
41
|
-
<%= f.
|
41
|
+
<%= f.email_field :email, :class => 'form-control' %>
|
42
42
|
</div>
|
43
43
|
</div>
|
44
44
|
<% unless @account.persisted? %>
|
@@ -17,9 +17,10 @@
|
|
17
17
|
|
18
18
|
<div id="plugin" class="form-group">
|
19
19
|
<%= label_tag :entered_plugin_name, 'Plugin name', :class => 'col-sm-2 control-label' %>
|
20
|
+
|
20
21
|
<div class="col-sm-4">
|
21
22
|
<select class="form-control" id="select_plugin_name"></select>
|
22
|
-
<%= text_field_tag :entered_plugin_name, nil, :
|
23
|
+
<%= text_field_tag :entered_plugin_name, nil, :placeholder => 'as defined in the plugin Activator file', :class => 'form-control', :tenant_plugin_config => @tenant_plugin_config.to_json %>
|
23
24
|
<div class="text plugin-suggestion text-danger"></div>
|
24
25
|
</div>
|
25
26
|
<div class="col-sm-1 spinner"><i class="fa fa-cog fa-2x fa-spin"></i></div>
|
@@ -29,7 +30,7 @@
|
|
29
30
|
<span class="slider round"></span>
|
30
31
|
</label>
|
31
32
|
</label>
|
32
|
-
<label class="col-sm-3 control-label toggle-label text-muted">
|
33
|
+
<label class="col-sm-3 control-label toggle-label text-muted">manual entry</label>
|
33
34
|
</div>
|
34
35
|
|
35
36
|
<div id="plugin_config_properties_header" class="form-group">
|
@@ -41,8 +42,11 @@
|
|
41
42
|
</label>
|
42
43
|
</label>
|
43
44
|
</div>
|
44
|
-
|
45
|
-
|
45
|
+
<div class="form-group">
|
46
|
+
<%= label_tag :configuration, 'Configuration', :class => 'col-sm-2 control-label' %>
|
47
|
+
<div class="col-sm-4">
|
48
|
+
<textarea name="plugin_properties[raw_config]" id="raw_config" rows="10" class="form-control"></textarea>
|
49
|
+
</div>
|
46
50
|
</div>
|
47
51
|
|
48
52
|
<div class="form-group">
|
@@ -54,23 +58,6 @@
|
|
54
58
|
</div>
|
55
59
|
<% end %>
|
56
60
|
|
57
|
-
<script id="plugin_config_properties_template" type="text/template">
|
58
|
-
<input type="hidden" id="plugin_key_values" value="{{data_json}}" />
|
59
|
-
{{#plugin_props_with_values}}
|
60
|
-
<div class="form-group">
|
61
|
-
<label class="col-sm-offset-1 col-sm-2 control-label" for="{{property}}">{{property_label}}</label>
|
62
|
-
<div class="col-sm-6">
|
63
|
-
{{#is_raw_config}}
|
64
|
-
<textarea name="plugin_properties[raw_config]" id="raw_config" rows="10" class="form-control">{{value}}</textarea>
|
65
|
-
{{/is_raw_config}}
|
66
|
-
{{^is_raw_config}}
|
67
|
-
<input type="text" name="plugin_properties[{{property}}]" id="{{property}}" class="form-control" value="{{value}}" />
|
68
|
-
{{/is_raw_config}}
|
69
|
-
</div>
|
70
|
-
</div>
|
71
|
-
{{/plugin_props_with_values}}
|
72
|
-
</script>
|
73
|
-
|
74
61
|
<script id="plugin_name_options_template" type="text/template">
|
75
62
|
<option></option>
|
76
63
|
{{#plugin_repository}}
|
@@ -101,48 +88,54 @@
|
|
101
88
|
$('#plugin_config_properties').empty();
|
102
89
|
$('#plugin_config_properties_header').hide();
|
103
90
|
$(".plugin-suggestion").html('');
|
91
|
+
$("#raw_config").val('');
|
104
92
|
});
|
105
93
|
|
106
|
-
|
107
|
-
|
108
|
-
|
94
|
+
/* Intercept TAB and potentially display known properties */
|
95
|
+
$('#entered_plugin_name').keydown(function (e) {
|
96
|
+
if (e.keyCode === 9) {
|
97
|
+
$("#plugin_name").val($('#entered_plugin_name').val());
|
98
|
+
$("#plugin_key").val('');
|
99
|
+
render_plugin_key_values();
|
109
100
|
}
|
101
|
+
});
|
102
|
+
/* Intercept mouseleave and potentially display known properties */
|
103
|
+
$('#entered_plugin_name').on('mouseleave', function() {
|
104
|
+
$("#plugin_name").val($('#entered_plugin_name').val());
|
105
|
+
$("#plugin_key").val('');
|
106
|
+
render_plugin_key_values();
|
107
|
+
});
|
110
108
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
var plugin_name = $('#entered_plugin_name').val();
|
117
|
-
var plugin_key = $("#plugin_key").val();
|
118
|
-
var existing_props = get_tenant_plugin_properties(plugin_key, plugin_name);
|
119
|
-
raw[0].value = existing_props['_raw'];
|
120
|
-
|
121
|
-
render_plugin_key_values(raw, plugin_key_values);
|
122
|
-
} else {
|
123
|
-
render_plugin_key_values(plugin_key_values, plugin_key_values);
|
124
|
-
}
|
109
|
+
$("#toggle_raw").on('change', function(e) {
|
110
|
+
$("#plugin_name").val($('#entered_plugin_name').val());
|
111
|
+
$("#plugin_key").val('');
|
112
|
+
render_plugin_key_values();
|
125
113
|
});
|
126
114
|
|
127
115
|
$('#select_plugin_name').on('change', function(e) {
|
116
|
+
// User has selected a plugin from the dropdown
|
128
117
|
var selectedOption = e.target.selectedOptions;
|
129
118
|
|
130
119
|
if (selectedOption.length > 0) {
|
131
120
|
var plugin_name = selectedOption[0].value;
|
132
121
|
var plugin_key = selectedOption[0].text;
|
122
|
+
|
133
123
|
$("#plugin_name").val(plugin_name);
|
134
124
|
$("#plugin_key").val(plugin_key);
|
135
|
-
$("#plugin_type").val(selectedOption[0].dataset['pluginType']);
|
125
|
+
$("#plugin_type").val(selectedOption[0].dataset['pluginType']); // java or ruby
|
136
126
|
$('#plugin_config_properties').attr('plugin_name', '');
|
137
127
|
$('#plugin_config_properties_header').hide();
|
138
128
|
$("#toggle_raw").prop('checked', false);
|
139
|
-
|
129
|
+
|
130
|
+
render_plugin_key_values();
|
140
131
|
}
|
141
132
|
});
|
142
133
|
|
143
134
|
populate_plugin_name_options();
|
144
135
|
function populate_plugin_name_options(){
|
145
|
-
var
|
136
|
+
var all_plugins = JSON.parse($("#plugin_repository").val());
|
137
|
+
// We only list installed plugins as to not confuse the user
|
138
|
+
var plugin_repository = all_plugins.filter(plugin => plugin.installed);
|
146
139
|
for (var idx = 0, size = plugin_repository.length; idx < size; idx++) {
|
147
140
|
if (idx == 0 && plugin_repository[idx].installed) {
|
148
141
|
plugin_repository[idx]['start_installed'] = true;
|
@@ -163,57 +156,14 @@
|
|
163
156
|
}
|
164
157
|
|
165
158
|
var template = $("#plugin_name_options_template").html();
|
166
|
-
var options_html = Mustache.render( template , { plugin_repository: plugin_repository});
|
159
|
+
var options_html = Mustache.render( template , { plugin_repository: plugin_repository });
|
167
160
|
$("#select_plugin_name").html(options_html);
|
168
161
|
}
|
169
162
|
|
170
163
|
function get_existing_tenant_plugin_properties(entered_plugin_name) {
|
171
164
|
var tenant_plugin_properties = $('#entered_plugin_name').attr('tenant_plugin_config');
|
172
|
-
var res =
|
173
|
-
|
174
|
-
$.each(tenant_plugin_properties.split(';'), function(idx, el) {
|
175
|
-
var el_parts = el.split('::');
|
176
|
-
var el_plugin_name = el_parts[0];
|
177
|
-
var el_props = el_parts[1];
|
178
|
-
if (el_plugin_name === entered_plugin_name) {
|
179
|
-
if (el_props.split('=')[0] == 'raw_config') {
|
180
|
-
res['raw_config'] = el_props.replace("raw_config=", "");
|
181
|
-
} else {
|
182
|
-
$.map(el_props.split('|'), function(el) {
|
183
|
-
var parts = el.split('=');
|
184
|
-
res[parts[0]] = parts.slice(1).join('=');
|
185
|
-
});
|
186
|
-
}
|
187
|
-
return false;
|
188
|
-
}
|
189
|
-
});
|
190
|
-
}
|
191
|
-
return res;
|
192
|
-
}
|
193
|
-
|
194
|
-
function get_selected_plugin_info(plugin_key) {
|
195
|
-
var plugin_config_str = $('#entered_plugin_name').attr('plugin_config');
|
196
|
-
var res = {}
|
197
|
-
/* Deserialize plugin/properties (see AdminTenant model)*/
|
198
|
-
$.each(plugin_config_str.split(';'), function(idx, el) {
|
199
|
-
var el_parts = el.split(':');
|
200
|
-
var el_parts_key = el_parts[0].split('#');
|
201
|
-
var el_plugin_name = el_parts_key[0];
|
202
|
-
var el_plugin_type = el_parts_key[1];
|
203
|
-
var el_plugin_props = el_parts[1];
|
204
|
-
if (el_plugin_name == plugin_key) {
|
205
|
-
res['type'] = el_plugin_type;
|
206
|
-
res['props'] = el_plugin_props == "" ? [] : (el_plugin_type == "" ? ['raw_config'] : el_plugin_props.split(','));
|
207
|
-
return false;
|
208
|
-
}
|
209
|
-
});
|
210
|
-
|
211
|
-
if (isBlank(res['props'])) {
|
212
|
-
res['type'] = '';
|
213
|
-
res['props'] = ['raw_config'];
|
214
|
-
}
|
215
|
-
|
216
|
-
return res;
|
165
|
+
var res = JSON.parse(tenant_plugin_properties);
|
166
|
+
return res[entered_plugin_name];
|
217
167
|
}
|
218
168
|
|
219
169
|
function get_tenant_plugin_properties(plugin_key, plugin_name) {
|
@@ -221,167 +171,25 @@
|
|
221
171
|
var existing_props = get_existing_tenant_plugin_properties(plugin_key);
|
222
172
|
|
223
173
|
// try by plugin name for proprietary plugins
|
224
|
-
if (isBlank(existing_props)) {
|
174
|
+
if (isBlank(existing_props) && !isBlank(plugin_name)) {
|
225
175
|
existing_props = get_existing_tenant_plugin_properties(plugin_name);
|
226
176
|
}
|
227
177
|
|
228
178
|
return existing_props;
|
229
179
|
}
|
230
180
|
|
231
|
-
function
|
232
|
-
var
|
233
|
-
|
234
|
-
if (isBlank(
|
235
|
-
$(
|
236
|
-
$(
|
237
|
-
return;
|
238
|
-
}
|
239
|
-
|
240
|
-
if ($('#plugin_config_properties').attr('plugin_name') == plugin_name) {
|
241
|
-
/* Already set...*/
|
242
|
-
return;
|
243
|
-
}
|
244
|
-
|
245
|
-
var existing_props = get_tenant_plugin_properties(plugin_key, plugin_name);
|
246
|
-
|
247
|
-
var type = plugin_info['type'];
|
248
|
-
var props = plugin_info['props']
|
249
|
-
|
250
|
-
if (isBlank(type)) {
|
251
|
-
$(".switch-half-container").hide();
|
252
|
-
} else {
|
253
|
-
$(".switch-half-container").show();
|
254
|
-
}
|
255
|
-
|
256
|
-
$('#plugin_type').val(type);
|
257
|
-
/* Prune the tree to restart from scratch */
|
258
|
-
$('#plugin_config_properties_header').show();
|
259
|
-
$('#plugin_config_properties').empty();
|
260
|
-
$('#plugin_config_properties').append('<div id="plugin_config_properties_anchor" class="col-sm-12"></div>');
|
261
|
-
|
262
|
-
var merged_props_with_values = existing_props;
|
263
|
-
if (props != undefined) {
|
264
|
-
$.each(props, function(idx, p) {
|
265
|
-
if (merged_props_with_values[p] == undefined) {
|
266
|
-
merged_props_with_values[p] = '';
|
267
|
-
}
|
268
|
-
});
|
269
|
-
}
|
270
|
-
|
271
|
-
add_property_form_entry(merged_props_with_values);
|
272
|
-
|
273
|
-
$('#plugin_config_properties').attr('plugin_name', plugin_name);
|
274
|
-
}
|
275
|
-
|
276
|
-
function format_label(input) {
|
277
|
-
/* Keep latest piece of a system property to keep it short */
|
278
|
-
var label_name = input.split('.').pop();
|
279
|
-
/* Replace underscore with comma */
|
280
|
-
label_name = label_name.replace(/_/g, ',');
|
281
|
-
/* Replace uppercase with comma + uppercase */
|
282
|
-
label_name = label_name.replace(/([A-Z]+)/g, ",$1");
|
283
|
-
/* Split name make sure each word starts with Uppercase */
|
284
|
-
var tmp1 = label_name.split(',');
|
285
|
-
var label_name_array = [];
|
286
|
-
$.map(tmp1, function(el) { label_name_array.push(el.charAt(0).toUpperCase() + el.slice(1)) });
|
287
|
-
label_name = label_name_array.join(' ');
|
288
|
-
return label_name;
|
289
|
-
}
|
290
|
-
|
291
|
-
function add_property_form_entry(merged_props_with_values) {
|
292
|
-
var plugin_props_with_values = [];
|
293
|
-
|
294
|
-
$.each(merged_props_with_values, function(p, v) {
|
295
|
-
if (p != '_raw') {
|
296
|
-
plugin_props_with_values.push({ property_label: format_label(p), property: p, value: v, is_raw_config: p == 'raw_config'});
|
297
|
-
}
|
298
|
-
});
|
299
|
-
|
300
|
-
render_plugin_key_values(plugin_props_with_values, plugin_props_with_values);
|
301
|
-
}
|
302
|
-
|
303
|
-
function render_plugin_key_values(plugin_props_with_values, original) {
|
304
|
-
var template = $("#plugin_config_properties_template").html();
|
305
|
-
var plugin_props_with_values_html = Mustache.render( template ,{ plugin_props_with_values: plugin_props_with_values,
|
306
|
-
data_json: JSON.stringify(original)});
|
307
|
-
$("#plugin_config_properties_anchor").html(plugin_props_with_values_html);
|
308
|
-
}
|
309
|
-
|
310
|
-
// Free text related functions and handlers
|
311
|
-
init_plugin_name_handlers();
|
312
|
-
function init_plugin_name_handlers() {
|
313
|
-
/* Intercept ENTER and potentially display property form if plugin is know */
|
314
|
-
$('#entered_plugin_name').keyup(function (e) {
|
315
|
-
e.preventDefault();
|
316
|
-
if (e.keyCode === 13) {
|
317
|
-
suggest_plugin_name();
|
318
|
-
}
|
319
|
-
});
|
320
|
-
|
321
|
-
/* Intercept mouseleave and potentially display property form if plugin is know */
|
322
|
-
$('#entered_plugin_name').on('mouseleave', function() {
|
323
|
-
suggest_plugin_name();
|
324
|
-
});
|
325
|
-
}
|
326
|
-
|
327
|
-
function suggested_response(response) {
|
328
|
-
$(".spinner").hide();
|
329
|
-
if (!isBlank(response.suggestion)) {
|
330
|
-
$(".plugin-suggestion").html(response.suggestion);
|
331
|
-
|
332
|
-
$("#suggested").click(function(e) {
|
333
|
-
var plugin_name = e.currentTarget.dataset['pluginName'];
|
334
|
-
var plugin_key = e.currentTarget.dataset['pluginKey'];
|
335
|
-
|
336
|
-
$("#entered_plugin_name").val(plugin_name);
|
337
|
-
$("#plugin_key").val(plugin_key);
|
338
|
-
$("#plugin_type").val(e.currentTarget.dataset['pluginType']);
|
339
|
-
$("#entered_plugin_name").data("last", plugin_name);
|
340
|
-
|
341
|
-
$(".plugin-suggestion").html('');
|
342
|
-
add_properties_for_plugin(isBlank(plugin_key) ? plugin_name : plugin_key, plugin_name);
|
343
|
-
});
|
344
|
-
|
181
|
+
function render_plugin_key_values() {
|
182
|
+
var plugin_name = "";
|
183
|
+
var plugin_key = "";
|
184
|
+
if (isBlank($('#entered_plugin_name').val())) {
|
185
|
+
plugin_name = $("#plugin_name").val();
|
186
|
+
plugin_key = $("#plugin_key").val();
|
345
187
|
} else {
|
346
|
-
$("
|
188
|
+
plugin_name = $("#entered_plugin_name").val();
|
347
189
|
}
|
348
190
|
|
349
|
-
var
|
350
|
-
|
351
|
-
$("#plugin_name").val(plugin_name);
|
352
|
-
|
353
|
-
add_properties_for_plugin(isBlank(plugin_key) ? plugin_name : plugin_key, plugin_name);
|
354
|
-
}
|
355
|
-
|
356
|
-
function suggest_plugin_name() {
|
357
|
-
var plugin_name = $("#entered_plugin_name").val();
|
358
|
-
var last_plugin_name = $("#entered_plugin_name").data("last");
|
359
|
-
$("#plugin_key").val(plugin_name);
|
360
|
-
|
361
|
-
if (isBlank(plugin_name)) {
|
362
|
-
return;
|
363
|
-
}
|
364
|
-
|
365
|
-
// no change
|
366
|
-
if ( plugin_name == last_plugin_name) {
|
367
|
-
return;
|
368
|
-
}
|
369
|
-
|
370
|
-
$('#plugin_config_properties').attr('plugin_name', '');
|
371
|
-
$('#plugin_config_properties').empty();
|
372
|
-
$(".plugin-suggestion").html('');
|
373
|
-
$("#entered_plugin_name").data("last", plugin_name);
|
374
|
-
$(".spinner").show();
|
375
|
-
$.ajax({
|
376
|
-
url: '<%= suggest_plugin_name_path() %>',
|
377
|
-
type: "GET",
|
378
|
-
dataType: "json",
|
379
|
-
data: {
|
380
|
-
"plugin_name": plugin_name,
|
381
|
-
},
|
382
|
-
success: suggested_response
|
383
|
-
});
|
191
|
+
var existing_props = get_tenant_plugin_properties(plugin_key, plugin_name);
|
192
|
+
$("#raw_config").val(existing_props);
|
384
193
|
}
|
385
|
-
|
386
194
|
});
|
387
|
-
<% end %>
|
195
|
+
<% end %>
|
@@ -88,6 +88,10 @@
|
|
88
88
|
var template = $("#currencies_template").html();
|
89
89
|
var currencies_html = Mustache.render(template,data);
|
90
90
|
$("#currency_select").html(currencies_html);
|
91
|
+
|
92
|
+
$('[id^="select_currencies"]').change(function() {
|
93
|
+
displayAmountsForCurrency();
|
94
|
+
});
|
91
95
|
}
|
92
96
|
|
93
97
|
function renderCatalog(data){
|
@@ -102,8 +106,8 @@
|
|
102
106
|
plan['new_plan_currency_path'] = Routes.kaui_engine_admin_tenant_new_plan_currency_path(<%= @tenant.id %>, {plan_id: plan['plan_id']});
|
103
107
|
plan['humanized_product_name'] = function(){
|
104
108
|
return function (input, render) {
|
105
|
-
|
106
|
-
return
|
109
|
+
// Keep the product name as-is to avoid confusing with casing
|
110
|
+
return render(input);
|
107
111
|
}
|
108
112
|
}
|
109
113
|
|
@@ -183,10 +187,6 @@
|
|
183
187
|
$("#select_catalog").change(function() {
|
184
188
|
fetchCatalog(this.value);
|
185
189
|
});
|
186
|
-
|
187
|
-
$('[id^="select_currencies"]').change(function() {
|
188
|
-
displayAmountsForCurrency();
|
189
|
-
});
|
190
190
|
});
|
191
191
|
<% end %>
|
192
192
|
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<div class="form-group" id="form_category">
|
12
12
|
<%= f.label :product_category, 'Product Category', :class => 'col-sm-3 control-label' %>
|
13
13
|
<div class="col-sm-4">
|
14
|
-
<%= f.select :product_category, options_for_select(@product_categories.map {|p| [humanized_product_category(p), p] },
|
14
|
+
<%= f.select :product_category, options_for_select(@product_categories.map {|p| [humanized_product_category(p), p] }, @simple_plan.product_category), :class => 'form-control' %>
|
15
15
|
</div>
|
16
16
|
</div>
|
17
17
|
<div class="form-group">
|
@@ -47,31 +47,31 @@
|
|
47
47
|
<div class="form-group">
|
48
48
|
<%= f.label :amount, 'Amount', :class => 'col-sm-3 control-label' %>
|
49
49
|
<div class="col-sm-4">
|
50
|
-
<%= f.number_field :amount, :class => 'form-control', :
|
50
|
+
<%= f.number_field :amount, :class => 'form-control', :step => :any %>
|
51
51
|
</div>
|
52
52
|
</div>
|
53
53
|
<div class="form-group">
|
54
54
|
<%= f.label :currency, 'Currency', :class => 'col-sm-3 control-label' %>
|
55
55
|
<div class="col-sm-4">
|
56
|
-
<%= f.select :currency, currencies, {:selected =>
|
56
|
+
<%= f.select :currency, currencies, {:selected => @simple_plan.currency}, :class => 'form-control' %>
|
57
57
|
</div>
|
58
58
|
</div>
|
59
59
|
<div class="form-group">
|
60
60
|
<%= f.label :billing_period, 'Billing Period', :class => 'col-sm-3 control-label' %>
|
61
61
|
<div class="col-sm-4">
|
62
|
-
<%= f.select :billing_period, options_for_select(@billing_period.map {|bp| [humanized_billing_period(bp), bp] },
|
62
|
+
<%= f.select :billing_period, options_for_select(@billing_period.map {|bp| [humanized_billing_period(bp), bp] }, @simple_plan.billing_period), :class => 'form-control' %>
|
63
63
|
</div>
|
64
64
|
</div>
|
65
65
|
<div class="form-group">
|
66
66
|
<%= f.label :trial_length, 'Trial Length', :class => 'col-sm-3 control-label' %>
|
67
67
|
<div class="col-sm-4">
|
68
|
-
<%= f.number_field :trial_length, :class => 'form-control', :
|
68
|
+
<%= f.number_field :trial_length, :class => 'form-control', :type => 'number', :min => 0, :step => 1 %>
|
69
69
|
</div>
|
70
70
|
</div>
|
71
71
|
<div class="form-group">
|
72
72
|
<%= f.label :trial_time_unit, 'Trial Time Unit', :class => 'col-sm-3 control-label' %>
|
73
73
|
<div class="col-sm-4">
|
74
|
-
<%= f.select :trial_time_unit, options_for_select(@time_units.map {|tu| [humanized_time_unit(tu), tu]},
|
74
|
+
<%= f.select :trial_time_unit, options_for_select(@time_units.map {|tu| [humanized_time_unit(tu), tu]}, @simple_plan.trial_time_unit), :class => 'form-control' %>
|
75
75
|
</div>
|
76
76
|
</div>
|
77
77
|
<div class="form-group">
|
@@ -111,15 +111,19 @@
|
|
111
111
|
|
112
112
|
function known_products() {
|
113
113
|
var result = [];
|
114
|
-
var selected_category = $("#simple_plan_product_category option:selected"
|
115
|
-
if (selected_category == '
|
114
|
+
var selected_category = $("#simple_plan_product_category option:selected").val();
|
115
|
+
if (selected_category == 'BASE') {
|
116
116
|
result = $('#simple_plan_product_name').attr('known_base');
|
117
|
-
} else if (selected_category == '
|
117
|
+
} else if (selected_category == 'ADD_ON') {
|
118
118
|
result = $('#simple_plan_product_name').attr('known_ao');
|
119
119
|
} else {
|
120
120
|
result = $('#simple_plan_product_name').attr('known_std');
|
121
121
|
}
|
122
|
-
|
122
|
+
if (result) {
|
123
|
+
return result.split(",");
|
124
|
+
} else {
|
125
|
+
return [];
|
126
|
+
}
|
123
127
|
}
|
124
128
|
|
125
129
|
function switch_xml_config() {
|
@@ -128,7 +132,7 @@ function switch_xml_config() {
|
|
128
132
|
}
|
129
133
|
|
130
134
|
function recompute_available_base_products_for_ao() {
|
131
|
-
if ($("#simple_plan_product_category option:selected" ).
|
135
|
+
if ($("#simple_plan_product_category option:selected" ).val() != 'ADD_ON') {
|
132
136
|
return;
|
133
137
|
}
|
134
138
|
var product_name = $('#simple_plan_product_name').val();
|
@@ -147,10 +151,7 @@ function recompute_available_base_products_for_ao() {
|
|
147
151
|
}
|
148
152
|
|
149
153
|
function display_available_base_products_for_ao() {
|
150
|
-
|
151
|
-
$('#simple_plan_product_name').val('');
|
152
|
-
|
153
|
-
if ($("#simple_plan_product_category option:selected" ).text() == 'Add_on') {
|
154
|
+
if ($("#simple_plan_product_category option:selected" ).val() == 'ADD_ON') {
|
154
155
|
$('#form_base_products').show();
|
155
156
|
} else {
|
156
157
|
$('#form_base_products').hide();
|