<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: LR  
    $Date: 2013-7-25 下午05:58:35  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure/>
    <a:view>
        <a:link id="con202_basic_clause_select_link" url="${/request/@context_path}/modules/cont/CON202/con_basic_clause_select.lview"/>
        <a:link id="con202_clause_templet_line_text_link" url="${/request/@context_path}/modules/cont/CON202/con_clause_templet_line_text.lview"/>
        <script type="text/javascript"><![CDATA[
            function con202_clause_templet_line_add() {
                var dataset = $('con202_clause_templet_line_result_ds');
                var record = dataset.getCurrentRecord();
                if (!Leaf.isEmpty(record)) {
                    if (!record.isNew) {
                        var parent_line_id = record.get('templet_line_id');
                        new Leaf.Window({
                            id: 'con202_basic_clause_select_window',
                            url: $('con202_basic_clause_select_link').getUrl() + '?templet_id=' + '${/parameter/@templet_id}' + '&clause_usage=' + '${/parameter/@templet_usage}' + '&parent_line_id=' + parent_line_id,
                            params: null,
                            title: '${l:CON202.CON_BASIC_CLAUSE_SELECT}',
                            width: 500,
                            height: 450
                        });
                    } else {
                        Leaf.showMessage('${l:HLS.PROMPT}', '${l:CON202.AFTER_SAVE_ADD}');
                    }
                }
            }
            
            function con202_clause_templet_line_query() {
                $('con202_clause_templet_line_result_ds').query();
            }
            
            function con202_clause_templet_line_addtop() {
                new Leaf.Window({
                    id: 'con202_basic_clause_select_window',
                    url: $('con202_basic_clause_select_link').getUrl() + '?templet_id=' + '${/parameter/@templet_id}' + '&clause_usage=' + '${/parameter/@templet_usage}',
                    params: null,
                    title: '${l:CON202.CON_BASIC_CLAUSE_SELECT}',
                    width: 500,
                    height: 450
                });
            }
            
            function con202_clause_templet_line_save() {
                $('con202_clause_templet_line_result_ds').submit();
            }
            
            function con202_clause_templet_line_submit() {}
            
            function con202_clause_templet_line_deleteNote() {
                Leaf.showConfirm('${l:HLS.PROMPT}', '${l:HLS030.CONFIRM_DELETE}', function okFun() {
                    var ds = $('con202_clause_templet_line_result_ds');
                    var records = ds.getSelected();
                    if (records.length > 0) {
                        ds.remove(records);
                    }
                });
            }
            
            function con202_clause_templet_line_clearNote() {
                var ds = $('con202_clause_templet_line_result_ds');
                var records = ds.getSelected();
                for (var i = 0;i < records.length;i++) {
                    records[i].isNew = true;
                }
                ds.remove(records);
            }
            
            function windowopen_template_clause_text(id) {
                new Leaf.Window({
                    id: 'con202_clause_templet_line_text_window',
                    url: $('con202_clause_templet_line_text_link').getUrl(),
                    params: {
                        language: '${/parameter/@language}'
                    },
                    title: '${l:CON202.CON_BASIC_CLAUSE_QUERY}',
                    width: 500,
                    height: 450
                });
            }
            
            function con202_clause_templet_line_grid_render(value, record, name) {
                if (name == 'edit') {
                    return '<a href="javascript:windowopen_template_clause_text(\'' + record.id + '\');">${l:CON202.SEE}</a>';
                }
            }
            
            function con202_clause_templet_line_result_ds_Onselect(ds, record, all) {
                if (!all) {
                    var parent_clause_id = record.get('templet_line_id');
                    var records = ds.getAll();
                    var selectedRecords1 = ds.getSelected();
                    for (var i = 0;i < records.length;i++) {
                        if (records[i].get('parent_line_id') == record.get('templet_line_id')) {
                            if (selectedRecords1.indexOf(records[i]) == -1) {
                                ds.select(records[i]);
                            }
                        }
                    }
                }
            }
            
            function con202_clause_templet_line_result_ds_Onunselect(ds, record, all) {
                if (!all) {
                    var parent_clause_id = record.get('templet_line_id');
                    var records = ds.getAll();
                    var selectedRecords1 = ds.getSelected();
                    for (var i = 0;i < records.length;i++) {
                        if (records[i].get('templet_line_id') == record.get('parent_line_id')) {
                            if (selectedRecords1.indexOf(records[i]) != -1) {
                                ds.unSelect(records[i]);
                            }
                        }
                    }
                }
            }
            
            function con202_clause_templet_line_grid_cellclick(grid, row, name, record) {
                if (name == 'parent_clause_code') {
                    record.getField('parent_clause_code').setLovService('cont.CON202.con_clause_templet_line');
                    record.getField('parent_clause_code').setLovPara('not_templet_line_id', record.get('templet_line_id'));
                }
            }
        ]]></script>
        <a:dataSets>
            <a:dataSet id="con202_clause_templet_line_mplet_usage_ds" lookupCode="MPLET_USAGE"/>
            <a:dataSet id="con202_clause_templet_line_approval_status_ds" lookupCode="CON_TERMS_APPROVE_STATUS"/>
            <a:dataSet id="con202_clause_templet_line_enabled_status_ds" lookupCode="ENABLED_STATUS"/>
            <a:dataSet id="con202_clause_templet_line_query_ds">
                <a:fields>
                    <a:field name="templet_id" defaultValue="${/parameter/@templet_id}"/>
                </a:fields>
            </a:dataSet>
            <a:dataSet id="con202_clause_templet_line_result_ds" autoCount="false" fetchAll="true" loadData="true" model="cont.CON202.con_clause_templet_line" queryDataSet="con202_clause_templet_line_query_ds" selectable="true">
                <a:fields>
                    <a:field name="clause_code"/>
                    <a:field name="description"/>
                    <a:field name="clause_text_cn" readOnly="true"/>
                    <a:field name="clause_text_en" readOnly="true"/>
                    <a:field name="clause_text_jp" readOnly="true"/>
                    <a:field name="revisable_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="nullable_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="deletable_flag" checkedValue="Y" defaultValue="Y" uncheckedValue="N"/>
                    <a:field name="expand_flag" checkedValue="Y" uncheckedValue="N"/>
                    <a:field name="parent_clause_code" lovGridHeight="320" lovHeight="450" lovWidth="500" title="CON201.CON_BASIC_CLAUSE.PARENT_CLAUSE_CODE">
                        <a:mapping>
                            <a:map from="templet_line_id" to="parent_line_id"/>
                            <a:map from="clause_code" to="parent_clause_code"/>
                        </a:mapping>
                    </a:field>
                </a:fields>
                <a:events>
                    <a:event name="select" handler="con202_clause_templet_line_result_ds_Onselect"/>
                    <a:event name="unselect" handler="con202_clause_templet_line_result_ds_Onunselect"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenBody>
            <a:screenTopToolbar>
                <a:gridButton click="con202_clause_templet_line_addtop" text="HLS030.TREE_ADDTOP"/>
                <a:gridButton click="con202_clause_templet_line_add" text="HLS030.TREE_ADDSON"/>
                <a:gridButton click="con202_clause_templet_line_query" text="HLS.QUERY" width="80"/>
                <a:gridButton click="con202_clause_templet_line_save" text="HLS.SAVE" width="80"/>
                <a:gridButton click="con202_clause_templet_line_deleteNote" text="HLS.REMOVE" width="80"/>
                <a:gridButton click="con202_clause_templet_line_clearNote" text="HLS.CLEAR" width="80"/>
            </a:screenTopToolbar>
            <a:treeGrid id="con202_clause_templet_line_functionTreeGrid" bindTarget="con202_clause_templet_line_result_ds" expandField="expand_flag" idField="templet_line_id" marginHeight="110" marginWidth="50" parentField="parent_line_id" sequenceField="order_seq" showCheckBox="false" width="800">
                <a:columns>
                    <a:column name="clause_code" prompt="CON201.CON_BASIC_CLAUSE.CLAUSE_CODE" width="250"/>
                    <a:column name="clause_desc" prompt="CON201.CON_BASIC_CLAUSE.DESCRIPTION" width="120"/>
                    <a:column name="parent_clause_code" editor="con202_clause_templet_line_grid_lov" prompt="CON201.CON_BASIC_CLAUSE.PARENT_CLAUSE_CODE" width="150"/>
                    <a:column name="edit" align="center" prompt="CON201.CON_BASIC_CLAUSE.EDIT" renderer="con202_clause_templet_line_grid_render" width="70"/>
                    <a:column name="order_seq" align="right" editor="con202_clause_templet_line_grid_nf" prompt="HLS030.TREE_SEQ" width="60"/>
                    <a:column name="display_seq" align="right" editor="con202_clause_templet_line_grid_nf" prompt="CON202.CON_CLAUSE_TEMPLET.DISPLAY_SEQ" width="60"/>
                    <a:column name="expand_flag" editor="con202_clause_templet_line_grid_ck" prompt="HLS030.EXPAND_FLAG" width="80"/>
                    <a:column name="revisable_flag" editor="con202_clause_templet_line_grid_ck" prompt="CON202.CON_CLAUSE_TEMPLET.REVISABLE_FLAG"/>
                    <a:column name="nullable_flag" editor="con202_clause_templet_line_grid_ck" prompt="CON202.CON_CLAUSE_TEMPLET.NULLABLE_FLAG"/>
                    <a:column name="deletable_flag" editor="con202_clause_templet_line_grid_ck" prompt="CON202.CON_CLAUSE_TEMPLET.DELETABLE_FLAG"/>
                </a:columns>
                <a:editors>
                    <a:numberField id="con202_clause_templet_line_grid_nf" allowDecimals="false" allowNegative="false" max="999"/>
                    <a:textField id="con202_clause_templet_line_grid_tf"/>
                    <a:checkBox id="con202_clause_templet_line_grid_ck"/>
                    <a:comboBox id="con202_clause_templet_line_grid_cb"/>
                    <a:lov id="con202_clause_templet_line_grid_lov"/>
                </a:editors>
                <a:events>
                    <a:event name="cellclick" handler="con202_clause_templet_line_grid_cellclick"/>
                </a:events>
            </a:treeGrid>
        </a:screenBody>
    </a:view>
</a:screen>
