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

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



DECLARE 

  e_dir_exists EXCEPTION;
  PRAGMA EXCEPTION_INIT(e_dir_exists, -31003);

  e_does_not_exists EXCEPTION;
  PRAGMA EXCEPTION_INIT(e_does_not_exists , -31001);

  result boolean;
  
BEGIN

  BEGIN

    result := DBMS_XDB.createfolder('/public/xxas/');
    result := DBMS_XDB.createfolder('/public/xxas/emp/');
    result := DBMS_XDB.createfolder('/public/xxas/emp/view/');

  EXCEPTION
    WHEN e_dir_exists THEN
      NULL;
  END;

  
  BEGIN

    DBMS_XDB.DeleteResource('/public/xxas/emp/view/block-notes.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/block-notes.xml',
'<View submitLabel="{message.XXAS_RB_COM_SAVE}" title="Notes block" defaultFormHandler="xxas_block_pkg.post_block_update">

  <EditFields>
    <Hidden id="MENU_ID"/>
    <Hidden id="FUNCTION_ID"/>
	  <Hidden id="PAGE_OBJECT_HANDLER"/>
    <Hidden id="PAGE_OBJECT_ID_FORMAT"/>
    <Hidden id="IS_PAGE_COLUMN_LAYOUT"/>
    <Combolist id="BLOCK_TYPE" label="{message.XXAS_BK_BLOCK_TYPE}" listProvider="LOOKUP_TYPE:XXAS_BLOCK_TYPES" enabled="false"/>
    <TextInput id="PROMPT" label="{message.XXAS_BK_PROMPT}" required="false" maxChars="60"/>
    <TextInput id="DESCRIPTION" label="{message.XXAS_BK_DESCRIPTION}" required="false" maxChars="240"/>
    <Number id="ENTRY_SEQUENCE" label="{message.XXAS_BK_ENTRY_SEQUENCE}" required="true"/>
    <Poplist id="STAMP" label="{message.XXAS_BK_STAMP}" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" value="N" positiveBooleanValue="Y" 
     description="Force this block&apos;s order to the top"/>
    <Poplist id="FULL_WIDTH" label="{message.XXAS_BK_FULL_WIDTH}" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" value="N" positiveBooleanValue="Y" 
     description="Force the block to full-width so it spans its columns" hideIf="model.IS_PAGE_COLUMN_LAYOUT.value == &apos;N&apos;"/>
    <ColorPicker id="BACKGROUND_COLOR" label="{message.XXAS_COM_BACKGROUND_COLOR}" required="false" allowEmpty="true" preferredFormat="hex"/> 
    <Icon id="FUNCTION_ICON" label="{message.XXAS_BK_FUNCTION_ICON}" required="false" maxChars="30"/>
    <TextInput id="FUNCTION_NAME" label="{message.XXAS_BK_FUNCTION_NAME}" enabled="false"/>
    <Combolist id="TYPE_OF_SECURITY" label="{message.XXAS_BK_TYPE_OF_SECURITY}" listProvider="LOOKUP_TYPE:XXAS_BLOCK_SECURITY_TYPES" required="true" value="RD" 
     hideIf="!model.PAGE_OBJECT_ID_FORMAT.value"/>
    <Combolist id="OBJECT_ID" label="{message.XXAS_BK_OBJECT_ID}" listProvider="REST:objects?q={searchText}" longlist="true" required="true" 
     hideIf="!model.TYPE_OF_SECURITY.value || model.TYPE_OF_SECURITY.value.id == &apos;RO&apos;"/> 
    <Poplist id="RESTRICT_DEVICE" label="Restrict devices" showAsBoolean="true" listProvider="LOOKUP_TYPE:YES_NO" positiveBooleanValue="Y" />
    <Combolist id="RESTRICTIONS" label="Hide on" multipleSelection="true" listProvider="VALUE_SET_NAME:XXAS_DEVICE_RESTRICTIONS_VS" 
     hideIf="model.RESTRICT_DEVICE.value != &apos;Y&apos;"/>	   
	  <Hidden id="NO_DATA_MESSAGE" label="No data message"/>
    <TextArea id="NO_DATA_TEXT" label="{message.XXAS_BK_NO_DATA_TEXT}" value="We could not find any information to show here." maxChars="1700" description="Supports HTML tags"/>
 
 </EditFields>

</View>' ); 
xxas_forms_pkg.update_forms_resource('/public/xxas/emp/view/block-notes.xml');
END;
/
COMMIT;
EXIT;
