Fixed error where searching for properties to insert while having other properties selected could prevent any insert from happening at all
This commit is contained in:
@@ -93,7 +93,15 @@ function insertPropertyFromNode(nodeId, ancestors, order){
|
||||
_id: nodeId,
|
||||
removed: {$ne: true},
|
||||
});
|
||||
if (!node) throw `Node not found for nodeId: ${nodeId}`;
|
||||
if (!node) {
|
||||
if (Meteor.isClient) return;
|
||||
else {
|
||||
throw new Meteor.Error(
|
||||
'Insert property from library failed',
|
||||
`No library document with id '${nodeId}' was found`
|
||||
);
|
||||
}
|
||||
}
|
||||
let oldParent = node.parent;
|
||||
let nodes = LibraryNodes.find({
|
||||
'ancestors.id': nodeId,
|
||||
|
||||
@@ -1,6 +1,42 @@
|
||||
import { check } from 'meteor/check';
|
||||
import Libraries from '/imports/api/library/Libraries.js';
|
||||
import LibraryNodes from '/imports/api/library/LibraryNodes.js';
|
||||
import { assertViewPermission } from '/imports/api/sharing/sharingPermissions.js';
|
||||
|
||||
Meteor.publish('selectedLibraryNodes', function(selectedNodeIds){
|
||||
console.log('attempting selectedLibraryNodes')
|
||||
check(selectedNodeIds, Array);
|
||||
// Limit to 20 selected nodes
|
||||
if (selectedNodeIds.length > 20){
|
||||
selectedNodeIds = selectedNodeIds.slice(0, 20);
|
||||
}
|
||||
let libraryViewPermissions = {};
|
||||
// Check view permissions of all libraries
|
||||
for (let id of selectedNodeIds){
|
||||
let node = LibraryNodes.findOne(id);
|
||||
if (!node) continue;
|
||||
let libraryId = node.ancestors[0].id;
|
||||
if (libraryViewPermissions[id]){
|
||||
continue;
|
||||
} else {
|
||||
let library = Libraries.findOne(libraryId, {fields: {
|
||||
owner: 1,
|
||||
readers: 1,
|
||||
writers: 1,
|
||||
public: 1,
|
||||
}});
|
||||
assertViewPermission(library, this.userId);
|
||||
libraryViewPermissions[id] = true;
|
||||
}
|
||||
}
|
||||
// Return all nodes and their children
|
||||
return [LibraryNodes.find({
|
||||
$or: [
|
||||
{_id: {$in: selectedNodeIds}},
|
||||
{'ancestors.id': {$in: selectedNodeIds}},
|
||||
],
|
||||
})];
|
||||
});
|
||||
|
||||
Meteor.publish('searchLibraryNodes', function(){
|
||||
let self = this;
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
meteor: {
|
||||
hideSpellsTab(){
|
||||
let creature = Creatures.findOne(this.creatureId);
|
||||
return creature?.settings.hideSpellsTab;
|
||||
return creature?.settings?.hideSpellsTab;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -298,6 +298,9 @@
|
||||
meteor: {
|
||||
'$subscribe':{
|
||||
'searchLibraryNodes': [],
|
||||
'selectedLibraryNodes'(){
|
||||
return [this.selectedNodeIds];
|
||||
},
|
||||
},
|
||||
showPropertyHelp(){
|
||||
let user = Meteor.user();
|
||||
|
||||
2
app/package-lock.json
generated
2
app/package-lock.json
generated
@@ -2735,7 +2735,7 @@
|
||||
},
|
||||
"signal-exit": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0="
|
||||
},
|
||||
"simpl-schema": {
|
||||
|
||||
Reference in New Issue
Block a user