<AppCol
    noRoot
    :visible="store.detailModel.{{item.codeName}}.visible"
    :layoutOpts="{{> @macro/common/layoutPos.hbs layout=item.psLayout layoutPos=item.psLayoutPos}}">
    {{#if (neq item.contentType "REPEATER")}}
    <AppFormMdCtrl
        key="{{item.codeName}}"
        name="{{item.codeName}}"
        {{#if item.psSysCss}} 
        class="{{item.psSysCss.cssName}}" 
        {{/if}}
        {{#if (or item.width item.height)}}
        style="{{#if item.width}}width: {{item.width}}px;{{/if}}{{#if item.height}}height: {{item.height}}px;{{/if}}"
        {{/if}}
        entityCodeName="{{#if (and item.contentPSControl item.contentPSControl.psAppDataEntity)}}{{item.contentPSControl.psAppDataEntity.codeName}}{{/if}}"
        deKeyField="{{#if (and item.contentPSControl item.contentPSControl.psAppDataEntity)}}{{item.contentPSControl.psAppDataEntity.keyPSAppDEField.codeName}}{{/if}}"
        contentType="{{item.contentType}}"
        :context="store.context"
        :viewParams="store.viewParams"
        @component-action="(actionParam: any) => { handleComponentAction(controller, actionParam) }">
        <template v-slot:default="{ context, viewParams, handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
            <{{item.contentPSControl.psAppDataEntity.codeName}}{{item.contentPSControl.codeName}}{{#if (eq item.contentType 'FORM')}}Form{{else if (eq item.contentType 'GRID')}}Grid{{/if}}
                name="{{item.contentPSControl.name}}"
                {{#if (eq item.contentType 'FORM')}}
                :actions="{
                    loadAction: 'GetTemp',
                    loadDraftAction: 'GetDraftTemp',
                    updateAction: 'UpdateTemp',
                    createAction: 'CreateTemp',
                    removeAction: 'RemoveTemp',
                }"
                {{else if (eq item.contentType 'GRID')}}
                :actions="{
                    loadDraftAction: 'GetDraftTemp',
                    updateAction: 'UpdateTemp',
                    createAction: 'CreateTemp',
                    removeAction: 'RemoveTemp',
                    fetchAction: 'FetchTempDefault',
                }"
                :defaultEnableRowEdit="true"
                {{/if}}
                :autoLoad="true"
                :localMode="true"
                :openView="store.openView"
                :newView="store.newView"
                :context="context"
                :viewParams="viewParams"
                :closeView="store.closeView"
                :pLoadingHelper="store.loadingHelper"
                :pViewCtx="store.viewCtx"
                @ctrl-init="(name:string, ability:any) => { handleCtrlInit(name, ability) }"
                @ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(name, action, data) }"
                @ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(name, data) }"
            />
        </template>
    </AppFormMdCtrl>
    {{else}}
    <AppFormMdCtrlRepeater
        caption="{{item.caption}}"
        {{#if item.columnAlign}}
        columnAlign="{{item.columnAlign}}"
        {{/if}}
        name="{{item.name}}"
        :layoutOpts="{{> @macro/common/layoutPos.hbs layout=item.psLayout layoutPos=item.psLayoutPos}}"
        {{#if repeaterIndex}}
        :level="{{repeaterIndex}}"
        {{/if}}
        {{#and item.parent (eq item.parent.detailType 'MDCTRL') (eq item.parent.contentType 'REPEATER')}}
        :parentData="data"
        :context="context"
        :viewParams="viewParams"
        {{else}}
        :parentData="store.data"
        :context="store.context"
        :viewParams="store.viewParams"
        {{/and}}
        {{#if item.psDEFormDetails}}
        :children="[
            {{#each item.psDEFormDetails as | formDetail |}}
            {{#unless formDetail.hidden}}
                {{#and (eq formDetail.detailType 'FORMITEM')}}
            { name: '{{lowerCase formDetail.codeName}}', type: 'FORMITEM', caption: '{{formDetail.caption}}' },
                {{/and}}
                {{#and (eq formDetail.detailType 'MDCTRL') (eq formDetail.contentType 'REPEATER')}}
            { name: '{{lowerCase formDetail.codeName}}', type: 'REPEATER', caption: '{{formDetail.caption}}' },
                {{/and}}
            {{/unless}}
            {{/each}}
        ]"
        {{/if}}
        mode="{{item.detailStyle}}"
        @component-action="(actionParam: any) => { handleComponentAction(controller, actionParam) }">
        {{#neq item.detailStyle 'STYLE2'}}
        <template #default="{ data, context, viewParams, handleComponentAction }">
        {{/neq}}
        {{#each item.psDEFormDetails as | formDetail |}}
            {{#unless formDetail.hidden}}
            {{#if repeaterIndex}}
            {{> @macro/widgets/form-detail/include-form.hbs type=formDetail.detailType item=formDetail repeaterMode=item.detailStyle repeaterIndex=(add 1 repeaterIndex)}}
            {{else}}
            {{> @macro/widgets/form-detail/include-form.hbs type=formDetail.detailType item=formDetail repeaterMode=item.detailStyle repeaterIndex=1}}
            {{/if}}
            {{/unless}}
        {{/each}}
        {{#neq item.detailStyle 'STYLE2'}}
        </template>
        {{/neq}}
    </AppFormMdCtrlRepeater>
    {{/if}}
</AppCol>
