Still converting to bootstrap 5. JS Validation fixes
This commit is contained in:
@@ -55,9 +55,9 @@
|
||||
<div class="input-group mb-3">
|
||||
${replaygain-preamp class="form-control"}
|
||||
<span class="input-group-text">dB</span>
|
||||
</div>
|
||||
<div class="invalid-feedback">
|
||||
${replaygain-preamp-info}
|
||||
<div class="invalid-feedback">
|
||||
${replaygain-preamp-info}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-4">
|
||||
@@ -67,9 +67,9 @@
|
||||
<div class="input-group mb-3">
|
||||
${replaygain-preamp-no-rg-info class="form-control"}
|
||||
<span class="input-group-text">dB</span>
|
||||
</div>
|
||||
<div class="invalid-feedback">
|
||||
${replaygain-preamp-no-rg-info-info}
|
||||
<div class="invalid-feedback">
|
||||
${replaygain-preamp-no-rg-info-info}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
${<if-has-subsonic-api>}
|
||||
|
||||
@@ -18,6 +18,7 @@ add_executable(lms
|
||||
ui/admin/UserView.cpp
|
||||
ui/admin/UsersView.cpp
|
||||
ui/common/DirectoryValidator.cpp
|
||||
ui/common/DoubleValidator.cpp
|
||||
ui/common/InfiniteScrollingContainer.cpp
|
||||
ui/common/LoadingIndicator.cpp
|
||||
ui/common/LoginNameValidator.cpp
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
|
||||
#include <Wt/WCheckBox.h>
|
||||
#include <Wt/WComboBox.h>
|
||||
#include <Wt/WDoubleValidator.h>
|
||||
#include <Wt/WDoubleSpinBox.h>
|
||||
#include <Wt/WFormModel.h>
|
||||
#include <Wt/WLineEdit.h>
|
||||
@@ -29,8 +28,9 @@
|
||||
#include <Wt/WString.h>
|
||||
#include <Wt/WTemplateFormView.h>
|
||||
|
||||
#include "common/PasswordValidator.hpp"
|
||||
#include "common/DoubleValidator.hpp"
|
||||
#include "common/MandatoryValidator.hpp"
|
||||
#include "common/PasswordValidator.hpp"
|
||||
#include "common/UUIDValidator.hpp"
|
||||
#include "common/ValueStringModel.hpp"
|
||||
|
||||
@@ -108,12 +108,10 @@ class SettingsModel : public Wt::WFormModel
|
||||
setValidator(TranscodeBitrateField, createMandatoryValidator());
|
||||
setValidator(TranscodeFormatField, createMandatoryValidator());
|
||||
setValidator(ReplayGainModeField, createMandatoryValidator());
|
||||
auto createPreAmpValidator = []
|
||||
auto createPreAmpValidator {[]
|
||||
{
|
||||
auto preampGainValidator {std::make_unique<Wt::WDoubleValidator>()};
|
||||
preampGainValidator->setRange(MediaPlayer::Settings::ReplayGain::minPreAmpGain, MediaPlayer::Settings::ReplayGain::maxPreAmpGain);
|
||||
return preampGainValidator;
|
||||
};
|
||||
return createDoubleValidator(MediaPlayer::Settings::ReplayGain::minPreAmpGain, MediaPlayer::Settings::ReplayGain::maxPreAmpGain);
|
||||
}};
|
||||
|
||||
setValidator(ReplayGainPreAmpGainField, createPreAmpValidator());
|
||||
setValidator(ReplayGainPreAmpGainIfNoInfoField, createPreAmpValidator());
|
||||
|
||||
@@ -69,12 +69,11 @@ class DatabaseSettingsModel : public Wt::WFormModel
|
||||
|
||||
auto dirValidator {createDirectoryValidator()};
|
||||
dirValidator->setMandatory(true);
|
||||
setValidator(MediaDirectoryField, dirValidator);
|
||||
setValidator(MediaDirectoryField, move(dirValidator));
|
||||
|
||||
setValidator(UpdatePeriodField, createMandatoryValidator());
|
||||
setValidator(UpdateStartTimeField, createMandatoryValidator());
|
||||
setValidator(RecommendationEngineTypeField, createMandatoryValidator());
|
||||
setValidator(TagsField, createTagsValidator());
|
||||
|
||||
// populate the model with initial data
|
||||
loadData();
|
||||
@@ -144,11 +143,6 @@ class DatabaseSettingsModel : public Wt::WFormModel
|
||||
}
|
||||
|
||||
private:
|
||||
static std::shared_ptr<Wt::WValidator> createTagsValidator()
|
||||
{
|
||||
auto v = std::make_shared<Wt::WValidator>();
|
||||
return v;
|
||||
}
|
||||
|
||||
void initializeModels()
|
||||
{
|
||||
|
||||
@@ -25,8 +25,9 @@ namespace UserInterface
|
||||
{
|
||||
class DirectoryValidator : public Wt::WValidator
|
||||
{
|
||||
public:
|
||||
private:
|
||||
Wt::WValidator::Result validate(const Wt::WString& input) const override;
|
||||
std::string javaScriptValidate() const override { return {}; }
|
||||
};
|
||||
|
||||
Wt::WValidator::Result
|
||||
@@ -48,7 +49,7 @@ namespace UserInterface
|
||||
return Wt::WValidator::Result(Wt::ValidationState::Invalid, Wt::WString::tr("Lms.not-a-directory"));
|
||||
}
|
||||
|
||||
std::shared_ptr<Wt::WValidator>
|
||||
std::unique_ptr<Wt::WValidator>
|
||||
createDirectoryValidator()
|
||||
{
|
||||
return std::make_unique<DirectoryValidator>();
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
std::shared_ptr<Wt::WValidator> createDirectoryValidator();
|
||||
std::unique_ptr<Wt::WValidator> createDirectoryValidator();
|
||||
} // namespace UserInterface
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Emeric Poupon
|
||||
*
|
||||
* This file is part of LMS.
|
||||
*
|
||||
* LMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* LMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "DoubleValidator.hpp"
|
||||
|
||||
#include <Wt/WDoubleValidator.h>
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
class DoubleValidator : public Wt::WDoubleValidator
|
||||
{
|
||||
public:
|
||||
using Wt::WDoubleValidator::WDoubleValidator;
|
||||
|
||||
private:
|
||||
std::string javaScriptValidate() const override { return {}; }
|
||||
};
|
||||
|
||||
std::unique_ptr<Wt::WValidator>
|
||||
createDoubleValidator(double min, double max)
|
||||
{
|
||||
auto validator {std::make_unique<DoubleValidator>(min, max)};
|
||||
return validator;
|
||||
}
|
||||
} // namespace UserInterface
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2022 Emeric Poupon
|
||||
*
|
||||
* This file is part of LMS.
|
||||
*
|
||||
* LMS is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* LMS is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Wt/WValidator.h>
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
std::unique_ptr<Wt::WValidator> createDoubleValidator(double min, double max);
|
||||
} // namespace UserInterface
|
||||
|
||||
@@ -24,10 +24,16 @@
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
std::shared_ptr<Wt::WValidator>
|
||||
class LengthValidator : public Wt::WLengthValidator
|
||||
{
|
||||
private:
|
||||
std::string javaScriptValidate() const override { return {}; }
|
||||
};
|
||||
|
||||
std::unique_ptr<Wt::WValidator>
|
||||
createLoginNameValidator()
|
||||
{
|
||||
auto v = std::make_unique<Wt::WLengthValidator>();
|
||||
auto v = std::make_unique<LengthValidator>();
|
||||
v->setMandatory(true);
|
||||
v->setMinimumLength(::Database::User::MinNameLength);
|
||||
v->setMaximumLength(::Database::User::MaxNameLength);
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
std::shared_ptr<Wt::WValidator> createLoginNameValidator();
|
||||
std::unique_ptr<Wt::WValidator> createLoginNameValidator();
|
||||
} // namespace UserInterface
|
||||
|
||||
|
||||
@@ -21,10 +21,16 @@
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
std::shared_ptr<Wt::WValidator>
|
||||
class MandatoryValidator : public Wt::WValidator
|
||||
{
|
||||
private:
|
||||
std::string javaScriptValidate() const override { return {}; }
|
||||
};
|
||||
|
||||
std::unique_ptr<Wt::WValidator>
|
||||
createMandatoryValidator()
|
||||
{
|
||||
auto v {std::make_shared<Wt::WValidator>()};
|
||||
auto v {std::make_unique<MandatoryValidator>()};
|
||||
v->setMandatory(true);
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
std::shared_ptr<Wt::WValidator> createMandatoryValidator();
|
||||
std::unique_ptr<Wt::WValidator> createMandatoryValidator();
|
||||
} // namespace UserInterface
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace UserInterface
|
||||
|
||||
private:
|
||||
Wt::WValidator::Result validate(const Wt::WString& input) const override;
|
||||
std::string javaScriptValidate() const override { return {}; }
|
||||
|
||||
PasswordValidationContextGetFunc _passwordValidationContextGetFunc;
|
||||
};
|
||||
@@ -61,16 +62,17 @@ namespace UserInterface
|
||||
throw LmsException {"internal error"};
|
||||
}
|
||||
|
||||
std::shared_ptr<Wt::WValidator>
|
||||
std::unique_ptr<Wt::WValidator>
|
||||
createPasswordStrengthValidator(PasswordValidationContextGetFunc passwordValidationContextGetFunc)
|
||||
{
|
||||
return std::make_shared<PasswordStrengthValidator>(std::move(passwordValidationContextGetFunc));
|
||||
return std::make_unique<PasswordStrengthValidator>(std::move(passwordValidationContextGetFunc));
|
||||
}
|
||||
|
||||
class PasswordCheckValidator : public Wt::WValidator
|
||||
{
|
||||
public:
|
||||
private:
|
||||
Wt::WValidator::Result validate(const Wt::WString& input) const override;
|
||||
std::string javaScriptValidate() const override { return {}; }
|
||||
};
|
||||
|
||||
Wt::WValidator::Result
|
||||
@@ -96,10 +98,10 @@ namespace UserInterface
|
||||
throw LmsException {"InternalError"};
|
||||
}
|
||||
|
||||
std::shared_ptr<Wt::WValidator>
|
||||
std::unique_ptr<Wt::WValidator>
|
||||
createPasswordCheckValidator()
|
||||
{
|
||||
return std::make_shared<PasswordCheckValidator>();
|
||||
return std::make_unique<PasswordCheckValidator>();
|
||||
}
|
||||
|
||||
} // namespace UserInterface
|
||||
|
||||
@@ -22,15 +22,14 @@
|
||||
#include <functional>
|
||||
#include <Wt/WValidator.h>
|
||||
|
||||
#include "services/database/Types.hpp"
|
||||
#include "services/auth/Types.hpp"
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
using PasswordValidationContextGetFunc = std::function<::Auth::PasswordValidationContext()>;
|
||||
std::shared_ptr<Wt::WValidator> createPasswordStrengthValidator(PasswordValidationContextGetFunc passwordValidationContextGetFunc);
|
||||
std::unique_ptr<Wt::WValidator> createPasswordStrengthValidator(PasswordValidationContextGetFunc passwordValidationContextGetFunc);
|
||||
|
||||
// Check current user password
|
||||
std::shared_ptr<Wt::WValidator> createPasswordCheckValidator();
|
||||
std::unique_ptr<Wt::WValidator> createPasswordCheckValidator();
|
||||
} // namespace UserInterface
|
||||
|
||||
|
||||
@@ -23,9 +23,18 @@
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
std::shared_ptr<Wt::WValidator>
|
||||
class RegExpValidator : public Wt::WRegExpValidator
|
||||
{
|
||||
public:
|
||||
using Wt::WRegExpValidator::WRegExpValidator;
|
||||
|
||||
private:
|
||||
std::string javaScriptValidate() const override { return {}; }
|
||||
};
|
||||
|
||||
std::unique_ptr<Wt::WValidator>
|
||||
createUUIDValidator()
|
||||
{
|
||||
return std::make_unique<Wt::WRegExpValidator>("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}");
|
||||
return std::make_unique<RegExpValidator>("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}");
|
||||
}
|
||||
} // namespace UserInterface
|
||||
|
||||
@@ -23,6 +23,6 @@
|
||||
|
||||
namespace UserInterface
|
||||
{
|
||||
std::shared_ptr<Wt::WValidator> createUUIDValidator();
|
||||
std::unique_ptr<Wt::WValidator> createUUIDValidator();
|
||||
} // namespace UserInterface
|
||||
|
||||
|
||||
Reference in New Issue
Block a user