diff --git a/portal/web/src/main/resources/org/gatein/portal/web/assets/javascripts/layout-model.js b/portal/web/src/main/resources/org/gatein/portal/web/assets/javascripts/layout-model.js index 06ff68263..b7553e1af 100644 --- a/portal/web/src/main/resources/org/gatein/portal/web/assets/javascripts/layout-model.js +++ b/portal/web/src/main/resources/org/gatein/portal/web/assets/javascripts/layout-model.js @@ -2,18 +2,6 @@ // An abstract model for Application and Container (Zone) in a layout var LayoutComponent = Backbone.Model.extend({ - - initialize : function() { - - // TODO: We should rely on Backbone.Model.defaults property instead - // TODO: Should we remove these default attributes ? - this.set({ - _parent : null, - draggable : false, - droppable : false - }); - }, - isDroppable : function(dragObj) { return false; }, @@ -25,7 +13,7 @@ // Return the parent object getParent : function() { - return this.get('_parent'); + return this._parent; }, // Return the root object @@ -98,43 +86,6 @@ _this.setContent(result.content); } }); - }, - - // TODO: Why do we need to overwrite the clone method from Backbone.Model ? - // It should be tested - clone: function() { - return new Application({ - id: this.getId(), - name : this.getName(), - applicationName : this.getApplicationName(), - title : this.getTitle(), - logo : this.getLogo(), - content: this.getContent() - }); - }, - - // Return the JSON object that contains metadata information - // TODO: Should we rely on the default #toJSON method from Backbone.Model ? - toJSON : function() { - return { - id : this.getId(), - type : "application", - name : this.getName(), - applicationName: this.getApplicationName() - }; - }, - - // Return a JSON object for rendering phase - // TODO: should it be merged with #toJSON() method ? - toJSONForRenderer : function() { - return { - id : this.getId(), - type : "application", - name : this.getName(), - title : this.getTitle(), - content : this.getContent(), - logo : this.getLogo() - }; } }); @@ -192,7 +143,7 @@ silent : options.silent }); } - child.set('_parent', this); + child._parent = this; // collection in backbone ignore move action in same container // need to remove then re-add this._children.remove(child, { @@ -216,7 +167,7 @@ this._children.remove(child, { silent : options.silent }); - child.set('_parent', null); + child._parent = null; } return this; }, @@ -267,7 +218,7 @@ }); // - var PageContainer = AbstractContainer.extend({ + var PageLayout = AbstractContainer.extend({ isDroppable : function(dragObj) { // Check for supported types @@ -287,7 +238,7 @@ return this.get('layout_id'); }, - // newContainer: is the new PageContainer object + // newContainer: is the new PageLayout object switchLayout : function(newContainer) { var conts = this.getChildren(); conts.sort(function(m1, m2) { @@ -369,7 +320,7 @@ 'LayoutComponent' : LayoutComponent, 'Application' : Application, 'Container' : Container, - 'PageContainer' : PageContainer, + 'PageLayout' : PageLayout, 'ComposerContainer' : ComposerContainer }; if (typeof window.require === "function" && window.require.amd) { diff --git a/portal/web/src/main/resources/org/gatein/portal/web/assets/javascripts/layout-view.js b/portal/web/src/main/resources/org/gatein/portal/web/assets/javascripts/layout-view.js index 672c514e0..9df3e220f 100644 --- a/portal/web/src/main/resources/org/gatein/portal/web/assets/javascripts/layout-view.js +++ b/portal/web/src/main/resources/org/gatein/portal/web/assets/javascripts/layout-view.js @@ -15,7 +15,7 @@ onAddChild : function(child) { var $container = $('#application-list'); - var html = _.template($("#portlet-template").html(), child.toJSONForRenderer()); + var html = _.template($("#portlet-template").html(), child.toJSON()); var $html = $(html); $container.append($html); @@ -38,7 +38,7 @@ }, render: function() { this.template = _.template($("#application-template").html()); - this.$el.html(this.template(this.model.toJSONForRenderer())); + this.$el.html(this.template(this.model.toJSON())); this.$el.attr("id", this.model.getId()); return this; }, @@ -234,8 +234,8 @@ // Build model from DOM buildModel : function() { - // TODO: Consider to initialize PageContainer model's url properly following Backbone standard - var _model = new PageContainer({id : 'layoutId'}, {url : this.editUrl}); + // TODO: Consider to initialize PageLayout model's url properly following Backbone standard + var _model = new PageLayout({id : 'layoutId'}, {url : this.editUrl}); this.$el.find('.sortable').each(function() { var cont = new Container({id : this.id}); $(this).children('.portlet').each(function() {