Пример #1
0
    def __init__(self, field, vocabulary, request):
        LaunchpadRadioWidget.__init__(self, field, vocabulary, request)

        # Bug tracker widget.
        self.bugtracker = Choice(
            vocabulary="WebBugTracker",
            __name__='bugtracker')
        self.bugtracker_widget = CustomWidgetFactory(BugTrackerPickerWidget)
        setUpWidget(
            self, 'bugtracker', self.bugtracker, IInputWidget,
            prefix=self.name, value=field.context.bugtracker,
            context=field.context)
        self.bugtracker_widget.onKeyPress = (
            "selectWidget('%s.2', event);" % self.name)

        # Upstream email address field and widget.
        ## This is to make email address bug trackers appear
        ## separately from the main bug tracker list.
        self.upstream_email_address = StrippedTextLine(
            required=False, constraint=email_validator,
            __name__='upstream_email_address')
        self.upstream_email_address_widget = (
            CustomWidgetFactory(StrippedTextWidget))
        setUpWidget(
            self, 'upstream_email_address', self.upstream_email_address,
            IInputWidget, prefix=self.name, value='',
            context=self.upstream_email_address.context)
        ## Select the corresponding radio option automatically if
        ## the user starts typing.
        if self.upstream_email_address_widget.extra is None:
            self.upstream_email_address_widget.extra = ''
        self.upstream_email_address_widget.extra += (
            ''' onkeypress="selectWidget('%s.3', event);"\n''' % self.name)
Пример #2
0
    def __init__(self, field, vocabulary, request):
        # Create the vocabulary and pass that to the radio button
        # constructor.
        self.suggestion_vocab = self._generateSuggestionVocab(
            field.context, vocabulary)

        LaunchpadRadioWidget.__init__(
            self, field, self.suggestion_vocab, request)

        self.other_selection_widget = getMultiAdapter(
            (field, request), IInputWidget)
        setUpWidget(
            self, 'other_selection', field, IInputWidget,
            prefix=self.name, context=field.context)

        # If there are suggestions to show explicitly, then we want to select
        # the 'Other' selection item when the user chooses a non-suggested
        # value.
        if self._shouldRenderSuggestions():
            self._autoselectOther()
Пример #3
0
    def __init__(self, field, vocabulary, request):
        LaunchpadRadioWidget.__init__(self, field, vocabulary, request)

        # Bug tracker widget.
        self.bugtracker = Choice(vocabulary="WebBugTracker",
                                 __name__='bugtracker')
        self.bugtracker_widget = CustomWidgetFactory(BugTrackerPickerWidget)
        setUpWidget(self,
                    'bugtracker',
                    self.bugtracker,
                    IInputWidget,
                    prefix=self.name,
                    value=field.context.bugtracker,
                    context=field.context)
        self.bugtracker_widget.onKeyPress = ("selectWidget('%s.2', event);" %
                                             self.name)

        # Upstream email address field and widget.
        ## This is to make email address bug trackers appear
        ## separately from the main bug tracker list.
        self.upstream_email_address = StrippedTextLine(
            required=False,
            constraint=email_validator,
            __name__='upstream_email_address')
        self.upstream_email_address_widget = (
            CustomWidgetFactory(StrippedTextWidget))
        setUpWidget(self,
                    'upstream_email_address',
                    self.upstream_email_address,
                    IInputWidget,
                    prefix=self.name,
                    value='',
                    context=self.upstream_email_address.context)
        ## Select the corresponding radio option automatically if
        ## the user starts typing.
        if self.upstream_email_address_widget.extra is None:
            self.upstream_email_address_widget.extra = ''
        self.upstream_email_address_widget.extra += (
            ''' onkeypress="selectWidget('%s.3', event);"\n''' % self.name)
Пример #4
0
    def hasInput(self):
        """Is there any input for the widget.

        We need to defer the call to the other widget when either there are no
        terms in the vocabulary or the other radio button was selected.
        """
        if not self._shouldRenderSuggestions():
            return self.other_selection_widget.hasInput()
        else:
            has_input = LaunchpadRadioWidget.hasInput(self)
            if has_input:
                if self._getFormInput() == "other":
                    return self.other_selection_widget.hasInput()
            return has_input
Пример #5
0
    def __init__(self, field, vocabulary, request):
        # Create the vocabulary and pass that to the radio button
        # constructor.
        self.suggestion_vocab = self._generateSuggestionVocab(
            field.context, vocabulary)

        LaunchpadRadioWidget.__init__(self, field, self.suggestion_vocab,
                                      request)

        self.other_selection_widget = getMultiAdapter((field, request),
                                                      IInputWidget)
        setUpWidget(self,
                    'other_selection',
                    field,
                    IInputWidget,
                    prefix=self.name,
                    context=field.context)

        # If there are suggestions to show explicitly, then we want to select
        # the 'Other' selection item when the user chooses a non-suggested
        # value.
        if self._shouldRenderSuggestions():
            self._autoselectOther()
Пример #6
0
    def hasInput(self):
        """Is there any input for the widget.

        We need to defer the call to the other widget when either there are no
        terms in the vocabulary or the other radio button was selected.
        """
        if not self._shouldRenderSuggestions():
            return self.other_selection_widget.hasInput()
        else:
            has_input = LaunchpadRadioWidget.hasInput(self)
            if has_input:
                if self._getFormInput() == "other":
                    return self.other_selection_widget.hasInput()
            return has_input
Пример #7
0
 def __call__(self):
     """Don't render the radio buttons if only one choice."""
     if not self._shouldRenderSuggestions():
         return self.other_selection_widget()
     else:
         return LaunchpadRadioWidget.__call__(self)
Пример #8
0
 def __call__(self):
     """Don't render the radio buttons if only one choice."""
     if not self._shouldRenderSuggestions():
         return self.other_selection_widget()
     else:
         return LaunchpadRadioWidget.__call__(self)