All files / ima/controller ControllerDecorator.js

50% Statements 13/26
0% Branches 0/2
33.33% Functions 6/18
50% Lines 13/26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194      2x                                     2x             2x             2x             2x             2x             2x                                                                                                               2x             1x                                             2x                                                                   2x                     1x       2x  
import ns from '../namespace';
import Controller from './Controller';
 
ns.namespace('ima.controller');
 
/**
 * Decorator for page controllers. The decorator manages references to the meta
 * attributes manager and other utilities so these can be easily provided to
 * the decorated page controller when needed.
 */
export default class ControllerDecorator extends Controller {
  /**
	 * Initializes the controller decorator.
	 *
	 * @param {Controller} controller The controller being decorated.
	 * @param {MetaManager} metaManager The meta page attributes manager.
	 * @param {Router} router The application router.
	 * @param {Dictionary} dictionary Localization phrases dictionary.
	 * @param {Object<string, *>} settings  Application settings for the
	 *        current application environment.
	 */
  constructor(controller, metaManager, router, dictionary, settings) {
    super();
 
    /**
		 * The controller being decorated.
		 *
		 * @type {Controller}
		 */
    this._controller = controller;
 
    /**
		 * The meta page attributes manager.
		 *
		 * @type {MetaManager}
		 */
    this._metaManager = metaManager;
 
    /**
		 * The application router.
		 *
		 * @type {Router}
		 */
    this._router = router;
 
    /**
		 * Localization phrases dictionary.
		 *
		 * @type {Dictionary}
		 */
    this._dictionary = dictionary;
 
    /**
		 * Application settings for the current application environment.
		 *
		 * @type {Object<string, *>}
		 */
    this._settings = settings;
  }
 
  /**
	 * @inheritdoc
	 */
  init() {
    this._controller.init();
  }
 
  /**
	 * @inheritdoc
	 */
  destroy() {
    this._controller.destroy();
  }
 
  /**
	 * @inheritdoc
	 */
  activate() {
    this._controller.activate();
  }
 
  /**
	 * @inheritdoc
	 */
  deactivate() {
    this._controller.deactivate();
  }
 
  /**
	 * @inheritdoc
	 */
  load() {
    return this._controller.load();
  }
 
  /**
	 * @inheritdoc
	 */
  update(params = {}) {
    return this._controller.update(params);
  }
 
  /**
	 * @inheritdoc
	 */
  setReactiveView(reactiveView) {
    this._controller.setReactiveView(reactiveView);
  }
 
  /**
	 * @inheritdoc
	 */
  setState(statePatch) {
    this._controller.setState(statePatch);
  }
 
  /**
	 * @inheritdoc
	 */
  getState() {
    return this._controller.getState();
  }
 
  /**
	 * @inheritdoc
	 */
  addExtension(extension) {
    this._controller.addExtension(extension);
 
    return this;
  }
 
  /**
	 * @inheritdoc
	 */
  getExtensions() {
    return this._controller.getExtensions();
  }
 
  /**
	 * @inheritdoc
	 */
  setMetaParams(loadedResources, metaManager, router, dictionary, settings) {
    this._controller.setMetaParams(
      loadedResources,
      this._metaManager,
      this._router,
      this._dictionary,
      this._settings
    );
  }
 
  /**
	 * @inheritdoc
	 */
  setRouteParams(params = {}) {
    this._controller.setRouteParams(params);
  }
 
  /**
	 * @inheritdoc
	 */
  getRouteParams() {
    return this._controller.getRouteParams();
  }
 
  /**
	 * @inheritdoc
	 */
  setPageStateManager(pageStateManager) {
    this._controller.setPageStateManager(pageStateManager);
  }
 
  /**
	 * @inheritdoc
	 */
  getHttpStatus() {
    return this._controller.getHttpStatus();
  }
 
  /**
	 * Returns the meta attributes manager configured by the decorated
	 * controller.
	 *
	 * @return {MetaManager} The Meta attributes manager configured by the
	 *         decorated controller.
	 */
  getMetaManager() {
    return this._metaManager;
  }
}
 
ns.ima.controller.ControllerDecorator = ControllerDecorator;