21 #ifndef INCLUDE_OLA_WEB_JSONSECTIONS_H_
22 #define INCLUDE_OLA_WEB_JSONSECTIONS_H_
44 GenericItem(
const std::string &description,
const std::string &
id):
45 m_description(description),
52 void SetButtonText(
const std::string &text) {
59 virtual std::string Type()
const = 0;
60 virtual void SetValue(
JsonObject *item)
const = 0;
61 virtual void SetExtraProperties(
JsonObject *item)
const {
66 std::string m_description;
68 std::string m_button_text;
78 const std::string &value,
79 const std::string &
id =
""):
85 std::string Type()
const {
return "string"; }
87 item->
Add(
"value", m_value);
100 UIntItem(
const std::string &description,
102 const std::string &
id =
""):
111 void SetMin(
unsigned int min) {
116 void SetMax(
unsigned int max) {
122 void SetExtraProperties(
JsonObject *item)
const;
123 std::string Type()
const {
return "uint"; }
125 item->
Add(
"value", m_value);
129 unsigned int m_value;
130 bool m_min_set, m_max_set;
138 BoolItem(
const std::string &description,
140 const std::string &
id):
146 std::string Type()
const {
return "bool"; }
148 item->
Add(
"value", m_value);
158 HiddenItem(
const std::string &value,
const std::string &
id):
164 std::string Type()
const {
return "hidden"; }
166 item->
Add(
"value", m_value);
180 const std::string &
id =
""):
182 m_selected_offset(0) {
185 void SetSelectedOffset(
unsigned int offset) { m_selected_offset = offset; }
186 void AddItem(
const std::string &label,
const std::string &value);
188 void AddItem(
const std::string &label,
unsigned int value);
191 void SetExtraProperties(
JsonObject *item)
const {
192 item->
Add(
"selected_offset", m_selected_offset);
194 std::string Type()
const {
return "select"; }
198 std::vector<std::pair<std::string, std::string> > m_values;
199 unsigned int m_selected_offset;
208 void SetSaveButton(
const std::string &text) { m_save_button_text = text; }
209 void SetError(
const std::string &error) { m_error = error; }
212 std::string AsString()
const;
215 bool m_allow_refresh;
217 std::string m_save_button_text;
218 std::vector<const GenericItem*> m_items;
222 #endif // INCLUDE_OLA_WEB_JSONSECTIONS_H_