Search in sources :

Example 16 with Form

use of com.enonic.xp.form.Form in project xp by enonic.

the class IndexConfigVisitorTest method htmlArea_in_optionSet.

@Test
public void htmlArea_in_optionSet() throws Exception {
    FormOptionSet formOptionSet = FormOptionSet.create().name("myOptionSet").label("My option set").helpText("Option set help text").addOptionSetOption(FormOptionSetOption.create().name("myOptionSetOption1").label("option label1").helpText("Option help text").addFormItem(Input.create().name("myTextLine1").label("textArea").inputType(InputTypeName.TEXT_AREA).build()).build()).addOptionSetOption(FormOptionSetOption.create().name("myOptionSetOption2").label("option label2").helpText("Option help text").addFormItem(Input.create().name("htmlArea").label("htmlArea").inputType(InputTypeName.HTML_AREA).build()).build()).build();
    Form form = Form.create().addFormItem(formOptionSet).build();
    final PatternIndexConfigDocument.Builder builder = PatternIndexConfigDocument.create();
    final IndexConfigVisitor validationVisitor = new IndexConfigVisitor("parent", builder);
    validationVisitor.traverse(form);
    final PatternIndexConfigDocument document = builder.build();
    assertEquals(1, document.getPathIndexConfigs().size());
    assertEquals("htmlStripper", document.getConfigForPath(PropertyPath.from("parent.myoptionset.myoptionsetoption2.htmlArea")).getIndexValueProcessors().get(0).getName());
}
Also used : FormOptionSet(com.enonic.xp.form.FormOptionSet) Form(com.enonic.xp.form.Form) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 17 with Form

use of com.enonic.xp.form.Form in project xp by enonic.

the class PageConfigProcessorTest method test_page_config_form_with_html_area_simple.

@Test
public void test_page_config_form_with_html_area_simple() throws Exception {
    Input myTextLine = Input.create().name("htmlArea").inputType(InputTypeName.HTML_AREA).label("htmlArea").required(true).build();
    Form form = Form.create().addFormItem(myTextLine).build();
    final PatternIndexConfigDocument result = processForm(form);
    assertEquals(6, result.getPathIndexConfigs().size());
    assertTrue(result.getPathIndexConfigs().contains(PathIndexConfig.create().path(PropertyPath.from(COMPONENTS, PAGE, CONFIG, descriptorKey.getApplicationKey().toString(), descriptorKey.getName())).indexConfig(IndexConfig.BY_TYPE).build()));
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(COMPONENTS, PAGE, CONFIG, descriptorKey.getApplicationKey().toString(), descriptorKey.getName(), "htmlarea")).getIndexValueProcessors().get(0).getName());
}
Also used : Input(com.enonic.xp.form.Input) Form(com.enonic.xp.form.Form) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 18 with Form

use of com.enonic.xp.form.Form in project xp by enonic.

the class DataConfigProcessorTest method test_data_form_with_html_area.

@Test
public void test_data_form_with_html_area() throws Exception {
    Input myTextLine = Input.create().name("htmlArea").inputType(InputTypeName.HTML_AREA).label("htmlArea").required(true).build();
    Form form = Form.create().addFormItem(myTextLine).build();
    final PatternIndexConfigDocument result = processForm(form);
    assertEquals(2, result.getPathIndexConfigs().size());
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(DATA + ".htmlArea")).getIndexValueProcessors().get(0).getName());
}
Also used : Input(com.enonic.xp.form.Input) Form(com.enonic.xp.form.Form) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 19 with Form

use of com.enonic.xp.form.Form in project xp by enonic.

the class PageRegionsConfigProcessorTest method test_complex_component_config.

@Test
public void test_complex_component_config() throws Exception {
    final PropertyTree config = new PropertyTree();
    final PropertySet items = config.addSet("items");
    items.addStrings("input", "a", "b", "c");
    final Page page = Page.create().regions(PageRegions.create().add(Region.create().name("region1").add(PartComponent.create().descriptor(DescriptorKey.from("appKey1:partName1")).config(new PropertyTree()).build()).add(LayoutComponent.create().descriptor(DescriptorKey.from("appKey2:layoutName")).config(new PropertyTree()).regions(LayoutRegions.create().add(Region.create().name("region").add(PartComponent.create().descriptor(DescriptorKey.from("appKey3:partName2")).config(new PropertyTree()).build()).build()).build()).build()).build()).build()).build();
    final Form form = Form.create().addFormItem(FormItemSet.create().name("items").addFormItem(Input.create().name("input").label("input").inputType(InputTypeName.TEXT_LINE).occurrences(0, 5).build()).build()).build();
    final PatternIndexConfigDocument result = processPage(page, Arrays.asList(form, form).listIterator(), singletonList(form).listIterator());
    assertEquals(8, result.getPathIndexConfigs().size());
    assertEquals(IndexConfig.BY_TYPE, result.getConfigForPath(PropertyPath.from("components.part.config.appKey1.partName1")));
    assertEquals(IndexConfig.BY_TYPE, result.getConfigForPath(PropertyPath.from("components.part.config.appKey2.layoutName")));
    assertEquals(IndexConfig.BY_TYPE, result.getConfigForPath(PropertyPath.from("components.part.config.appkey3.partname2")));
}
Also used : Form(com.enonic.xp.form.Form) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) Page(com.enonic.xp.page.Page) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Example 20 with Form

use of com.enonic.xp.form.Form in project xp by enonic.

the class XDataConfigProcessorTest method test_data_form_with_html_area.

@Test
public void test_data_form_with_html_area() throws Exception {
    Input myTextLine = Input.create().name("htmlArea").inputType(InputTypeName.HTML_AREA).label("htmlArea").required(true).build();
    Form form = Form.create().addFormItem(myTextLine).build();
    final PatternIndexConfigDocument result = processForms(form);
    assertEquals(2, result.getPathIndexConfigs().size());
    assertEquals("htmlStripper", result.getConfigForPath(PropertyPath.from(EXTRA_DATA + ".appname.localname0.htmlarea")).getIndexValueProcessors().get(0).getName());
}
Also used : Input(com.enonic.xp.form.Input) Form(com.enonic.xp.form.Form) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Aggregations

Form (com.enonic.xp.form.Form)79 Test (org.junit.jupiter.api.Test)59 PropertyTree (com.enonic.xp.data.PropertyTree)36 FormDefaultValuesProcessor (com.enonic.xp.form.FormDefaultValuesProcessor)17 Input (com.enonic.xp.form.Input)17 FormItemSet (com.enonic.xp.form.FormItemSet)13 FormOptionSet (com.enonic.xp.form.FormOptionSet)11 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)10 ContentType (com.enonic.xp.schema.content.ContentType)8 FormOptionSetOption (com.enonic.xp.form.FormOptionSetOption)7 AbstractSchemaTest (com.enonic.xp.core.impl.schema.AbstractSchemaTest)5 PropertySet (com.enonic.xp.data.PropertySet)5 Content (com.enonic.xp.content.Content)4 CreateContentParams (com.enonic.xp.content.CreateContentParams)4 EditableContent (com.enonic.xp.content.EditableContent)4 MacroKey (com.enonic.xp.macro.MacroKey)4 XData (com.enonic.xp.schema.xdata.XData)4 SiteConfigs (com.enonic.xp.site.SiteConfigs)4 ContentPath (com.enonic.xp.content.ContentPath)3 Page (com.enonic.xp.page.Page)3