Skip to content
Snippets Groups Projects
Commit 79cee4ef authored by Colin Jakob's avatar Colin Jakob
Browse files

Function for cloning requirements

parent 7ae75018
No related branches found
No related tags found
1 merge request!4merge dev to main
...@@ -78,7 +78,9 @@ ...@@ -78,7 +78,9 @@
<td> <td>
<div class="btn-group btn-group-sm"> <div class="btn-group btn-group-sm">
<!-- Clone requirement button --> <!-- Clone requirement button -->
<button class="btn btn-outline-secondary" title="Klonen"> <button onclick="cloneRequirement('{{ .ID.Hex }}', '{{ .RequirementID }}')"
class="btn btn-outline-secondary"
title="Klonen">
📋 📋
</button> </button>
<!-- Delete requirement button --> <!-- Delete requirement button -->
...@@ -94,4 +96,55 @@ ...@@ -94,4 +96,55 @@
</div> </div>
{{ end }} {{ end }}
</div> </div>
<script>
function cloneRequirement(reqId, reqName) {
// Get list of available projects from the current page context
const projects = [
{{ range $.Data.Project.Project.CreatedBy }}
// This won't work, we need to get projects differently
{{ end }}
];
// Simple prompt-based solution for now
const targetProjectId = prompt(`Anforderung "${reqName}" klonen.\n\nGeben Sie die Projekt-ID des Zielprojekts ein:`);
if (!targetProjectId) return;
const newName = prompt(`Neuer Name für die geklonte Anforderung:`, `${reqName}-kopie`);
if (!newName) return;
// Debug: Log the request details
console.log('Making clone request:', {
url: `/requirement/${reqId}/clone`,
targetProjectId: targetProjectId,
newName: newName
});
// Make the clone request
fetch(`/requirement/${reqId}/clone`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: `ProjectID=${encodeURIComponent(targetProjectId)}&Name=${encodeURIComponent(newName)}`
})
.then(response => {
console.log('Response status:', response.status);
console.log('Response headers:', response.headers);
return response.text().then(text => {
console.log('Response body:', text);
if (response.ok) {
alert(`Anforderung erfolgreich nach Projekt "${targetProjectId}" geklont!`);
location.reload(); // Refresh to show changes
} else {
alert(`Fehler beim Klonen der Anforderung: ${response.status} - ${text}`);
}
});
})
.catch(error => {
console.error('Error:', error);
alert('Fehler beim Klonen der Anforderung: ' + error.message);
});
}
</script>
{{ end }} {{ end }}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment