mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-09-20 22:56:46 +08:00
Render webhooks form url errors using data-error-text attribute [SCI-9743] (#6869)
This commit is contained in:
parent
dd312062d3
commit
9ade9e890f
|
@ -24,7 +24,13 @@
|
|||
});
|
||||
}
|
||||
$('.activity-filters-list').on('ajax:error', '.webhook-form', function(e, data) {
|
||||
$(this).renderFormErrors('webhook', data.responseJSON.errors);
|
||||
const { errors } = data.responseJSON;
|
||||
// display url errors with data-error-text attribute
|
||||
if (errors.url) {
|
||||
$(this).find('.url-input-container').addClass('error').attr('data-error-text', `${errors.url.join(', ')}`);
|
||||
delete errors.url;
|
||||
}
|
||||
$(this).renderFormErrors('webhook', errors);
|
||||
});
|
||||
|
||||
$('.activity-filters-list').on('click', '.create-webhook', function() {
|
||||
|
@ -33,6 +39,11 @@
|
|||
filterElement.find('.create-webhook-container').removeClass('hidden');
|
||||
});
|
||||
|
||||
// clear url form errors
|
||||
$('.activity-filters-list').on('click', '.cancel-action, .save-webhook', () => {
|
||||
$('.url-input-container').removeClass('error').attr('data-error-text', '');
|
||||
});
|
||||
|
||||
$('.activity-filters-list').on('click', '.create-webhook-container .cancel-action', function(e) {
|
||||
let webhookContainer = $(this).closest('.create-webhook-container');
|
||||
e.preventDefault();
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="edit-webhook-container hidden">
|
||||
<%= form_with model: webhook, url: users_settings_webhook_path(webhook, filter_id: filter.id, sort: @current_sort), class: 'webhook-form', method: :patch do |f| %>
|
||||
<%= form_with model: webhook, url: users_settings_webhook_path(webhook, filter_id: filter.id, sort: @current_sort), class: 'webhook-form', method: :patch, data: { remote: true } do |f| %>
|
||||
<%= render partial: 'webhook_form', locals: {f: f} %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -220,7 +220,7 @@ en:
|
|||
configuration:
|
||||
disabled: 'Webhooks are disabled'
|
||||
url:
|
||||
not_valid: 'Not valid URL'
|
||||
not_valid: 'not valid URL'
|
||||
result_text:
|
||||
attributes:
|
||||
text:
|
||||
|
|
Loading…
Reference in a new issue