Exemplo n.º 1
0
 def make_edit_link(view, funding_request):
     form = Form(view, 'edit_%s' % funding_request.id)
     form.add_child(
         Button(
             form,
             funding_request.events.edit.with_arguments(
                 funding_request_id=funding_request.id)))
     return form
Exemplo n.º 2
0
def test_button_layouts(web_fixture):
    """A ButtonLayout can be be used on a Button to customise various visual effects."""

    event = Event(label='click me')
    event.bind('event', web_fixture)
    form = Form(web_fixture.view, 'test')
    form.define_event_handler(event)

    # Case: the defaults
    button = Button(form, event).use_layout(ButtonLayout())

    tester = WidgetTester(button)
    [button] = tester.xpath(XPath.button_labelled('click me'))
    assert button.attrib['class'] == 'btn reahl-primitiveinput'

    # Case: possible effects
    form = Form(web_fixture.view, 'test')
    form.define_event_handler(event)
    button = Button(form, event).use_layout(
        ButtonLayout(style='secondary', size='sm', active=True, wide=True))

    tester = WidgetTester(button)
    [button] = tester.xpath(XPath.button_labelled('click me'))
    assert button.attrib[
        'class'] == 'active btn btn-block btn-secondary btn-sm reahl-primitiveinput'
Exemplo n.º 3
0
    def __init__(self, view, address_book_ui):
        super(AddressBookPanel, self).__init__(view)
        self.rows = self.initialise_rows()

        self.add_child(H(view, 1, text='Addresses'))

        form = self.add_child(Form(view, 'address_table_form'))
        self.define_event_handler(self.events.delete_selected)

        def make_link_widget(view, row):
            return A.from_bookmark(
                view,
                address_book_ui.get_edit_bookmark(row.address,
                                                  description='Edit'))

        def make_checkbox_widget(view, row):
            return PrimitiveCheckboxInput(form, row.fields.selected_by_user)

        def make_delete_selected_button(view):
            return Button(form, self.events.delete_selected)

        columns = [
            StaticColumn(Field(label='Name'), 'name'),
            StaticColumn(EmailField(label='Email'), 'email_address'),
            DynamicColumn('', make_link_widget),
            DynamicColumn(make_delete_selected_button, make_checkbox_widget)
        ]

        table = Table(view,
                      caption_text='All my friends',
                      summary='Summary for screen reader')
        table.use_layout(TableLayout(striped=True))
        table.with_data(columns, self.rows)

        form.add_child(table)
Exemplo n.º 4
0
            def __init__(self, view):
                super(PopupTestPanel, self).__init__(view)
                popup_a = self.add_child(PopupA(view, view.as_bookmark(), '#contents'))
                popup_contents = self.add_child(P(view, text='this is the content of the popup'))
                popup_contents.set_id('contents')
                form = self.add_child(Form(view, 'aform')).use_layout(FormLayout())
                checkbox = form.layout.add_input(CheckboxInput(form, self.fields.field))

                popup_a.add_js_button('Checkit', CheckCheckboxScript(checkbox))
Exemplo n.º 5
0
 def create_contents(self):
     div = self.add_child(Div(self.view))
     self.set_html_representation(div)
     div.add_child(P(self.view, text=self.task.title))
     form = div.add_child(Form(self.view, 'task_form'))
     form.use_layout(FormLayout())
     defer_btn = form.add_child(Button(form, self.user_interface.workflow_interface.events.defer_task))
     defer_btn.use_layout(ButtonLayout(style='primary'))
     release_btn = form.add_child(Button(form, self.user_interface.workflow_interface.events.release_task.with_arguments(task=self.task)))
     release_btn.use_layout(ButtonLayout(style='primary'))
Exemplo n.º 6
0
 def __init__(self, view, task):
     super(TaskBox, self).__init__(view)
     self.task = task
     self.add_child(P(view, text=self.task.title))
     form = self.add_child(Form(view, 'task_%s' % task.id))
     form.use_layout(FormLayout())
     take_btn = form.layout.add_input(Button(form, self.user_interface.workflow_interface.events.take_task.with_arguments(task=self.task)), hide_label=True)
     take_btn.use_layout(ButtonLayout(style='primary'))
     go_to_btn = form.layout.add_input(Button(form, self.user_interface.workflow_interface.events.go_to_task.with_arguments(task=self.task)), hide_label=True)
     go_to_btn.use_layout(ButtonLayout(style='primary'))
Exemplo n.º 7
0
def test_dropdown_menu_with_form(web_fixture):
    """You can add form to a DropdownMenu."""
    sub_menu = DropdownMenu(web_fixture.view)

    my_form = Form(web_fixture.view, 'myform')
    form = sub_menu.add_form(my_form)

    assert form is my_form
    [form] = sub_menu.html_representation.children
    assert 'px-4' in form.get_attribute('class').split()
    assert 'py-3' in form.get_attribute('class').split()
Exemplo n.º 8
0
def disabled_state(fixture):
    """Visible cues are inserted to indicate that inputs are disabled. """
    form = Form(fixture.view, 'test').use_layout(FormLayout())
    field = fixture.field
    field.bind('field', fixture)

    form.layout.add_input(TextInput(form, field))

    tester = WidgetTester(form)

    [form_group] = tester.xpath(FormLayoutFixture.form_group_xpath)
    if fixture.expects_disabled_class:
        vassert('disabled ' in form_group.attrib['class'])
    else:
        vassert('disabled' not in form_group.attrib['class'])
Exemplo n.º 9
0
def test_choice_disabled_state(web_fixture, disabled_scenarios):
    """Visible cues are inserted to indicate that inputs are disabled. """
    fixture = disabled_scenarios

    form = Form(web_fixture.view, 'test')
    field = fixture.field
    field.bind('field', fixture)

    container = Div(web_fixture.view).use_layout(ChoicesLayout())
    container.layout.add_choice(PrimitiveCheckboxInput(form, field))

    [checkbox_container] = container.children
    [checkbox_input, label] = checkbox_container.children
    checkbox_container_classes = checkbox_container.get_attribute('class').split(' ')
    if fixture.expects_disabled_class:
        assert 'disabled' in checkbox_container_classes
        assert checkbox_input.html_representation.get_attribute('disabled') == 'disabled'
    else:
        assert 'disabled' not in checkbox_container_classes
        with expected(KeyError):
            checkbox_input.html_representation.get_attribute('disabled')
Exemplo n.º 10
0
 def new_form(self):
     return Form(self.web_fixture.view, 'myform')
Exemplo n.º 11
0
 def new_form(self):
     return Form(self.view, 'test')
Exemplo n.º 12
0
 def new_form(self):
     return Form(self.view, 'myform')
Exemplo n.º 13
0
 def new_form(self):
     return Form(self.web_fixture.view, 'test')