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());
}
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());
}
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());
}
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")));
}
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());
}
Aggregations