Fixed: Cancelling editing a modal will reset to previous saved state

This commit is contained in:
Mark McDowall
2014-08-14 23:06:17 -07:00
parent 39c66b7951
commit d76e3d2ed6
16 changed files with 216 additions and 285 deletions
+13 -13
View File
@@ -6,19 +6,19 @@ define(
'Profile/ProfileCollection',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/AsEditModalView',
'Mixins/AutoComplete'
], function (vent, Marionette, Profiles, AsModelBoundView, AsValidatedView) {
], function (vent, Marionette, Profiles, AsModelBoundView, AsValidatedView, AsEditModalView) {
var view = Marionette.ItemView.extend({
template: 'Series/Edit/EditSeriesViewTemplate',
ui: {
profile: '.x-profile',
path : '.x-path'
profile : '.x-profile',
path : '.x-path'
},
events: {
'click .x-save' : '_saveSeries',
'click .x-remove': '_removeSeries'
},
@@ -27,16 +27,14 @@ define(
this.model.set('profiles', Profiles);
},
_saveSeries: function () {
var self = this;
_onBeforeSave: function () {
var profileId = this.ui.profile.val();
this.model.set({ profileId: profileId});
},
this.model.save().done(function () {
self.trigger('saved');
vent.trigger(vent.Commands.CloseModalCommand);
});
_onAfterSave: function () {
this.trigger('saved');
vent.trigger(vent.Commands.CloseModalCommand);
},
onRender: function () {
@@ -48,7 +46,9 @@ define(
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
AsEditModalView.call(view);
AsModelBoundView.apply(view);
return AsValidatedView.apply(view);
return view;
});
@@ -6,8 +6,7 @@
<div class="modal-body edit-series-modal">
<div class="row">
<div class="col-sm-3 hidden-xs">
<img class="series-poster" src="{{poster}}"
{{defaultImg}}>
<img class="series-poster" src="{{poster}}" {{defaultImg}}>
</div>
<div class="col-sm-9">
<div class="form-horizontal">
@@ -89,6 +88,8 @@
</div>
<div class="modal-footer">
<button class="btn btn-danger pull-left x-remove">delete</button>
<span class="indicator x-indicator"><i class="icon-spinner icon-spin"></i></span>
<button class="btn" data-dismiss="modal">cancel</button>
<button class="btn btn-primary x-save">save</button>
</div>