/* $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/add_page_action.xml');

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;
  
   result := DBMS_XDB.createresource('/public/xxas/emp/view/add_page_action.xml',
'<View submitLabel="{message.XXAS_RB_COM_SAVE}" title="Page action" defaultFormHandler="xxas_block_pkg.post_block_action_create">
  <CreateFields>
    <Hidden id="MENU_ID"/>
    <Hidden id="FUNCTION_ID"/>
    <Hidden id="TITLE_NAME"/>
    <TextInput id="BA_TITLE" label="Title" required="true"/>
    <Combolist id="OBJ_NAME" label="{message.XXAS_OBJECT}" visible="true" enabled="true" longlist="true" listProvider="REST:data-objects/objname?q={searchText}"/>
    <Poplist id="OPERATION" required="true" label="Operation" listProvider="VALUE_SET_NAME:Applaud Action Operations"/>
    <TextInput id="RESTEND" label="REST Endpoint" required="true" hideIf="!(model.OPERATION.value) || (model.OPERATION.value.id == &apos;LINK&apos;)"/>
    <Poplist id="TYPE" label="Type" required="true" listProvider="VALUE_SET_NAME:Applaud Action Type"  hideIf="model.OPERATION.value.id != &apos;LINK&apos;"/>
    <Combolist id="PAGE" label="Page" longlist="true" required="true" listProvider="REST:page-action?q={searchText}" hideIf="(model.TYPE.value.id != &quot;Applaud page&quot;)"/>
    <TextInput id="OBJECTID" label="Object Id" required="true" hideIf="(model.TYPE.value.id != &quot;Applaud page&quot;)"/>
    <TextInput id="URL" label="URL" required="true" hideIf="!(model.OPERATION.value) || (model.OPERATION.value.id != &apos;LINK&apos;) || (model.TYPE.value.id != &quot;External URL&quot;)"/>
    <Poplist id="MODAL" label="Show in modal" required="true" showAsBoolean="true" listProvider="LOOKUP_TYPE:YES_NO" positiveBooleanValue="Y" hideIf="((model.OPERATION.value.id != &apos;LINK&apos;) || (model.OPERATION.value.id == &apos;LINK&apos; &amp;&amp; model.TYPE.value.id == &quot;External URL&quot;))"/>
    <Icon id="ACTION_ICON" label="Icon"/>
    <Poplist id="WEIGHT" label="Weight" required="true" listProvider="VALUE_SET_NAME:Applaud Button Weights" value="light"/>
    <Poplist id="COLOR" label="Color" listProvider="VALUE_SET_NAME:Applaud Button Colors" value="positive"/>
    <Poplist id="CONFIRMATION" label="Require confirmation" showAsBoolean="true" listProvider="LOOKUP_TYPE:YES_NO" positiveBooleanValue="Y"/>
    <TextArea id="MESSAGE" label="Confirmation message" required="true" hideIf="model.CONFIRMATION.value != &apos;Y&apos;"/>
  </CreateFields>
</View>' );
END;
/
COMMIT;
EXIT;