Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/kaui/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def index
@max_records = {}
%w[account payment invoice].each do |type|
model = "Kaui::#{type.capitalize}".constantize
@max_records[type.to_sym] = model.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records || 0
@max_records[type.to_sym] = model.list_or_search(nil, 0, 0, options_for_klient).pagination_max_nb_records
end
end

Expand Down
9 changes: 9 additions & 0 deletions app/controllers/kaui/invoices_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ def download
Kaui::Invoice.list_or_search(query_string, 0, MAXIMUM_NUMBER_OF_RECORDS_DOWNLOAD, options_for_klient.merge(params: kb_params))
end

if start_date && end_date
invoices = invoices.select do |invoice|
start_date_parsed = Date.parse(start_date)
end_date_parsed = Date.parse(end_date)
invoice_date = Date.parse(invoice.invoice_date)
invoice_date.between?(start_date_parsed, end_date_parsed)
end
end

csv_string = CSV.generate(headers: true) do |csv|
csv << columns

Expand Down
2 changes: 2 additions & 0 deletions app/helpers/kaui/plugin_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def installed_plugin_names
'/kenui'
when /payment-test/
'/payment_test'
when /aviate/
'/aviate'
else
"/#{plugin_key}"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<path d="M2.5 8.3335H17.5" stroke="#A4A7AE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</label>
<input type="text" class="form-control center-input" id="startDate" placeholder="All Accounts" name="startDate">
<input type="text" class="form-control center-input" id="startDate" placeholder="All Account Timelines" name="startDate">
<div id="dash" class="dash">–</div>
<input type="text" class="form-control right-input" id="endDate" placeholder="" name="endDate">
<div id="toggle-wrapper" class="position-absolute" style="width: 100%; height: 100%;" onclick="document.getElementById('single-toggle').click()"></div>
Expand Down
10 changes: 4 additions & 6 deletions app/views/kaui/accounts/_billing_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,10 @@
<% end %>
</div>

<% if can? :trigger, Kaui::Invoice %>
<div class="info-item">
<b>Next invoice date</b>
<p id='next-invoice-date'>N/A</p>
</div>
<% end %>
<div class="info-item">
<b>Next invoice date</b>
<p id='next-invoice-date'>N/A</p>
</div>
</div>

<!-- Right Column -->
Expand Down
25 changes: 8 additions & 17 deletions app/views/kaui/admin_allowed_users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,12 @@
<td><%= link_to u.kb_username, admin_allowed_user_path(u.id) %></td>
<td><%= u.description %></td>
<td class="text-end">


<%= render "kaui/components/button/button", {
label: 'Delete',
variant: "outline-secondary d-inline-flex align-items-center gap-1",
type: "button",
html_class: "kaui-button delete-button custom-hover",
html_options: {
data: {
confirm: "Are you sure?",
method: "delete",
turbo: false,
"url": kaui_engine.admin_allowed_user_path(u.id)
}
}
} %>
<%= link_to kaui_engine.edit_admin_allowed_user_path(u.id), :class => '' do %>
<%= form_tag kaui_engine.admin_allowed_user_path(u.id), method: :delete, class: 'd-inline', onsubmit: "return confirm('Are you sure?');" do %>
<%= button_tag type: 'submit', class: 'btn btn-outline-secondary d-inline-flex align-items-center gap-1 kaui-button delete-button custom-hover' do %>
Delete
<% end %>
<% end %>
<%= link_to kaui_engine.edit_admin_allowed_user_path(u.id), class: 'text-decoration-none' do %>
<%= render "kaui/components/button/button", {
label: "Edit",
variant: "outline-secondary d-inline-flex align-items-center gap-1",
Expand Down Expand Up @@ -154,6 +143,8 @@
$header.find('.sort-' + direction).addClass('active');
}

} catch (e) {
console.error('Error initializing DataTable:', e);
}
}, 100);
});
Expand Down
66 changes: 66 additions & 0 deletions app/views/kaui/admin_tenants/new_catalog.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ function switch_basic_config() {
$(document).ready(function() {
switch_basic_config();

// jQuery UI autocomplete interferes with HTML5 validation
// So we keep the custom JS validation
$('#simple_plan_product_name').autocomplete({
source: function(query, process) {
process(known_products());
Expand All @@ -261,8 +263,72 @@ $(document).ready(function() {
$('#simple_plan_product_name').on('mouseleave', function() {
recompute_available_base_products_for_ao();
});

// Custom validation since HTML5 validation is not working
// (possibly due to jQuery autocomplete or other JavaScript interference)
$('#catalog_simple form').on('submit', function(e) {
var isValid = true;
var pattern = /^[a-zA-Z_][\w\.-]*$/;

// Validate Product Name
var productName = $('#simple_plan_product_name').val().trim();
var productNameField = $('#simple_plan_product_name');

if (productName === '') {
showError(productNameField, 'Product Name is required');
isValid = false;
} else if (!pattern.test(productName)) {
showError(productNameField, 'Product Name must start with a letter or underscore, and can only contain letters, digits, underscores, hyphens, and periods');
isValid = false;
} else {
clearError(productNameField);
}

// Validate Plan Name
var planName = $('#simple_plan_plan_id').val().trim();
var planNameField = $('#simple_plan_plan_id');

if (planName === '') {
showError(planNameField, 'Plan Name is required');
isValid = false;
} else if (!pattern.test(planName)) {
showError(planNameField, 'Plan Name must start with a letter or underscore, and can only contain letters, digits, underscores, hyphens, and periods');
isValid = false;
} else {
clearError(planNameField);
}

if (!isValid) {
e.preventDefault();
e.stopPropagation();
// Scroll to first error
$('.error-message:first').get(0)?.scrollIntoView({ behavior: 'smooth', block: 'center' });
return false;
}

return true;
});

// Clear errors on input
$('#simple_plan_product_name, #simple_plan_plan_id').on('input', function() {
clearError($(this));
});
});

function showError(field, message) {
clearError(field);
field.addClass('error-field');
field.css('border-color', '#dc3545');
var errorDiv = $('<div class="error-message" style="color: #dc3545; font-size: 0.875rem; margin-top: 0.25rem;"></div>').text(message);
field.parent().append(errorDiv);
}

function clearError(field) {
field.removeClass('error-field');
field.css('border-color', '');
field.parent().find('.error-message').remove();
}

document.querySelectorAll('.toggle-option').forEach(el => {
el.addEventListener('click', () => {
document.querySelectorAll('.toggle-option').forEach(opt => opt.classList.remove('active-btn'));
Expand Down
2 changes: 1 addition & 1 deletion app/views/kaui/audit_logs/_multi_functions_bar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<path d="M2.5 8.3335H17.5" stroke="#A4A7AE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</label>
<input type="text" class="form-control center-input" id="startDate" placeholder="All Accounts" name="startDate">
<input type="text" class="form-control center-input" id="startDate" placeholder="All Logs" name="startDate">
<div id="dash" class="dash">–</div>
<input type="text" class="form-control right-input" id="endDate" placeholder="" name="endDate">
<div id="toggle-wrapper" class="position-absolute" style="width: 100%; height: 100%;" onclick="document.getElementById('single-toggle').click()"></div>
Expand Down
3 changes: 2 additions & 1 deletion app/views/kaui/components/dashboard/_card.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<% count_text = count.nil? ? "20k+" : count.to_i %>
<div class="col-md-4">
<div class="dashboard-card border rounded-4 d-flex flex-column justify-content-between h-100">
<div class="d-flex px-4 py-3 align-items-center gap-3">
Expand All @@ -6,7 +7,7 @@
</div>
<div>
<h6 class="mb-0 fw-600 text-black-900"><%= title %></h6>
<p class="text-muted fw-normal text-tertiary small mb-0"><%= count %></p>
<p class="text-muted fw-normal text-tertiary small mb-0"><%= count_text %></p>
</div>
</div>
<div class="w-full dashboard-card-divider"></div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/kaui/invoices/_multi_functions_bar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<path d="M2.5 8.3335H17.5" stroke="#A4A7AE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</label>
<input type="text" class="form-control center-input" id="startDate" placeholder="All Accounts" name="startDate">
<input type="text" class="form-control center-input" id="startDate" placeholder="All Invoices" name="startDate">
<div id="dash" class="dash">–</div>
<input type="text" class="form-control right-input" id="endDate" placeholder="" name="endDate">
<div id="toggle-wrapper" class="position-absolute" style="width: 100%; height: 100%;" onclick="document.getElementById('single-toggle').click()"></div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/kaui/payments/_multi_functions_bar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
<path d="M2.5 8.3335H17.5" stroke="#A4A7AE" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</label>
<input type="text" class="form-control center-input" id="startDate" placeholder="All Accounts" name="startDate">
<input type="text" class="form-control center-input" id="startDate" placeholder="All Payments" name="startDate">
<div id="dash" class="dash">–</div>
<input type="text" class="form-control right-input" id="endDate" placeholder="" name="endDate">
<div id="toggle-wrapper" class="position-absolute" style="width: 100%; height: 100%;" onclick="document.getElementById('single-toggle').click()"></div>
Expand Down
1 change: 1 addition & 0 deletions test/dummy/config/initializers/money.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Money.locale_backend = :currency
Money.rounding_mode = BigDecimal::ROUND_HALF_UP
Money.default_currency = 'USD'
Loading