|
|
@@ -78,23 +78,30 @@ $(function() {
|
|
|
});
|
|
|
$extraFieldsRow.collapse("show");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
});
|
|
|
|
|
|
+ $(document).on("change", "#template-extra-fields-container input", () => autogenProjectName());
|
|
|
+
|
|
|
$("#template-id").trigger("change");
|
|
|
|
|
|
$("#autogen-name").on("change", event => {
|
|
|
const checked = event.currentTarget.checked;
|
|
|
$("#name").prop("readonly", checked);
|
|
|
- if(checked) {
|
|
|
- autogenProjectName();
|
|
|
- }
|
|
|
+ if(checked) autogenProjectName();
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
+function getCheckedTemplateKeys() {
|
|
|
+ const keys = [];
|
|
|
+ $("#template-extra-fields-container input").each((index, element) => {
|
|
|
+ const $checkbox = $(element);
|
|
|
+ const isChecked = $checkbox.prop("checked");
|
|
|
+ if(isChecked) keys.push($checkbox.val());
|
|
|
+ });
|
|
|
+ return keys;
|
|
|
+}
|
|
|
+
|
|
|
function handleSelectButton() {
|
|
|
|
|
|
let lgi = $(this).closest(".list-group-item");
|
|
|
@@ -200,7 +207,21 @@ function autogenProjectName() {
|
|
|
templateInitials.push(templateWords[i].charAt(0));
|
|
|
}
|
|
|
|
|
|
- const projectName = `${customerName} ${dateStartMonth} ${dateStartYear} ${templateInitials.join("")} ${timeOfDay}`;
|
|
|
+ const templateKeys = getCheckedTemplateKeys();
|
|
|
+
|
|
|
+ const parts = [];
|
|
|
+ parts.push(customerName);
|
|
|
+ parts.push(dateStartMonth);
|
|
|
+ parts.push(dateStartYear);
|
|
|
+ parts.push(templateInitials.join(""));
|
|
|
+
|
|
|
+ if(templateKeys.length > 0) {
|
|
|
+ parts.push(`(${templateKeys.join(" + ")})`);
|
|
|
+ }
|
|
|
+
|
|
|
+ parts.push(timeOfDay);
|
|
|
+
|
|
|
+ const projectName = parts.join(" ");
|
|
|
|
|
|
$("#name").val(projectName);
|
|
|
|