VRFS-1848 : Halt claim recording and show error if "Save to Youtube" selected, but not logged into google.
This commit is contained in:
parent
267e5a7e10
commit
b6fad726c4
|
|
@ -141,18 +141,44 @@
|
|||
return false;
|
||||
}
|
||||
|
||||
function hasGoogleAuth() {
|
||||
var auth=false
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
url: "/auth/has_google_auth"
|
||||
}).success(function(data) {
|
||||
if(!data.has_google_auth) {
|
||||
auth=true
|
||||
}
|
||||
})
|
||||
return auth
|
||||
}
|
||||
|
||||
function claimRecording(e) {
|
||||
|
||||
resetForm();
|
||||
registerClaimRecordingHandlers(false);
|
||||
|
||||
var upload_to_youtube = $('#recording-finished-dialog form input[name=upload_to_youtube]').is(':checked')
|
||||
|
||||
if (upload_to_youtube && !hasGoogleAuth()) {
|
||||
var error_ul = $('<ul class="error-text upload_to_youtube"><li>You must sign in to YouTube</li></ul>')
|
||||
$('#recording-finished-dialog form [purpose=upload_to_youtube]').addClass('error').append(error_ul)
|
||||
} else {
|
||||
performClaim()
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function performClaim() {
|
||||
var name = $('#recording-finished-dialog form input[name=name]').val();
|
||||
var description = $('#recording-finished-dialog form textarea[name=description]').val();
|
||||
var genre = $('#recording-finished-dialog form select[name=genre]').val();
|
||||
var is_public = $('#recording-finished-dialog form input[name=is_public]').is(':checked')
|
||||
var save_video = $('#recording-finished-dialog form input[name=save_video]').is(':checked')
|
||||
var upload_to_youtube = $('#recording-finished-dialog form input[name=upload_to_youtube]').is(':checked')
|
||||
|
||||
|
||||
rest.claimRecording({
|
||||
id: recording.id,
|
||||
name: name,
|
||||
|
|
@ -162,47 +188,43 @@
|
|||
save_video: save_video,
|
||||
upload_to_youtube: upload_to_youtube
|
||||
})
|
||||
.done(function () {
|
||||
$dialog.data('result', {keep:true});
|
||||
app.layout.closeDialog('recordingFinished');
|
||||
context.JK.GA.trackMakeRecording();
|
||||
})
|
||||
.fail(function (jqXHR) {
|
||||
if (jqXHR.status == 422) {
|
||||
var errors = JSON.parse(jqXHR.responseText);
|
||||
.done(function () {
|
||||
$dialog.data('result', {keep:true});
|
||||
app.layout.closeDialog('recordingFinished');
|
||||
context.JK.GA.trackMakeRecording();
|
||||
})
|
||||
.fail(function (jqXHR) {
|
||||
if (jqXHR.status == 422) {
|
||||
var errors = JSON.parse(jqXHR.responseText);
|
||||
|
||||
var $name_errors = context.JK.format_errors('name', errors);
|
||||
if ($name_errors) $('#recording-finished-dialog form input[name=name]').closest('div.field').addClass('error').end().after($name_errors);
|
||||
var $name_errors = context.JK.format_errors('name', errors);
|
||||
if ($name_errors) $('#recording-finished-dialog form input[name=name]').closest('div.field').addClass('error').end().after($name_errors);
|
||||
|
||||
var $description_errors = context.JK.format_errors('description', errors);
|
||||
if ($description_errors) $('#recording-finished-dialog form input[name=description]').closest('div.field').addClass('error').end().after($description_errors);
|
||||
var $description_errors = context.JK.format_errors('description', errors);
|
||||
if ($description_errors) $('#recording-finished-dialog form input[name=description]').closest('div.field').addClass('error').end().after($description_errors);
|
||||
|
||||
var $genre_errors = context.JK.format_errors('genre', errors);
|
||||
if ($genre_errors) $('#recording-finished-dialog form select[name=genre]').closest('div.field').addClass('error').end().after($genre_errors);
|
||||
var $genre_errors = context.JK.format_errors('genre', errors);
|
||||
if ($genre_errors) $('#recording-finished-dialog form select[name=genre]').closest('div.field').addClass('error').end().after($genre_errors);
|
||||
|
||||
var $is_public_errors = context.JK.format_errors('is_public', errors);
|
||||
if ($is_public_errors) $('#recording-finished-dialog form input[name=is_public]').closest('div.field').addClass('error').end().after($is_public_errors);
|
||||
var $is_public_errors = context.JK.format_errors('is_public', errors);
|
||||
if ($is_public_errors) $('#recording-finished-dialog form input[name=is_public]').closest('div.field').addClass('error').end().after($is_public_errors);
|
||||
|
||||
var $save_video_errors = context.JK.format_errors('save_video', errors);
|
||||
if ($save_video_errors) $('#recording-finished-dialog form input[name=save_video]').closest('div.field').addClass('error').end().after($save_video_errors);
|
||||
var $save_video_errors = context.JK.format_errors('save_video', errors);
|
||||
if ($save_video_errors) $('#recording-finished-dialog form input[name=save_video]').closest('div.field').addClass('error').end().after($save_video_errors);
|
||||
|
||||
var recording_error = context.JK.get_first_error('recording_id', errors);
|
||||
|
||||
var $upload_to_youtube_errors = context.JK.format_errors('upload_to_youtube', errors);
|
||||
if ($upload_to_youtube_errors) $('#recording-finished-dialog form input[name=upload_to_youtube]').closest('div.field').addClass('error').end().after($upload_to_youtube_errors);
|
||||
if (recording_error) context.JK.showErrorDialog(app, "Unable to claim recording.", recording_error);
|
||||
}
|
||||
else {
|
||||
logger.error("unable to claim recording %o", arguments);
|
||||
|
||||
var recording_error = context.JK.get_first_error('recording_id', errors);
|
||||
|
||||
if (recording_error) context.JK.showErrorDialog(app, "Unable to claim recording.", recording_error);
|
||||
}
|
||||
else {
|
||||
logger.error("unable to claim recording %o", arguments);
|
||||
|
||||
context.JK.showErrorDialog(app, "Unable to claim recording.", jqXHR.responseText);
|
||||
}
|
||||
})
|
||||
.always(function () {
|
||||
registerClaimRecordingHandlers(true);
|
||||
});
|
||||
return false;
|
||||
context.JK.showErrorDialog(app, "Unable to claim recording.", jqXHR.responseText);
|
||||
}
|
||||
})
|
||||
.always(function () {
|
||||
registerClaimRecordingHandlers(true);
|
||||
});
|
||||
}
|
||||
|
||||
function registerClaimRecordingHandlers(onOff) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue