<div class="col-sm-9 col-md-10 col-sm-push-3 col-md-push-2">

    <ol class="breadcrumb">
        <li><a href="#/realms/{{realm.realm}}/roles">{{:: 'roles' | translate}}</a></li>
        <li data-ng-hide="create">{{role.name}}</li>
        <li data-ng-show="create">{{:: 'add-role' | translate}}</li>
    </ol>

    <h1 data-ng-hide="create">{{role.name|capitalize}} <i id="removeRole" class="pficon pficon-delete clickable" data-ng-show="!create && access.manageRealm" 
    	data-ng-hide="changed" data-ng-click="remove()"></i></h1>
    <h1 data-ng-show="create">{{:: 'add-role' | translate}}</h1>

    <form class="form-horizontal clearfix" name="realmForm" novalidate kc-read-only="!access.manageRealm">
        <fieldset>
            <div class="form-group">
                <label class="col-md-2 control-label" for="name"><span class="required" data-ng-show="create">*</span> {{:: 'role-name' | translate}}</label>

                <div class="col-md-6">
                    <input class="form-control" type="text" id="name" name="name" data-ng-model="role.name" autofocus
                           required data-ng-readonly="!create">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="description">{{:: 'description' | translate}} </label>

                <div class="col-md-6">
                    <textarea class="form-control" rows="5" cols="50" id="description" name="description" data-ng-model="role.description"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="scopeParamRequired">{{:: 'scope-param-required' | translate}} </label>
                <kc-tooltip>{{:: 'scope-param-required.tooltip' | translate}}</kc-tooltip>
                <div class="col-md-6">
                    <input ng-model="role.scopeParamRequired" name="scopeParamRequired" id="scopeParamRequired" onoffswitch on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
            </div>
            <div class="form-group" data-ng-hide="create">
                <label class="col-md-2 control-label" for="compositeSwitch" class="control-label">{{:: 'composite-roles' | translate}}</label>
                <div class="col-md-6">
                    <input ng-model="compositeSwitch" name="compositeSwitch" id="compositeSwitch" ng-disabled="compositeSwitchDisabled" onoffswitch on-text="{{:: 'onText' | translate}}" off-text="{{:: 'offText' | translate}}" />
                </div>
                <kc-tooltip>{{:: 'composite-roles.tooltip' | translate}}</kc-tooltip>
            </div>
        </fieldset>

        <div class="form-group">
            <div class="col-md-10 col-md-offset-2" data-ng-show="create">
                <button kc-save data-ng-show="changed">{{:: 'save' | translate}}</button>
                <button kc-cancel data-ng-click="cancel()" data-ng-show="changed">{{:: 'cancel' | translate}}</button>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-10 col-md-offset-2" data-ng-show="!create && access.manageRealm">
                <button kc-save data-ng-disabled="!changed">{{:: 'save' | translate}}</button>
                <button kc-reset data-ng-disabled="!changed">{{:: 'cancel' | translate}}</button>
            </div>
        </div>

        <fieldset data-ng-show="!create && (compositeSwitch || role.composite)">
            <legend uncollapsed class="collapsible"><span class="text">{{:: 'composite-roles' | translate}}</span> </legend>
            <div class="form-group">
                <label class="col-md-2 control-label" class="control-label">{{:: 'realm-roles' | translate}}</label>

                <div class="col-md-10">
                    <div class="row">
                        <div class="col-md-4">
                            <label class="control-label">{{:: 'available-roles' | translate}}</label>
                            <kc-tooltip>{{:: 'composite.available-roles.tooltip' | translate}}</kc-tooltip>
                            <select id="available" class="form-control" multiple size="5"
                                    ng-multiple="true"
                                    ng-model="selectedRealmRoles"
                                    ng-options="r.name for r in realmRoles | orderBy:'name'">
                            </select>
                            <button ng-disabled="selectedRealmRoles.length == 0" class="btn btn-default" type="submit" ng-click="addRealmRole()">
                                {{:: 'add-selected' | translate}} <i class="fa fa-angle-double-right"></i>
                            </button>
                        </div>
                        <div class="col-md-4">
                            <label class="control-label">{{:: 'associated-roles' | translate}}</label>
                            <kc-tooltip>{{:: 'composite.associated-roles.tooltip' | translate}}</kc-tooltip>
                            <select id="assigned" class="form-control" multiple size=5
                                    ng-multiple="true"
                                    ng-model="selectedRealmMappings"
                                    ng-options="r.name for r in realmMappings | orderBy:'name'">
                            </select>
                            <button ng-disabled="selectedRealmMappings.length == 0" class="btn btn-default" type="submit" ng-click="deleteRealmRole()">
                                <i class="fa fa-angle-double-left"></i> {{:: 'remove-selected' | translate}}
                            </button>
                        </div>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-2 control-label" class="control-label">
                    <span>{{:: 'client-roles' | translate}}</span>
                    <select class="form-control" id="clients" name="clients" ng-change="changeClient()" ng-model="compositeClient" ng-options="a.clientId for a in clients | orderBy:'clientId'" ng-disabled="false"></select>
                </label>

                <div class="col-md-10">
                    <div class="row" data-ng-hide="compositeClient">
                        <div class="col-md-4"><span class="text-muted">{{:: 'select-client-to-view-roles' | translate}}</span></div>
                    </div>
                    <div class="row" data-ng-show="compositeClient">
                        <div class="col-md-4">
                            <label class="control-label" for="available-client">{{:: 'available-roles' | translate}}</label>
                            <kc-tooltip>{{:: 'composite.available-roles-client.tooltip' | translate}}</kc-tooltip>
                            <select id="available-client" class="form-control" multiple size="5"
                                    ng-multiple="true"
                                    ng-model="selectedClientRoles"
                                    ng-options="r.name for r in clientRoles | orderBy:'name'">
                            </select>
                            <button ng-disabled="selectedClientRoles.length == 0" class="btn btn-default" type="submit" ng-click="addClientRole()">
                                {{:: 'add-selected' | translate}} <i class="fa fa-angle-right"></i>
                            </button>
                        </div>
                        <div class="col-md-4">
                            <label class="control-label" for="assigned-client">{{:: 'associated-roles' | translate}}</label>
                            <kc-tooltip>{{:: 'composite.associated-roles-client.tooltip' | translate}}</kc-tooltip>
                            <select id="assigned-client" class="form-control" multiple size=5
                                    ng-multiple="true"
                                    ng-model="selectedClientMappings"
                                    ng-options="r.name for r in clientMappings | orderBy:'name'">
                            </select>
                            <button ng-disabled="selectedClientMappings.length == 0" class="btn btn-default" type="submit" ng-click="deleteClientRole()">
                                <i class="fa fa-angle-left"></i> {{:: 'remove-selected' | translate}}
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>
    </form>
</div>

<kc-menu></kc-menu>