Skip to content

Commit

Permalink
Dataset form: Validation broken for uri field (#2835)
Browse files Browse the repository at this point in the history
  • Loading branch information
maurofmferrao authored Dec 23, 2024
1 parent 6a77bd0 commit 51fa6cc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ui/src/core/xibo-cms.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ window.XiboInitialise = function(scope, options) {
});

// Form validation
$(scope + ' .XiboForm').each((_idx, form) => {
$(scope + ' .XiboForm:not(.custom-validation)').each((_idx, form) => {
const $form = $(form);
forms.validateForm(
$form, // form
Expand Down
2 changes: 1 addition & 1 deletion views/dataset-form-add.twig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<li class="nav-item tabForRemoteDataSet"><a class="nav-link" href="#data" role="tab" data-toggle="tab"><span>{% trans "Data" %}</span></a></li>
<li class="nav-item tabForRemoteDataSet"><a class="nav-link" href="#params" role="tab" data-toggle="tab"><span>{% trans "Advanced" %}</span></a></li>
</ul>
<form id="dataSetAddForm" class="XiboForm form-horizontal" method="post" action="{{ url_for("dataSet.add") }}">
<form id="dataSetAddForm" class="XiboForm custom-validation form-horizontal" method="post" action="{{ url_for("dataSet.add") }}">
<div class="tab-content">
<div class="tab-pane active" id="general">

Expand Down
2 changes: 1 addition & 1 deletion views/dataset-form-edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<li class="nav-item tabForRemoteDataSet"><a class="nav-link" href="#data" role="tab" data-toggle="tab"><span>{% trans "Data" %}</span></a></li>
<li class="nav-item tabForRemoteDataSet"><a class="nav-link" href="#params" role="tab" data-toggle="tab"><span>{% trans "Advanced" %}</span></a></li>
</ul>
<form id="dataSetEditForm" class="XiboForm form-horizontal" method="put" action="{{ url_for("dataSet.edit", {id: dataSet.dataSetId}) }}">
<form id="dataSetEditForm" class="XiboForm custom-validation form-horizontal" method="put" action="{{ url_for("dataSet.edit", {id: dataSet.dataSetId}) }}">
<input type="hidden" name="testDataSetId" value="{{ dataSet.dataSetId }}"/>
<div class="tab-content">
<div class="tab-pane active" id="general">
Expand Down
20 changes: 20 additions & 0 deletions views/dataset-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,26 @@
$(dialog).find('#sourceId').on('change', function() {
onSourceFieldChanged(dialog);
});
// Validate form manually because
// uri field depends on isRemote being checked
if (forms != undefined) {
const $form = $(dialog).find('form');
forms.validateForm(
$form, // form
$form.parent(), // container
{
submitHandler: XiboFormSubmit,
rules: {
uri: {
required: function(element) {
return $form.find('#isRemote').is(':checked')
},
},
},
},
);
}
}
function onIsRealTimeFieldChanged(dialog) {
Expand Down

0 comments on commit 51fa6cc

Please sign in to comment.