mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
fix for recurring_invoice permissions (#2159)
This commit is contained in:
parent
f4db62cf51
commit
3c8b1791ca
@ -1,160 +1,153 @@
|
|||||||
@extends('header')
|
@extends('header')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
@parent
|
@parent
|
||||||
@include('accounts.nav', ['selected' => ACCOUNT_USER_MANAGEMENT])
|
@include('accounts.nav', ['selected' => ACCOUNT_USER_MANAGEMENT])
|
||||||
|
|
||||||
{!! Former::open($url)->autocomplete('off')->method($method)->addClass('warn-on-exit user-form')->rules(array(
|
{!! Former::open($url)->autocomplete('off')->method($method)->addClass('warn-on-exit user-form')->rules(array(
|
||||||
'first_name' => 'required',
|
'first_name' => 'required',
|
||||||
'last_name' => 'required',
|
'last_name' => 'required',
|
||||||
'email' => 'required|email',
|
'email' => 'required|email',
|
||||||
)); !!}
|
)); !!}
|
||||||
|
|
||||||
@if ($user)
|
@if ($user)
|
||||||
{!! Former::populate($user) !!}
|
{!! Former::populate($user) !!}
|
||||||
{{ Former::populateField('is_admin', intval($user->is_admin)) }}
|
{{ Former::populateField('is_admin', intval($user->is_admin)) }}
|
||||||
@endif
|
|
||||||
|
|
||||||
<div style="display:none">
|
|
||||||
{!! Former::text('action') !!}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-heading">
|
|
||||||
<h3 class="panel-title">{!! trans('texts.user_details') !!}</h3>
|
|
||||||
</div>
|
|
||||||
<div class="panel-body form-padding-right">
|
|
||||||
|
|
||||||
{!! Former::text('first_name') !!}
|
|
||||||
{!! Former::text('last_name') !!}
|
|
||||||
{!! Former::text('email') !!}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-heading">
|
|
||||||
<h3 class="panel-title">{!! trans('texts.permissions') !!}</h3>
|
|
||||||
</div>
|
|
||||||
<div class="panel-body form-padding-right">
|
|
||||||
|
|
||||||
@if ( ! Utils::hasFeature(FEATURE_USER_PERMISSIONS))
|
|
||||||
<div class="alert alert-warning">{{ trans('texts.upgrade_for_permissions') }}</div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(function() {
|
|
||||||
$('input[type=checkbox]').prop('disabled', true);
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
{!! Former::checkbox('is_admin')
|
<div style="display:none">
|
||||||
->label(' ')
|
{!! Former::text('action') !!}
|
||||||
->value(1)
|
</div>
|
||||||
->text(trans('texts.administrator'))
|
|
||||||
->help(trans('texts.administrator_help')) !!}
|
|
||||||
|
|
||||||
<div class="panel-body">
|
<div class="panel panel-default">
|
||||||
<table class="table table-striped data-table" >
|
<div class="panel-heading">
|
||||||
<thead>
|
<h3 class="panel-title">{!! trans('texts.user_details') !!}</h3>
|
||||||
<th></th>
|
</div>
|
||||||
<th>{!! Former::checkbox('create')
|
<div class="panel-body form-padding-right">
|
||||||
|
|
||||||
|
{!! Former::text('first_name') !!}
|
||||||
|
{!! Former::text('last_name') !!}
|
||||||
|
{!! Former::text('email') !!}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h3 class="panel-title">{!! trans('texts.permissions') !!}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="panel-body form-padding-right">
|
||||||
|
|
||||||
|
@if ( ! Utils::hasFeature(FEATURE_USER_PERMISSIONS))
|
||||||
|
<div class="alert alert-warning">{{ trans('texts.upgrade_for_permissions') }}</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function() {
|
||||||
|
$('input[type=checkbox]').prop('disabled', true);
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
{!! Former::checkbox('is_admin')
|
||||||
|
->label(' ')
|
||||||
|
->value(1)
|
||||||
|
->text(trans('texts.administrator'))
|
||||||
|
->help(trans('texts.administrator_help')) !!}
|
||||||
|
|
||||||
|
<div class="panel-body">
|
||||||
|
<table class="table table-striped data-table" >
|
||||||
|
<thead>
|
||||||
|
<th></th>
|
||||||
|
<th>{!! Former::checkbox('create')
|
||||||
->text( trans('texts.create') )
|
->text( trans('texts.create') )
|
||||||
->value('create_')
|
->value('create_')
|
||||||
->label(' ')
|
->label(' ')
|
||||||
->id('create_all') !!}</th>
|
->id('create_all') !!}</th>
|
||||||
<th>{!! Former::checkbox('view')
|
<th>{!! Former::checkbox('view')
|
||||||
->text( trans('texts.view') )
|
->text( trans('texts.view') )
|
||||||
->value('view_')
|
->value('view_')
|
||||||
->label(' ')
|
->label(' ')
|
||||||
->id('view_all') !!}</th>
|
->id('view_all') !!}</th>
|
||||||
<th>{!! Former::checkbox('edit')
|
<th>{!! Former::checkbox('edit')
|
||||||
->text( trans('texts.edit') )
|
->text( trans('texts.edit') )
|
||||||
->value('edit_')
|
->value('edit_')
|
||||||
->label(' ')
|
->label(' ')
|
||||||
->id('edit_all') !!}</th>
|
->id('edit_all') !!}</th>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach (json_decode(PERMISSION_ENTITIES,1) as $permissionEntity)
|
@foreach (json_decode(PERMISSION_ENTITIES,1) as $permissionEntity)
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if($user)
|
if($user)
|
||||||
$permissions = json_decode($user->permissions,1);
|
$permissions = json_decode($user->permissions,1);
|
||||||
else
|
else
|
||||||
$permissions = [];
|
$permissions = [];
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ ucfirst($permissionEntity) }}</td>
|
<td>{{ ucfirst($permissionEntity) }}</td>
|
||||||
<td>{!! Former::checkbox('permissions[create_' . $permissionEntity . ']')
|
<td>{!! Former::checkbox('permissions[create_' . $permissionEntity . ']')
|
||||||
->label(' ')
|
->label(' ')
|
||||||
->value('create_' . $permissionEntity . '')
|
->value('create_' . $permissionEntity . '')
|
||||||
->id('create_' . $permissionEntity . '')
|
->id('create_' . $permissionEntity . '')
|
||||||
->check(is_array($permissions) && in_array('create_' . $permissionEntity, $permissions, FALSE) ? true : false) !!}</td>
|
->check(is_array($permissions) && in_array('create_' . $permissionEntity, $permissions, FALSE) ? true : false) !!}</td>
|
||||||
<td>{!! Former::checkbox('permissions[view_' . $permissionEntity . ']')
|
<td>{!! Former::checkbox('permissions[view_' . $permissionEntity . ']')
|
||||||
->label(' ')
|
->label(' ')
|
||||||
->value('view_' . $permissionEntity . '')
|
->value('view_' . $permissionEntity . '')
|
||||||
->id('view_' . $permissionEntity . '')
|
->id('view_' . $permissionEntity . '')
|
||||||
->check(is_array($permissions) && in_array('view_' . $permissionEntity, $permissions, FALSE) ? true : false) !!}</td>
|
->check(is_array($permissions) && in_array('view_' . $permissionEntity, $permissions, FALSE) ? true : false) !!}</td>
|
||||||
<td>{!! Former::checkbox('permissions[edit_' . $permissionEntity . ']')
|
<td>{!! Former::checkbox('permissions[edit_' . $permissionEntity . ']')
|
||||||
->label(' ')
|
->label(' ')
|
||||||
->value('edit_' . $permissionEntity . '')
|
->value('edit_' . $permissionEntity . '')
|
||||||
->id('edit_' . $permissionEntity . '')
|
->id('edit_' . $permissionEntity . '')
|
||||||
->check(is_array($permissions) && in_array('edit_' . $permissionEntity, $permissions, FALSE) ? true : false) !!}</td>
|
->check(is_array($permissions) && in_array('edit_' . $permissionEntity, $permissions, FALSE) ? true : false) !!}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@endforeach
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
<center class="buttons">
|
||||||
</div>
|
{!! Button::normal(trans('texts.cancel'))->asLinkTo(URL::to('/settings/user_management'))->appendIcon(Icon::create('remove-circle'))->large() !!}
|
||||||
|
{!! ($user) ? Button::success(trans('texts.save'))->withAttributes(['onclick' => 'submitAction("save")'])->large()->appendIcon(Icon::create('floppy-disk')) : false !!}
|
||||||
|
{!! (! $user || ! $user->confirmed) ? Button::info(trans($user ? 'texts.resend_invite' : 'texts.send_invite'))->withAttributes(['onclick' => 'submitAction("email")'])->large()->appendIcon(Icon::create('send')) : false !!}
|
||||||
|
</center>
|
||||||
|
|
||||||
<center class="buttons">
|
{!! Former::close() !!}
|
||||||
{!! Button::normal(trans('texts.cancel'))->asLinkTo(URL::to('/settings/user_management'))->appendIcon(Icon::create('remove-circle'))->large() !!}
|
|
||||||
{!! ($user) ? Button::success(trans('texts.save'))->withAttributes(['onclick' => 'submitAction("save")'])->large()->appendIcon(Icon::create('floppy-disk')) : false !!}
|
|
||||||
{!! (! $user || ! $user->confirmed) ? Button::info(trans($user ? 'texts.resend_invite' : 'texts.send_invite'))->withAttributes(['onclick' => 'submitAction("email")'])->large()->appendIcon(Icon::create('send')) : false !!}
|
|
||||||
</center>
|
|
||||||
|
|
||||||
{!! Former::close() !!}
|
<script type="text/javascript">
|
||||||
|
|
||||||
<script type="text/javascript">
|
function submitAction(value) {
|
||||||
|
$('#action').val(value);
|
||||||
|
$('.user-form').submit();
|
||||||
|
}
|
||||||
|
|
||||||
function submitAction(value) {
|
</script>
|
||||||
$('#action').val(value);
|
|
||||||
$('.user-form').submit();
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
|
|
||||||
@section('onReady')
|
@section('onReady')
|
||||||
|
|
||||||
//start legacy
|
|
||||||
$('#first_name').focus();
|
$('#first_name').focus();
|
||||||
$('#is_admin, #permissions_view_all').change(fixCheckboxes);
|
|
||||||
function fixCheckboxes(){
|
|
||||||
var adminChecked = $('#is_admin').is(':checked');
|
|
||||||
var viewChecked = $('#permissions_view_all').is(':checked');
|
|
||||||
|
|
||||||
$('#permissions_view_all').prop('disabled', adminChecked);
|
|
||||||
$('#permissions_create_all').prop('disabled', adminChecked);
|
|
||||||
$('#permissions_edit_all').prop('disabled', adminChecked || !viewChecked);
|
|
||||||
if(!viewChecked)$('#permissions_edit_all').prop('checked',false)
|
|
||||||
}
|
|
||||||
fixCheckboxes();
|
|
||||||
//end legacy
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Iterate over all permission checkboxes and ensure VIEW/EDIT
|
* Iterate over all permission checkboxes and ensure VIEW/EDIT
|
||||||
* combinations are enabled/disabled depending on VIEW state.
|
* combinations are enabled/disabled depending on VIEW state.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$("input[type='checkbox'][id^='view_']").each(function() {
|
$("input[type='checkbox'][id^='view_']").each(function() {
|
||||||
|
|
||||||
var entity = $(this).attr('id').split("_")[1].replace("]",""); //get entity name
|
var entity = $(this).attr('id')
|
||||||
|
.replace('create_',"")
|
||||||
|
.replace('view_',"")
|
||||||
|
.replace('edit_',"")
|
||||||
|
.replace(']',"")
|
||||||
|
.replace('[',""); //get entity name
|
||||||
|
|
||||||
$('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox
|
$('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -168,9 +161,14 @@
|
|||||||
|
|
||||||
$("input[type='checkbox'][id^='view_']").change(function(){
|
$("input[type='checkbox'][id^='view_']").change(function(){
|
||||||
|
|
||||||
var entity = $(this).attr('id').split("_")[1].replace("]",""); //get entity name
|
var entity = $(this).attr('id')
|
||||||
|
.replace('create_',"")
|
||||||
|
.replace('view_',"")
|
||||||
|
.replace('edit_',"")
|
||||||
|
.replace(']',"")
|
||||||
|
.replace('[',""); //get entity name
|
||||||
|
|
||||||
$('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox
|
$('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox
|
||||||
|
|
||||||
if(!$('#view_' + entity).is(':checked')) {
|
if(!$('#view_' + entity).is(':checked')) {
|
||||||
$('#edit_' + entity).prop('checked', false); //remove checkbox value from edit dependant on View state.
|
$('#edit_' + entity).prop('checked', false); //remove checkbox value from edit dependant on View state.
|
||||||
@ -183,16 +181,26 @@
|
|||||||
var checked = $(this).is(':checked');
|
var checked = $(this).is(':checked');
|
||||||
var permission_type = $(this).val();
|
var permission_type = $(this).val();
|
||||||
|
|
||||||
$("input[type='checkbox'][id^=" + permission_type + "]").each(function() {
|
$("input[type='checkbox'][id^=" + permission_type + "]").each(function() {
|
||||||
|
|
||||||
|
var entity = $(this).attr('id')
|
||||||
|
.replace('create_',"")
|
||||||
|
.replace('view_',"")
|
||||||
|
.replace('edit_',"")
|
||||||
|
.replace(']',"")
|
||||||
|
.replace('[',""); //get entity name
|
||||||
|
|
||||||
var entity = $(this).attr('id').split("_")[1].replace("]",""); //get entity name
|
|
||||||
$('#' + permission_type + entity).prop('checked', checked); //set state of edit checkbox
|
$('#' + permission_type + entity).prop('checked', checked); //set state of edit checkbox
|
||||||
|
|
||||||
if(!$('#view_' + entity).is(':checked')) {
|
if(!$('#view_' + entity).is(':checked')) {
|
||||||
$('#edit_' + entity).prop('checked', false); //remove checkbox value from edit dependant on View state.
|
$('#edit_' + entity).prop('checked', false); //remove checkbox value from edit dependant on View state.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user