Returns a new Summary with the article at the given level, with subsequent article shifted. @param {Summary} summary @param {Article} article @param {String|Article} level: level to insert at @return {Summary}
(summary, article, level)
| 13 | @return {Summary} |
| 14 | */ |
| 15 | function insertArticle(summary, article, level) { |
| 16 | article = SummaryArticle(article); |
| 17 | level = is.string(level)? level : level.getLevel(); |
| 18 | |
| 19 | var parent = summary.getParent(level); |
| 20 | if (!parent) { |
| 21 | return summary; |
| 22 | } |
| 23 | |
| 24 | // Find the index to insert at |
| 25 | var articles = parent.getArticles(); |
| 26 | var index = getLeafIndex(level); |
| 27 | |
| 28 | // Insert the article at the right index |
| 29 | articles = articles.insert(index, article); |
| 30 | |
| 31 | // Reindex the level from here |
| 32 | parent = parent.set('articles', articles); |
| 33 | parent = indexArticleLevels(parent); |
| 34 | |
| 35 | return mergeAtLevel(summary, parent.getLevel(), parent); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | @param {String} |
no test coverage detected
searching dependent graphs…