define(function(require) {
'use strict';
+/* globals gettext */
var $ = require('libs/jquery'),
Backbone = require('libs/backbone'),
var actionState = this.action.getState();
+ if(!actionState) {
+ this.$el.html(buttonTemplate({label: gettext('error :('), iconName:''}));
+ this._button().attr('disabled', true);
+ return;
+ }
+
var templateContext = {
label: actionState.label || '?',
iconName: (iconExists(actionState.icon)) ? actionState.icon : null,
},
showAction: function(action) {
var state = action.getState(),
+ description;
+
+ if(!state) {
+ description = gettext('error :(');
+ logger.error('Got undefined action state: ' + action.name);
+ } else {
description = state.description;
- if(!description) {
- description = state.allowed ? gettext('Undescribed action') : gettext('Action not allowed');
- logger.info('Undescribed action: ' + action.name);
+ if(!description) {
+ description = state.allowed ? gettext('Undescribed action') : gettext('Action not allowed');
+ logger.info('Undescribed action: ' + action.name);
+ }
}
+
view.text(description);
if(!state.allowed) {
view.prepend('<span class="badge badge-warning" style="margin-right: 5px">!</span>');