<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">
    <kc-navigation-oauth-client></kc-navigation-oauth-client>
    <div id="content">
        <ol class="breadcrumb" data-ng-show="create">
            <li><a href="#/realms/{{realm.realm}}/oauth-clients">OAuth Clients</a></li>
            <li><a href="#/realms/{{realm.realm}}/oauth-clients/{{oauth.id}}">{{oauth.name}}</a></li>
            <li><a href="#/realms/{{realm.realm}}/oauth-clients/{{oauth.id}}/mappers">{{oauth.name}} Mappers</a></li>
            <li class="active">Create Protocol Mapper</li>
        </ol>

        <ol class="breadcrumb" data-ng-hide="create">
            <li><a href="#/realms/{{realm.realm}}/oauth-clients">OAuth Clients</a></li>
            <li><a href="#/realms/{{realm.realm}}/oauth-clients/{{oauth.id}}">{{oauth.name}}</a></li>
            <li><a href="#/realms/{{realm.realm}}/oauth-clients/{{oauth.id}}/mappers">{{oauth.name}} Mappers</a></li>
            <li class="active">{{mapper.name}}</li>
        </ol>
        <h2 class="pull-left" data-ng-hide="create">{{mapper.name}} Protocol Mapper</h2>
        <h2 class="pull-left" data-ng-show="create">Create 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' || option.type == 'List'">
                        <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>
                    <div class="col-sm-4" data-ng-show="option.type == 'List'">
                        <select ng-model="mapper.config[ option.name ]" ng-options="data for data in option.defaultValue">
                            <option value="" selected> Select one... </option>
                        </select>
                    </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>