generated from VLADIMIR/template
add crud for node
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -5,8 +5,8 @@
|
|||||||
<link rel="icon" href="/favicon.ico">
|
<link rel="icon" href="/favicon.ico">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>ВД Админка</title>
|
<title>ВД Админка</title>
|
||||||
<script type="module" crossorigin src="/assets/index-DTvRzGpy.js"></script>
|
<script type="module" crossorigin src="/assets/index-WLMuUXZt.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-BkyopZAN.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-D8kPNaZP.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
@@ -97,18 +97,44 @@ func (s *StoryService) GetPlace(code string) *Place {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *StoryService) UpdatePlace(code string, node *GraphNode) error {
|
func (s *StoryService) UpdatePlace(code string, node *GraphNode) error {
|
||||||
|
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(
|
||||||
|
nodeApplications,
|
||||||
|
&Application{
|
||||||
|
Name: application.Name,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
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
|
update := false
|
||||||
for i := range s.story.Places {
|
for i := range s.story.Places {
|
||||||
if s.story.Places[i].Code == code {
|
if s.story.Places[i].Code == 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{
|
s.story.Places[i] = &Place{
|
||||||
Code: node.Code,
|
Code: node.Code,
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
@@ -122,15 +148,6 @@ func (s *StoryService) UpdatePlace(code string, node *GraphNode) error {
|
|||||||
if !update {
|
if !update {
|
||||||
for i := range s.story.Places {
|
for i := range s.story.Places {
|
||||||
if s.story.Places[i].Code == node.Code {
|
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{
|
s.story.Places[i] = &Place{
|
||||||
Code: code,
|
Code: code,
|
||||||
Name: node.Name,
|
Name: node.Name,
|
||||||
|
|||||||
Reference in New Issue
Block a user