Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] Missing "Please first make a selection..." (front)

Missing "Please first make a selection..." (front) 19 Aug 2013 11:19 #10817

  • Tomaselli
  • Tomaselli's Avatar
  • Offline
  • Elite Member
  • Posts: 293
  • Thank you received: 87
  • Karma: 46
Missing the alert "Please first make a selection from the list" in the frontend list view on any TOOLBAR BUTTON TASK.

fix on file ROOT\administrator\components\com_component\dom\html.php:

find: /* hack */
	protected function jsCommand()
	{
		//When a static link is set : No JS execution
		if (!empty($this->route))
			return;
		
		$cmd = '';
		$version = new JVersion;
		
		if ($this->jVersion('2.5'))
			$jinput = JFactory::getApplication()->input;		
		else		
			$jinput = new JInput;
		
		$task = $this->getTaskExec();

		$checkList = false;
		//Grid task
		if (is_numeric($this->num))
		{
			$cmd = "listItemTask('cb" . (int)$this->num . "', '" . $this->getTaskExec(true) . "')";
		
			//Embed in a test to check if an item is checked
			if (isset($this->list) && $this->list)
				$checkList = true;
		}
		
		//Toolbar task button
		else if (!empty($task))
		{
			$taskCtrl = $this->getTaskExec(true);
			
			$cmd = "Joomla.";
			
			//Check if opened in modal
			if ($jinput->get('tmpl') == 'component')
				$cmd .= "submitformAjax";
			else
				$cmd .= "submitform";
			
				
			$cmd = "return " . $cmd . "('" . $taskCtrl . "');";
			
			/* hack */
			$excludedTasks = array('cancel', 'add', 'save', 'save2new', 'save2copy', 'apply');
			if(!in_array($task, $excludedTasks)){
				$checkList = true;
			}
			/* hack */
			
			//Because there is no other place for it...
			switch($task)
			{
				case 'delete':
					$this->alertConfirm = JText::_('JDOM_ALERT_ASK_BEFORE_REMOVE');
					break;
	
				case 'trash':
					$this->alertConfirm = JText::_('JDOM_ALERT_ASK_BEFORE_TRASH');
					break;
			}
			
		}
		
		if (empty($cmd))
			return;
		
		//Embed in a confirmation alert box
		if (isset($this->alertConfirm) && $this->alertConfirm)
		{
			$cmd = "if (window.confirm('" . addslashes($this->JText($this->alertConfirm)) . "')){"
					. 		$cmd
					. 	"}";
		}
		
		//Embed in a test to check if an item is checked
		if ($checkList)
		{
			$msgList = JText::sprintf('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST', $task);
			
			$cmd = 	"if (document.adminForm.boxchecked.value==0){"
				.		"alert('" . addslashes($msgList)  ."');"
				.	"}else{"
				. 		$cmd
				. 	"}";
		}
		
		$this->link_js = $cmd;
	}
Last Edit: 19 Aug 2013 12:11 by Tomaselli.
The administrator has disabled public write access.
The following user(s) said Thank You: admin

Missing "Please first make a selection..." (front) 19 Aug 2013 13:17 #10819

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Fixed.

K++

Well, I need to explain the changes :
The JDom:: toolbar receives now the list of items when it is related to a list.

It is important to make the difference because for instance, publish task can be both in list or in item.
So, then the only one excluded task for checking in the list is 'add'

Changed files :
- tmpl files (lists)
- dom/html.php
- dom/html/toolbar.php
- dom/link/button/toolbar.php
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.060 seconds

Get Started