fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove mismatched html tags
[fnpeditor.git]
/
src
/
fnpjs
/
actions.js
diff --git
a/src/fnpjs/actions.js
b/src/fnpjs/actions.js
index
d369ff0
..
b8aa033
100644
(file)
--- a/
src/fnpjs/actions.js
+++ b/
src/fnpjs/actions.js
@@
-3,7
+3,11
@@
define(function(require) {
'use strict';
var _ = require('libs/underscore'),
'use strict';
var _ = require('libs/underscore'),
- Backbone = require('libs/backbone');
+ Backbone = require('libs/backbone'),
+ logging = require('fnpjs/logging/logging');
+
+var logger = logging.getLogger('fnpjs.actions');
+
var Action = function(fqName, definition, config, appObject) {
this.fqName = fqName;
var Action = function(fqName, definition, config, appObject) {
this.fqName = fqName;
@@
-52,7
+56,12
@@
_.extend(Action.prototype, Backbone.Events, {
getState: function() {
var gotState;
if(!this._cache) {
getState: function() {
var gotState;
if(!this._cache) {
- gotState = this.definition.getState.call(this, this.params);
+ try {
+ gotState = this.definition.getState.call(this, this.params);
+ } catch(e) {
+ logger.exception(e);
+ return;
+ }
if(typeof gotState === 'boolean') {
gotState = {allowed: gotState};
}
if(typeof gotState === 'boolean') {
gotState = {allowed: gotState};
}
@@
-65,8
+74,13
@@
_.extend(Action.prototype, Backbone.Events, {
},
execute: function() {
var state = this.getState();
},
execute: function() {
var state = this.getState();
+
+ var callback = function(ret) {
+ this.trigger('actionExecuted', ret);
+ }.bind(this);
+
if(state.allowed) {
if(state.allowed) {
- return state.execute.call(this, this.params, this.appObject);
+ return state.execute.call(this,
callback,
this.params, this.appObject);
}
throw new Error('Execution not allowed');
}
}
throw new Error('Execution not allowed');
}