{{> headers/_TitleWithSubAndIcon title=form.chainData._id type="console.authentication.editChains.chains" icon="link" }}

<p class="page-description">{{t 'console.authentication.editChains.moduleHelp'}}</p>

<div class="tab-menu">
    <ul class="nav nav-tabs" role="tablist">
        <li class="active"><a href="#chains" role="tab"  data-toggle="tab" aria-expanded="true"> {{t 'console.authentication.editChains.editChain'}}</a></li>
        <li><a href="#settings" role="tab" data-toggle="tab" aria-expanded="true"> {{t 'common.form.settings'}}</a></li>
    </ul>
</div>

<div class="panel panel-default fr-panel-tab">

    <div class="tab-content" id="editChainView">

        <div role="tabpanel" class="tab-pane active" id="chains">

            <div class="panel-body">
                <div class="btn-toolbar hidden">
                    <button type="button" class="btn btn-primary" data-add-new-module>
                        <i class="fa fa-plus"></i> {{t 'console.authentication.editChains.addModule'}}
                    </button>
                    <div class="pull-right text-valign-middle auth-chains-legend">
                        {{t 'console.authentication.editChains.legend.0'}}
                        <span class="badge badge-success"><i class="fa fa-flag"></i></span>
                        {{t 'console.authentication.editChains.legend.1'}}
                        <span class="badge badge-danger"><i class="fa fa-flag"></i> </span>
                        {{t 'console.authentication.editChains.legend.2'}}
                    </div>
                </div>

                <div id="sortableContainer">
                    <ol id="sortableAuthChain" class="list-unstyled hidden"></ol>
                </div>
                <div class="call-to-action-block hidden">
                    <h3>{{t 'console.authentication.editChains.callToAction'}}</h3>
                    <button type="button" class="btn btn-primary" data-add-new-module>
                        <i class="fa fa-plus"></i> {{t 'console.authentication.editChains.addModule'}}
                    </button>
                </div>

                <div id="lowerAuthChainsLegend" class="hidden">
                    <div class="panel panel-default">
                        <div class="panel-body">
                            <div class="text-center auth-chains-legend">
                                {{t 'console.authentication.editChains.legend.0'}}
                                <span class="badge badge-success"><i class="fa fa-flag"></i></span>
                                {{t 'console.authentication.editChains.legend.1'}}
                                <span class="badge badge-danger"><i class="fa fa-flag"></i> </span>
                                {{t 'console.authentication.editChains.legend.2'}}
                            </div>
                        </div>
                    </div>
                </div>
                <div id="alertContainer"></div>
            </div>

            <div class="panel-footer clearfix">
                <div class="pull-right">
                    {{!-- TODO: change to data-save after refactoring of the save logic --}}
                    <button data-save-chain class="btn btn-primary" type="button" disabled>
                        <span>{{t "common.form.saveChanges"}}</span>
                    </button>
                </div>
            </div>

        </div>

        <div role="tabpanel" class="tab-pane" id="settings">

            <div class="panel-body">

                <div class="block clearfix">
                    <h3 class="block-header">{{t 'console.authentication.editChains.redirectUrls'}}</h3>
                    <p class="panel-description">{{t 'console.authentication.editChains.redirectUrlsHelp'}}</p>
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label for="loginSuccessUrl" class="control-label col-sm-4">{{t 'console.authentication.editChains.successUrl'}}</label>
                            <div class="col-sm-6">
                                <input id="loginSuccessUrl" type="text" class="form-control input-btn" placeholder="{{t 'console.authentication.editChains.addUrl'}}"  value="{{form.chainData.loginSuccessUrl.[0]}}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="loginFailureUrl" class="control-label col-sm-4">{{t 'console.authentication.editChains.failUrl'}}</label>
                            <div class="col-sm-6">
                                <input id="loginFailureUrl" type="text" class="form-control input-btn" placeholder="{{t 'console.authentication.editChains.addUrl'}}" value="{{form.chainData.loginFailureUrl.[0]}}">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="block clearfix">
                    <h3 class="block-header">{{t 'console.authentication.editChains.processingClass.title'}}</h3>
                    <p class="panel-description">{{t 'console.authentication.editChains.processingClass.help'}}</p>
                    <table class="table" id="postProcessView"></table>
                </div>

                <div class="panel-footer clearfix">
                    <div class="pull-right">
                        {{!-- TODO: change to data-save after refactoring of the save logic --}}
                        <button data-save-settings class="btn btn-primary" type="button">
                            <span>{{t "common.form.saveChanges"}}</span>
                        </button>
                    </div>
                </div>

            </div>

        </div>

    </div>

</div>
