Search in sources :

Example 1 with Rules

use of org.olat.admin.landingpages.model.Rules in project OpenOLAT by OpenOLAT.

the class LandingPagesModule method init.

@Override
public void init() {
    String rulesObj = getStringPropertyValue(CONFIG_RULES, true);
    if (StringHelper.containsNonWhitespace(rulesObj)) {
        rules = (Rules) rulesXStream.fromXML(rulesObj);
    } else {
        rules = new Rules();
        rules.setRules(new ArrayList<Rule>(1));
    }
}
Also used : Rule(org.olat.admin.landingpages.model.Rule) Rules(org.olat.admin.landingpages.model.Rules)

Example 2 with Rules

use of org.olat.admin.landingpages.model.Rules in project OpenOLAT by OpenOLAT.

the class LandingPagesAdminController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("landingpages.title");
    // add the table
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.position.i18nKey(), RCols.position.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.role.i18nKey(), RCols.role.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.userAttributeKey.i18nKey(), RCols.userAttributeKey.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.userAttributeValue.i18nKey(), RCols.userAttributeValue.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.landingPage.i18nKey(), RCols.landingPage.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.landingPageChooser.i18nKey(), RCols.landingPageChooser.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("up", -1, "up", new StaticFlexiCellRenderer("", "up", "o_icon o_icon-lg o_icon_move_up", translate("up"))));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("down", -1, "down", new StaticFlexiCellRenderer("", "down", "o_icon o_icon-lg o_icon_move_down", translate("down"))));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("add", translate("add"), "add"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("delete", translate("delete"), "delete"));
    // pack the rules
    Rules rules = lpModule.getRules();
    List<Rule> ruleList = new ArrayList<>(rules.getRules());
    if (ruleList.isEmpty()) {
        ruleList.add(new Rule());
    }
    List<RuleWrapper> wrappers = new ArrayList<>();
    int i = 0;
    for (Rule rule : ruleList) {
        wrappers.add(initRuleWrapper(++i, rule, formLayout));
    }
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("rules", wrappers);
    }
    model = new RulesDataModel(columnsModel, wrappers);
    tableEl = uifactory.addTableElement(getWindowControl(), "rules", model, getTranslator(), formLayout);
    tableEl.setCustomizeColumns(false);
    tableEl.setRendererType(FlexiTableRendererType.classic);
    FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add("buttons", buttonLayout);
    saveButton = uifactory.addFormSubmitButton("save", buttonLayout);
}
Also used : StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) ArrayList(java.util.ArrayList) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Rule(org.olat.admin.landingpages.model.Rule) Rules(org.olat.admin.landingpages.model.Rules) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Example 3 with Rules

use of org.olat.admin.landingpages.model.Rules in project openolat by klemens.

the class LandingPagesAdminController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    setFormTitle("landingpages.title");
    // add the table
    FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel();
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.position.i18nKey(), RCols.position.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.role.i18nKey(), RCols.role.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.userAttributeKey.i18nKey(), RCols.userAttributeKey.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.userAttributeValue.i18nKey(), RCols.userAttributeValue.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.landingPage.i18nKey(), RCols.landingPage.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(RCols.landingPageChooser.i18nKey(), RCols.landingPageChooser.ordinal()));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("up", -1, "up", new StaticFlexiCellRenderer("", "up", "o_icon o_icon-lg o_icon_move_up", translate("up"))));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("down", -1, "down", new StaticFlexiCellRenderer("", "down", "o_icon o_icon-lg o_icon_move_down", translate("down"))));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("add", translate("add"), "add"));
    columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("delete", translate("delete"), "delete"));
    // pack the rules
    Rules rules = lpModule.getRules();
    List<Rule> ruleList = new ArrayList<>(rules.getRules());
    if (ruleList.isEmpty()) {
        ruleList.add(new Rule());
    }
    List<RuleWrapper> wrappers = new ArrayList<>();
    int i = 0;
    for (Rule rule : ruleList) {
        wrappers.add(initRuleWrapper(++i, rule, formLayout));
    }
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        layoutCont.contextPut("rules", wrappers);
    }
    model = new RulesDataModel(columnsModel, wrappers);
    tableEl = uifactory.addTableElement(getWindowControl(), "rules", model, getTranslator(), formLayout);
    tableEl.setCustomizeColumns(false);
    tableEl.setRendererType(FlexiTableRendererType.classic);
    FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
    formLayout.add("buttons", buttonLayout);
    saveButton = uifactory.addFormSubmitButton("save", buttonLayout);
}
Also used : StaticFlexiCellRenderer(org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer) ArrayList(java.util.ArrayList) FlexiTableColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) Rule(org.olat.admin.landingpages.model.Rule) Rules(org.olat.admin.landingpages.model.Rules) DefaultFlexiColumnModel(org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)

Example 4 with Rules

use of org.olat.admin.landingpages.model.Rules in project openolat by klemens.

the class LandingPagesAdminController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    int rowCount = model.getRowCount();
    List<Rule> ruleList = new ArrayList<Rule>(rowCount);
    for (int i = 0; i < rowCount; i++) {
        ruleList.add(model.getObject(i).save());
    }
    Rules rules = new Rules();
    rules.setRules(ruleList);
    lpModule.setRules(rules);
}
Also used : ArrayList(java.util.ArrayList) Rule(org.olat.admin.landingpages.model.Rule) Rules(org.olat.admin.landingpages.model.Rules)

Example 5 with Rules

use of org.olat.admin.landingpages.model.Rules in project OpenOLAT by OpenOLAT.

the class LandingPagesAdminController method formOK.

@Override
protected void formOK(UserRequest ureq) {
    int rowCount = model.getRowCount();
    List<Rule> ruleList = new ArrayList<Rule>(rowCount);
    for (int i = 0; i < rowCount; i++) {
        ruleList.add(model.getObject(i).save());
    }
    Rules rules = new Rules();
    rules.setRules(ruleList);
    lpModule.setRules(rules);
}
Also used : ArrayList(java.util.ArrayList) Rule(org.olat.admin.landingpages.model.Rule) Rules(org.olat.admin.landingpages.model.Rules)

Aggregations

Rule (org.olat.admin.landingpages.model.Rule)6 Rules (org.olat.admin.landingpages.model.Rules)6 ArrayList (java.util.ArrayList)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)2 DefaultFlexiColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.DefaultFlexiColumnModel)2 FlexiTableColumnModel (org.olat.core.gui.components.form.flexible.impl.elements.table.FlexiTableColumnModel)2 StaticFlexiCellRenderer (org.olat.core.gui.components.form.flexible.impl.elements.table.StaticFlexiCellRenderer)2