<div class="bs-sidebar col-sm-3 " data-ng-include data-src="resourceUrl + '/partials/realm-menu.html'"></div>
<div id="content-area" class="col-sm-9" role="main">
    <ul class="nav nav-tabs nav-tabs-pf">
        <li><a href="#/realms/{{realm.realm}}/protocols/{{protocol}}/mappers">Mappers</a></li>
    </ul>
    <div id="content">
        <ol class="breadcrumb" data-ng-hide="create">
            <li><a href="#/realms/{{realm.realm}}/protocols/{{protocol}}/mappers">Protocol Mappers</a></li>
            <li><a href="#/realms/{{realm.realm}}/protocols/{{protocol}}/mappers/{{mapper.id}}">{{mapper.name}}</a></li>
            <li class="active">Protocol Mapper</li>
        </ol>
        <ol class="breadcrumb" data-ng-show="create">
            <li><a href="#/realms/{{realm.realm}}/protocols/{{protocol}}/mappers">Protocol Mappers</a></li>
            <li class="active">Add Protocol Mapper</li>
        </ol>
        <h2 class="pull-left" data-ng-hide="create">Protocol Mapper Settings</h2>
        <h2 class="pull-left" data-ng-show="create">Add Protocol Mapper</h2>
        <p class="subtitle"><span class="required">*</span> Required fields</p>
        <form class="form-horizontal" name="realmForm" novalidate kc-read-only="!access.manageRealm">

            <fieldset>
                <div class="form-group clearfix">
                    <label class="col-sm-2 control-label" for="protocol">Protocol</label>
                    <div class="col-sm-4">
                        <input class="form-control" id="protocol" type="text" ng-model="protocol" readonly>
                    </div>
                    <span tooltip-placement="right" tooltip="Protocol." class="fa fa-info-circle"></span>
                </div>
                <div class="form-group clearfix" data-ng-show="!create">
                    <label class="col-sm-2 control-label" for="mapperId">ID </label>
                    <div class="col-sm-4">
                        <input class="form-control" id="mapperId" type="text" ng-model="mapper.id" readonly>
                    </div>
                </div>
                <div class="form-group clearfix">
                    <label class="col-sm-2 control-label" for="name">Name</label>
                    <div class="col-sm-4">
                        <input class="form-control" id="name" type="text" ng-model="mapper.name" data-ng-readonly="!create">
                    </div>
                    <span tooltip-placement="right" tooltip="Name of the mapper." class="fa fa-info-circle"></span>
                </div>
                <div class="form-group">
                    <label for="consentRequired" class="col-sm-2 control-label">Consent required</label>
                    <div class="col-sm-4">
                        <input ng-model="mapper.consentRequired" name="consentRequired" id="consentRequired" onoffswitch />
                    </div>
                    <span tooltip-placement="right" tooltip="When granting temporary access, must the user consent to providing this data to the client?" class="fa fa-info-circle"></span>
                </div>
                <div class="form-group" data-ng-show="mapper.consentRequired">
                    <label class="col-sm-2 control-label" for="consentText">Consent Text </label>

                    <div class="col-sm-4">
                        <textarea class="form-control" rows="5" cols="50" id="consentText" name="consentText" data-ng-model="mapper.consentText"></textarea>
                    </div>
                    <span tooltip-placement="right" tooltip="Text to display on consent page" class="fa fa-info-circle"></span>
                </div>
                <div class="form-group" data-ng-show="create">
                    <label class="col-sm-2 control-label" for="mapperTypeCreate">Mapper Type</label>
                    <div class="col-sm-6">
                        <div class="select-kc">
                            <select id="mapperTypeCreate"
                                    ng-model="mapperType"
                                    ng-options="mapperType.name for mapperType in mapperTypes">
                            </select>
                        </div>
                    </div>
                    <span tooltip-placement="right" tooltip="{{mapperType.helpText}}" class="fa fa-info-circle"></span>
                </div>
                <div class="form-group clearfix" data-ng-hide="create">
                    <label class="col-sm-2 control-label" for="mapperType">Mapper Type</label>
                    <div class="col-sm-4">
                        <input class="form-control" id="mapperType" type="text" ng-model="mapperType.name" data-ng-readonly="true">
                    </div>
                    <span tooltip-placement="right" tooltip="{{mapperType.helpText}}" class="fa fa-info-circle"></span>
                </div>
                <div data-ng-repeat="option in mapperType.properties" class="form-group">
                    <label class="col-sm-2 control-label">{{option.label}} </label>

                    <div class="col-sm-4" data-ng-hide="option.type == 'boolean'">
                        <input class="form-control" type="text" data-ng-model="mapper.config[ option.name ]" >
                    </div>
                    <div class="col-sm-4" data-ng-show="option.type == 'boolean'">
                        <input ng-model="mapper.config[ option.name ]" value="'true'" name="option.name" id="option.name" onoffswitchmodel />
                    </div>
                    <span tooltip-placement="right" tooltip="{{option.helpText}}" class="fa fa-info-circle"></span>
                </div>

            </fieldset>
            <div class="pull-right form-actions" data-ng-show="create && access.manageRealm">
                <button kc-cancel data-ng-click="cancel()">Cancel</button>
                <button kc-save>Save</button>
            </div>

            <div class="pull-right form-actions" data-ng-show="!create && access.manageRealm">
                <button kc-reset data-ng-show="changed">Clear changes</button>
                <button kc-save  data-ng-show="changed">Save</button>
                <button kc-delete data-ng-click="remove()" data-ng-hide="changed">Delete</button>
            </div>
        </form>
    </div>
</div>