Web Script: org/alfresco/modules/remove-component.post
Generated from /share/service/script/org/alfresco/modules/remove-component.post on Jun 15, 2026 4:42:58 PM

Script Properties
Id:org/alfresco/modules/remove-component.post
Short Name:remove-component
Description:Given a component id, removes it from the dashboard
Authentication:none
Transaction:none
Method:POST
URL Template:/modules/remove-component
Format Style:any
Default Format:html
Negotiated Formats:[undefined]
Implementation:class org.alfresco.web.scripts.DeclarativeWebScript
Extensions:[undefined]

Store: classpath:alfresco/site-webscripts

File: org/alfresco/modules/remove-component.post.desc.xml
<webscript>
  <shortname>remove-component</shortname>
  <description>Given a component id, removes it from the dashboard</description>
  <url>/modules/remove-component</url>
</webscript>
File: org/alfresco/modules/remove-component.post.html.ftl
${msg}
File: org/alfresco/modules/remove-component.post.json.js
var dashboardURL = json.get("dashboardURL");

var componentId = json.get("componentId");
var component = sitedata.getComponent(componentId);

if (component)
{
   var regionId = component.properties["region-id"]; 
   sitedata.unbindComponent("page", regionId, dashboardURL);
   
   var pos = getComponentPosition(component);
   
   var components = sitedata.findComponents("page", null, dashboardURL, null);
   var re = /^component-(\d+)-(\d+)$/;
   var c, coord;
   for (var idx=0; idx < components.length; idx++)
   {
      c = components[idx];
      if (!re.test(c.properties["region-id"]))
      {
         continue;
      }
      
      coord = getComponentPosition(c);
     
      if (coord.column > pos.column)
      {
         continue; // the order of the components is not guaranteed so we need to continue
      }
      
      if (coord.column === pos.column && coord.row > pos.row)
      {
         // reposition component - move it up one row
         c.properties["region-id"] = "component-" + pos.column + "-" + (coord.row-1);
         c.save();
      }
   }
   model.msg = "Success";  
}
else
{
   model.msg = "Failed";
}

/**
 * Takes a dashboard component and returns the column / row properties.
 *
 * @return {Object} "row" and "column" properties 
 */
function getComponentPosition(component)
{
   var re = /^component-(\d+)-(\d+)$/;
   var regionId = component.properties["region-id"];
  
   var result = regionId.match(re);
  
   return {
      row: result[2],
      column: result[1]
   };   
}

Store: classpath:alfresco/webscripts

[No implementation files]