/* $Id$ */
/*============================================================================*
 |                 Copyright (c) 2015 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_forms_basic_details_v
AS
SELECT xfv.title form_title
      --,EXTRACTVALUE(view_xml,'View/@defaultFormHandler') default_form_handler  
      ,EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@postToHref') post_href
      ,decode(EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@postToHref'),null,'Y','forms/{blockFunctionId}','N','N') use_fsh
      ,EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@defaultFormHandler') default_form_handler
	  ,decode(EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@showSubmit'),'true','Y',null) show_submit
      ,EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@submitLabel') submit_label
      ,EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@submitButtonIcon') submit_icon
      ,EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@submitButtonColor') submit_color
      ,EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@formHelp') form_help
      ,DECODE(EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@autosave'),null,
        DECODE(EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@clientAutosave'),'true','CSA',null),'SSA') auto_save
      ,EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@autosaveMessage') auto_save_message
      ,to_number(EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@autosaveTimeout')) auto_save_timeout
      ,EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@clientAutosaveResetText') auto_save_text
      ,EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@clientAutosaveResetButton') auto_save_bl
      ,decode(EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@sendBasicAuthentication'),'true','Y',null) send_basic_auth
      ,decode(EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@sendToken'),'true','Y',null) send_token
      ,decode(EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@basicAuthUsernameField'),null,
        decode(EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@basicAuthPasswordField'),null,
         decode(EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@tokenField'),null,'N','Y')
        ,'Y')
       ,'Y') login_form
      ,EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@basicAuthUsernameField') basic_auth_un
      ,EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@basicAuthPasswordField') basic_auth_pw
      ,EXTRACTVALUE(XDBURIType(xfv.any_path).getXML(),'View/@tokenField') token_field
      ,xfv.any_path xdb_uri
      ,xfv.form_id
      ,xxas_forms_pkg.container_exists(xfv.form_id) container_exists
      --,REPLACE(xfv.any_path,'/','_') xdb_uri
FROM xxas_forms_resource xfv;

BEGIN
  xxas_fnd_dictionary_pkg.add_view
   (p_application_short_name => xxas_util_pkg.app
   ,p_view_name              => 'XXAS_FORMS_BASIC_DETAILS_V'
   ,p_description            => 'Applaud Forms Basic Details');
END;
/

COMMIT;
EXIT;