<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-2-26 下午2:37:49  
    $Revision: 1.0  
    $Purpose: layoutScreen
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="pageLink_screen_setup" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_tab_screen.lview?_csrf=${/session/@_csrf.token}"/>
        <a:link id="pageLink_tab_setup" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_tab.lview?_csrf=${/session/@_csrf.token}"/>
        <a:link id="pageLink_config_setup" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_config.lview?_csrf=${/session/@_csrf.token}"/>
        <a:link id="pageLink_layout_copy" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_copy.lview?_csrf=${/session/@_csrf.token}"/>
        <a:link id="pageLink_tree_setup" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_tree_setup.lview?_csrf=${/session/@_csrf.token}"/>
        <a:link id="pageLink_button_setup" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_button_setup.lview?_csrf=${/session/@_csrf.token}"/>
        <a:link id="pageLink_welcome" url="${/request/@context_path}/welcome.lview?_csrf=${/session/@_csrf.token}"/>
        <a:link id="hls_doc_layout_cache_clear_link_id" url="${/request/@context_path}/modules/hls/HLS030/hls_doc_layout_cache_clear.svc"/>
        <script type="text/javascript"><![CDATA[
            function layoutScreen_query() {
                $('layoutDs').query();
            }
            
            function layoutScreen_clear() {
                $('layoutDs_grid').clear();
            }
            
            function layoutScreen_add() {
                $('layoutDs_grid').showEditorByRecord($('layoutDs').create());
            }
            
            function layoutScreen_save() {
                var ds = $('layoutDs');
                if (ds.validate()) {
                    ds.submit();
                }
            }
            
            function layoutScreen_quit() {
                location.href = $('pageLink_welcome').getUrl();
            }
            
            function editFunction_layoutDs_grid(record, name) {
                if (name == 'layout_code') {
                    if (record.isNew) {
                        return 'layoutDs_grid_tf_upper';
                    }
                    return '';
                } else if (name == 'document_category_desc') {
                    if (record.isNew) {
                        return 'layoutDs_grid_lov';
                    }
                    return '';
                }
                return '';
            }
            
            function winOpen_tab_setup(layout_code, document_category) {
                new Leaf.Window({
                    id: 'hls_doc_layout_tab',
                    url: $('pageLink_tab_setup').getUrl(),
                    params: {
                        layout_code: layout_code,
                        document_category: document_category
                    },
                    title: '${l:HLS030.WIN_TITLE.TAB_SETUP}' + '(' + layout_code + ')',
                    fullScreen: true
                });
            }
            
            function winOpen_screen_setup(layout_code) {
                new Leaf.Window({
                    id: 'hls_doc_layout_tab_screen',
                    url: $('pageLink_screen_setup').getUrl(),
                    params: {
                        layout_code: layout_code
                    },
                    title: '${l:HLS030.WIN_TITLE.SCREEN_SETUP}',
                    fullScreen: true,
                    draggable: true
                });
            }
            
            function winOpen_config_setup(layout_code) {
                new Leaf.Window({
                    id: 'hls_doc_layout_config',
                    url: $('pageLink_config_setup').getUrl(),
                    params: {
                        layout_code: layout_code
                    },
                    title: '${l:HLS030.WIN_TITLE.CONFIG_SETUP}',
                    fullScreen: true,
                    draggable: true
                });
            }
            
            function winOpen_layout_copy(layout_code) {
                new Leaf.Window({
                    id: 'hls_doc_layout_copy',
                    url: $('pageLink_layout_copy').getUrl(),
                    params: {
                        layout_code: layout_code
                    },
                    title: '${l:HLS030.WIN_TITLE.LAYOUT_COPY}',
                    width: 500,
                    height: 200
                });
            }
            
            function winOpen_tree_setup(layout_code) {
                new Leaf.Window({
                    id: 'hls_doc_tree_setup',
                    url: $('pageLink_tree_setup').getUrl(),
                    params: {
                        layout_code: layout_code
                    },
                    title: '${l:HLS030.TREE_SETUP}',
                    fullScreen: true
                });
            }
            
            function winOpen_button_setup(layout_code, layout_desc) {
                new Leaf.Window({
                    id: 'hls_doc_button_setup',
                    url: $('pageLink_button_setup').getUrl(),
                    params: {
                        layout_code: layout_code,
                        layout_desc: layout_desc
                    },
                    title: '${l:HLS031.BUTTON_CONFIG}',
                    fullScreen: true
                });
            }
            
            function render_layoutDs_grid(value, record, name) {
                var layout_code = record.get('layout_code');
                if (name == 'layout_code') {
                    if (record.isNew) {
                        return value;
                    } else {
                        return '<a href="javascript:winOpen_tab_setup(\'' + layout_code + '\',\'' + record.get('document_category') + '\');">' + value + '</a>';
                    }
                }
                if (!record.isNew) {
                    if (name == 'screen_setup') {
                        return '<a href="javascript:winOpen_screen_setup(\'' + layout_code + '\');">' + '${l:HLS030.LINK.SCREEN_SETUP}' + '</a>';
                    } else if (name == 'tab_setup') {
                        return '<a href="javascript:winOpen_tab_setup(\'' + layout_code + '\',\'' + record.get('document_category') + '\');">' + '${l:HLS030.LINK.TAB_SETUP}' + '</a>';
                    } else if (name == 'config_setup') {
                        return '<a href="javascript:winOpen_config_setup(\'' + layout_code + '\');">' + '${l:HLS030.LINK.CONFIG_SETUP}' + '</a>';
                    } else if (name == 'layout_copy') {
                        return '<a href="javascript:winOpen_layout_copy(\'' + layout_code + '\');">' + '${l:HLS030.LINK.LAYOUT_COPY}' + '</a>';
                    } else if (name == 'tree_setup' && record.get('document_category') == 'PROJECT') {
                        return '<a href="javascript:winOpen_tree_setup(\'' + layout_code + '\');">' + '${l:HLS030.TREE_SETUP}' + '</a>';
                    } else if (name == 'button_setup') {
                        var layout_desc = record.get('description');
                        return '<a href="javascript:winOpen_button_setup(\'' + layout_code + '\',\'' + layout_desc + '\');">' + '${l:HLS031.BUTTON_CONFIG}' + '</a>';
                    }
                    return '';
                }
                return '';
            }
            
            function onSubmitSuccess_layoutDs(ds) {
                layoutScreen_query();
            }
            
            function layoutCache_clear() {
                var records = $('layoutDs').getSelected();
                var saveData = [];
                if (!records.length) {
                    Leaf.showMessage('${l:PROMPT}', '${l:HLS.SELECT_RECORD}');
                    return;
                } else {
                    for (var i = 0;i < records.length;i++) {
                        saveData.push(records[i].data);
                    }
                    Leaf.request({
                        url: $('hls_doc_layout_cache_clear_link_id').getUrl(),
                        para: saveData,
                        success: function(res) {
                            Leaf.SideBar.show({
                                msg: '${l:HLS.SUBMIT_SUCCESS}',
                                duration: 2000
                            });
                        },
                        scope: this
                    });
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="enabled_flag_ds" lookupCode="HLS_CHECKBOX"/>
            <a:dataSet id="layout_query_ds">
                <a:fields>
                    <a:field name="layout_code_ref"/>
                    <a:field name="document_category_desc" lovGridHeight="300" lovHeight="450" lovService="hls.HLS030.hls_document_category_lov" lovWidth="600" title="HLS.DOCUMENT_CATEGORY">
                        <a:mapping>
                            <a:map from="description" to="document_category_desc"/>
                            <a:map from="document_category" to="document_category"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="description"/>
                    <a:field name="enabled_flag_desc" displayField="code_value_name" options="enabled_flag_ds" returnField="enabled_flag" valueField="code_value"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="layoutDs" autoPageSize="true" autoQuery="true" model="hls.HLS030.hls_doc_layout" queryDataSet="layout_query_ds" selectable="true">
                <a:fields>
                    <a:field name="layout_code" required="true"/>
                    <a:field name="description" required="true"/>
                    <a:field name="enabled_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="document_category_desc" autoComplete="true" lovGridHeight="300" lovHeight="450" lovService="hls.HLS030.hls_document_category_lov" lovWidth="600" required="true" title="HLS.DOCUMENT_CATEGORY">
                        <a:mapping>
                            <a:map from="description" to="document_category_desc"/>
                            <a:map from="document_category" to="document_category"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
                <a:events>
                    <a:event name="submitsuccess" handler="onSubmitSuccess_layoutDs"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:screenTitle/>
                <a:gridButton click="layoutScreen_quit" text="HLS.CLOSE"/>
                <a:gridButton click="layoutScreen_query" text="HLS.QUERY"/>
                <a:gridButton click="layoutScreen_add" text="HLS.NEW"/>
                <a:gridButton click="layoutScreen_clear" text="HLS.CLEAR"/>
                <a:gridButton click="layoutScreen_save" text="HLS.SAVE"/>
                <a:gridButton click="layoutCache_clear" text="HLS.LAYOUT_CACHE_CLEAR"/>
            </a:screenTopToolbar>
            <a:form column="4" title="HLS.QUERY_TITLE">
                <a:lov name="document_category_desc" bindTarget="layout_query_ds" prompt="HLS.DOCUMENT_CATEGORY_DESC"/>
                <a:textField name="layout_code_ref" bindTarget="layout_query_ds" prompt="HLS.LAYOUT_CODE"/>
                <a:textField name="description" bindTarget="layout_query_ds" prompt="HLS.DESCRIPTION"/>
                <a:comboBox name="enabled_flag_desc" bindTarget="layout_query_ds" prompt="HLS.ENABLED_FLAG"/>
            </a:form>
            <a:grid id="layoutDs_grid" autoFocus="true" bindTarget="layoutDs" marginHeight="140" marginWidth="30" navBar="true">
                <a:columns>
                    <a:column name="layout_code" editorFunction="editFunction_layoutDs_grid" renderer="render_layoutDs_grid" width="200"/>
                    <a:column name="description" editor="layoutDs_grid_tf" width="200"/>
                    <a:column name="width" editor="layoutDs_grid_nf_integer" prompt="HLS.SCREEN_WIDTH" width="100"/>
                    <a:column name="height" editor="layoutDs_grid_nf_integer" prompt="HLS.SCREEN_HEIGHT" width="100"/>
                    <a:column name="enabled_flag" align="center" editor="layoutDs_grid_check" width="60"/>
                    <a:column name="order_seq" align="right" editor="layoutDs_grid_nf_integer" width="60"/>
                    <a:column name="document_category_desc" editorFunction="editFunction_layoutDs_grid" width="150"/>
                    <a:column name="tab_setup" align="center" prompt="HLS030.WIN_TITLE.TAB_SETUP" renderer="render_layoutDs_grid"/>
                    <a:column name="button_setup" align="center" prompt="HLS031.BUTTON_CONFIG" renderer="render_layoutDs_grid"/>
                    <a:column name="tree_setup" align="center" prompt="HLS030.TREE_SETUP" renderer="render_layoutDs_grid"/>
                    <!--
                    <a:column name="screen_setup" align="center" prompt="HLS030.WIN_TITLE.SCREEN_SETUP" renderer="render_layoutDs_grid"/>
                    <a:column name="config_setup" align="center" prompt="HLS030.WIN_TITLE.CONFIG_SETUP" renderer="render_layoutDs_grid"/>
                    -->
                    <a:column name="layout_copy" align="center" prompt="HLS030.WIN_TITLE.LAYOUT_COPY" renderer="render_layoutDs_grid"/>
                </a:columns>
                <a:editors>
                    <a:lov id="layoutDs_grid_lov"/>
                    <a:numberField id="layoutDs_grid_nf_integer" allowDecimals="false" allowNegative="false"/>
                    <a:textField id="layoutDs_grid_tf"/>
                    <a:textField id="layoutDs_grid_tf_upper" maxLength="30" typeCase="upper"/>
                    <a:checkBox id="layoutDs_grid_check"/>
                </a:editors>
            </a:grid>
        </a:screenBody>
    </a:view>
</a:screen>
