add crud for node

This commit is contained in:
Владимир Фёдоров 2025-12-13 21:31:45 +07:00
parent 3b182d7380
commit 6b18709e61
5 changed files with 153 additions and 136 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5,8 +5,8 @@
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ВД Админка</title>
<script type="module" crossorigin src="/assets/index-DTvRzGpy.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BkyopZAN.css">
<script type="module" crossorigin src="/assets/index-WLMuUXZt.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-D8kPNaZP.css">
</head>
<body>
<div id="app"></div>

View File

@ -97,9 +97,16 @@ func (s *StoryService) GetPlace(code string) *Place {
}
func (s *StoryService) UpdatePlace(code string, node *GraphNode) error {
update := false
if code != "" && node.Code == "" {
for i := range s.story.Places {
if s.story.Places[i].Code == code {
s.story.Places = append(s.story.Places[:i], s.story.Places[i+1:]...)
break
}
}
s.Update()
return nil
}
nodeApplications := make([]*Application, 0, len(node.Applications))
for _, application := range node.Applications {
nodeApplications = append(
@ -109,6 +116,25 @@ func (s *StoryService) UpdatePlace(code string, node *GraphNode) error {
},
)
}
if code == "" && node.Code != "" {
s.story.Places = append(
s.story.Places,
&Place{
Code: node.Code,
Name: node.Name,
Text: formatText(node.Text),
Applications: nodeApplications,
},
)
s.Update()
return nil
}
if code == "" || node.Code == "" {
return nil
}
update := false
for i := range s.story.Places {
if s.story.Places[i].Code == code {
s.story.Places[i] = &Place{
Code: node.Code,
Name: node.Name,
@ -122,15 +148,6 @@ func (s *StoryService) UpdatePlace(code string, node *GraphNode) error {
if !update {
for i := range s.story.Places {
if s.story.Places[i].Code == node.Code {
nodeApplications := make([]*Application, 0, len(node.Applications))
for _, application := range node.Applications {
nodeApplications = append(
nodeApplications,
&Application{
Name: application.Name,
},
)
}
s.story.Places[i] = &Place{
Code: code,
Name: node.Name,