Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26
Like Tree3Likes

Thread: Hide Panels in EditView (6.5)

  1. #21
    CastleBravo is offline Sugar Community Member
    Join Date
    Feb 2012
    Location
    California
    Posts
    52

    Default Re: Hide Panels in EditView (6.5)

    Quote Originally Posted by eggsurplus View Post
    Cool! I wonder with the :hidden selector if it is an ordering issue because at the time your js is ran the table is not yet hidden so the selector doesn't find any hidden table elements. Your js needs to run after the SugarLogic runs. Not sure how to properly chain it with SugarLogic. Anyone else with ideas?
    Yep, that's exactly what the issue is.

    I used the setTimeout JS function and set the delay to 3 seconds and the $('table:hidden').parent().hide(); works like a charm. My only concern with doing it this way is that there may be issues where users with slower computers have the page display slower yet the setTimeout function has already been called. In that case, the panels will not be hidden because the Sugar Logic hasn't applied the hidden style to the elements yet. If I could figure out a way to get the Sugar Logic run through the detailviewdefs.php to run later, that would work better I believe. Hmm...
    Last edited by CastleBravo; 2012-10-18 at 10:25 PM.

  2. #22
    CastleBravo is offline Sugar Community Member
    Join Date
    Feb 2012
    Location
    California
    Posts
    52

    Default Re: Hide Panels in EditView (6.5)

    Should using something like the following inside detailviewdefs inside templateMeta (but after my setPanelDependencies) trigger properly in theory? I really hate use to use the setTimeout() function. I'm having the JS file write something to the console just so I can see if it's getting there, but I'm not seeing anything. A portion of my detailviewdefs (from custom/modules/Cases/metadata) is below showing where I'm inserting the include. Am I doing it wrong?

    Code:
    'includes' => 
          array (
            0 => 
            array (
              'file' => '<PATH TO JS FILE>',
            ),
          ),
    Code:
    <?php
    $viewdefs ['Cases'] = 
    array (
      'DetailView' => 
      array (
    	'templateMeta' =>	 
    	array (
          'form' => 
          array (
            'buttons' => 
            array (
              0 => 'EDIT',
              1 => 'DUPLICATE',
              2 => 'DELETE',
              3 => 'FIND_DUPLICATES',
              4 => 
              array (
               'customCode' => '<input title="{$MOD.LBL_CREATE_KB_DOCUMENT}" accessKey="M" class="button" onclick="this.form.return_module.value=\'Cases\'; this.form.return_action.value=\'DetailView\';this.form.action.value=\'EditView\';this.form.module.value=\'KBDocuments\'" type="submit" name="button" value="{$MOD.LBL_CREATE_KB_DOCUMENT}">',
    		  ),
            ),
          ),	  
      	  'maxColumns' => '2',
          'widths' => 
          array (
            0 => 
            array (
              'label' => '10',
              'field' => '30',
            ),
            1 => 
            array (
              'label' => '10',
              'field' => '30',
            ),
          ),
          'useTabs' => true,
          'syncDetailEditViews' => true,
    	  'panelDependencies' => 
          array (
            'lbl_editview_panel1' => 'equal($record_type_dd_c, "01240000000990R")',
            'lbl_editview_panel14' => 'equal($record_type_dd_c, "01240000000141F")',
            'lbl_editview_panel13' => 'equal($record_type_dd_c, "01240000000141F")',
            'lbl_editview_panel12' => 'equal($record_type_dd_c, "01240000000141F")',
            'lbl_editview_panel11' => 'equal($record_type_dd_c, "01240000000141F")',
            'lbl_editview_panel10' => 'equal($record_type_dd_c, "01240000000141F")',
            'lbl_editview_panel15' => 'equal($record_type_dd_c, "01240000000141F")',
            'lbl_editview_panel16' => 'or(equal($record_type_dd_c, "012300000000Ji6"), equal($record_type_dd_c, "012300000000Cqw"))',
            'lbl_editview_panel18' => 'equal($record_type_dd_c, "012300000000Cqw")',
            'lbl_editview_panel19' => 'equal($record_type_dd_c, "012300000000Cqw")',
            'lbl_editview_panel20' => 'equal($record_type_dd_c, "0124000000013gH")',
            'lbl_editview_panel21' => 'equal($record_type_dd_c, "0124000000013gH")',
            'lbl_editview_panel22' => 'equal($record_type_dd_c, "012300000000OQ2")',
            'lbl_editview_panel23' => 'equal($record_type_dd_c, "0124000000014qm")',
            'lbl_editview_panel24' => 'equal($record_type_dd_c, "0123000000094Wh")',
            'lbl_editview_panel25' => 'equal($record_type_dd_c, "0123000000094Wh")',
            'lbl_editview_panel26' => 'equal($record_type_dd_c, "0123000000094Wh")',
            'lbl_editview_panel27' => 'equal($record_type_dd_c, "012300000000CvI")',
            'lbl_editview_panel28' => 'equal($record_type_dd_c, "012300000000Chf")',
            'lbl_editview_panel29' => 'equal($record_type_dd_c, "0124000000015HJ")',
            'lbl_editview_panel3' => 'equal($record_type_dd_c, "01240000000990R")',
            'lbl_editview_panel30' => 'equal($record_type_dd_c, "0124000000015HJ")',
            'lbl_editview_panel31' => 'equal($record_type_dd_c, "0124000000015HJ")',
            'lbl_editview_panel34' => 'equal($record_type_dd_c, "0124000000014qm")',
            'lbl_editview_panel35' => 'equal($record_type_dd_c, "0124000000014qm")',
            'lbl_editview_panel36' => 'equal($record_type_dd_c, "0124000000014qm")',
            'lbl_editview_panel37' => 'or(equal($record_type_dd_c, "0124000000014qm"), equal($record_type_dd_c, "012300000000OQ2"))',
            'lbl_editview_panel4' => 'equal($record_type_dd_c, "01240000000990R")',
            'lbl_editview_panel5' => 'equal($record_type_dd_c, "01240000000990R")',
            'lbl_editview_panel6' => 'equal($record_type_dd_c, "0124000000097fm")',
            'lbl_editview_panel7' => 'equal($record_type_dd_c, "01240000000990R")',
            'lbl_editview_panel8' => 'equal($record_type_dd_c, "0124000000014DL")',
            'lbl_editview_panel9' => 'equal($record_type_dd_c, "0124000000014DL")',
            'LBL_EDITVIEW_PANEL40' => 'equal($record_type_dd_c, "SysEng")',
          ),
          'includes' => 
              array (
                  0 => 
                      array (
                           'file' => '<PATH TO JS FILE>',
                      ),
               ),	  	
          'tabDefs' => 
          array (
            'LBL_CASE_INFORMATION' => 
            array (
              'newTab' => true,
              'panelDefault' => 'expanded',
            ),
            'LBL_EDITVIEW_PANEL33' => 
            array (
              'newTab' => false,
              'panelDefault' => 'expanded',
            ),
    ...

  3. #23
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,858

    Default Re: Hide Panels in EditView (6.5)

    Have you tried Gerald's suggestion yet?

    With the timeout I honestly haven't dug into it to see where the proper point to insert your js while working with SugarLogic. You may be the first to try this.

    Anyone else have any suggestions?
    [SIGPIC][/SIGPIC]

    Using CE and have 2 or more users? You need SecuritySuite - Teams

  4. #24
    CastleBravo is offline Sugar Community Member
    Join Date
    Feb 2012
    Location
    California
    Posts
    52

    Default Re: Hide Panels in EditView (6.5)

    I tried Gerald's solution below and it appears to function exactly the same as our current Sugar Logic panel dependencies do when set in detail/editviewdefs. It correctly hides the appropriate panels (<table>) but apparently (as Jason pointed out) the DOM was updated at some point between 6.2.3 and 6.5.5 and there is a parent <div> that is not being hidden. I tried using detailpanel_4 and DETAILPANEL_4 in the target below but that doesn't seem to hide anything. See my comments in the code below:

    Code:
    <div id="detailpanel_4" class="detail view detail508 expanded"> // This div tag is not being hidden. This is ultimately what I need hidden along with the table below.
    <h4>
    <table id="LBL_EDITVIEW_PANEL7" class="panelContainer" cellspacing="0" style="overflow: hidden; height: 0px; display: none;"> // Gerald's solution does hide this table correctly
    <script type="text/javascript">
    </div>
    Quote Originally Posted by geraldclark View Post
    All,

    If I'm understanding this issue correctly, couldn't you use SetPanelVisibility?

    SugarCRM Developer Blog Blog Archive Learning Sugar Logic: Using custom dependencies.


    custom/Extension/modules/MyModule/Ext/Dependencies/panelVisibility.php

    Code:
    $dependencies['MyModule']['myPanelVisibility'] = array(
    	'hooks' => array("edit","view"),
    	'trigger' => 'true', 
    	'triggerFields' => array('my_field_c'),
    	'onload' => true,
    	//Actions is a list of actions to fire when the trigger is true
    	'actions' => array(
    		array(
    			'name' => 'SetPanelVisibility',
    			//The parameters passed in will depend on the action type set in 'name'
    			'params' => array(
    				//uppercase panel id
    				'target' => 'LBL_PANEL_ID', 
    				'value' => 'equal($my_field_c, "MyValue")',
    			),
    		),
    	),
    );
    Please let me know!

  5. #25
    Ramblin is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    199

    Default Re: Hide Panels in EditView (6.5)

    Did you ever get this resolved to work in 6.5 without relying on Timeout machinations?

    Ramblin

  6. #26
    Ramblin is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    199

    Default Re: Hide Panels in EditView (6.5)

    Got it all working, thanks to your posts and some others, so thought I'd post results here.

    Scenario for me:
    I have information that I want people to see/edit for some Account types but not others, so I triggered Accounts panel visibility based on value of account_type field (which is populated from account_type_dom dropdown )

    Note that if you use Tabs the tab will still appear but it will have no content. If you use panels, the header and content disappear. So I used a tab for the first and second "panels", put the rest as panels (which makes them appear in the second tab if they are enabled but disappear completely if not enabled).

    I got the Panel Labels from either:
    Get the original Panel labels from <sugar_root>/modules/Accounts/metadata/detailviewdefs.php
    Get any new Panel labels from <sugar_root>/custom/modules/Accounts/metadata/detailviewdefs.php

    I put, into <sugar_root>/custom/modules/Accounts/views/view.detail.php
    Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    
    // Points to 'modules/Accounts/views/view.detail.php' instead of 'include/MVC/View/views/view.detail.php'
    // since accounts already overrides the stock view
    // require_once('include/MVC/View/views/view.detail.php');
    require_once('modules/Accounts/views/view.detail.php');
    
    class CustomAccountsViewDetail extends AccountsViewDetail 
    {
    	function CustomAccountsViewDetail()
    	{
    		parent::AccountsViewDetail();
    	}
    
    	function display()
    	{
    		$GLOBALS['focus'] = $this->bean;
    		if ($this->bean->account_type == 'Investor' || $this->bean->account_type == 'Competitor')
    		{
    $js=<<<EOQ
    			<script>
    				$('#LBL_PANEL_ADVANCED').parent().show();
    				$('#LBL_PANEL_ASSIGNMENT').parent().hide();
    			</script>
    EOQ;
    		}
    		parent::display();
    		echo $js;
    	}
    }
    ?>
    I put into <sugar_root>/custom/modules/Accounts/views/view.edit.php
    Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
    
    require_once('include/MVC/View/views/view.edit.php');
    
    class CustomAccountsViewEdit extends ViewEdit 
    {
    	function CustomAccountsViewEdit()
    	{
    		parent::ViewEdit();
    	}
    
    
    	public function display()
    	{
    		$PreLoad = 'document.getElementById(\'account_type\').onchange();';
    
    $js=<<<EOQ
    		<script>
    			document.getElementById("account_type").onchange = function() 
    			{
    				AccountType = document.getElementsByName('account_type')[0].value;
    				if (AccountType == 'Investor' || AccountType == 'Competitor')
    				{
    					$('#LBL_PANEL_ADVANCED').parent().show();
    					$('#LBL_PANEL_ASSIGNMENT').parent().hide();
    				}
    				else
    				{
    					$('#LBL_PANEL_ADVANCED').parent().show();
    					$('#LBL_PANEL_ASSIGNMENT').parent().show();
    				}
    			}
    		$PreLoad;
    		</script>
    EOQ;
    		parent::display();
    		echo $js;
    	}
    }
    ?>
    This makes sure that the etail View reflects the changes made and the Edit view reflects the changes as they are made.

    R
    eggsurplus likes this.

Page 3 of 3 FirstFirst 123

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. hide panels in detailview
    By sreekanths478 in forum Developer Help
    Replies: 2
    Last Post: 2012-01-26, 10:16 AM
  2. Editview Panels not working in IE8
    By shyam007 in forum Developer Help
    Replies: 1
    Last Post: 2011-06-06, 02:36 PM
  3. How to Hide Layout Panels in usermodule??
    By m3suriya in forum Developer Help
    Replies: 1
    Last Post: 2010-07-14, 02:50 PM
  4. Editview panels show/hide?
    By madhrishi in forum Help
    Replies: 5
    Last Post: 2009-05-05, 04:47 PM
  5. Hide Panels
    By kasperd in forum Help
    Replies: 0
    Last Post: 2008-12-10, 01:44 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •