Commit 452402e9 authored by jan.koester's avatar jan.koester
Browse files

test

parent c1ce5b4d
Loading
Loading
Loading
Loading
+26 −0
Changes for src/webedit/survey/survey.cpp: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ extern "C" {
            std::string surveyTitle = "Survey";
            bool hidden = false;
            bool m_hidden = false;
            std::string customCss = "";

        public:

@@ -106,6 +107,7 @@ extern "C" {
                addField("survey_name", "Survey Name", "text", "kundenzufriedenheit");
                addField("survey_title", "Display Title", "text", "Ihre Meinung");
                addField("hidden", "Hidden", "checkbox", nullptr, true);
                addField("custom_css", "Custom CSS", "textarea", ".we-xxx { color: red; }");
                return arr;
            }

@@ -118,6 +120,12 @@ extern "C" {
                el->SetAttribute("survey_title", surveyTitle.c_str());
                el->SetAttribute("hidden", hidden ? "true" : "false");
                el->SetAttribute("m_hidden", m_hidden ? "true" : "false");

                if (!customCss.empty()) {
                    tinyxml2::XMLElement* cssEl = doc->NewElement("CustomCss");
                    cssEl->SetText(customCss.c_str());
                    el->InsertEndChild(cssEl);
                }
                return el;
            }

@@ -131,6 +139,12 @@ extern "C" {
                if (val) hidden = (strcmp(val, "true") == 0);
                val = xml_data->Attribute("m_hidden");
                if (val) m_hidden = (strcmp(val, "true") == 0);

                tinyxml2::XMLElement* cssEl = xml_data->FirstChildElement("CustomCss");
                if (cssEl) {
                    const char* cssVal = cssEl->GetText();
                    if (cssVal) customCss = cssVal;
                }
            }

            // --- Properties JSON ---
@@ -140,6 +154,7 @@ extern "C" {
                json_object_object_add(obj, "survey_title", json_object_new_string(surveyTitle.c_str()));
                json_object_object_add(obj, "hidden", json_object_new_boolean(hidden));
                json_object_object_add(obj, "m_hidden", json_object_new_boolean(m_hidden));
                json_object_object_add(obj, "custom_css", json_object_new_string(customCss.c_str()));
                const char *result = json_object_to_json_string_ext(obj, JSON_C_TO_STRING_NOSLASHESCAPE);
                std::string out(result);
                json_object_put(obj);
@@ -164,6 +179,10 @@ extern "C" {
                    hidden = json_object_get_boolean(val_obj);
                if (json_object_object_get_ex(obj, "m_hidden", &val_obj))
                    m_hidden = json_object_get_boolean(val_obj);
                if (json_object_object_get_ex(obj, "custom_css", &val_obj)) {
                    val = json_object_get_string(val_obj);
                    if (val) customCss = val;
                }

                json_object_put(obj);
            }
@@ -180,6 +199,13 @@ extern "C" {
                if (hidden) wrapStyle += "display:none;";
                if (!wrapStyle.empty()) wrapper.setAttribute("style", wrapStyle.c_str());

                if (!customCss.empty()) {
                    libhtmlpp::HtmlElement cssStyle("style");
                    std::string scopedCSS = "." + responsiveClass + " { " + customCss + " }";
                    cssStyle.appendChild(libhtmlpp::TextElement(scopedCSS.c_str()));
                    el.appendChild(cssStyle);
                }

                if (surveyName.empty()) {
                    libhtmlpp::HtmlElement msg("p");
                    msg.appendChild(libhtmlpp::TextElement("Survey: No survey configured."));