@extends('ui::layouts.app')

@section('content')

    <div class="ui menu top attached">
        <a href="{{ route('overide::roles.index') }}" class="item"><i class="icon angle left"></i></a>
        <h3 class="ui header item">@lang('overide::label.edit_role')</h3>
    </div>

    <div class="ui segment very padded bottom attached">
        {!! Form::open()->put()->action(route('overide::roles.update', $role['id'])) !!}
        <div class="field required">
            {!! Form::text('name', old('name', $role['name']))->label(trans('overide::roles.name')) !!}
        </div>

        <table class="ui table">
            <thead>
            <tr>
                <th>
                    <div class="ui checkbox" data-toggle="checkall" data-selector=".checkbox[data-type='check-all-child']">
                        <input type="checkbox">
                        <label><strong>Hak Akses</strong></label>
                        <input type="hidden" name="permissions[]" value="0">
                    </div>
                </th>
            </tr>
            </thead>
            <tbody>

            @foreach($permissions as $permission)
                <tr>
                    <td>
                        <div class="ui checkbox" data-type="check-all-child">
                            <input type="checkbox" name="permissions[]" value="{{ $permission->id }}" {{ (in_array($permission->id, $assignedPermissions))?'checked=checked':'' }}>
                            <label>{{ $permission->name }}</label>
                        </div>
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>

        <div class="ui divider hidden"></div>

        <button class="ui button primary" type="submit" name="submit" value="1">@lang('overide::action.save')</button>
        <a href="{{ route('overide::roles.index') }}" class="ui button">@lang('overide::action.cancel')</a>
        {!! Form::close() !!}

    </div>

    <div class="ui segment very padded red" style="display: none">
        <h3 class="">@lang('overide::label.delete_role')</h3>
        <p>@lang('overide::message.delete_role_intro', ['count' => $role->users->count()])

        {!! Form::open()->delete()->action(route('overide::roles.destroy', $role['id'])) !!}
        <button class="ui button red" type="submit" name="submit" value="1" onclick="return confirm('@lang('overide::message.role_deletion_confirmation')')">@lang('overide::action.delete')</button>
        {!! Form::close() !!}
    </div>
@endsection
