mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
adds submit button, getting setAttribute error
This commit is contained in:
parent
62b4c79150
commit
a63ea560ae
|
@ -41,6 +41,7 @@ class SlackSettingsForm extends Component
|
||||||
|
|
||||||
public function submit()
|
public function submit()
|
||||||
{
|
{
|
||||||
|
dd("we here now");
|
||||||
|
|
||||||
$this->validate();
|
$this->validate();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div>
|
<div>
|
||||||
<form wire:submit.prevent="save">
|
<form wire:submit.prevent ="save">
|
||||||
<div class="form-group required {{ $errors->has('slack_endpoint') ? 'error' : '' }}">
|
<div class="form-group required {{ $errors->has('slack_endpoint') ? 'error' : '' }}">
|
||||||
<div class="col-md-2">
|
<div class="col-md-2">
|
||||||
{{ Form::label('slack_endpoint', trans('admin/settings/general.slack_endpoint')) }}
|
{{ Form::label('slack_endpoint', trans('admin/settings/general.slack_endpoint')) }}
|
||||||
|
@ -52,5 +52,14 @@
|
||||||
{!! $errors->first('slack_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
{!! $errors->first('slack_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -71,15 +71,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div> <!--/-->
|
</div> <!--/-->
|
||||||
</div> <!--/.box-body-->
|
</div> <!--/.box-body-->
|
||||||
<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" disabled><i class="fas fa-check icon-white" aria-hidden="true"></i> {{ trans('general.save') }}</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div> <!-- /box -->
|
</div> <!-- /box -->
|
||||||
</div> <!-- /.col-md-8-->
|
</div> <!-- /.col-md-8-->
|
||||||
</div> <!-- /.row-->
|
</div> <!-- /.row-->
|
||||||
|
@ -88,129 +80,129 @@
|
||||||
|
|
||||||
@stop
|
@stop
|
||||||
|
|
||||||
@push('js')
|
{{--@push('js')--}}
|
||||||
<script nonce="{{ csrf_token() }}">
|
{{-- <script nonce="{{ csrf_token() }}">--}}
|
||||||
var fieldcheck = function (event) {
|
{{-- var fieldcheck = function (event) {--}}
|
||||||
if($('#slack_endpoint').val() != "" && $('#slack_channel').val() != "" && $('#slack_botname').val() != "") {
|
{{-- if($('#slack_endpoint').val() != "" && $('#slack_channel').val() != "" && $('#slack_botname').val() != "") {--}}
|
||||||
//enable test button *only* if all three fields are filled in
|
{{-- //enable test button *only* if all three fields are filled in--}}
|
||||||
$('#slacktestcontainer').fadeIn(500);
|
{{-- $('#slacktestcontainer').fadeIn(500);--}}
|
||||||
} else {
|
{{-- } else {--}}
|
||||||
//otherwise it's hidden
|
{{-- //otherwise it's hidden--}}
|
||||||
$('#slacktestcontainer').fadeOut(500);
|
{{-- $('#slacktestcontainer').fadeOut(500);--}}
|
||||||
}
|
{{-- }--}}
|
||||||
|
|
||||||
if(event) { //on 'initial load' we don't *have* an 'event', but in the regular keyup callback, we *do*. So this only fires on 'real' callback events, not on first load
|
{{-- if(event) { //on 'initial load' we don't *have* an 'event', but in the regular keyup callback, we *do*. So this only fires on 'real' callback events, not on first load--}}
|
||||||
if($('#slack_endpoint').val() == "" && $('#slack_channel').val() == "" && $('#slack_botname').val() == "") {
|
{{-- if($('#slack_endpoint').val() == "" && $('#slack_channel').val() == "" && $('#slack_botname').val() == "") {--}}
|
||||||
// if all three fields are blank, the user may want to disable Slack integration; enable the Save button
|
{{-- // if all three fields are blank, the user may want to disable Slack integration; enable the Save button--}}
|
||||||
$('#save_slack').removeAttr('disabled');
|
{{-- $('#save_slack').removeAttr('disabled');--}}
|
||||||
}
|
{{-- }--}}
|
||||||
}
|
{{-- }--}}
|
||||||
};
|
{{-- };--}}
|
||||||
|
|
||||||
fieldcheck(); //run our field-checker once on page-load to set the initial state correctly.
|
{{-- fieldcheck(); //run our field-checker once on page-load to set the initial state correctly.--}}
|
||||||
|
|
||||||
$('input:text').keyup(fieldcheck); // if *any* text field changes, we recalculate button states
|
{{-- $('input:text').keyup(fieldcheck); // if *any* text field changes, we recalculate button states--}}
|
||||||
|
|
||||||
$("#slacktest").click(function() {
|
{{-- $("#slacktest").click(function() {--}}
|
||||||
|
|
||||||
$("#slacktestrow").removeClass('text-success');
|
{{-- $("#slacktestrow").removeClass('text-success');--}}
|
||||||
$("#slacktestrow").removeClass('text-danger');
|
{{-- $("#slacktestrow").removeClass('text-danger');--}}
|
||||||
$("#slackteststatus").removeClass('text-danger');
|
{{-- $("#slackteststatus").removeClass('text-danger');--}}
|
||||||
$("#slackteststatus").html('');
|
{{-- $("#slackteststatus").html('');--}}
|
||||||
$("#slacktesticon").html('<i class="fas fa-spinner spin"></i> {{ trans('admin/settings/message.slack.sending') }}');
|
{{-- $("#slacktesticon").html('<i class="fas fa-spinner spin"></i> {{ trans('admin/settings/message.slack.sending') }}');--}}
|
||||||
$.ajax({
|
{{-- $.ajax({--}}
|
||||||
|
{{-- --}}
|
||||||
// If I comment this back in, I always get a success (200) message
|
{{-- // If I comment this back in, I always get a success (200) message--}}
|
||||||
// Without it, I get
|
{{-- // Without it, I get --}}
|
||||||
// beforeSend: function (xhr) {
|
{{-- // beforeSend: function (xhr) { --}}
|
||||||
// xhr.setRequestHeader("Content-Type","application/json");
|
{{-- // xhr.setRequestHeader("Content-Type","application/json");--}}
|
||||||
// xhr.setRequestHeader("Accept","text/json");
|
{{-- // xhr.setRequestHeader("Accept","text/json");--}}
|
||||||
// },
|
{{-- // },--}}
|
||||||
|
{{-- --}}
|
||||||
|
{{-- --}}
|
||||||
url: '{{ route('api.settings.slacktest') }}',
|
{{-- url: '{{ route('api.settings.slacktest') }}',--}}
|
||||||
type: 'POST',
|
{{-- type: 'POST',--}}
|
||||||
headers: {
|
{{-- headers: {--}}
|
||||||
"X-Requested-With": 'XMLHttpRequest',
|
{{-- "X-Requested-With": 'XMLHttpRequest',--}}
|
||||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content'),
|
{{-- "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content'),--}}
|
||||||
// 'Accept': 'application/json',
|
{{-- // 'Accept': 'application/json',--}}
|
||||||
// 'Content-Type': 'application/json',
|
{{-- // 'Content-Type': 'application/json',--}}
|
||||||
},
|
{{-- },--}}
|
||||||
data: {
|
{{-- data: {--}}
|
||||||
'slack_endpoint': $('#slack_endpoint').val(),
|
{{-- 'slack_endpoint': $('#slack_endpoint').val(),--}}
|
||||||
'slack_channel': $('#slack_channel').val(),
|
{{-- 'slack_channel': $('#slack_channel').val(),--}}
|
||||||
'slack_botname': $('#slack_botname').val(),
|
{{-- 'slack_botname': $('#slack_botname').val(),--}}
|
||||||
|
|
||||||
},
|
{{-- },--}}
|
||||||
|
|
||||||
dataType: 'json',
|
{{-- dataType: 'json',--}}
|
||||||
|
|
||||||
accepts: {
|
{{-- accepts: {--}}
|
||||||
text: "application/json"
|
{{-- text: "application/json"--}}
|
||||||
},
|
{{-- },--}}
|
||||||
|
|
||||||
success: function (data) {
|
{{-- success: function (data) {--}}
|
||||||
$('#save_slack').removeAttr('disabled');
|
{{-- $('#save_slack').removeAttr('disabled');--}}
|
||||||
$("#slacktesticon").html('');
|
{{-- $("#slacktesticon").html('');--}}
|
||||||
$("#slacktestrow").addClass('text-success');
|
{{-- $("#slacktestrow").addClass('text-success');--}}
|
||||||
$("#slackteststatus").addClass('text-success');
|
{{-- $("#slackteststatus").addClass('text-success');--}}
|
||||||
//TODO: This is a bit hacky...Might need some cleanup
|
{{-- //TODO: This is a bit hacky...Might need some cleanup--}}
|
||||||
$("#slackteststatus").html('<i class="fas fa-check text-success"></i> {{ trans('admin/settings/message.slack.success_pt1') }} ' + $('#slack_channel').val() + '{{ trans('admin/settings/message.slack.success_pt2') }}');
|
{{-- $("#slackteststatus").html('<i class="fas fa-check text-success"></i> {{ trans('admin/settings/message.slack.success_pt1') }} ' + $('#slack_channel').val() + '{{ trans('admin/settings/message.slack.success_pt2') }}');--}}
|
||||||
},
|
{{-- },--}}
|
||||||
|
|
||||||
error: function (data) {
|
{{-- error: function (data) {--}}
|
||||||
|
|
||||||
|
|
||||||
if (data.responseJSON) {
|
{{-- if (data.responseJSON) {--}}
|
||||||
var errors = data.responseJSON.errors;
|
{{-- var errors = data.responseJSON.errors;--}}
|
||||||
var error_msg = data.responseJSON.message;
|
{{-- var error_msg = data.responseJSON.message;--}}
|
||||||
} else {
|
{{-- } else {--}}
|
||||||
var errors;
|
{{-- var errors;--}}
|
||||||
var error_msg = trans('admin/settings/message.slack.error');
|
{{-- var error_msg = trans('admin/settings/message.slack.error');--}}
|
||||||
}
|
{{-- }--}}
|
||||||
|
|
||||||
var error_text = '';
|
{{-- var error_text = '';--}}
|
||||||
|
|
||||||
$('#save_slack').attr("disabled", true);
|
{{-- $('#save_slack').attr("disabled", true);--}}
|
||||||
$("#slacktesticon").html('');
|
{{-- $("#slacktesticon").html('');--}}
|
||||||
$("#slackteststatus").addClass('text-danger');
|
{{-- $("#slackteststatus").addClass('text-danger');--}}
|
||||||
$("#slacktesticon").html('<i class="fas fa-exclamation-triangle text-danger"></i><span class="text-danger">' + error_msg+ '</span>');
|
{{-- $("#slacktesticon").html('<i class="fas fa-exclamation-triangle text-danger"></i><span class="text-danger">' + error_msg+ '</span>');--}}
|
||||||
|
|
||||||
|
{{-- --}}
|
||||||
if (data.status == 500) {
|
{{-- if (data.status == 500) {--}}
|
||||||
$('#slackteststatus').html('{{ trans('admin/settings/message.slack.500') }}');
|
{{-- $('#slackteststatus').html('{{ trans('admin/settings/message.slack.500') }}');--}}
|
||||||
} else if ((data.status == 400) || (data.status == 422)) {
|
{{-- } else if ((data.status == 400) || (data.status == 422)) {--}}
|
||||||
console.log('Type of errors is '+ typeof errors);
|
{{-- console.log('Type of errors is '+ typeof errors);--}}
|
||||||
console.log('Data status was 400 or 422');
|
{{-- console.log('Data status was 400 or 422');--}}
|
||||||
|
|
||||||
if (typeof errors != 'string') {
|
{{-- if (typeof errors != 'string') {--}}
|
||||||
|
{{-- --}}
|
||||||
console.log(errors.length);
|
{{-- console.log(errors.length);--}}
|
||||||
|
|
||||||
for (i in errors) {
|
{{-- for (i in errors) {--}}
|
||||||
if (errors[i]) {
|
{{-- if (errors[i]) {--}}
|
||||||
error_text += '<li>Error: ' + errors[i];
|
{{-- error_text += '<li>Error: ' + errors[i];--}}
|
||||||
}
|
{{-- }--}}
|
||||||
|
|
||||||
}
|
{{-- }--}}
|
||||||
|
|
||||||
} else {
|
{{-- } else {--}}
|
||||||
|
|
||||||
error_text = errors;
|
{{-- error_text = errors;--}}
|
||||||
}
|
{{-- }--}}
|
||||||
|
|
||||||
$('#slackteststatus').html(error_text);
|
{{-- $('#slackteststatus').html(error_text);--}}
|
||||||
|
|
||||||
} else {
|
{{-- } else {--}}
|
||||||
$('#slackteststatus').html(data.responseText.message);
|
{{-- $('#slackteststatus').html(data.responseText.message);--}}
|
||||||
}
|
{{-- }--}}
|
||||||
}
|
{{-- }--}}
|
||||||
|
|
||||||
|
|
||||||
});
|
{{-- });--}}
|
||||||
return false;
|
{{-- return false;--}}
|
||||||
});
|
{{-- });--}}
|
||||||
|
|
||||||
</script>
|
{{-- </script>--}}
|
||||||
|
|
||||||
@endpush
|
{{--@endpush--}}
|
||||||
|
|
Loading…
Reference in a new issue