/**
  @module ember-flexberry-gis-dummy
*/

import EditFormController from 'ember-flexberry/controllers/edit-form';
import EditFormControllerOperationsIndicationMixin from 'ember-flexberry/mixins/edit-form-controller-operations-indication';
import FlexberryLinksEditorActionsHandlerMixin from 'ember-flexberry-gis/mixins/flexberry-links-editor-actions-handler';

/**
  Maps layers metadata edit controller.

  @class NewPlatformFlexberrtGISLayerMetadataEController
  @extends EditFormController
  @uses EditFormControllerOperationsIndicationMixin
  @uses FlexberryLinksEditorActionsHandlerMixin
*/
export default EditFormController.extend(EditFormControllerOperationsIndicationMixin, FlexberryLinksEditorActionsHandlerMixin, {
  /**
    Parent route.

    @property parentRoute
    @type String
    @default 'new-platform-flexberry-g-i-s-layer-metadata-l'
  */
  parentRoute: 'new-platform-flexberry-g-i-s-layer-metadata-l',

  /**
    Layer's links' property path.

    @property linksPropertyPath
    @type String
    @default 'model.linkMetadata'
  */
  linksPropertyPath: 'model.linkMetadata',

  /**
    Layer's links' model name.

    @property linksModelName
    @type String
    @default 'new-platform-flexberry-g-i-s-link-metadata'
  */
  linksModelName: 'new-platform-flexberry-g-i-s-link-metadata',

  /**
    Layer's links' parameters model name.

    @property linksParametersModelName
    @type String
    @default 'new-platform-flexberry-g-i-s-parameter-metadata'
  */
  linksParametersModelName: 'new-platform-flexberry-g-i-s-parameter-metadata',

  /**
    Layer's links' parameters model projection.

    @property linksParametersModelProjection
    @type String
    @default 'ParameterMetadataD'
  */
  linksParametersModelProjection: 'ParameterMetadataD',

  actions: {
    /**
      Handles {{#crossLink "FlexberryEditLayerComponent/sendingActions.onInit:method"}}'flexberry-edit-layer' component's 'onInit' action{{/crossLink}}.

      @method actions.initLayerProperties
    */
    initLayerProperties(getLayerPropertiesFunction) {
      this.set('getLayerProperties', getLayerPropertiesFunction);
    },

    /**
      Default action for button 'Save'.

      @method actions.save
    */
    save() {
      this._mutateModel();

      this._super(...arguments);
    },

    /**
      Default action for button 'SaveAndClose'.

      @method actions.saveAndClose
    */
    saveAndClose() {
      this._mutateModel();

      this._super(...arguments);
    }
  },

  /**
    Mutates layer metadta model with properties sended from 'flexberry-edit-layermap' component.

    @method _mutateModel
    @private
  */
  _mutateModel() {
    let model = this.get('model');
    let layerProperties = this.get('getLayerProperties')();

    model.set('type', layerProperties.type);
    model.set('name', layerProperties.name);
    model.set('description', layerProperties.description);
    model.set('keyWords', layerProperties.keyWords);
    model.set('scale', layerProperties.scale);
    model.set('coordinateReferenceSystem', layerProperties.coordinateReferenceSystem);
    model.set('settings', layerProperties.settings);
  }
});

@@ -2750,391 +2750,104 @@
     
-model.set('type', layerProperties.type);%0A    model.set('name', layerProperties.name);%0A    model.set('description', layerProperties.description);%0A    model.set('keyWords', layerProperties.keyWords);%0A    model.set('scale', layerProperties.scale);%0A    model.set('coordinateReferenceSystem', layerProperties.coordinateReferenceSystem);%0A    model.set('settings', layerProperties.settings)
+for (let %5Battr, value%5D of Object.entries(layerProperties)) %7B%0A      model.set(attr, value);%0A    %7D
 ;%0A  

add BoundingBox to PATCH request to db