Fixed: Refresh series details after series refresh and renamepull/32/head
parent
c2129054a0
commit
bd1a9db0ef
@ -1,56 +1,66 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
define(
|
define(
|
||||||
[
|
[
|
||||||
|
'app',
|
||||||
'Commands/CommandModel',
|
'Commands/CommandModel',
|
||||||
'Commands/CommandCollection',
|
'Commands/CommandCollection',
|
||||||
'underscore',
|
'underscore',
|
||||||
'jQuery/jquery.spin'
|
'jQuery/jquery.spin'
|
||||||
], function (CommandModel, CommandCollection, _) {
|
], function (App, CommandModel, CommandCollection, _) {
|
||||||
|
|
||||||
return{
|
var singleton = function () {
|
||||||
|
|
||||||
Execute: function (name, properties) {
|
return {
|
||||||
|
|
||||||
var attr = _.extend({name: name.toLocaleLowerCase()}, properties);
|
Execute: function (name, properties) {
|
||||||
|
|
||||||
var commandModel = new CommandModel(attr);
|
var attr = _.extend({name: name.toLocaleLowerCase()}, properties);
|
||||||
|
|
||||||
return commandModel.save().success(function () {
|
var commandModel = new CommandModel(attr);
|
||||||
CommandCollection.add(commandModel);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
bindToCommand: function (options) {
|
return commandModel.save().success(function () {
|
||||||
|
CommandCollection.add(commandModel);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
var self = this;
|
bindToCommand: function (options) {
|
||||||
|
|
||||||
var existingCommand = CommandCollection.findCommand(options.command);
|
var self = this;
|
||||||
|
|
||||||
if (existingCommand) {
|
var existingCommand = CommandCollection.findCommand(options.command);
|
||||||
this._bindToCommandModel.call(this, existingCommand, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
CommandCollection.bind('add sync', function (model) {
|
if (existingCommand) {
|
||||||
if (model.isSameCommand(options.command)) {
|
this._bindToCommandModel.call(this, existingCommand, options);
|
||||||
self._bindToCommandModel.call(self, model, options);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
_bindToCommandModel: function bindToCommand(model, options) {
|
CommandCollection.bind('add sync', function (model) {
|
||||||
|
if (model.isSameCommand(options.command)) {
|
||||||
|
self._bindToCommandModel.call(self, model, options);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
if (!model.isActive()) {
|
_bindToCommandModel: function bindToCommand(model, options) {
|
||||||
options.element.stopSpin();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
model.bind('change:state', function (model) {
|
|
||||||
if (!model.isActive()) {
|
if (!model.isActive()) {
|
||||||
options.element.stopSpin();
|
options.element.stopSpin();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
options.element.startSpin();
|
model.bind('change:state', function (model) {
|
||||||
}
|
if (!model.isActive()) {
|
||||||
|
options.element.stopSpin();
|
||||||
|
|
||||||
|
if (model.isComplete()) {
|
||||||
|
App.vent.trigger(App.Events.CommandComplete, { command: model, model: options.model });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
options.element.startSpin();
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
return singleton();
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in new issue