Example #1
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'
Example #2
0
    def __init__(self, view):
        super().__init__(view, 'simple_form')
        self.use_layout(FormLayout())
        if self.exception:
            self.layout.add_alert_for_domain_exception(self.exception)

        domain_object = self.get_or_create_domain_object()

        link = self.add_child(
            A(view, Url('/'), description='Open another tab...'))
        link.set_attribute('target', '_blank')
        self.add_child(
            P(view,
              text=
              '...and increment the value there. Come back here and submit the value. A Concurrency error will be shown'
              ))

        #Your own widget that tracks changes
        self.add_child(MyConcurrencyWidget(view, domain_object))

        self.layout.add_input(
            TextInput(self, domain_object.fields.some_field_value))
        self.define_event_handler(domain_object.events.submit)
        self.add_child(Button(self, domain_object.events.submit))
        self.define_event_handler(domain_object.events.increment)
        self.add_child(Button(self, domain_object.events.increment))
Example #3
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'))
Example #4
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'))
Example #5
0
    def __init__(self, view, account_management_interface):
        self.account_management_interface = account_management_interface
        super().__init__(view, 'choose_password')

        if self.exception:
            self.add_child(
                Alert(view, self.exception.as_user_message(), 'warning'))

        inputs = self.add_child(
            FieldSet(view, legend_text=_('Choose a new password'))).use_layout(
                FormLayout())
        inputs.layout.add_input(
            TextInput(self, account_management_interface.fields.email))
        inputs.layout.add_input(
            TextInput(self, account_management_interface.fields.secret))
        inputs.layout.add_input(
            PasswordInput(self, account_management_interface.fields.password))
        inputs.layout.add_input(
            PasswordInput(self,
                          account_management_interface.fields.repeat_password))

        actions = self.add_child(ActionButtonGroup(view))
        btn = actions.add_child(
            Button(self,
                   account_management_interface.events.choose_password_event))
        btn.use_layout(ButtonLayout(style='primary'))
Example #6
0
    def __init__(self, view, event_channel_name, account_management_interface):
        self.account_management_interface = account_management_interface
        super().__init__(view, event_channel_name)

        if self.exception:
            self.add_child(
                Alert(view, self.exception.as_user_message(), 'warning'))

        identification_inputs = self.add_child(
            FieldSet(view,
                     legend_text=_(
                         'Please supply the following details'))).use_layout(
                             FormLayout())

        identification_inputs.layout.add_input(
            TextInput(self, account_management_interface.fields.email))
        identification_inputs.layout.add_input(
            TextInput(self, account_management_interface.fields.secret))
        identification_inputs.layout.add_input(
            PasswordInput(self, account_management_interface.fields.password))

        actions = self.add_child(ActionButtonGroup(view))
        btn = actions.add_child(
            Button(self, account_management_interface.events.verify_event))
        btn.use_layout(ButtonLayout(style='primary'))
Example #7
0
    def __init__(self, view, address):
        form_name = 'address_%s' % address.id
        super(AddressBox, self).__init__(view, form_name)
        self.use_layout(FormLayout())

        par = self.add_child(P(view, text='%s: %s ' % (address.name, address.email_address)))
        par.add_child(Button(self, address.events.edit.with_arguments(address_id=address.id)))
Example #8
0
 def add_upload_controls(self):
     controls_panel = self.upload_form.add_child(Div(self.view)).use_layout(FormLayout())
     file_input = controls_panel.layout.add_input(FileInput(self.upload_form.form, self.fields.uploaded_file), hide_label=True)
     
     button_addon = file_input.html_representation.add_child(Div(self.view))
     button_addon.append_class('input-group-append')
     button_addon.add_child(Button(self.upload_form.form, self.events.upload_file, style='secondary', outline=True))
     return controls_panel
Example #9
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
Example #10
0
 def __init__(self, view):
     super().__init__(view, 'aform')
     self.set_attribute('novalidate', 'novalidate')
     self.use_layout(FormLayout())
     self.layout.add_input(TextInput(self, fixture.domain_object.fields.an_attribute))
     self.layout.add_input(TextInput(self, fixture.domain_object.fields.another_attribute))
     self.define_event_handler(fixture.domain_object.events.submit)
     self.add_child(Button(self, fixture.domain_object.events.submit))
Example #11
0
 def __init__(self, view, address):
     form_name = 'address_%s' % address.id  # Forms need unique names!
     super(AddressBox, self).__init__(view, form_name)
     paragraph = self.add_child(
         P(view, text='%s: %s ' % (address.name, address.email_address)))
     paragraph.add_child(
         Button(self,
                address.events.edit.with_arguments(address_id=address.id)))
Example #12
0
 def __init__(self, form, remove_event, persisted_file, css_id=None):
     super().__init__(form.view, css_id=css_id)
     self.set_attribute('class', 'reahl-bootstrap-file-upload-li')
     self.add_child(
         Button(
             form,
             remove_event.with_arguments(filename=persisted_file.filename)))
     self.add_child(Span(self.view, persisted_file.filename))
Example #13
0
 def __init__(self, view):
     super().__init__(view, 'aform')
     self.use_layout(FormLayout())
     self.layout.add_input(
         CheckboxInput(self,
                       fixture.domain_object.fields.an_attribute))
     self.define_event_handler(fixture.domain_object.events.submit)
     self.add_child(
         Button(self, fixture.domain_object.events.submit))
Example #14
0
    def __init__(self, view, address):
        super().__init__(view, 'edit_form')

        grouped_inputs = self.add_child(FieldSet(view, legend_text='Edit address'))
        grouped_inputs.use_layout(FormLayout())
        grouped_inputs.layout.add_input(TextInput(self, address.fields.name))
        grouped_inputs.layout.add_input(TextInput(self, address.fields.email_address))

        grouped_inputs.add_child(Button(self, address.events.update, style='primary'))
Example #15
0
    def __init__(self, view):
        super(RegistrationPendingForm, self).__init__(view, 'register_pending')

        if self.exception:
            self.add_child(Alert(view, self.exception.as_user_message(), 'warning'))
        
        actions = self.add_child(ActionButtonGroup(view, legend_text=_('Re-send registration email')))
        btn = actions.add_child(Button(self, self.user_interface.account_management_interface.events.resend_event))
        btn.use_layout(ButtonLayout(style='primary'))
Example #16
0
    def __init__(self, view):
        super().__init__(view, 'add_form')

        new_address = Address()
        grouped_inputs = self.add_child(FieldSet(view, legend_text='Add an address'))
        grouped_inputs.use_layout(FormLayout())
        grouped_inputs.layout.add_input(TextInput(self, new_address.fields.name))
        grouped_inputs.layout.add_input(TextInput(self, new_address.fields.email_address))

        grouped_inputs.add_child(Button(self, new_address.events.save, style='primary'))
Example #17
0
    def __init__(self, view, address):
        super(EditAddressForm, self).__init__(view, 'edit_form')

        grouped_inputs = self.add_child(FieldSet(view, legend_text='Edit address'))
        grouped_inputs.use_layout(FormLayout())
        grouped_inputs.layout.add_input(TextInput(self, address.fields.name))
        grouped_inputs.layout.add_input(TextInput(self, address.fields.email_address))

        btn = grouped_inputs.add_child(Button(self, address.events.update.with_arguments(address_book_id=address.address_book.id)))
        btn.use_layout(ButtonLayout(style='primary'))
Example #18
0
    def __init__(self, view):
        super(CommentForm, self).__init__(view, 'myform')
        comment = Comment()

        self.use_layout(FormLayout())

        self.layout.add_input(TextInput(self, comment.fields.greyed_out_field))

        self.define_event_handler(comment.events.greyed_out_event)
        self.add_child(Button(self, comment.events.greyed_out_event))
Example #19
0
        def __init__(self, view):
            super().__init__(view, 'myform')
            self.use_layout(FormLayout())
            model_object = ModelObject()

            if self.exception:
                self.layout.add_alert_for_domain_exception(self.exception)

            self.layout.add_input(TextInput(self, model_object.fields.some_field))

            self.define_event_handler(model_object.events.submit_break)
            self.add_child(Button(self, model_object.events.submit_break))
Example #20
0
    def __init__(self, view, account_management_interface):
        super(ResetPasswordForm, self).__init__(view, 'reset_password')

        if self.exception:
            self.add_child(Alert(view, self.exception.as_user_message(), 'warning'))

        inputs = self.add_child(FieldSet(view, legend_text=_('Request a secret key'))).use_layout(FormLayout())
        inputs.layout.add_input(TextInput(self, account_management_interface.fields.email))

        actions = self.add_child(ActionButtonGroup(view))
        btn = actions.add_child(Button(self, account_management_interface.events.reset_password_event))
        btn.use_layout(ButtonLayout(style='primary'))
Example #21
0
    def __init__(self, view):
        super().__init__(view, 'simple_form')
        self.use_layout(FormLayout())
        if self.exception:
            self.layout.add_alert_for_domain_exception(self.exception)

        self.add_child(P(view, text='Press Submit to cause an error'))

        self.domain_object = SimpleDomainObject()

        self.define_event_handler(self.domain_object.events.submit)
        self.add_child(Button(self, self.domain_object.events.submit))
Example #22
0
    def __init__(self, view, accounts):
        super().__init__(view, 'login')
        self.use_layout(FormLayout())

        if self.exception:
            self.layout.add_alert_for_domain_exception(self.exception)

        self.layout.add_input(TextInput(self, accounts.fields.email))
        self.layout.add_input(PasswordInput(self, accounts.fields.password))

        self.define_event_handler(accounts.events.login_event)
        self.add_child(Button(self, accounts.events.login_event, style='primary'))
    def __init__(self, view, tr):
        super(__class__, self).__init__(view, 'address_form')

        inputs = self.add_child(FieldSet(view, legend_text='Enter data then click button'))
        inputs.use_layout(FormLayout())

        inputs.layout.add_input(TextInput(self, tr.fields.input_text))
        inputs.layout.add_input(TextInput(self, tr.fields.separator), help_text='(Regular expression)')
        inputs.layout.add_input(TextInput(self, tr.fields.joiner), help_text='(Character string)')

        button = inputs.add_child(Button(self, tr.events.save))
        button.use_layout(ButtonLayout(style='primary'))
Example #24
0
    def __init__(self, view, address_book):
        super(AddAddressForm, self).__init__(view, 'add_form')

        new_address = Address(address_book=address_book)

        grouped_inputs = self.add_child(FieldSet(view, legend_text='Add an address'))
        grouped_inputs.use_layout(FormLayout())
        grouped_inputs.layout.add_input(TextInput(self, new_address.fields.name))
        grouped_inputs.layout.add_input(TextInput(self, new_address.fields.email_address))

        btn = grouped_inputs.add_child(Button(self, new_address.events.save.with_arguments(address_book_id=address_book.id)))
        btn.use_layout(ButtonLayout(style='primary'))
Example #25
0
    def __init__(self, view, account_management_interface):
        super(RegisterHelpForm, self).__init__(view, 'register_help')

        if self.exception:
            self.add_child(Alert(view, self.exception.as_user_message(), 'warning'))
        
        inputs = self.add_child(FieldSet(view, legend_text=_('Please supply the email address you tried to register with.'))).use_layout(FormLayout())
        inputs.layout.add_input(TextInput(self, account_management_interface.fields.email),
                                help_text=_('Please supply the email address you tried to register with.'))

        actions = self.add_child(ActionButtonGroup(view))
        btn = actions.add_child(Button(self, account_management_interface.events.investigate_event))
        btn.use_layout(ButtonLayout(style='primary'))
Example #26
0
    def __init__(self, view):
        super().__init__(view, 'investment_order_allocation_details_form')
        self.use_layout(FormLayout())

        self.investment_order = InvestmentOrder.for_current_session()
        self.enable_refresh(
            on_refresh=self.investment_order.events.allocation_changed)

        self.add_allocation_controls()
        self.add_allocation_table()

        self.define_event_handler(self.investment_order.events.submit)
        self.add_child(Button(self, self.investment_order.events.submit))
Example #27
0
    def __init__(self, form, investment_order):
        super().__init__(form.view, css_id='investment_allocation_details')
        self.form = form
        self.use_layout(FormLayout())

        self.investment_order = investment_order    
        self.enable_refresh(on_refresh=self.investment_order.events.allocation_changed)

        self.add_allocation_controls()
        self.add_allocation_table()

        self.define_event_handler(self.investment_order.events.submit)
        self.add_child(Button(self.form, self.investment_order.events.submit))
Example #28
0
    def __init__(self, view):
        super(AddAddressForm, self).__init__(view, 'add_form')

        new_address = Address()

        grouped_inputs = self.add_child(FieldSet(view, legend_text=_('Add an address')))
        grouped_inputs.use_layout(FormLayout())
        grouped_inputs.layout.add_input(TextInput(self, new_address.fields.name))
        grouped_inputs.layout.add_input(TextInput(self, new_address.fields.email_address))

        self.define_event_handler(new_address.events.save)
        btn = grouped_inputs.add_child(Button(self, new_address.events.save))
        btn.use_layout(ButtonLayout(style='primary'))
Example #29
0
    def __init__(self, view, accounts):
        super(LoginForm, self).__init__(view, 'login')
        self.use_layout(FormLayout())

        if self.exception:
            self.add_child(Alert(view, self.exception.as_user_message(), 'warning'))

        self.layout.add_input(TextInput(self, accounts.fields.email))
        self.layout.add_input(PasswordInput(self, accounts.fields.password))

        self.define_event_handler(accounts.events.login_event)
        btn = self.add_child(Button(self, accounts.events.login_event))
        btn.use_layout(ButtonLayout(style='primary'))
Example #30
0
 def __init__(self, view, funding_request):
     form_name = 'fund_%s' % funding_request.id  # Forms need unique names!
     super(FundingRequestBox, self).__init__(view, form_name)
     allow_edit_symbol = '…' if funding_request.allow_user_changes else '⏹'
     paragraph = self.add_child(
         P(view,
           text='%s : %s: %s' % (allow_edit_symbol, funding_request.name,
                                 funding_request.email_address)))
     paragraph.add_child(
         Button(
             self,
             funding_request.events.edit.with_arguments(
                 funding_request_id=funding_request.id)))