generated from VLADIMIR/template
update editor
This commit is contained in:
@@ -16,6 +16,7 @@ type GraphNode struct {
|
||||
type GraphEdge struct {
|
||||
From int32
|
||||
To int32
|
||||
Type string
|
||||
}
|
||||
|
||||
type GraphApplication struct {
|
||||
|
||||
@@ -69,12 +69,22 @@ func (s *StoryService) GetPlace(code string) *Place {
|
||||
for _, place := range s.story.Places {
|
||||
if clearCode(place.Code) == code {
|
||||
re := regexp.MustCompile(`\(\[[a-zA-Zа-яА-Я\d-]+\]\)`)
|
||||
applications := make([]*Application, 0, len(place.Applications))
|
||||
for _, application := range place.Applications {
|
||||
name := re.ReplaceAllString(application.Name, "")
|
||||
applications = append(
|
||||
applications,
|
||||
&Application{
|
||||
Name: name,
|
||||
},
|
||||
)
|
||||
}
|
||||
text := re.ReplaceAllString(place.Text, "")
|
||||
return &Place{
|
||||
Code: place.Code,
|
||||
Name: place.Name,
|
||||
Text: text,
|
||||
Applications: place.Applications,
|
||||
Applications: applications,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,11 +98,20 @@ func (s *StoryService) GetPlace(code string) *Place {
|
||||
func (s *StoryService) UpdatePlace(node *GraphNode) error {
|
||||
for i := range s.story.Places {
|
||||
if s.story.Places[i].Code == node.Label {
|
||||
applications := make([]*Application, 0, len(node.Applications))
|
||||
for _, application := range node.Applications {
|
||||
applications = append(
|
||||
applications,
|
||||
&Application{
|
||||
Name: application.Name,
|
||||
},
|
||||
)
|
||||
}
|
||||
s.story.Places[i] = &Place{
|
||||
Code: s.story.Places[i].Code,
|
||||
Name: node.Name,
|
||||
Text: node.Text,
|
||||
Applications: s.story.Places[i].Applications,
|
||||
Applications: applications,
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -137,9 +156,24 @@ func (s *StoryService) GetGraph(ctx context.Context) *Graph {
|
||||
&GraphEdge{
|
||||
From: m[clearCode(place.Code)],
|
||||
To: m[clearMatch(match)],
|
||||
Type: "node",
|
||||
},
|
||||
)
|
||||
}
|
||||
for _, application := range place.Applications {
|
||||
re := regexp.MustCompile(`\(\[[a-zA-Zа-яА-Я\d-]+\]\)`)
|
||||
matches := re.FindAllString(application.Name, -1)
|
||||
for _, match := range matches {
|
||||
edges = append(
|
||||
edges,
|
||||
&GraphEdge{
|
||||
From: m[clearCode(place.Code)],
|
||||
To: m[clearMatch(match)],
|
||||
Type: "application",
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return &Graph{
|
||||
|
||||
Reference in New Issue
Block a user