Skip to content

Commit

Permalink
Merge pull request #20 from MarshallOfSound/master
Browse files Browse the repository at this point in the history
Fixed bug where uploading an attachment would discard your changes
  • Loading branch information
MarshallOfSound committed Mar 10, 2015
2 parents 50c6573 + e674840 commit ebe0149
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/webapp/modules/feature-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,25 @@ YUI.add('feature-test', function (Y) {
},
_addClickListeners: function () {
Y.all('.upload-attachment').each(Y.bind(function (item) {
item.ancestor().on('click', Y.bind(function(e) {
var editInProgress = function(model) {
var i = 0;
for (var property in model.changed) {
if (model.changed.hasOwnProperty(property)) {
i++;
}
}
return i>0;
},
model = this.get('model');

if (editInProgress(model)) {
alert('Please save or discard your changes before uploading attachments');
e.preventDefault();
e.stopPropagation();
return false;
}
}, this));
item.on('change', Y.bind(function () {
var model = this.get('model'),
formgroup = item.ancestor(".image-form"),
Expand Down

0 comments on commit ebe0149

Please sign in to comment.