import Ember from 'ember';
import { Query } from 'ember-flexberry-data';
import FdPreloadStageMetadata from 'ember-flexberry-designer/utils/fd-preload-stage-metadata';
import ListFormRoute from 'ember-flexberry/routes/list-form';

export default ListFormRoute.extend({
  /**
    Name of model projection to be used as record's properties limitation.

    @property modelProjection
    @type String
    @default 'ListFormView'
  */
  modelProjection: 'ListFormView',

  /**
    Name of model to be used as list's records types.

    @property modelName
    @type String
    @default 'fd-dev-stage'
  */
  modelName: 'fd-dev-stage',

  /**
    Defined user settings developer.
    For default userSetting use empty name ('').
    Property `<componentName>` may contain any of properties: `colsOrder`, `sorting`, `colsWidth` or being empty.

    ```javascript
    {
      <componentName>: {
        <settingName>: {
          colsOrder: [ { propName :<colName>, hide: true|false }, ... ],
          sorting: [{ propName: <colName>, direction: "asc"|"desc" }, ... ],
          colsWidths: [ <colName>:<colWidth>, ... ],
        },
        ...
      },
      ...
    }
    ```

    @property developerUserSettings
    @type Object
    @default {}
  */
  developerUserSettings: { FdStageListForm: {} },

  /**
    Link to {{#crossLink "FdCurrentProjectContextService"}}FdCurrentProjectContextService{{/crossLink}}.

    @property currentContext
    @type FdCurrentProjectContextService
  */
  currentContext: Ember.inject.service('fd-current-project-context'),

  actions: {
    objectListViewRowClick(stage, options) {
      if (options.column === null) {
        return this._super(...arguments);
      } else {
        this.get('currentContext').setCurrentStage(stage);
        FdPreloadStageMetadata.call(this, this.get('store'), this.get('currentContext').getCurrentStage()).then(() =>
          this.get('currentContext').getAutogeneratedSystemPromise()).then(() => {
            this.transitionTo('fd-appstruct-form');
        });
      }
    },
  },

  objectListViewLimitPredicate() {
    let configuration = this.get('currentContext').getCurrentConfiguration();
    return new Query.SimplePredicate('configuration', '==', configuration);
  },
});

import Ember from 'ember';
import { Query } from 'ember-flexberry-data';
import FdPreloadStageMetadata from 'ember-flexberry-designer/utils/fd-preload-stage-metadata';
import ListFormRoute from 'ember-flexberry/routes/list-form';

export default ListFormRoute.extend({
  /**
    Name of model projection to be used as record's properties limitation.

    @property modelProjection
    @type String
    @default 'ListFormView'
  */
  modelProjection: 'ListFormView',

  /**
    Name of model to be used as list's records types.

    @property modelName
    @type String
    @default 'fd-dev-stage'
  */
  modelName: 'fd-dev-stage',

  /**
    Defined user settings developer.
    For default userSetting use empty name ('').
    Property `<componentName>` may contain any of properties: `colsOrder`, `sorting`, `colsWidth` or being empty.

    ```javascript
    {
      <componentName>: {
        <settingName>: {
          colsOrder: [ { propName :<colName>, hide: true|false }, ... ],
          sorting: [{ propName: <colName>, direction: "asc"|"desc" }, ... ],
          colsWidths: [ <colName>:<colWidth>, ... ],
        },
        ...
      },
      ...
    }
    ```

    @property developerUserSettings
    @type Object
    @default {}
  */
  developerUserSettings: { FdStageListForm: {} },

  /**
    Link to {{#crossLink "FdCurrentProjectContextService"}}FdCurrentProjectContextService{{/crossLink}}.

    @property currentContext
    @type FdCurrentProjectContextService
  */
  currentContext: Ember.inject.service('fd-current-project-context'),

  actions: {
    objectListViewRowClick(stage, options) {
      if (options.column === null) {
        return this._super(...arguments);
      } else {
        this.get('currentContext').setCurrentStage(stage);
        FdPreloadStageMetadata.call(this, this.get('store'), this.get('currentContext').getCurrentStage()).then(() =>
          this.get('currentContext').getAutogeneratedSystemPromise()).then(() => {
            this.transitionTo('fd-appstruct-form');
          });
      }
    },
  },

  objectListViewLimitPredicate() {
    let configuration = this.get('currentContext').getCurrentConfiguration();
    return new Query.SimplePredicate('configuration', '==', configuration);
  },
});

Fix travis 2