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()
|
||||
{
|
||||
dd("we here now");
|
||||
|
||||
$this->validate();
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div>
|
||||
<form wire:submit.prevent="save">
|
||||
<form wire:submit.prevent ="save">
|
||||
<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')) }}
|
||||
|
@ -52,5 +52,14 @@
|
|||
{!! $errors->first('slack_botname', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
|
||||
</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>
|
||||
</div>
|
||||
|
|
|
@ -71,15 +71,7 @@
|
|||
</div>
|
||||
</div> <!--/-->
|
||||
</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> <!-- /.col-md-8-->
|
||||
</div> <!-- /.row-->
|
||||
|
@ -88,129 +80,129 @@
|
|||
|
||||
@stop
|
||||
|
||||
@push('js')
|
||||
<script nonce="{{ csrf_token() }}">
|
||||
var fieldcheck = function (event) {
|
||||
if($('#slack_endpoint').val() != "" && $('#slack_channel').val() != "" && $('#slack_botname').val() != "") {
|
||||
//enable test button *only* if all three fields are filled in
|
||||
$('#slacktestcontainer').fadeIn(500);
|
||||
} else {
|
||||
//otherwise it's hidden
|
||||
$('#slacktestcontainer').fadeOut(500);
|
||||
}
|
||||
{{--@push('js')--}}
|
||||
{{-- <script nonce="{{ csrf_token() }}">--}}
|
||||
{{-- var fieldcheck = function (event) {--}}
|
||||
{{-- if($('#slack_endpoint').val() != "" && $('#slack_channel').val() != "" && $('#slack_botname').val() != "") {--}}
|
||||
{{-- //enable test button *only* if all three fields are filled in--}}
|
||||
{{-- $('#slacktestcontainer').fadeIn(500);--}}
|
||||
{{-- } else {--}}
|
||||
{{-- //otherwise it's hidden--}}
|
||||
{{-- $('#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($('#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
|
||||
$('#save_slack').removeAttr('disabled');
|
||||
}
|
||||
}
|
||||
};
|
||||
{{-- 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 all three fields are blank, the user may want to disable Slack integration; enable the Save button--}}
|
||||
{{-- $('#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-danger');
|
||||
$("#slackteststatus").removeClass('text-danger');
|
||||
$("#slackteststatus").html('');
|
||||
$("#slacktesticon").html('<i class="fas fa-spinner spin"></i> {{ trans('admin/settings/message.slack.sending') }}');
|
||||
$.ajax({
|
||||
|
||||
// If I comment this back in, I always get a success (200) message
|
||||
// Without it, I get
|
||||
// beforeSend: function (xhr) {
|
||||
// xhr.setRequestHeader("Content-Type","application/json");
|
||||
// xhr.setRequestHeader("Accept","text/json");
|
||||
// },
|
||||
|
||||
|
||||
url: '{{ route('api.settings.slacktest') }}',
|
||||
type: 'POST',
|
||||
headers: {
|
||||
"X-Requested-With": 'XMLHttpRequest',
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content'),
|
||||
// 'Accept': 'application/json',
|
||||
// 'Content-Type': 'application/json',
|
||||
},
|
||||
data: {
|
||||
'slack_endpoint': $('#slack_endpoint').val(),
|
||||
'slack_channel': $('#slack_channel').val(),
|
||||
'slack_botname': $('#slack_botname').val(),
|
||||
{{-- $("#slacktestrow").removeClass('text-success');--}}
|
||||
{{-- $("#slacktestrow").removeClass('text-danger');--}}
|
||||
{{-- $("#slackteststatus").removeClass('text-danger');--}}
|
||||
{{-- $("#slackteststatus").html('');--}}
|
||||
{{-- $("#slacktesticon").html('<i class="fas fa-spinner spin"></i> {{ trans('admin/settings/message.slack.sending') }}');--}}
|
||||
{{-- $.ajax({--}}
|
||||
{{-- --}}
|
||||
{{-- // If I comment this back in, I always get a success (200) message--}}
|
||||
{{-- // Without it, I get --}}
|
||||
{{-- // beforeSend: function (xhr) { --}}
|
||||
{{-- // xhr.setRequestHeader("Content-Type","application/json");--}}
|
||||
{{-- // xhr.setRequestHeader("Accept","text/json");--}}
|
||||
{{-- // },--}}
|
||||
{{-- --}}
|
||||
{{-- --}}
|
||||
{{-- url: '{{ route('api.settings.slacktest') }}',--}}
|
||||
{{-- type: 'POST',--}}
|
||||
{{-- headers: {--}}
|
||||
{{-- "X-Requested-With": 'XMLHttpRequest',--}}
|
||||
{{-- "X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr('content'),--}}
|
||||
{{-- // 'Accept': 'application/json',--}}
|
||||
{{-- // 'Content-Type': 'application/json',--}}
|
||||
{{-- },--}}
|
||||
{{-- data: {--}}
|
||||
{{-- 'slack_endpoint': $('#slack_endpoint').val(),--}}
|
||||
{{-- 'slack_channel': $('#slack_channel').val(),--}}
|
||||
{{-- 'slack_botname': $('#slack_botname').val(),--}}
|
||||
|
||||
},
|
||||
{{-- },--}}
|
||||
|
||||
dataType: 'json',
|
||||
{{-- dataType: 'json',--}}
|
||||
|
||||
accepts: {
|
||||
text: "application/json"
|
||||
},
|
||||
{{-- accepts: {--}}
|
||||
{{-- text: "application/json"--}}
|
||||
{{-- },--}}
|
||||
|
||||
success: function (data) {
|
||||
$('#save_slack').removeAttr('disabled');
|
||||
$("#slacktesticon").html('');
|
||||
$("#slacktestrow").addClass('text-success');
|
||||
$("#slackteststatus").addClass('text-success');
|
||||
//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') }}');
|
||||
},
|
||||
{{-- success: function (data) {--}}
|
||||
{{-- $('#save_slack').removeAttr('disabled');--}}
|
||||
{{-- $("#slacktesticon").html('');--}}
|
||||
{{-- $("#slacktestrow").addClass('text-success');--}}
|
||||
{{-- $("#slackteststatus").addClass('text-success');--}}
|
||||
{{-- //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') }}');--}}
|
||||
{{-- },--}}
|
||||
|
||||
error: function (data) {
|
||||
{{-- error: function (data) {--}}
|
||||
|
||||
|
||||
if (data.responseJSON) {
|
||||
var errors = data.responseJSON.errors;
|
||||
var error_msg = data.responseJSON.message;
|
||||
} else {
|
||||
var errors;
|
||||
var error_msg = trans('admin/settings/message.slack.error');
|
||||
}
|
||||
{{-- if (data.responseJSON) {--}}
|
||||
{{-- var errors = data.responseJSON.errors;--}}
|
||||
{{-- var error_msg = data.responseJSON.message;--}}
|
||||
{{-- } else {--}}
|
||||
{{-- var errors;--}}
|
||||
{{-- var error_msg = trans('admin/settings/message.slack.error');--}}
|
||||
{{-- }--}}
|
||||
|
||||
var error_text = '';
|
||||
{{-- var error_text = '';--}}
|
||||
|
||||
$('#save_slack').attr("disabled", true);
|
||||
$("#slacktesticon").html('');
|
||||
$("#slackteststatus").addClass('text-danger');
|
||||
$("#slacktesticon").html('<i class="fas fa-exclamation-triangle text-danger"></i><span class="text-danger">' + error_msg+ '</span>');
|
||||
{{-- $('#save_slack').attr("disabled", true);--}}
|
||||
{{-- $("#slacktesticon").html('');--}}
|
||||
{{-- $("#slackteststatus").addClass('text-danger');--}}
|
||||
{{-- $("#slacktesticon").html('<i class="fas fa-exclamation-triangle text-danger"></i><span class="text-danger">' + error_msg+ '</span>');--}}
|
||||
|
||||
|
||||
if (data.status == 500) {
|
||||
$('#slackteststatus').html('{{ trans('admin/settings/message.slack.500') }}');
|
||||
} else if ((data.status == 400) || (data.status == 422)) {
|
||||
console.log('Type of errors is '+ typeof errors);
|
||||
console.log('Data status was 400 or 422');
|
||||
{{-- --}}
|
||||
{{-- if (data.status == 500) {--}}
|
||||
{{-- $('#slackteststatus').html('{{ trans('admin/settings/message.slack.500') }}');--}}
|
||||
{{-- } else if ((data.status == 400) || (data.status == 422)) {--}}
|
||||
{{-- console.log('Type of errors is '+ typeof errors);--}}
|
||||
{{-- console.log('Data status was 400 or 422');--}}
|
||||
|
||||
if (typeof errors != 'string') {
|
||||
|
||||
console.log(errors.length);
|
||||
{{-- if (typeof errors != 'string') {--}}
|
||||
{{-- --}}
|
||||
{{-- console.log(errors.length);--}}
|
||||
|
||||
for (i in errors) {
|
||||
if (errors[i]) {
|
||||
error_text += '<li>Error: ' + errors[i];
|
||||
}
|
||||
{{-- for (i in errors) {--}}
|
||||
{{-- if (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 {
|
||||
$('#slackteststatus').html(data.responseText.message);
|
||||
}
|
||||
}
|
||||
{{-- } else {--}}
|
||||
{{-- $('#slackteststatus').html(data.responseText.message);--}}
|
||||
{{-- }--}}
|
||||
{{-- }--}}
|
||||
|
||||
|
||||
});
|
||||
return false;
|
||||
});
|
||||
{{-- });--}}
|
||||
{{-- return false;--}}
|
||||
{{-- });--}}
|
||||
|
||||
</script>
|
||||
{{-- </script>--}}
|
||||
|
||||
@endpush
|
||||
{{--@endpush--}}
|
||||
|
|
Loading…
Reference in a new issue