Iterate Enum fixes

This commit is contained in:
CommanderRedYT
2022-06-12 18:55:32 +02:00
parent ca1b7173e7
commit 1366f3fedb

View File

@ -53,7 +53,7 @@ typename std::enable_if<
!std::is_same_v<T, LedstripAnimation> && !std::is_same_v<T, LedstripAnimation> &&
!std::is_same_v<T, HandbremseMode> && !std::is_same_v<T, HandbremseMode> &&
!std::is_same_v<T, CloudMode> && !std::is_same_v<T, CloudMode> &&
!std::is_same_v<T, BobbyQuickActions> !std::is_same_v<T, BatteryCellType>
, void>::type , void>::type
showInputForSetting(std::string_view key, T value, std::string &body) showInputForSetting(std::string_view key, T value, std::string &body)
{ {
@ -203,69 +203,17 @@ showInputForSetting(std::string_view key, T value, std::string &body)
template<typename T> template<typename T>
typename std::enable_if< typename std::enable_if<
std::is_same_v<T, OtaAnimationModes> std::is_same_v<T, OtaAnimationModes> ||
, void>::type std::is_same_v<T, LedstripAnimation> ||
showInputForSetting(std::string_view key, T value, std::string &body) std::is_same_v<T, BatteryCellType> ||
{ std::is_same_v<T, CloudMode> ||
HtmlTag select{"select", fmt::format("name=\"{}\"", esphttpdutils::htmlentities(key)), body};
iterateOtaAnimationModes([&](T enumVal, std::string_view enumKey){
HtmlTag option{"option", fmt::format("value=\"{}\"{}", std::to_underlying(enumVal), value == enumVal ? " selected" : ""), body};
body += esphttpdutils::htmlentities(enumKey);
});
}
template<typename T>
typename std::enable_if<
std::is_same_v<T, LedstripAnimation>
, void>::type
showInputForSetting(std::string_view key, T value, std::string &body)
{
HtmlTag select{"select", fmt::format("name=\"{}\"", esphttpdutils::htmlentities(key)), body};
iterateLedstripAnimation([&](T enumVal, std::string_view enumKey){
HtmlTag option{"option", fmt::format("value=\"{}\"{}", std::to_underlying(enumVal), value == enumVal ? " selected" : ""), body};
body += esphttpdutils::htmlentities(enumKey);
});
}
template<typename T>
typename std::enable_if<
std::is_same_v<T, HandbremseMode> std::is_same_v<T, HandbremseMode>
, void>::type , void>::type
showInputForSetting(std::string_view key, T value, std::string &body) showInputForSetting(std::string_view key, T value, std::string &body)
{ {
HtmlTag select{"select", fmt::format("name=\"{}\"", esphttpdutils::htmlentities(key)), body}; HtmlTag select{"select", fmt::format("name=\"{}\"", esphttpdutils::htmlentities(key)), body};
iterateHandbremseMode([&](T enumVal, std::string_view enumKey){ iterateEnum<T>::iterate([&](T enumVal, std::string_view enumKey){
HtmlTag option{"option", fmt::format("value=\"{}\"{}", std::to_underlying(enumVal), value == enumVal ? " selected" : ""), body};
body += esphttpdutils::htmlentities(enumKey);
});
}
template<typename T>
typename std::enable_if<
std::is_same_v<T, BobbyQuickActions>
, void>::type
showInputForSetting(std::string_view key, T value, std::string &body)
{
HtmlTag select{"select", fmt::format("name=\"{}\"", esphttpdutils::htmlentities(key)), body};
iterateBobbyQuickActions([&](T enumVal, std::string_view enumKey){
HtmlTag option{"option", fmt::format("value=\"{}\"{}", std::to_underlying(enumVal), value == enumVal ? " selected" : ""), body};
body += esphttpdutils::htmlentities(enumKey);
});
}
template<typename T>
typename std::enable_if<
std::is_same_v<T, CloudMode>
, void>::type
showInputForSetting(std::string_view key, T value, std::string &body)
{
HtmlTag select{"select", fmt::format("name=\"{}\"", esphttpdutils::htmlentities(key)), body};
iterateCloudMode([&](T enumVal, std::string_view enumKey){
HtmlTag option{"option", fmt::format("value=\"{}\"{}", std::to_underlying(enumVal), value == enumVal ? " selected" : ""), body}; HtmlTag option{"option", fmt::format("value=\"{}\"{}", std::to_underlying(enumVal), value == enumVal ? " selected" : ""), body};
body += esphttpdutils::htmlentities(enumKey); body += esphttpdutils::htmlentities(enumKey);
}); });