<commit_before>
  /**
   *  Dialog to edit the fields of a feature from the map
   */

   /*
    
    TODO:
      - Geometry editor
      - Tests
      - Change old editors for those new ones.
      - Remove old tests
   */


  cdb.admin.EditFeatureFields = cdb.admin.BaseDialog.extend({

    editTypeFields: {
      'date':     'Date',
      'number':   'Number',
      'boolean':  'Boolean',
      'geometry': 'String',
      'string':   'String'
    },

    render: function() {
      cdb.ui.common.Dialog.prototype.render.call(this);
      this.activeWizardOption(this.option);
    
      // Custom scroll code (showing gradients at the end and beginning of the content)
      this.scroll = new cdb.admin.CustomScrolls({
        parent: this.$('div.content'),
        el:     this.$('div.content > div.wrapper')
      });

      this.addView(this.scroll);

      return this;
    },

    /**
     *  Render content
     */
    render_content: function() {

      var $content      = $('<div>').addClass('wrapper')
        , self          = this
        , schema        = this.options.table.get('schema')
        , hiddenColumns = this.options.table.hiddenColumns;

      _.each(this.model.attributes,function(val,attr){
        if (!_.contains(hiddenColumns,attr)) {
          // Get column type
          var type = _.find(schema, function(arr,i){
            return attr == arr[0]
          })[1];

          // Create subview
          var subView = new cdb.admin[self.editTypeFields[type] + 'Field']({
            label: true,
            model: new cdb.core.Model({
              attribute:  attr,
              value:      val
            })
          }).bind('ENTER', function(e) {
            this._ok();
          }, self)

          // Add to content
          $content.append(subView.render().el);

          // Add subview to this view (cleaning purposes)
          self.addView(subView);
        }
      });

      return $content;
    },

    ok: function() {
      // Get values from the subviews
      var new_model = {};
      _(this._subviews).each(function(v) {
        new_model[v.model.get("attribute")] = v.model.get("value");
      });

      // Set row model
      this.model.save(new_model);
    }
  });<commit_msg>fixed problem with custom scroll and getting value model in edit feature window<commit_after>
  /**
   *  Dialog to edit the fields of a feature from the map
   */

   /*
    
    TODO:
      - Geometry editor
      - Tests
      - Change old editors for those new ones.
      - Remove old tests
   */


  cdb.admin.EditFeatureFields = cdb.admin.BaseDialog.extend({

    editTypeFields: {
      'date':     'Date',
      'number':   'Number',
      'boolean':  'Boolean',
      'geometry': 'String',
      'string':   'String'
    },

    /**
     *  Render content
     */
    render_content: function() {

      var $content      = $('<div>').addClass('edit_content')
        , $wrapper      = $('<div>').addClass('wrapper')
        , self          = this
        , schema        = this.options.table.get('schema')
        , hiddenColumns = this.options.table.hiddenColumns;


      _.each(this.model.attributes,function(val,attr){
        if (!_.contains(hiddenColumns,attr)) {
          // Get column type
          var type = _.find(schema, function(arr,i){
            return attr == arr[0]
          })[1];

          // Create subview
          var subView = new cdb.admin[self.editTypeFields[type] + 'Field']({
            label: true,
            model: new cdb.core.Model({
              attribute:  attr,
              value:      val
            })
          }).bind('ENTER', function(e) {
            this._ok();
          }, self)

          // Add to content
          $wrapper.append(subView.render().el);

          // Add subview to this view (cleaning purposes)
          self.addView(subView);
        }
      });

      // Custom scroll code (showing gradients at the end and beginning of the content)
      var scroll = new cdb.admin.CustomScrolls({
        parent: $content,
        el:     $wrapper
      });

      this.addView(scroll);

      $content.append($wrapper);

      return $content;
    },

    ok: function() {
      // Get values from the subviews
      var new_model = {};
      _(this._subviews).each(function(v) {
        if (v.model && v.model.get('value'))
          new_model[v.model.get("attribute")] = v.model.get("value");
      });

      // Set row model
      this.model.save(new_model);
    }
  });
{'fraction_non_alphanumeric': 0.13815350389321468, 'fraction_numerical': 0.0008898776418242492, 'mean_word_length': 1.7084337349397591, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '259545', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1286, 'n_words': 300}