/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2016 Applaud Solutions UK Ltd                |
 |                             All rights reserved                            |
 *===========================================================================*/

SET VERIFY OFF
SET FEEDBACK OFF
WHENEVER OSERROR  EXIT FAILURE ROLLBACK
WHENEVER SQLERROR EXIT FAILURE ROLLBACK

CREATE OR REPLACE VIEW xxas_block_blocks_v
AS
SELECT b.menu_id
      ,b.function_id
      ,b.function_name
	  ,b.seeded_block_flag
      ,b.entry_sequence
      ,b.prompt
      ,b.object_id
      ,b.obj_name
	    ,decode(xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pHideIf'),null,'N','Y') RESTRICT_DEVICE
      ,(xxas_block_pkg.get_restrictions(b.function_parameters)) RESTRICTIONS
      ,b.description
      ,b.function_icon
      ,b.security_type type_of_security
      ,upper(b.block_type) block_type
      ,xxas_util_pkg.boolean_to_flag(xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pStamp')) stamp
      ,xxas_util_pkg.boolean_to_flag(xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pFullWidth')) full_width
      ,xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pChildMenu') child_menu 
      ,xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pRepeatHandler') block_provider_function 
      ,xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pFunctionToRepeat') func_to_repeat
      ,xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pBackgroundColor') background_color
      ,nvl(xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pAutohideIfOnlyOneFlag'),'N') AUTO_HIDEIF
      ,p.context_handler page_object_handler
      ,p.object_id_format page_object_id_format
      ,CASE WHEN xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pRepeatHandler') IS NOT NULL 
            THEN 'R'
            ELSE 'P' 
       END child_block_source
      ,CASE WHEN p.layout = 'columns2'
            THEN 'Y'
            WHEN p.layout = 'columns3'
            THEN 'Y'
            ELSE 'N'
       END  is_page_column_layout
      ,p.layout page_layout
	  ,CASE WHEN p.layout = 'columns3' 
			THEN decode(xxas_com_sec_pkg.get_parameter_value(b.function_parameters,'pBlockSize'),'two-third','Two-third','full-width','Full width','One-third') 
			ELSE NULL
		END BLOCK_SIZE
      FROM xxas_blocks_v b
          ,xxas_pages_v p
      WHERE  b.block_type = 'blocks'
      AND b.menu_id = p.menu_id;


BEGIN
  xxas_fnd_dictionary_pkg.add_view
   (p_application_short_name => xxas_util_pkg.app
   ,p_view_name              => 'XXAS_BLOCK_BLOCKS_V'
   ,p_description            => 'Applaud Block Blocks');
END;
/

COMMIT;
EXIT;

