def __init__(self, form, investment_order):
        super().__init__(form.view, css_id='investor_details_section')
        self.enable_refresh()
        self.use_layout(FormLayout())

        investor_info = self.add_child(
            FieldSet(self.view, legend_text='Investor information'))
        investor_info.use_layout(FormLayout())

        if investment_order.new_or_existing == 'new':
            investor_info.layout.add_input(
                TextInput(form, investment_order.fields.name))
            investor_info.layout.add_input(
                TextInput(form, investment_order.fields.surname))
            self.add_child(
                IDDocumentSection(form, investment_order.id_document))

        elif investment_order.new_or_existing == 'existing':
            investor_info.layout.add_input(
                TextInput(form,
                          investment_order.fields.existing_account_number))

        self.layout.add_input(
            CheckboxInput(form,
                          investment_order.fields.agreed_to_terms,
                          refresh_widget=self))
        if investment_order.agreed_to_terms:
            self.add_child(AllocationDetailSection(form, investment_order))
Exemple #2
0
 def create_form_group(self, html_input):
     if isinstance(html_input, RadioButtonSelectInput):
         form_group = self.widget.add_child(FieldSet(self.view))
     else:
         form_group = self.widget.add_child(Div(self.view))
     form_group.append_class('form-group')
     html_input.add_attribute_source(reahl.web.ui.ValidationStateAttributes(html_input,
                                                          error_class='is-invalid',
                                                          success_class='is-valid'))
     return form_group
    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'))
Exemple #4
0
    def add_allocation_controls(self):
        allocation_controls = self.add_child(FieldSet(self.view, legend_text='Investment allocation'))
        allocation_controls.use_layout(FormLayout())

        if self.form.exception:
            self.layout.add_alert_for_domain_exception(self.form.exception, form=self.form, unique_name='details_section')
        
        total_amount_input = TextInput(self.form, self.investment_order.fields.amount, refresh_widget=self)
        allocation_controls.layout.add_input(total_amount_input)

        amount_or_percentage_radio = RadioButtonSelectInput(self.form, self.investment_order.fields.amount_or_percentage, refresh_widget=self)
        allocation_controls.layout.add_input(amount_or_percentage_radio)
Exemple #5
0
    def __init__(self, view):
        super().__init__(view, 'address_form')

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

        button = inputs.add_child(Button(self, new_address.events.save))
        button.use_layout(ButtonLayout(style='primary'))
Exemple #6
0
    def __init__(self, view):
        super().__init__(view, 'myform')

        new_comment = Comment()
        grouped_inputs = self.add_child(
            FieldSet(view, legend_text='Leave a comment'))
        grouped_inputs.use_layout(FormLayout())
        grouped_inputs.layout.add_input(
            TextInput(self, new_comment.fields.email_address))
        grouped_inputs.layout.add_input(
            TextInput(self, new_comment.fields.text))

        attachments = self.add_child(FieldSet(view,
                                              legend_text='Attach files'))
        attachments.use_layout(FormLayout())
        attachments.layout.add_input(FileUploadInput(
            self, new_comment.fields.uploaded_files),
                                     hide_label=True)

        self.define_event_handler(new_comment.events.submit)
        self.add_child(
            ButtonInput(self, new_comment.events.submit, style='primary'))
Exemple #7
0
    def __init__(self, view):
        super().__init__(view, 'dynamic_content_error_form')
        self.use_layout(FormLayout())
        self.calculator = Calculator.for_current_session()

        try:
            self.enable_refresh(
                on_refresh=self.calculator.events.inputs_changed)
        except DomainException as ex:
            self.layout.add_alert_for_domain_exception(ex)

        controls = self.add_child(
            FieldSet(view).use_layout(InlineFormLayout()))
        self.add_inputs(controls)
        self.display_result(controls)
Exemple #8
0
    def __init__(self, view):
        super().__init__(view, 'new_investment_form')
        self.enable_refresh()
        self.use_layout(FormLayout())

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

        investment_order = InvestmentOrder.for_current_session()
        type_of_investor = self.add_child(FieldSet(view, legend_text='Introduction'))
        type_of_investor.use_layout(FormLayout())

        new_or_existing_radio = RadioButtonSelectInput(self, investment_order.fields.new_or_existing, refresh_widget=self)
        type_of_investor.layout.add_input(new_or_existing_radio)

        if investment_order.new_or_existing:
            self.add_child(InvestorDetailsSection(self, investment_order))
Exemple #9
0
    def add_allocation_controls(self):
        allocation_controls = self.add_child(
            FieldSet(self.view, legend_text='Investment allocation'))
        allocation_controls.use_layout(FormLayout())

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

        total_amount_input = TextInput(self,
                                       self.investment_order.fields.amount,
                                       refresh_widget=self)
        allocation_controls.layout.add_input(total_amount_input)

        amount_or_percentage_radio = RadioButtonSelectInput(
            self,
            self.investment_order.fields.amount_or_percentage,
            refresh_widget=self)
        allocation_controls.layout.add_input(amount_or_percentage_radio)
Exemple #10
0
    def __init__(self, view):
        super().__init__(view, 'my_cool_form')

        calculator = Calculator.for_current_session()
        self.enable_refresh(on_refresh=calculator.events.input_changed)

        grouped_inputs = self.add_child(
            FieldSet(view, legend_text='Calculator'))
        grouped_inputs.use_layout(InlineFormLayout())

        grouped_inputs.layout.add_input(
            TextInput(self, calculator.fields.operandA,
                      refresh_widget=self)).use_layout(
                          MarginLayout(2, right=True))
        grouped_inputs.layout.add_input(
            SelectInput(self, calculator.fields.operandB, refresh_widget=self))

        self.add_child(P(self.view, text='Sum: %s' % calculator.sum))