saves data correctly now

This commit is contained in:
Godfrey M 2023-01-31 11:32:05 -08:00
parent fc044528b8
commit 1e0c58c3cf
3 changed files with 90 additions and 84 deletions

View file

@ -52,7 +52,10 @@ class SlackSettingsForm extends Component
$this->setting->slack_channel = $this->slack_channel;
$this->setting->slack_botname = $this->slack_botname;
$this->successMessage= trans('admin/settings/message.update.success');
$this->setting->save();
session()->flash('message',trans('admin/settings/message.update.success'));
}
}

View file

@ -1,29 +1,26 @@
<div>
<div class="row">
<div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">
<div class="panel box box-default">
<div class="box-header with-border">
<h2 class="box-title">
<i class="fab fa-slack"></i> {{ trans('admin/settings/general.slack') }}
</h2>
</div>
<div class="box-body">
<div class="col-md-12" style="border-top: 0px;">
{{$successMessage}}
@if (session()->has('message'))
<div class="alert alert-success">
{{session('message')}}
</div>
@endif
<form wire:submit.prevent ="submit">
{{csrf_field()}}
<!--slack endpoint-->
<div class="form-group required {{ $errors->has('slack_endpoint') ? 'error' : '' }}">
<div class="col-md-2">
{{ Form::label('slack_endpoint', trans('admin/settings/general.slack_endpoint')) }}
</div>
<div class="col-md-10">
@if (config('app.lock_passwords')===true)
{{-- {{ Form::text('slack_endpoint', old('slack_endpoint', $setting->slack_endpoint), array('class' => 'form-control','disabled'=>'disabled','placeholder' => 'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX', 'id' => 'slack_endpoint')) }}--}}
{{-- {{ Form::text('slack_endpoint', old('slack_endpoint', $setting->slack_endpoint), array('class' => 'form-control','disabled'=>'disabled','placeholder' => 'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX', 'id' => 'slack_endpoint')) }}--}}
<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
<input type="text" wire:model.defer="slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX'" {{old('slack_endpoint', $slack_endpoint)}} >
<input type="text" wire:model.defer="slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX'" {{old('slack_endpoint', $slack_endpoint)}} ><br>
@else
<input type="text" wire:model.defer="slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX'" {{old('slack_endpoint', $slack_endpoint)}} >
{{-- {{ Form::text('slack_endpoint', old('slack_endpoint', $setting->slack_endpoint), array('class' => 'form-control','placeholder' => 'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX', 'id' => 'slack_endpoint')) }}--}}
<input type="text" wire:model.defer="slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX'" {{old('slack_endpoint', $slack_endpoint)}} ><br>
{{-- {{ Form::text('slack_endpoint', old('slack_endpoint', $setting->slack_endpoint), array('class' => 'form-control','placeholder' => 'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX', 'id' => 'slack_endpoint')) }}--}}
@endif
{!! $errors->first('slack_endpoint', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
@ -36,11 +33,11 @@
</div>
<div class="col-md-10">
@if (config('app.lock_passwords')===true)
<input type="text" wire:model.defer="slack_channel" id="slack_channel" class= 'form-control' placeholder="'#IT-Ops'" {{old('slack_channel', $slack_channel)}} >
<input type="text" wire:model.defer="slack_channel" id="slack_channel" class= 'form-control' placeholder="'#IT-Ops'" {{old('slack_channel', $slack_channel)}} ><br>
<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
@else
<input type="text" wire:model.defer="slack_channel" id="slack_channel" class= 'form-control' placeholder="'#IT-Ops'" {{old('slack_channel', $slack_channel)}} >
<input type="text" wire:model.defer="slack_channel" id="slack_channel" class= 'form-control' placeholder="'#IT-Ops'" {{old('slack_channel', $slack_channel)}} ><br>
@endif
{!! $errors->first('slack_channel', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
@ -53,21 +50,20 @@
</div>
<div class="col-md-10">
@if (config('app.lock_passwords')===true)
{{ Form::text('slack_botname', old('slack_botname', $setting->slack_botname), array('class' => 'form-control','disabled'=>'disabled','placeholder' => 'Snipe-Bot')) }}
<input type="text" wire:model.defer="slack_botname" id="slack_botname" class= 'form-control' placeholder="'Snipe-Bot'" {{old('slack_botname', $slack_botname)}} >
{{-- {{ Form::text('slack_botname', old('slack_botname', $setting->slack_botname), array('class' => 'form-control','disabled'=>'disabled','placeholder' => 'Snipe-Bot')) }}--}}
<input type="text" wire:model.defer="slack_botname" id="slack_botname" class= 'form-control' placeholder="'Snipe-Bot'" {{old('slack_botname', $slack_botname)}} ><br>
<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
@else
<input type="text" wire:model.defer="slack_botname" id="slack_botname" class= 'form-control' placeholder="'Snipe-Bot'" {{old('slack_botname', $slack_botname)}} >
<input type="text" wire:model.defer="slack_botname" id="slack_botname" class= 'form-control' placeholder="'Snipe-Bot'" {{old('slack_botname', $slack_botname)}} ><br>
@endif
{!! $errors->first('slack_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div><!--col-md-10-->
</div>
<div class="box-footer">
<div class="text-left col-md-6">
<a class="btn btn-link text-left" href="{{ route('settings.index') }}">{{ trans('button.cancel') }}</a>
</div>
<div class="text-right col-md-6">
<button type="submit" id="save_slack" class="btn btn-primary"><i class="fas fa-check icon-white" aria-hidden="true"></i> {{ trans('general.save') }}</button>
@ -75,11 +71,6 @@
</div><!--box-footer-->
</form>
</div> <!--/-->
</div> <!--/.box-body-->
</div> <!-- /box -->
</div> <!-- /.col-md-8-->
</div> <!-- /.row-->
</div>

View file

@ -19,25 +19,37 @@
padding-right: 40px;
}
</style>
{{csrf_field()}}
<!-- CSRF Token -->
<div class="row">
<div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">
<div class="panel box box-default">
<div class="box-header with-border">
<h2 class="box-title">
<i class="fab fa-slack"></i> {{ trans('admin/settings/general.slack') }}
</h2>
</div>
<div class="box-body">
<p style="padding: 20px;">
{!! trans('admin/settings/general.slack_integration_help',array('slack_link' => 'https://my.slack.com/services/new/incoming-webhook')) !!}
{{-- @if (($setting->slack_channel=='') && ($setting->slack_endpoint==''))--}}
{{-- {{ trans('admin/settings/general.slack_integration_help_button') }}--}}
{{-- @endif--}}
{{-- </p>--}}
</p>
@livewire('slack-settings-form')
</div> <!-- /.col-md-8-->
</div> <!-- /.row-->
@stop