21 #ifndef INCLUDE_OLA_WEB_JSONSECTIONS_H_
22 #define INCLUDE_OLA_WEB_JSONSECTIONS_H_
25 #include <ola/web/Json.h>
46 GenericItem(
const string &description,
const string &
id):
47 m_description(description),
54 void SetButtonText(
const string &text) {
61 virtual string Type()
const = 0;
62 virtual void SetValue(
JsonObject *item)
const = 0;
63 virtual void SetExtraProperties(
JsonObject *item)
const {
81 const string &
id =
""):
87 string Type()
const {
return "string"; }
89 item->Add(
"value", m_value);
104 const string &
id =
""):
111 void SetMin(
unsigned int min) {
115 void SetMax(
unsigned int max) {
121 void SetExtraProperties(
JsonObject *item)
const;
122 string Type()
const {
return "uint"; }
124 item->Add(
"value", m_value);
128 unsigned int m_value;
129 bool m_min_set, m_max_set;
145 string Type()
const {
return "bool"; }
147 item->Add(
"value", m_value);
157 HiddenItem(
const string &value,
const string &
id):
163 string Type()
const {
return "hidden"; }
165 item->Add(
"value", m_value);
179 const string &
id =
""):
181 m_selected_offset(0) {
184 void SetSelectedOffset(
unsigned int offset) { m_selected_offset = offset; }
185 void AddItem(
const string &label,
const string &value);
187 void AddItem(
const string &label,
unsigned int value);
190 void SetExtraProperties(
JsonObject *item)
const {
191 item->Add(
"selected_offset", m_selected_offset);
193 string Type()
const {
return "select"; }
197 std::vector<std::pair<string, string> > m_values;
198 unsigned int m_selected_offset;
207 void SetSaveButton(
const string &text) { m_save_button_text = text; }
208 void SetError(
const string &error) { m_error = error; }
211 string AsString()
const;
214 bool m_allow_refresh;
216 string m_save_button_text;
217 std::vector<const GenericItem*> m_items;
221 #endif // INCLUDE_OLA_WEB_JSONSECTIONS_H_