'use strict';

var Component = require('substance/ui/Component');
var TextPropertyEditor = require('substance/ui/TextPropertyEditor');

function EntityComponent() {
  EntityComponent.super.apply(this, arguments);
}

EntityComponent.Prototype = function() {

  this.render = function($$) {
    var el = $$('div').addClass('sc-entity').attr('data-id', this.props.node.id);
    el.attr('contenteditable', false);

    var enabled = !!this.props.enabled;

    var nameEl = $$('div').ref('name').addClass('se-name');
    nameEl.append($$('div').ref('name.label').addClass('se-label').append('Name:'));
    nameEl.append($$(TextPropertyEditor, {
      enabled: enabled,
      path: [this.props.node.id, 'name']
    }).ref('nameEditor'));

    var descriptionEl = $$('div').ref('description').addClass('se-description');
    descriptionEl.append($$('div').ref('description.label').addClass('se-label').append('Description:'));
    descriptionEl.append($$(TextPropertyEditor, {
      enabled: enabled,
      path: [this.props.node.id, 'description']
    }).ref('descriptionEditor'));

    el.append(nameEl);
    el.append(descriptionEl);

    return el;
  };

  this.enable = function() {
    this.refs.nameEditor.enable();
    this.refs.descriptionEditor.enable();
  };

  this.disable = function() {
    this.refs.nameEditor.disable();
    this.refs.descriptionEditor.disable();
  };

};

Component.extend(EntityComponent);

EntityComponent.static.isPropertyEditor = true;

module.exports = EntityComponent;

@@ -326,22 +326,37 @@
 entity')
-.attr(
+%0A    el.attr(%7B%0A      
 'data-id
@@ -356,17 +356,17 @@
 data-id'
-,
+:
  this.pr
@@ -380,24 +380,16 @@
 e.id
-);
+,
 %0A    
-el.attr('
+  
 cont
@@ -403,19 +403,80 @@
 able
-',
+:
  false
-);%0A
+%0A    %7D);%0A%0A    var documentSession = this.context.documentSession;
 %0A   
@@ -705,32 +705,8 @@
 , %7B%0A
-      enabled: enabled,%0A
     
@@ -741,16 +741,41 @@
  'name'%5D
+,%0A      enabled: enabled,
 %0A    %7D).
@@ -1036,32 +1036,8 @@
 , %7B%0A
-      enabled: enabled,%0A
     
@@ -1079,16 +1079,40 @@
 iption'%5D
+,%0A      enabled: enabled
 %0A    %7D).

Fix regression.