Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

PROBLEM WITH CONTROLLER TO STAY IN VIEW AFTER SAVE 09 Jun 2015 16:39 #13248

CHEF PLEASE, Let me know if you need more information in order to fix the issue.

JCOOK is no longer generating the component correctly in any of the versions (2.65 or 2.7.1) in order to stay in the Item view after saving.

I did try to generate the component in both versions. I did not work neither in JCOOK component Sandbox nor the downloaded file.

Then I wondered why if I new It was working the first time we downloaded the component. Then I compared the latest version generated with JCOOK and the initial version that I knew it was working.

Bellow are my findings:
I notice some changes on the controller file that are generated.

First version where it was working:
public function add()
	{
		CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
		$this->_result = $result = parent::add();
		$model = $this->getModel();

		//Define the redirections
		switch($this->getLayout() .'.'. $this->getTask())
		{
			case 'default.add':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.asset.asset'
				), array(

			
				));
				break;

			case 'modal.add':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.asset.asset'
				), array(

			
				));
				break;

			default:
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.asset.asset'
				));
				break;
		}
	}

New downloaded version that DOES NOT WORK:
	public function add()
	{
		CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
		$this->_result = $result = parent::add();
		$model = $this->getModel();

		//Define the redirections
		switch($this->getLayout() .'.'. $this->getTask())
		{
			case 'default.':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				), array(
					'cid[]' => null

				));
				break;

			case 'modal.':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				), array(
					'cid[]' => null

				));
				break;

			default:
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.asset.asset'
				));
				break;
		}
	}


Here you would see that each case has something missing.

Also the SAVE function is different:
First version where it was working:
public function save()
	{
		CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
		//Check the ACLs
		$model = $this->getModel();
		$item = $model->getItem();
		$result = false;
		if ($model->canEdit($item, true))
		{
			$result = parent::save();
			//Get the model through postSaveHook()
			if ($this->model)
			{
				$model = $this->model;
				$item = $model->getItem();	
			}
		}
		else
			JError::raiseWarning( 403, JText::sprintf('ACL_UNAUTORIZED_TASK', JText::_('HASTORAGEAPP_JTOOLBAR_SAVE')) );

		$this->_result = $result;

		//Define the redirections
		switch($this->getLayout() .'.'. $this->getTask())
		{
			case 'asset.apply':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.asset.asset'
				), array(
					'cid[]' => $model->getState('asset.id')
				));
				break;

			case 'asset.save':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				), array(
					'cid[]' => null
				));
				break;

			case 'asset.save2new':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.asset.asset'
				), array(
					'cid[]' => null
				));
				break;

			default:
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				));
				break;
		}
	}


New downloaded version that DOES NOT WORK:
public function save()
	{
		CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
		//Check the ACLs
		$model = $this->getModel();
		$item = $model->getItem();
		$result = false;
		if ($model->canEdit($item, true))
		{
			$result = parent::save();
			//Get the model through postSaveHook()
			if ($this->model)
			{
				$model = $this->model;
				$item = $model->getItem();	
			}
		}
		else
			JError::raiseWarning( 403, JText::sprintf('ACL_UNAUTORIZED_TASK', JText::_('HASTORAGEAPP_JTOOLBAR_SAVE')) );

		$this->_result = $result;

		//Define the redirections
		switch($this->getLayout() .'.'. $this->getTask())
		{
			case 'asset.':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				), array(
					'cid[]' => null
				));
				break;

			case 'asset.':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				), array(
					'cid[]' => null
				));
				break;

			case 'asset.':
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				), array(
					'cid[]' => null
				));
				break;

			default:
				$this->applyRedirection($result, array(
					'stay',
					'com_hastorageapp.assets.default'
				));
				break;
		}
	}

Here you can see also a difference in each Case value:
Also the redirect is sending it to 'com_hastorageapp.assets.default' (sending it back to the Assets collection view) instead of keeping it on 'com_hastorageapp.asset.asset' (Item view)

Also since it is sending to to the Collection view it is removing the item id:
First version downloaded:
'cid[]' => $model->getState('asset.id')
Latest version NOT WORKING:
'cid[]' => null


Talk to you

Miguel Santana
MS - Lyquix

Please Log in or Create an account to join the conversation.

PROBLEM WITH CONTROLLER TO STAY IN VIEW AFTER SAVE 09 Jun 2015 17:10 #13249

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Yes, indeed I have rewrited here recently.

This redirector is a mess, I should rewrite it all.

Well I can see the tasks aliases are missing.
I will have a look.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

PROBLEM WITH CONTROLLER TO STAY IN VIEW AFTER SAVE 09 Jun 2015 17:24 #13250

Let me know if I can help

Miguel Santana
ps: you know how to contact me directly or private if necesary
MS - Lyquix
The following user(s) said Thank You: admin

Please Log in or Create an account to join the conversation.

PROBLEM WITH CONTROLLER TO STAY IN VIEW AFTER SAVE 10 Jun 2015 08:23 #13251

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Fixed.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.054 seconds
  I still don't believe he can really be human to do all this ! From all of the forums that I've ever participated in this is certainly the one that most encapsulates the feeling of being truly open source where everyone's opinions and contributions can and will shape the development of the service! It's truly awesome! Hope you enjoy cooking and look forward to reading and contributing to any of the editorial work that you proposed too!! Thanks
Gez (audibleid - JED)

Get Started