Skip to content

Commit

Permalink
Merge branch 'release-1.3.3'
Browse files Browse the repository at this point in the history
Fixes issue 12
  • Loading branch information
abidibo committed Feb 21, 2019
2 parents 031f9d2 + 63e3be6 commit 59ff19d
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
6 changes: 3 additions & 3 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.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "baton",
"version": "1.3.2",
"version": "1.3.3",
"description": "Django Baton App",
"main": "index.js",
"scripts": {
Expand Down
26 changes: 22 additions & 4 deletions baton/static/baton/app/src/core/ChangeForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@ let ChangeForm = {
* Display loading spinner if multipart
*/
init: function (opts) {
this.form = $('#content-main form')
if (opts.confirmUnsavedChanges) {
this.formSubmitting = false
this.form = $('#content-main form')
this.initData = this.form.serialize()
this.t = new Translator($('html').attr('lang'))
this.activate()
var self = this
// wait for django SelectFilter to do its job
setTimeout(function () {
self.initData = self.serializeData()
self.activate()
}, 500)
}
if (opts.showMultipartUploading) {
this.spinner()
Expand All @@ -24,8 +28,22 @@ let ChangeForm = {
this.form.on('submit', () => (this.formSubmitting = true))
$(window).on('beforeunload', this.alertDirty.bind(this))
},
serializeData: function () {
// form serialize does not detect filter_horizontal controllers because
// in that case options are not selected, just added to the list of options,
// and jquery form serialize only serializes values which are set!
let data = this.form.serialize()
$('select.filtered[multiple][id$=_to]').each(function (k, select) {
let optionsValues = []
$(select).children('option').each(function (kk, option) {
optionsValues.push($(option).attr('value'))
})
data += `&${jQuery(select).attr('name')}=${optionsValues.sort().join(',')}`
})
return data
},
isDirty: function () {
return this.form.serialize() !== this.initData
return this.serializeData() !== this.initData
},
alertDirty: function (e) {
if (this.formSubmitting || !this.isDirty()) {
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'1.3.2'
version = u'1.3.3'
# The full version, including alpha/beta/rc tags.
release = u'1.3.2'
release = u'1.3.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 @@ -9,7 +9,7 @@

setup(
name='django-baton',
version='1.3.2',
version='1.3.3',
packages=['baton', 'baton.autodiscover', 'baton.templatetags'],
include_package_data=True,
license='MIT License',
Expand Down

0 comments on commit 59ff19d

Please sign in to comment.