Search in sources :

Example 6 with Tag

use of org.structr.api.util.html.Tag in project structr by structr.

the class ConfigServlet method setupDocument.

// ----- private methods -----
private Tag setupDocument(final HttpServletRequest request, final Document doc) {
    final Tag head = doc.block("head");
    head.block("title").text(TITLE);
    head.empty("meta").attr(new Attr("http-equiv", "Content-Type"), new Attr("content", "text/html;charset=utf-8"));
    head.empty("meta").attr(new Name("viewport"), new Attr("content", "width=1024, user-scalable=yes"));
    head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/lib/jquery-ui-1.10.3.custom.min.css"));
    head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/main.css"));
    head.empty("link").attr(new Rel("stylesheet"), new Href("/structr/css/config.css"));
    head.empty("link").attr(new Rel("icon"), new Href("favicon.ico"), new Type("image/x-icon"));
    head.block("script").attr(new Src("/structr/js/lib/jquery-1.11.1.min.js"));
    head.block("script").attr(new Src("/structr/js/lib/jquery-ui-1.11.0.custom.min.js"));
    head.block("script").attr(new Src("/structr/js/icons.js"));
    head.block("script").attr(new Src("/structr/js/config.js"));
    final Tag body = doc.block("body");
    final Tag header = body.block("div").id("header");
    header.block("i").css("logo sprite sprite-structr-logo");
    final Tag links = header.block("div").id("menu").css("menu").block("ul");
    if (isAuthenticated(request)) {
        final Tag form = links.block("li").block("form").attr(new Attr("action", ConfigUrl), new Attr("method", "post"), new Style("display: none")).id("logout-form");
        form.empty("input").attr(new Type("hidden"), new Name("action"), new Value("logout"));
        links.block("a").text("Logout").attr(new Style("cursor: pointer"), new OnClick("$('#logout-form').submit();"));
    }
    return body;
}
Also used : Rel(org.structr.api.util.html.attr.Rel) Href(org.structr.api.util.html.attr.Href) Tag(org.structr.api.util.html.Tag) Attr(org.structr.api.util.html.Attr)

Example 7 with Tag

use of org.structr.api.util.html.Tag in project structr by structr.

the class SettingsGroup method render.

public void render(final Tag parent) {
    final Map<String, List<Setting>> mapped = new LinkedHashMap<>();
    final List<Setting> otherSettings = new LinkedList<>();
    final Tag div = parent.block("div");
    // sort / categorize settings
    for (final Setting setting : settings) {
        final String group = setting.getCategory();
        // ignore hidden settings
        if ("hidden".equals(group)) {
            continue;
        }
        if (group != null) {
            List<Setting> list = mapped.get(group);
            if (list == null) {
                list = new LinkedList<>();
                mapped.put(group, list);
            }
            list.add(setting);
        } else {
            otherSettings.add(setting);
        }
    }
    // display grouped settings
    for (final Entry<String, List<Setting>> entry : mapped.entrySet()) {
        final String name = entry.getKey();
        final Tag groupContainer = div.block("div").css("config-group");
        groupContainer.block("h3").text(name);
        for (final Setting setting : entry.getValue()) {
            setting.render(groupContainer);
        }
    }
    // display settings w/o group
    if (!otherSettings.isEmpty()) {
        final Tag groupContainer = div.block("div").css("config-group");
        // display title only if other groups exist
        if (!mapped.isEmpty()) {
            groupContainer.block("h3").text("Custom");
        }
        for (final Setting setting : otherSettings) {
            setting.render(groupContainer);
        }
    }
}
Also used : List(java.util.List) LinkedList(java.util.LinkedList) Tag(org.structr.api.util.html.Tag) LinkedList(java.util.LinkedList) LinkedHashMap(java.util.LinkedHashMap)

Example 8 with Tag

use of org.structr.api.util.html.Tag in project structr by structr.

the class StringSetting method render.

@Override
public void render(final Tag parent) {
    final Tag group = parent.block("div").css("form-group");
    final Tag label = group.block("label").text(getKey());
    if (getComment() != null) {
        label.attr(new Attr("class", "has-comment"));
        label.attr(new Attr("data-comment", getComment()));
    }
    final Tag input = group.empty("input").attr(new Attr("type", "text"), new Attr("name", getKey()));
    final String value = getValue();
    // display value if non-empty
    if (value != null) {
        input.attr(new Attr("value", value));
    }
    renderResetButton(group);
}
Also used : Tag(org.structr.api.util.html.Tag) Attr(org.structr.api.util.html.Attr)

Example 9 with Tag

use of org.structr.api.util.html.Tag in project structr by structr.

the class BooleanSetting method render.

@Override
public void render(final Tag parent) {
    final Tag group = parent.block("div").css("form-group");
    final Tag label = group.block("label").text(getKey());
    if (getComment() != null) {
        label.attr(new Attr("class", "has-comment"));
        label.attr(new Attr("data-comment", getComment()));
    }
    final Tag trueInput = group.empty("input").attr(new Attr("type", "radio"), new Attr("name", getKey()), new Attr("value", "true"));
    group.block("span").text("Enabled");
    final Tag falseInput = group.empty("input").attr(new Attr("type", "radio"), new Attr("name", getKey()), new Attr("value", "false"));
    group.block("span").text("Disabled");
    if (getValue()) {
        trueInput.attr(new Attr("checked", "checked"));
    } else {
        falseInput.attr(new Attr("checked", "checked"));
    }
    renderResetButton(group);
}
Also used : Tag(org.structr.api.util.html.Tag) Attr(org.structr.api.util.html.Attr)

Example 10 with Tag

use of org.structr.api.util.html.Tag in project structr by structr.

the class ChoiceSetting method render.

@Override
public void render(final Tag parent) {
    final Tag group = parent.block("div").css("form-group");
    group.block("label").text(getKey());
    final Tag select = group.block("select").attr(new Attr("name", getKey()));
    for (final String choice : choices) {
        final Tag option = select.block("option").text(choice);
        // selected?
        if (choice.equals(getValue())) {
            option.attr(new Attr("selected", "selected"));
        }
    }
}
Also used : Tag(org.structr.api.util.html.Tag) Attr(org.structr.api.util.html.Attr)

Aggregations

Tag (org.structr.api.util.html.Tag)12 Attr (org.structr.api.util.html.Attr)11 Href (org.structr.api.util.html.attr.Href)3 Document (org.structr.api.util.html.Document)2 Css (org.structr.api.util.html.attr.Css)2 If (org.structr.api.util.html.attr.If)2 Onload (org.structr.api.util.html.attr.Onload)2 Type (org.structr.api.util.html.attr.Type)2 App (org.structr.core.app.App)2 StructrApp (org.structr.core.app.StructrApp)2 SchemaNode (org.structr.core.entity.SchemaNode)2 Tx (org.structr.core.graph.Tx)2 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 SettingsGroup (org.structr.api.config.SettingsGroup)1 Service (org.structr.api.service.Service)1 Rel (org.structr.api.util.html.attr.Rel)1 Services (org.structr.core.Services)1