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

  EXCEPTION
    WHEN e_does_not_exists THEN
      NULL;
  END;

  
  result := DBMS_XDB.createresource('/public/xxas/emp/view/page_create.xml',
'<View submitLabel="{message.XXAS_RB_COM_SAVE}" title="Page" defaultFormHandler="xxas_page_pkg.post_page_create">

  <EditFields>
    <Container id="PAGE_BASICS" label="Page basics">
      <Hidden id="MENU_ID"/>
      <TextInput id="TITLE" label="Title" emptyValue="Enter a title" description="The page title will show in the browser tab and in the app" required="true"/>
      <!--TextInput id="TITLE_MESSAGE" label="Title message" enabled="false"/!-->
      <TextInput id="DESCRIPTION" label="Description" emptyValue="Enter a description" description="The page description is for informational purposes only" required="false"/>
      <!--TextInput id="DESCRIPTION_MESSAGE" label="Description message" enabled="false"/-->
      <Icon id="ICON" label="Icon" emptyValue="Search for icon" required="false" maxChars="30"/>
      <ColorPicker id="ICON_COLOR_HEX" label="Icon color" required="false" allowEmpty="true" preferredFormat="hex"/>      
      <TextInput id="SLUG" label="Page Id" emptyValue="Ex: home-page" description="This part of the URL and should be meaningful to end users, eg: https://somesite.com/&lt;strong&gt;home-page&lt;/strong&gt;" required="true" disableAutocapitalize="true" disableAutocomplete="true" disableAutocorrect="true" disableSpellcheck="true"/>
      <TextInput id="OBJECT_ID_FORMAT" label="Object Id format" emptyValue="Ex: {PERSON_ID}" description="Use this when the contents of a page change based on a context. Separate multiple contexts with an undescore, eg, {PERSON_ID}_{ASSIGNMENT_ID}" required="false"/>
      <TextInput id="CONTEXT_HANDLER" label="Object Id handler" emptyValue="PLSQL package function" description="Advanced: PLSQL function to derive additional keys that can be used by blocks" required="false"/>
      <Html id="HREF" label="Page Link"/>
      <Poplist id="STATUS" label="Status" required="true" listProvider="LOOKUP_TYPE:XXAS_PAGE_STATUSES" value="PUBLISHED" description="Draft pages are not accessible; published pages are visible to those with access"/>
      <TextInput id="MENU_NAME" label="Linked menu" enabled="false" hideIf="model.PAGE_BASICS.MENU_ID.value == null"/>
      <Poplist id="SUB_MENU_NAME" label="Sub-menu" listProvider="VALUE_SET_NAME:Applaud Sub-menus" description="The sub-menu shown when this page is visited" refreshOnChange="true"/>
      <Poplist id="ADDTOSM" label="Add this page into the sub menu" showAsBoolean="true" listProvider="LOOKUP_TYPE:YES_NO" positiveBooleanValue="Y" value="N" hideIf="!(model.PAGE_BASICS.SUB_MENU_NAME.value)"/>
      <Poplist id="LOCATION" label="Location" required="true" listProvider="REST:page-create/${field.SUB_MENU_NAME}" hideIf="((model.PAGE_BASICS.ADDTOSM.value != &apos;Y&apos;) || (!(model.PAGE_BASICS.SUB_MENU_NAME.value)))" />
      <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.PAGE_BASICS.RESTRICT_DEVICE.value != &apos;Y&apos;"/>
    </Container>
    
    <Container id="PAGE_LAYOUT" label="Layout">
      <Poplist id="LAYOUT" label="Layout" required="true" listProvider="LOOKUP_TYPE:XXAS_PAGE_LAYOUTS" value="STACKED" description="Determines how a page lays out its blocks when a page has more than 1 block; phones and other small devices are always stacked"/>
      <Poplist id="USE_DYNAMIC_TITLE" label="Use dynamic title" listProvider="LOOKUP_TYPE:YES_NO" value="N" showAsBoolean="true" positiveBooleanValue="Y"/>
      <TextInput id="TITLE_FUNCTION" label="Title function" emptyValue="Enter PLSQL package function" description="This is used to create a dynamic page title. Learn more." required="true" hideIf="model.PAGE_LAYOUT.USE_DYNAMIC_TITLE.value != &apos;Y&apos;"/>
      <Poplist id="HIDE_TITLE_FLAG" label="Hide title bar" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y" value="N" description="Hides the page title bar; use when the title is not all that important"/>
      <Poplist id="FIX_TITLE_FLAG" label="Anchor title bar" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y" value="N" description="Anchors the page when scrolling below it; use when the page will contain important Call-to-action buttons like &quot;Buy Now&quot;"
      hideIf="model.PAGE_LAYOUT.HIDE_TITLE_FLAG.value == &apos;Y&apos;"/>
      <TextInput id="BACKGROUND_IMAGE" label="Background Image" emptyValue="Ex: /OA_MEDIA/xxas/custom/a_background.png" description="Use to an image shown as the page background " required="false"/>
      <Poplist id="BACKGROUND_IMAGE_REPEAT" label="Background image repeat" required="true" listProvider="LOOKUP_TYPE:XXAS_PAGE_REPEAT" value="NO-REPEAT" description="If the image is tiled, use this to repeat the image across the entire page background"/>
      <Poplist id="UNCLOSABLE_MODAL" label="Unclosable Page Window" listProvider="LOOKUP_TYPE:YES_NO" showAsBoolean="true" positiveBooleanValue="Y" value="N" description="This is used to restrict the page window from closing"/>
    </Container>

  </EditFields>

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