Projet

Général

Profil

0001-forms-add-list-add-class-to-add-item-widget-45688.patch

Frédéric Péters, 09 août 2020 11:17

Télécharger (1,92 ko)

Voir les différences:

Subject: [PATCH] forms: add list-add class to "add item" widget (#45688)

 tests/test_form_pages.py | 1 +
 wcs/qommon/form.py       | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)
tests/test_form_pages.py
8655 8655
    assert resp.text.count('>Test<') == 1
8656 8656
    assert resp.text.count('>hintblock<') == 1
8657 8657
    assert 'Add another' in resp
8658
    assert resp.html.find('div', {'class': 'list-add'})
8658 8659
    resp = resp.form.submit('f1$add_element')
8659 8660
    assert resp.text.count('>Test<') == 2
8660 8661
    assert resp.text.count('>hintblock<') == 1
wcs/qommon/form.py
237 237

  
238 238

  
239 239
class SubmitWidget(quixote.form.widget.SubmitWidget):
240
    def __init__(self, *args, **kwargs):
241
        self.extra_css_class = kwargs.pop('extra_css_class', None)
242
        super().__init__(*args, **kwargs)
243

  
240 244
    def render_content(self):
241 245
        if self.name in ('cancel', 'previous', 'save-draft'):
242 246
            self.attrs['formnovalidate'] = 'formnovalidate'
......
387 391
        r = TemplateIO(html=True)
388 392
        classnames = '%s widget %s-button %s' % (
389 393
                button.__class__.__name__, button.name,
390
                getattr(button, 'extra_css_class', ''))
394
                getattr(button, 'extra_css_class', None) or '')
391 395
        r += htmltext('<div class="%s">') % classnames
392 396
        r += htmltext('<div class="content">')
393 397
        r += button.render_content()
394
-