This repository has been archived by the owner on Jun 9, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ba6fed
commit 9e5b6db
Showing
9 changed files
with
191 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,74 @@ | ||
(function ($) { | ||
var url = AJS.contextPath() + "/rest/prnfs-admin/1.0/"; | ||
$(document).ready(function() { | ||
$(".trigger").submit(function(e) { | ||
e.preventDefault(); | ||
AJS.$.ajax({ | ||
url: url, | ||
type: "POST", | ||
contentType: "application/json", | ||
data: JSON.stringify(AJS.$(".trigger").serializeArray(), null, 2), | ||
processData: false | ||
}); | ||
}); | ||
var config_resource = AJS.contextPath() + "/rest/prnfs-admin/1.0/"; | ||
$(document).ready(function() { | ||
function setEvents() { | ||
$('input[name="delete"]').click(function(e) { | ||
var $form = $(this).closest('form'); | ||
var formIdentifier = $('input[name="FORM_IDENTIFIER"]',$form).val(); | ||
$.ajax({ | ||
url: config_resource + formIdentifier, | ||
dataType: "json", | ||
type: "DELETE", | ||
error: function(xhr, data, error) { | ||
console.log(xhr); | ||
console.log(data); | ||
console.log(error); | ||
}, | ||
success: function(data, text, xhr) { | ||
$form.remove(); | ||
} | ||
}); | ||
}); | ||
|
||
$('input[name="save"]').click(function(e) { | ||
var $form = $(this).closest('form'); | ||
$(".post",$form).html("Saving..."); | ||
$.ajax({ | ||
url: config_resource, | ||
dataType: "json", | ||
type: "POST", | ||
contentType: "application/json", | ||
data: JSON.stringify($form.serializeArray(), null, 2), | ||
processData: false, | ||
error: function(xhr, data, error) { | ||
$.each(xhr.responseJSON, function(field,errorString) { | ||
$(".error."+field,$form).html(errorString); | ||
$(".post",$form).html("There were errors, form not saved!"); | ||
}); | ||
}, | ||
success: function(data, text, xhr) { | ||
getAll(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function addNewForm() { | ||
var $template = $(".prnfs-template").clone(); | ||
$('input[name="delete"]',$template).remove(); | ||
$(".prnfs").append($template.html()); | ||
} | ||
|
||
$.ajax({ | ||
url: url, | ||
dataType: "json" | ||
}).done(function(config) { | ||
|
||
function getAll() { | ||
$.ajax({ | ||
url: config_resource, | ||
dataType: "json" | ||
}).done(function(configs) { | ||
$(".prnfs").html(""); | ||
$.each(configs, function(index, config) { | ||
var $template = $(".prnfs-template").clone(); | ||
$.each(config, function(fieldIndex,field_map) { | ||
$('input[type="text"][name="'+field_map.name+'"]', $template).attr('value', field_map.value); | ||
$('input[type="hidden"][name="'+field_map.name+'"]', $template).attr('value', field_map.value); | ||
$('input[type="checkbox"][name="'+field_map.name+'"][value="'+field_map.value+'"]', $template).attr('checked','checked'); | ||
}); | ||
$(".prnfs").append($template.html()); | ||
}); | ||
}); | ||
addNewForm(); | ||
setEvents(); | ||
}); | ||
} | ||
|
||
getAll(); | ||
}); | ||
})(AJS.$ || jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.