Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,25 @@
*/

// any CSS you require will output into a single css file (app.css in this case)
require('../css/app.scss');
require("../css/app.scss");

// Need jQuery? Install it with "yarn add jquery", then uncomment to require it.
const $ = require('jquery');
require('bootstrap');
const $ = require("jquery");
require("bootstrap");

$(document).ready(function() {
$('[data-toggle="popover"]').popover();
$('[data-toggle="popover"]').popover();
});

const axios = require('axios');
const axios = require("axios");

if (typeof usingVersionedFileJs !== "undefined") {
let versionedFileElement = document.getElementById('versionedFile');
axios.get('/build/manifest.json')
.then(function (response) {
versionedFileElement.innerText = response.data['build/app.js'];
})
.catch(function (error) {
versionedFileElement.innerText = 'Error: '.error;
});
let versionedFileElement = document.getElementById("versionedFile");
axios
.get("/build/manifest.json")
.then(
response =>
(versionedFileElement.innerText = response.data["build/app.js"])
)
.catch(error => (versionedFileElement.innerText = "Error: ".error));
}
24 changes: 23 additions & 1 deletion assets/js/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const axios = require('axios');

let name = document.getElementById('name');
let validationResult = document.getElementById('validation-result');
const validateName = function () {

const validateName = () => {
validationResult.innerText = '...';
axios.post(validationResult.dataset.path, {input: name.value})
.then(function(response) {
Expand All @@ -19,3 +20,24 @@ const validateName = function () {

name.onkeyup = validateName;
name.onchange = validateName;

let team = document.getElementById('team');
let validationResultTeam = document.getElementById('validation-result-team');

const validateTeam = () => {
validationResultTeam.innerText = '...';
axios.post(validationResultTeam.dataset.path, {input: team.value})
.then(function(response) {
if (response.data.valid) {
validationResultTeam.innerHTML = ":)";
} else {
validationResultTeam.innerHTML = ":(";
}
})
.catch(function (error) {
validationResultTeam.innerText = 'Error: ' + error;
});
};

team.onkeyup = validateTeam;
team.onchange = validateTeam;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dependencies": {
"axios": "^0.19.0",
"prop-types": "^15.7.2",
"react": "^16.11.0",
"react-dom": "^16.11.0"
"react": "^16.12.0",
"react-dom": "^16.12.0"
}
}
15 changes: 14 additions & 1 deletion src/Controller/PeopleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ public function validate(Request $request, string $element)
}

$students = $this->getStudents();
$teams = $this->getTeams();
switch ($element) {
case 'name':
return new JsonResponse(['valid' => in_array(strtolower($input), $students)]);
case 'team':
return new JsonResponse(['valid' => in_array(strtolower($input), $teams)]);
}

return new JsonResponse(['error' => 'Invalid arguments'], Response::HTTP_BAD_REQUEST);
Expand Down Expand Up @@ -212,7 +215,7 @@ private function getStorage()
"Viktoras"
],
"students": [
"Karolis",
"Karolis a",
"Arnas",
"Evaldas",
"Algirdas"
Expand Down Expand Up @@ -242,4 +245,14 @@ private function getStudents(): array
}
return $students;
}

private function getTeams(): array
{
$teams = [];
$storage = json_decode($this->getStorage(), true);
foreach ($storage as $teamName => $value) {
$teams[] = strtolower($teamName);
}
return $teams;
}
}
8 changes: 7 additions & 1 deletion templates/people/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
<div>
Versijuojamas JavaScript failas: <b id="versionedFile">...</b>
</div>

<label>Įveskite komandos nario vardą: </label>
<input type="text" id="name"/>
<span id="validation-result" data-path="{{ path('validatePerson', {'element': 'name'}) }}"></span>
<br/>
<label>Įveskite projekto pavadinimą: </label>
<input type="text" id="team"/>
<span id="validation-result-team" data-path="{{ path('validatePerson', {'element': 'team'}) }}"></span>

{% endblock %}


{% block javascripts %}
<script>
var usingVersionedFileJs = true;
Expand Down
26 changes: 13 additions & 13 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5499,25 +5499,25 @@ rc@^1.2.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"

react-dom@^16.11.0:
version "16.11.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.11.0.tgz#7e7c4a5a85a569d565c2462f5d345da2dd849af5"
integrity sha512-nrRyIUE1e7j8PaXSPtyRKtz+2y9ubW/ghNgqKFHHAHaeP0fpF5uXR+sq8IMRHC+ZUxw7W9NyCDTBtwWxvkb0iA==
react-dom@^16.12.0:
version "16.12.0"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.12.0.tgz#0da4b714b8d13c2038c9396b54a92baea633fe11"
integrity sha512-LMxFfAGrcS3kETtQaCkTKjMiifahaMySFDn71fZUNpPHZQEzmk/GiAeIT8JSOrHB23fnuCOMruL2a8NYlw+8Gw==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.2"
scheduler "^0.17.0"
scheduler "^0.18.0"

react-is@^16.8.1:
version "16.11.0"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.11.0.tgz#b85dfecd48ad1ce469ff558a882ca8e8313928fa"
integrity sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw==

react@^16.11.0:
version "16.11.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.11.0.tgz#d294545fe62299ccee83363599bf904e4a07fdbb"
integrity sha512-M5Y8yITaLmU0ynd0r1Yvfq98Rmll6q8AxaEe88c8e7LxO8fZ2cNgmFt0aGAS9wzf1Ao32NKXtCl+/tVVtkxq6g==
react@^16.12.0:
version "16.12.0"
resolved "https://registry.yarnpkg.com/react/-/react-16.12.0.tgz#0c0a9c6a142429e3614834d5a778e18aa78a0b83"
integrity sha512-fglqy3k5E+81pA8s+7K0/T3DBCF0ZDOher1elBFzF7O6arXJgzyu/FW+COxFvAWXJoJN9KIZbT2LXlukwphYTA==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
Expand Down Expand Up @@ -5877,10 +5877,10 @@ sax@^1.2.4, sax@~1.2.4:
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==

scheduler@^0.17.0:
version "0.17.0"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.17.0.tgz#7c9c673e4ec781fac853927916d1c426b6f3ddfe"
integrity sha512-7rro8Io3tnCPuY4la/NuI5F2yfESpnfZyT6TtkXnSWVkcu0BCDJ+8gk5ozUaFaxpIyNuWAPXrH0yFcSi28fnDA==
scheduler@^0.18.0:
version "0.18.0"
resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.18.0.tgz#5901ad6659bc1d8f3fdaf36eb7a67b0d6746b1c4"
integrity sha512-agTSHR1Nbfi6ulI0kYNK0203joW2Y5W4po4l+v03tOoiJKpTBbxpNhWDvqc/4IcOw+KLmSiQLTasZ4cab2/UWQ==
dependencies:
loose-envify "^1.1.0"
object-assign "^4.1.1"
Expand Down