Got in-dialog help working with new docs

This commit is contained in:
Stefan Zermatten
2022-11-22 03:01:59 +02:00
parent 0f12c98408
commit 9741d1d56c
2 changed files with 33 additions and 3 deletions

View File

@@ -112,6 +112,31 @@ function getDocLink(doc, urlName) {
return address.join('/');
}
function rebuildDocAncestors(docId) {
const newDoc = Docs.findOne(docId);
Docs.find({ 'ancestors.id': docId }).forEach(doc => {
doc.ancestors.forEach((a, i) => {
if (a.id === docId) {
Docs.update(doc._id, {
$set: {
[`ancestors.${i}`]: {
id: newDoc._id,
collection: 'docs',
urlName: newDoc.urlName,
name: newDoc.name,
}
}
});
}
});
doc = Docs.findOne(doc._id);
const newLink = getDocLink(doc);
if (doc.href !== newLink) {
Docs.update(doc._id, { $set: { href: newLink } })
}
});
}
// Add a means of seeding new servers with documentation
if (Meteor.isClient) {
Docs.getJsonDocs = function () {
@@ -200,12 +225,17 @@ const updateDoc = new ValidatedMethod({
}
modifier.$set = modifier.$set || {};
modifier.$set.href = newLink;
rebuildDocAncestors(_id);
}
const updates = Docs.update(_id, modifier);
if (pathString === 'name' || pathString === 'urlName') {
rebuildDocAncestors(_id);
}
reorderDocs({
collection: Docs,
ancestorId: 'root',
});
return Docs.update(_id, modifier);
return updates;
},
});

View File

@@ -78,8 +78,8 @@ export default {
},
},
doc() {
const doc = Docs.findOne(this.path);
return doc && doc.text;
const doc = Docs.findOne({href: '/docs/' + this.path});
return doc && doc.description;
},
},
methods: {