From 09d2f8ec66f3685915f444382c10cc07b46e7cee Mon Sep 17 00:00:00 2001 From: Jan Vansteenlandt Date: Sun, 27 Dec 2015 21:39:20 +0100 Subject: [PATCH 1/2] added schedule to edit action in js --- dev/js/jobs.js | 5 ++++- public/jobs.min.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dev/js/jobs.js b/dev/js/jobs.js index c102dbe..0ffa037 100644 --- a/dev/js/jobs.js +++ b/dev/js/jobs.js @@ -32,7 +32,6 @@ $('.btn-add-job').on('click', function(e){ // Get the schedule data['schedule'] = $('#schedule option:checked').val(); - console.log(data); // Ajax call $.ajax({ @@ -100,6 +99,10 @@ $('.btn-edit-job').on('click', function(e){ data[sequence] = object; }); + // Get the schedule + data['schedule'] = $('#schedule option:checked').val(); + console.log(data); + // Ajax call $.ajax({ url: baseURL + 'api/input/' + collection, diff --git a/public/jobs.min.js b/public/jobs.min.js index 8845dd9..06fef1b 100644 --- a/public/jobs.min.js +++ b/public/jobs.min.js @@ -1 +1 @@ -$(".btn-add-job").on("click",function(e){e.preventDefault(),$(this).prop("disabled",!0);var t=$("form.add-job"),a=new Object,o=$('input[name="collection"]').val();$(".tab-pane.active",t).each(function(){var e=$(this),t=new Object;t.type=e.data("type"),$("input, textarea, select",e).each(function(){$(this).attr("name")&&("checkbox"==$(this).attr("type")?t[$(this).attr("name")]=$(this).prop("checked")?1:0:t[$(this).attr("name")]=$(this).val())}),a[e.data("part")]=t}),a.schedule=$("#schedule option:checked").val(),console.log(a),$.ajax({url:baseURL+"api/input/"+o,data:JSON.stringify(a),method:"PUT",headers:{Accept:"application/json",Authorization:authHeader},success:function(e){window.location=baseURL+"api/admin/jobs"},error:function(e){if($(".btn-add-job").prop("disabled",!1),405!=e.status){var t=JSON.parse(e.responseText);t.error&&t.error.message&&($(".error .text").html(t.error.message),$(".error").removeClass("hide").show().focus())}else window.location=baseURL+"api/admin/jobs"}})}),$(".btn-edit-job").on("click",function(e){e.preventDefault(),$(this).prop("disabled",!0);var t=$("form.edit-job"),a=new Object,o=$('input[name="collection"]').val();$(".tab-pane",t).each(function(){var e=$(this),t=e.attr("id"),o=new Object;o.type=e.data("type"),$("input, textarea, select",e).each(function(){$(this).attr("name")&&("checkbox"==$(this).attr("type")?o[$(this).attr("name")]=$(this).prop("checked")?1:0:o[$(this).attr("name")]=$(this).val())}),a[t]=o}),$.ajax({url:baseURL+"api/input/"+o,data:JSON.stringify(a),method:"POST",headers:{Accept:"application/json",Authorization:authHeader},success:function(e){window.location=baseURL+"api/admin/jobs"},error:function(e){if($(".btn-edit-job").prop("disabled",!1),405!=e.status){var t=JSON.parse(e.responseText);t.error&&t.error.message&&($(".error .text").html(t.error.message),$(".error").removeClass("hide").show().focus())}else window.location=baseURL+"api/admin/jobs"}})}); \ No newline at end of file +$(".btn-add-job").on("click",function(e){e.preventDefault(),$(this).prop("disabled",!0);var t=$("form.add-job"),a=new Object,o=$('input[name="collection"]').val();$(".tab-pane.active",t).each(function(){var e=$(this),t=new Object;t.type=e.data("type"),$("input, textarea, select",e).each(function(){$(this).attr("name")&&("checkbox"==$(this).attr("type")?t[$(this).attr("name")]=$(this).prop("checked")?1:0:t[$(this).attr("name")]=$(this).val())}),a[e.data("part")]=t}),a.schedule=$("#schedule option:checked").val(),$.ajax({url:baseURL+"api/input/"+o,data:JSON.stringify(a),method:"PUT",headers:{Accept:"application/json",Authorization:authHeader},success:function(e){window.location=baseURL+"api/admin/jobs"},error:function(e){if($(".btn-add-job").prop("disabled",!1),405!=e.status){var t=JSON.parse(e.responseText);t.error&&t.error.message&&($(".error .text").html(t.error.message),$(".error").removeClass("hide").show().focus())}else window.location=baseURL+"api/admin/jobs"}})}),$(".btn-edit-job").on("click",function(e){e.preventDefault(),$(this).prop("disabled",!0);var t=$("form.edit-job"),a=new Object,o=$('input[name="collection"]').val();$(".tab-pane",t).each(function(){var e=$(this),t=e.attr("id"),o=new Object;o.type=e.data("type"),$("input, textarea, select",e).each(function(){$(this).attr("name")&&("checkbox"==$(this).attr("type")?o[$(this).attr("name")]=$(this).prop("checked")?1:0:o[$(this).attr("name")]=$(this).val())}),a[t]=o}),a.schedule=$("#schedule option:checked").val(),$.ajax({url:baseURL+"api/input/"+o,data:JSON.stringify(a),method:"POST",headers:{Accept:"application/json",Authorization:authHeader},success:function(e){window.location=baseURL+"api/admin/jobs"},error:function(e){if($(".btn-edit-job").prop("disabled",!1),405!=e.status){var t=JSON.parse(e.responseText);t.error&&t.error.message&&($(".error .text").html(t.error.message),$(".error").removeClass("hide").show().focus())}else window.location=baseURL+"api/admin/jobs"}})}); \ No newline at end of file From 55fdc668d74f1842fb4ca1b5857a04fa4061bcda Mon Sep 17 00:00:00 2001 From: Jan Vansteenlandt Date: Sun, 27 Dec 2015 21:40:58 +0100 Subject: [PATCH 2/2] added schedule to edit action in js --- dev/js/jobs.js | 1 - 1 file changed, 1 deletion(-) diff --git a/dev/js/jobs.js b/dev/js/jobs.js index 0ffa037..bebffeb 100644 --- a/dev/js/jobs.js +++ b/dev/js/jobs.js @@ -101,7 +101,6 @@ $('.btn-edit-job').on('click', function(e){ // Get the schedule data['schedule'] = $('#schedule option:checked').val(); - console.log(data); // Ajax call $.ajax({