Uploaded image for project: 'CMS'
  1. CMS
  2. CMS-4228

Backoffice SearchTool and selection

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 3.5
    • None
    • None
    • None

      Selecting a content send synchronous request while the tool is blocked.
      Here is a patch to asynchronise it :

      org.ametys.cms.tool.search.SearchTool.prototype._onSelectionChange = function (sm)
      {
      	window.clearTimeout(this._sendTimeout);
      	this._sendTimeout = this._fireMessages.defer(10, this, [sm]);
      }
      
      org.ametys.cms.tool.search.SearchTool.prototype._fireMessages = function (sm)
      {
      	var records = sm.getSelections();
      	var ids = [];
      	for (var i=0; i < records.length; i++)
      	{
      		ids.push(records[i].data.id);
      	}
      	
      	if (ids.length == 0)
      	{
      		this._fireMessages2([], sm);
      	}
      	else
      	{
      		ContentDAO.getContents(ids, this._fireMessages2.createDelegate(this, [sm], true));
      	}
      }
      org.ametys.cms.tool.search.SearchTool.prototype._fireMessages2 = function (contents, sm)
      {
      	// compare contents to current selection (to avoid overtaking of requests)
      	var records = sm.getSelections();
      	if (records.length != contents.length)
      	{
      		return;
      	}
      	else
      	{
      		for (var i=0; i < records.length; i++)
      		{
      			var found = false;
      			Ext.each(contents, function(item, index, allItems) {
      				if (item.getId() == records[i].data.id)
      				{
      					found = true;
      					return false;
      				}
      			})
      			if (!found)
      			{
      				return;
      			}
      		}
      	}
      
      	
      	var targets = org.ametys.messagebus.bus.MessageBuilder.getInstance().createTargets("content", {'contents': contents});
      	
      	var event = org.ametys.messagebus.bus.MessageBuilder.getInstance().createMessage(org.ametys.ribbon.RibbonManager.EVENTTYPE_SELECTIONCHANGED, null, targets);
      	var eventBus =  org.ametys.messagebus.MessageBus.getInstance();
      	eventBus.fireMessages ([event]);
      }
      

            trizzi Thibaut Rizzi (Inactive)
            raphael Raphaƫl Franchet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: