|
|
@@ -46,6 +46,17 @@ $(function() {
|
|
|
|
|
|
initialiseTooltips();
|
|
|
|
|
|
+ $("#template-id, #time-of-day, #date-start-month, #date-start-year").on("change", () => autogenProjectName());
|
|
|
+ autogenProjectName();
|
|
|
+
|
|
|
+ $("#autogen-name").on("change", event => {
|
|
|
+ const checked = event.currentTarget.checked;
|
|
|
+ $("#name").prop("readonly", checked);
|
|
|
+ if(checked) {
|
|
|
+ autogenProjectName();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
|
|
|
function handleSelectButton() {
|
|
|
@@ -134,3 +145,27 @@ function refreshLocationAlerts() {
|
|
|
$("#selected-locations-alert").show();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+function autogenProjectName() {
|
|
|
+
|
|
|
+ const autogenChecked = $("#autogen-name").is(":checked");
|
|
|
+ if(!autogenChecked) return;
|
|
|
+
|
|
|
+ const customerName = $("#customer-name").text();
|
|
|
+ const templateName = $("#template-id").find("option:selected").text();
|
|
|
+ const dateStartMonth = $("#date-start-month").find("option:selected").text();
|
|
|
+ const dateStartYear = $("#date-start-year").find("option:selected").text();
|
|
|
+ const timeOfDay = $("#time-of-day").find("option:selected").text();
|
|
|
+
|
|
|
+ const templateWords = templateName.split(" ");
|
|
|
+ const templateWordCount = templateWords.length;
|
|
|
+ const templateInitials = [];
|
|
|
+ for(let i = 0; i < templateWordCount; i++) {
|
|
|
+ templateInitials.push(templateWords[i].charAt(0));
|
|
|
+ }
|
|
|
+
|
|
|
+ const projectName = `${customerName} ${dateStartMonth} ${dateStartYear} ${templateInitials.join("")} ${timeOfDay}`;
|
|
|
+
|
|
|
+ $("#name").val(projectName);
|
|
|
+
|
|
|
+}
|