Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HARMONY-experimental-branch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Robin Korfmann
HARMONY-experimental-branch
Commits
79cee4ef
Commit
79cee4ef
authored
2 weeks ago
by
Colin Jakob
Browse files
Options
Downloads
Patches
Plain Diff
Function for cloning requirements
parent
7ae75018
No related branches found
No related tags found
1 merge request
!4
merge dev to main
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
templates/project/_requirements-list.go.html
+54
-1
54 additions, 1 deletion
templates/project/_requirements-list.go.html
with
54 additions
and
1 deletion
templates/project/_requirements-list.go.html
+
54
−
1
View file @
79cee4ef
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment