mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-26 13:10:55 -08:00
adds rest of inputs, and corrects Data binding
This commit is contained in:
parent
2e22eeade5
commit
a69cb6204a
|
@ -4,23 +4,46 @@ namespace App\Http\Livewire;
|
||||||
|
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
|
use App\Http\Requests\Request;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SlackSettingsForm extends Component
|
class SlackSettingsForm extends Component
|
||||||
{
|
{
|
||||||
|
public $slack_endpoint;
|
||||||
|
public $slack_channel;
|
||||||
|
public $slack_botname;
|
||||||
|
|
||||||
public Setting $setting;
|
public Setting $setting;
|
||||||
|
|
||||||
protected $rules = [
|
protected $rules = [
|
||||||
'setting.slack_endpoint' => 'url|required_with:slack_channel|starts_with:https://hooks.slack.com/|nullable',
|
'slack_endpoint' => 'url|required_with:slack_channel|starts_with:https://hooks.slack.com/|nullable',
|
||||||
'setting.slack_channel' => 'required_with:slack_endpoint|starts_with:#|nullable',
|
'slack_channel' => 'required_with:slack_endpoint|starts_with:#|nullable',
|
||||||
'setting.slack_botname' => 'string|nullable',
|
'slack_botname' => 'string|nullable',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public function mount(){
|
||||||
|
|
||||||
|
$this->setting= Setting::getSettings();
|
||||||
|
$this->slack_endpoint = $this->setting->slack_endpoint;
|
||||||
|
$this->slack_channel = $this->setting->slack_channel;
|
||||||
|
$this->slack_botname = $this->setting->slack_botname;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
return view('livewire.slack-settings-form');
|
return view('livewire.slack-settings-form');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function submit()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->validate();
|
||||||
|
|
||||||
|
$this->setting->slack_endpoint = $this->slack_endpoint;
|
||||||
|
$this->setting->slack_channel = $this->slack_channel;
|
||||||
|
$this->setting->slack_botname = $this->slack_botname;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,49 @@
|
||||||
@if (config('app.lock_passwords')===true)
|
@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>
|
<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
|
||||||
<input type="text" wire:model.lazy="setting.slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX'" {{old('slack_endpoint', $setting->slack_endpoint)}} >
|
<input type="text" wire:model.lazy="slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX'" {{old('slack_endpoint', $slack_endpoint)}} >
|
||||||
@else
|
@else
|
||||||
<input type="text" wire:model.lazy="setting.slack_endpoint" id="slack_endpoint" class= 'form-control' placeholder="'https://hooks.slack.com/services/XXXXXXXXXXXXXXXXXXXXX'" {{old('slack_endpoint', $setting->slack_endpoint)}} >
|
<input type="text" wire:model.lazy="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')) }}--}}
|
{{-- {{ 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
|
@endif
|
||||||
{!! $errors->first('slack_endpoint', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
{!! $errors->first('slack_endpoint', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- slack channel -->
|
||||||
|
<div class="form-group required {{ $errors->has('slack_channel') ? 'error' : '' }}">
|
||||||
|
<div class="col-md-2">
|
||||||
|
{{ Form::label('slack_channel', trans('admin/settings/general.slack_channel')) }}
|
||||||
|
</div>
|
||||||
|
<div class="col-md-10">
|
||||||
|
@if (config('app.lock_passwords')===true)
|
||||||
|
<input type="text" wire:model.lazy="slack_channel" id="slack_channel" class= 'form-control' placeholder="'#IT-Ops'" {{old('slack_channel', $slack_channel)}} >
|
||||||
|
<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
|
||||||
|
|
||||||
|
@else
|
||||||
|
<input type="text" wire:model.lazy="slack_channel" id="slack_channel" class= 'form-control' placeholder="'#IT-Ops'" {{old('slack_channel', $slack_channel)}} >
|
||||||
|
@endif
|
||||||
|
{!! $errors->first('slack_channel', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- slack botname -->
|
||||||
|
<div class="form-group required {{ $errors->has('slack_botname') ? 'error' : '' }}">
|
||||||
|
<div class="col-md-2">
|
||||||
|
{{ Form::label('slack_botname', trans('admin/settings/general.slack_botname')) }}
|
||||||
|
</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.lazy="slack_botname" id="slack_botname" class= 'form-control' placeholder="'Snipe-Bot'" {{old('slack_botname', $slack_botname)}} >
|
||||||
|
|
||||||
|
<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
|
||||||
|
|
||||||
|
@else
|
||||||
|
<input type="text" wire:model.lazy="slack_botname" id="slack_botname" class= 'form-control' placeholder="'Snipe-Bot'" {{old('slack_botname', $slack_botname)}} >
|
||||||
|
@endif
|
||||||
|
{!! $errors->first('slack_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -50,41 +50,9 @@
|
||||||
<div class="col-md-12" style="border-top: 0px;">
|
<div class="col-md-12" style="border-top: 0px;">
|
||||||
|
|
||||||
|
|
||||||
@livewire('slack-settings-form', ['setting' => $setting])
|
@livewire('slack-settings-form')
|
||||||
|
|
||||||
<!-- slack channel -->
|
|
||||||
<div class="form-group required {{ $errors->has('slack_channel') ? 'error' : '' }}">
|
|
||||||
<div class="col-md-2">
|
|
||||||
{{ Form::label('slack_channel', trans('admin/settings/general.slack_channel')) }}
|
|
||||||
</div>
|
|
||||||
<div class="col-md-10">
|
|
||||||
@if (config('app.lock_passwords')===true)
|
|
||||||
{{ Form::text('slack_channel', old('slack_channel', $setting->slack_channel), array('class' => 'form-control','disabled'=>'disabled','placeholder' => '#IT-Ops')) }}
|
|
||||||
<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
|
|
||||||
|
|
||||||
@else
|
|
||||||
{{ Form::text('slack_channel', old('slack_channel', $setting->slack_channel), array('class' => 'form-control','placeholder' => '#IT-Ops')) }}
|
|
||||||
@endif
|
|
||||||
{!! $errors->first('slack_channel', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- slack botname -->
|
|
||||||
<div class="form-group required {{ $errors->has('slack_botname') ? 'error' : '' }}">
|
|
||||||
<div class="col-md-2">
|
|
||||||
{{ Form::label('slack_botname', trans('admin/settings/general.slack_botname')) }}
|
|
||||||
</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')) }}
|
|
||||||
<p class="text-warning"><i class="fas fa-lock"></i> {{ trans('general.feature_disabled') }}</p>
|
|
||||||
|
|
||||||
@else
|
|
||||||
{{ Form::text('slack_botname', old('slack_botname', $setting->slack_botname), array('class' => 'form-control','placeholder' => 'Snipe-Bot')) }}
|
|
||||||
@endif
|
|
||||||
{!! $errors->first('slack_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group" id="slacktestcontainer" style="display: none">
|
<div class="form-group" id="slacktestcontainer" style="display: none">
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
|
|
Loading…
Reference in a new issue