Reduced fields loaded by library tree view
This should improve performance a little for large libraries, at the expense of loading when a property is selected
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import Libraries from '/imports/api/library/Libraries.js';
|
||||
import LibraryNodes from '/imports/api/library/LibraryNodes.js';
|
||||
import { assertViewPermission } from '/imports/api/sharing/sharingPermissions.js';
|
||||
import { assertViewPermission, assertDocViewPermission } from '/imports/api/sharing/sharingPermissions.js';
|
||||
|
||||
Meteor.publish('libraries', function(){
|
||||
this.autorun(function (){
|
||||
@@ -63,12 +63,64 @@ Meteor.publish('libraryNodes', function(libraryId){
|
||||
LibraryNodes.find({
|
||||
'ancestors.id': libraryId,
|
||||
}, {
|
||||
sort: {order: 1},
|
||||
sort: { order: 1 },
|
||||
fields: {
|
||||
_id: 1,
|
||||
name: 1,
|
||||
type: 1,
|
||||
icon: 1,
|
||||
color: 1,
|
||||
order: 1,
|
||||
parent: 1,
|
||||
ancestors: 1,
|
||||
// Effect
|
||||
operation: 1,
|
||||
targetTags: 1,
|
||||
stats: 1,
|
||||
// Item
|
||||
quantity: 1,
|
||||
plural: 1,
|
||||
equipped: 1,
|
||||
// Branch
|
||||
branchType: 1,
|
||||
// Damage:
|
||||
damageType: 1,
|
||||
stat: 1,
|
||||
amount: 1,
|
||||
// Class level
|
||||
level: 1,
|
||||
// Proficiency
|
||||
value: 1,
|
||||
// Reference
|
||||
cache: 1,
|
||||
}
|
||||
}),
|
||||
];
|
||||
});
|
||||
});
|
||||
|
||||
const nodeIdSchema = new SimpleSchema({
|
||||
libraryNodeId: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
},
|
||||
});
|
||||
|
||||
Meteor.publish('libraryNode', function (libraryNodeId) {
|
||||
if (!libraryNodeId) return [];
|
||||
nodeIdSchema.validate({ libraryNodeId });
|
||||
this.autorun(function () {
|
||||
const userId = this.userId;
|
||||
const nodeCursor = LibraryNodes.find({_id: libraryNodeId});
|
||||
let node = nodeCursor.fetch()[0];
|
||||
try { assertDocViewPermission(node, userId) }
|
||||
catch (e) {
|
||||
return this.error(e);
|
||||
}
|
||||
return [ nodeCursor ];
|
||||
});
|
||||
});
|
||||
|
||||
Meteor.publish('softRemovedLibraryNodes', function(libraryId){
|
||||
if (!libraryId) return [];
|
||||
libraryIdSchema.validate({libraryId});
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
:model="model"
|
||||
:editing="editing"
|
||||
:flat="flat"
|
||||
:embedded="embedded"
|
||||
@duplicate="duplicate"
|
||||
@move="move"
|
||||
@remove="remove"
|
||||
@@ -12,32 +13,41 @@
|
||||
@color-changed="value => change({path: ['color'], value})"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="model">
|
||||
<v-fade-transition
|
||||
mode="out-in"
|
||||
<v-fade-transition
|
||||
mode="out-in"
|
||||
>
|
||||
<div v-if="!_id" />
|
||||
<div
|
||||
v-else-if="!$subReady.libraryNode"
|
||||
class="fill-height layout justify-center align-center"
|
||||
>
|
||||
<component
|
||||
:is="model.type + 'Form'"
|
||||
v-if="editing"
|
||||
:key="_id"
|
||||
class="library-node-form"
|
||||
:model="model"
|
||||
@change="change"
|
||||
@push="push"
|
||||
@pull="pull"
|
||||
<v-progress-circular
|
||||
indeterminate
|
||||
color="primary"
|
||||
size="64"
|
||||
/>
|
||||
<component
|
||||
:is="model.type + 'Viewer'"
|
||||
v-else-if="!editing && $options.components[model.type + 'Viewer']"
|
||||
:key="_id"
|
||||
class="creature-property-viewer"
|
||||
:model="model"
|
||||
/>
|
||||
<p v-else>
|
||||
This property can't be viewed yet.
|
||||
</p>
|
||||
</v-fade-transition>
|
||||
</template>
|
||||
</div>
|
||||
<component
|
||||
:is="model.type + 'Form'"
|
||||
v-else-if="model && editing"
|
||||
:key="_id"
|
||||
class="library-node-form"
|
||||
:model="model"
|
||||
@change="change"
|
||||
@push="push"
|
||||
@pull="pull"
|
||||
/>
|
||||
<component
|
||||
:is="model.type + 'Viewer'"
|
||||
v-else-if="model && !editing && $options.components[model.type + 'Viewer']"
|
||||
:key="_id"
|
||||
class="creature-property-viewer"
|
||||
:model="model"
|
||||
/>
|
||||
<p v-else>
|
||||
This property can't be viewed yet.
|
||||
</p>
|
||||
</v-fade-transition>
|
||||
<div
|
||||
v-if="!embedded"
|
||||
slot="actions"
|
||||
@@ -136,6 +146,11 @@
|
||||
},
|
||||
},
|
||||
meteor: {
|
||||
$subscribe: {
|
||||
'libraryNode'(){
|
||||
return [this._id];
|
||||
}
|
||||
},
|
||||
model(){
|
||||
return LibraryNodes.findOne(this.currentId);
|
||||
},
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</span>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ model.stat || 'Attribute' }} damage
|
||||
<span>{{ model.stat || 'Attribute' }} damage</span>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user