1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-21 14:19:43 +02:00

completed red-line links

This commit is contained in:
Harvey Kandola 2016-10-27 16:53:36 -07:00
parent 16b7fd45d7
commit 7c2051cc7a
8 changed files with 70 additions and 16 deletions

View file

@ -290,6 +290,10 @@ func (p *Persister) UpdatePage(page entity.Page, refID, userID string, skipRevis
// find any content links in the HTML
links := util.GetContentLinks(page.Body)
// get a copy of previously saved links
previousLinks, _ := p.GetPageLinks(page.DocumentID, page.RefID)
fmt.Println(len(previousLinks))
// delete previous content links for this page
_, _ = p.DeleteSourcePageLinks(page.RefID)
@ -299,11 +303,22 @@ func (p *Persister) UpdatePage(page entity.Page, refID, userID string, skipRevis
link.OrgID = p.Context.OrgID
link.UserID = p.Context.UserID
link.SourceDocumentID = page.DocumentID
link.SourcePageID = page.RefID
if link.LinkType == "section" {
link.SourcePageID = page.RefID
if link.LinkType == "document" {
link.TargetID = ""
}
// We check if there was a previously saved version of this link.
// If we find one, we carry forward the orphan flag.
for _, p := range previousLinks {
if link.TargetID == p.TargetID && link.LinkType == p.LinkType {
link.Orphan = p.Orphan
break
}
}
// save
err := p.AddContentLink(link)
if err != nil {