Skip to content

Commit

Permalink
Merge branch 'release-2.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
abidibo committed Feb 23, 2021
2 parents a468da8 + 26f7554 commit 91289d9
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 26 deletions.
4 changes: 2 additions & 2 deletions baton/static/baton/app/dist/baton.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion baton/static/baton/app/dist/baton.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion baton/static/baton/app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion baton/static/baton/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "baton",
"version": "2.1.2",
"version": "2.1.3",
"description": "Django Baton App",
"main": "index.js",
"scripts": {
Expand Down
26 changes: 11 additions & 15 deletions baton/static/baton/app/src/core/Tabs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import $ from 'jquery'
import bootstrap from 'bootstrap/dist/js/bootstrap'

let Tabs = {
/**
Expand Down Expand Up @@ -42,10 +43,9 @@ let Tabs = {
.append($('<a />', {
'class': 'nav-link' + (this.mainOrder === 0 ? ' active' : ''),
'data-bs-toggle': 'tab',
href: '#main-tab'
}).text(this.main.children('h2').hide().text()).on('click', function () {
location.hash = $(this).attr('href')
}))
'data-bs-target': '#main-tab'
// href: '#main-tab'
}).text(this.main.children('h2').hide().text()))
.appendTo(this.nav)

this.tabsEl.forEach((el) => {
Expand Down Expand Up @@ -73,10 +73,9 @@ let Tabs = {
.append($('<a />', {
'class': 'nav-link ' + (currentOrder === 0 ? ' active' : ''),
'data-bs-toggle': 'tab',
href: '#' + el
}).text(domEl.find('h2:first-child').first().hide().text()).on('click', function () {
location.hash = $(this).attr('href')
}))
'data-bs-target': '#' + el
// href: '#' + el
}).text(domEl.find('h2:first-child').first().hide().text()))
.appendTo(this.nav)
currentOrder += 1
if (currentOrder === this.mainOrder) {
Expand All @@ -86,11 +85,6 @@ let Tabs = {

this.main.before(this.nav)

// do not preserve hash if pressing save and add another
$('input[name="_addanother"]').on('click', function () {
location.hash = ''
})

$('a[data-bs-toggle="tab"]').on('shown.bs.tab', function (e) {
$('[title]:not(iframe)').tooltip()
})
Expand Down Expand Up @@ -146,14 +140,16 @@ let Tabs = {
for (let i = 0, len = els.length; i < len; i++) {
let el = els[i]
if (el.find('.form-row.errors, .errorlist').length) {
this.nav.find('a[href="#' + el.attr('data-baton-tab') + '"]').trigger('click')
const tab = new bootstrap.Tab(this.nav.find('a[data-bs-target="#' + el.attr('data-baton-tab') + '"]')[0])
tab.show()
break
}
}
},
checkHash: function () {
if (location.hash) {
this.nav.find('a[href="' + location.hash + '"]').trigger('click')
const tab = new bootstrap.Tab(this.nav.find('a[data-bs-target="' + location.hash + '"]')[0])
tab.show()
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion baton/static/baton/app/src/styles/_changeform.scss
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,17 @@
.nav-link {
background: #fafafa;
border: 1px solid #dee2e6;
font-weight: bold;
color: #999;
cursor: pointer;

&:hover {
color: $gray-700;
text-decoration: none;
}

&.active {
font-weight: bold;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
# built documents.
#
# The short X.Y version.
version = u'2.1.2'
version = u'2.1.3'
# The full version, including alpha/beta/rc tags.
release = u'2.1.2'
release = u'2.1.3'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name='django-baton',
version='2.1.2',
version='2.1.3',
packages=['baton', 'baton.autodiscover', 'baton.templatetags'],
include_package_data=True,
license='MIT License',
Expand Down
41 changes: 39 additions & 2 deletions testapp/app/app/tests/test_e2e_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
os.environ['WDM_LOG_LEVEL'] = '0'


class TestBatonInputFilter(TestCase):
class TestBatonTabs(TestCase):
def setUp(self):
chrome_options = Options()
chrome_options.add_argument("--headless")
Expand Down Expand Up @@ -96,6 +96,43 @@ def test_tabs(self):
add_button = inlines.find_element_by_css_selector('.add-row a')
self.assertEqual(add_button.is_displayed(), True)
time.sleep(3) # fade
add_button.click()
# try except because first click will fail in selenium
try:
add_button.click()
except:
add_button.click()
time.sleep(10)
attachments_rows = inlines.find_elements_by_css_selector('.dynamic-attachments')
self.assertEqual(len(attachments_rows), 3)

def test_detect_tab_error(self):
# Wait until baton is ready
wait = WebDriverWait(self.driver, 10)
wait.until(element_has_css_class((By.TAG_NAME, 'body'), "baton-ready"))
time.sleep(2)

# tabs number
tabs_li = self.driver.find_elements_by_css_selector(
'.nav-tabs .nav-item')

tabs_li[3].click() # change tab attachments
time.sleep(2) # fade

field = self.driver.find_element_by_id("id_attachments-1-caption")
button = self.driver.find_element_by_css_selector('input[type=submit][name=_continue]')
time.sleep(1)
field.send_keys('test')
time.sleep(1)
try:
button.click()
except:
button.click()

wait = WebDriverWait(self.driver, 10)
wait.until(element_has_css_class((By.TAG_NAME, 'body'), "baton-ready"))
time.sleep(2)
input_share = self.driver.find_element_by_id('id_share')
self.assertEqual(input_share.is_displayed(), False)
description_att = self.driver.find_element_by_css_selector('.tab-fs-attachments .description')
self.assertEqual(description_att.is_displayed(), True)
self.assertEqual(description_att.get_attribute('innerText'), 'Add as many attachments as you want')
Binary file modified testapp/app/db.sqlite3
Binary file not shown.

0 comments on commit 91289d9

Please sign in to comment.