Fix creating a system with the correct role, Fix need to have hold/active on creation

This commit is contained in:
Deon George 2022-03-01 22:07:08 +11:00
parent 6db16712ee
commit cf3b1947a4
2 changed files with 23 additions and 26 deletions

View File

@ -31,6 +31,7 @@ class SystemController extends Controller
*/ */
public function add_address(Request $request,System $o) public function add_address(Request $request,System $o)
{ {
// @todo a point address is failing validation
// @todo This should be admin of the zone // @todo This should be admin of the zone
$this->authorize('admin',$o); $this->authorize('admin',$o);
session()->flash('accordion','address'); session()->flash('accordion','address');
@ -161,7 +162,7 @@ class SystemController extends Controller
$oo->host_id = $request->post('host_id_new'); $oo->host_id = $request->post('host_id_new');
$oo->node_id = $request->post('node_id_new'); $oo->node_id = $request->post('node_id_new');
$oo->point_id = 0; $oo->point_id = 0;
$oo->role = Address::NODE_NC; $oo->role = Address::NODE_ACTIVE;
$oo->active = TRUE; $oo->active = TRUE;
$o->addresses()->save($oo); $o->addresses()->save($oo);
@ -204,7 +205,7 @@ class SystemController extends Controller
$oo->node_id = $request->post('node_id'); $oo->node_id = $request->post('node_id');
$oo->point_id = $request->post('point_id'); $oo->point_id = $request->post('point_id');
$oo->hub_id = $request->post('hub_id') > 0 ? $request->post('hub_id') : NULL; $oo->hub_id = $request->post('hub_id') > 0 ? $request->post('hub_id') : NULL;
$oo->role = (! $oo->point_id) && $request->post('hub') ? Address::NODE_HC : Address::NODE_ACTIVE; $oo->role = ((! $oo->point_id) && $request->post('hub')) ? Address::NODE_HC : Address::NODE_ACTIVE;
$oo->active = TRUE; $oo->active = TRUE;
$o->addresses()->save($oo); $o->addresses()->save($oo);

View File

@ -21,38 +21,34 @@
<!-- Active --> <!-- Active -->
<div class="col-2"> <div class="col-2">
@if($o->exists) @can('update',$o)
@can('update',$o) <label for="active" class="form-label">Active</label>
<label for="active" class="form-label">Active</label> <div class="input-group">
<div class="input-group"> <div class="btn-group" role="group">
<div class="btn-group" role="group"> <input type="radio" class="btn-check" name="active" id="active_yes" value="1" required @if(old('active',$o->active))checked @endif>
<input type="radio" class="btn-check" name="active" id="active_yes" value="1" required @if(old('active',$o->active))checked @endif> <label class="btn btn-outline-success" for="active_yes">Yes</label>
<label class="btn btn-outline-success" for="active_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="active" id="active_no" value="0" required @if(! old('active',$o->active))checked @endif> <input type="radio" class="btn-check btn-danger" name="active" id="active_no" value="0" required @if(! old('active',$o->active))checked @endif>
<label class="btn btn-outline-danger" for="active_no">No</label> <label class="btn btn-outline-danger" for="active_no">No</label>
</div>
</div> </div>
@endcan </div>
@endif @endcan
</div> </div>
<!-- Hold --> <!-- Hold -->
<div class="col-2"> <div class="col-2">
@if($o->exists) @can('update',$o)
@can('update',$o) <label for="hold" class="form-label">Hold Mail</label>
<label for="hold" class="form-label">Hold Mail</label> <div class="input-group">
<div class="input-group"> <div class="btn-group" role="group">
<div class="btn-group" role="group"> <input type="radio" class="btn-check" name="hold" id="hold_yes" value="1" required @if(old('hold',$o->hold))checked @endif>
<input type="radio" class="btn-check" name="hold" id="hold_yes" value="1" required @if(old('hold',$o->hold))checked @endif> <label class="btn btn-outline-success" for="hold_yes">Yes</label>
<label class="btn btn-outline-success" for="hold_yes">Yes</label>
<input type="radio" class="btn-check btn-danger" name="hold" id="hold_no" value="0" required @if(! old('hold',$o->hold))checked @endif> <input type="radio" class="btn-check btn-danger" name="hold" id="hold_no" value="0" required @if(! old('hold',$o->hold))checked @endif>
<label class="btn btn-outline-danger" for="hold_no">No</label> <label class="btn btn-outline-danger" for="hold_no">No</label>
</div>
</div> </div>
@endcan </div>
@endif @endcan
</div> </div>
<!-- ZeroTier ID --> <!-- ZeroTier ID -->