Skip to content

Commit

Permalink
Merge pull request ANSTO#16 from joshpme/master
Browse files Browse the repository at this point in the history
Fix up some of the issues found with the new prefill functionality
  • Loading branch information
joshpme authored May 6, 2023
2 parents 41dfe20 + a64a0f4 commit 348e0ae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions public/js/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ $("#pre-fill-action").click(function(){
if (typeof response.conference_pub_date !== 'undefined') {
let pub_date = new Date(Date.parse(response.conference_pub_date));
$("#appbundle_conference_isPublished").prop("checked", true);
$("#appbundle_conference_pubMonth").val(pub_date.getUTCFullYear());
$("#appbundle_conference_pubYear").val(pub_date.getUTCMonth()+1);
$("#appbundle_conference_pubYear").val(pub_date.getUTCFullYear());
$("#appbundle_conference_pubMonth").val(pub_date.getUTCMonth()+1);
}

if (typeof response.conference_url !== 'undefined') {
Expand All @@ -236,6 +236,7 @@ $("#pre-fill-action").click(function(){

if (typeof response.conference_name !== 'undefined') {
$("#appbundle_conference_doiCode").val(response.conference_name);
$("#appbundle_conference_useDoi").val(1);
}
});
});
7 changes: 5 additions & 2 deletions src/Controller/ConferenceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ public function parserAction(Request $request): JsonResponse
$lines = explode("\n", $content);
$data = [];
foreach ($lines as $line) {
[$key, $value] = explode("=", $line, 2);
$data[trim($key)] = trim($value);
$contents = explode("=", $line, 2);
if (count($contents) == 2) {
[$key, $value] = $contents;
$data[trim($key)] = trim($value);
}
}

return new JsonResponse($data);
Expand Down
2 changes: 1 addition & 1 deletion templates/base.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<script src="{{ path('fos_js_routing_js', { callback: 'fos.Router.setData' }) }}"></script>
<script src="{{ asset("js/typeahead.bundle.min.js") }}"></script>
<script>var datasources = [];</script>
<script src="{{ asset("js/global.js") }}?4" async></script>
<script src="{{ asset("js/global.js") }}?5" async></script>
{% endblock %}
</body>
</html>

0 comments on commit 348e0ae

Please sign in to comment.