Fix and update easysearch

This commit is contained in:
Daniel Kaiser 2022-08-05 13:06:02 +02:00
parent 3ddb97c8c9
commit 339e044a30
11 changed files with 40 additions and 45 deletions

View file

@ -20,7 +20,7 @@ cfs:standard-packages
cottz:publish-relations
dburles:collection-helpers
idmontie:migrations
matteodem:easy-search
easy:search
mongo@1.15.0
mquandalle:collection-mutations

View file

@ -52,7 +52,10 @@ ddp-server@2.5.0
deps@1.0.12
diff-sequence@1.1.1
dynamic-import@0.7.2
easy:search@2.2.1
easylogic:summernote@0.8.8
easysearch:components@2.2.2
easysearch:core@2.2.2
ecmascript@0.16.2
ecmascript-runtime@0.8.0
ecmascript-runtime-client@0.12.1
@ -82,7 +85,6 @@ lmieulet:meteor-coverage@1.1.4
localstorage@1.2.0
logging@1.3.1
matb33:collection-hooks@1.1.2
matteodem:easy-search@1.6.4
mdg:validation-error@0.5.1
meteor@1.10.0
meteor-autosize@5.0.1

View file

@ -1811,13 +1811,7 @@ Template.cardAssigneesPopup.helpers({
Template.cardAssigneePopup.helpers({
userData() {
// We need to handle a special case for the search results provided by the
// `matteodem:easy-search` package. Since these results gets published in a
// separate collection, and not in the standard Meteor.Users collection as
// expected, we use a component parameter ("property") to distinguish the
// two cases.
const userCollection = this.esSearch ? ESSearchResults : Users;
return userCollection.findOne(this.userId, {
return Users.findOne(this.userId, {
fields: {
profile: 1,
username: 1,

View file

@ -56,17 +56,17 @@ template(name="importMapMembersAddPopup")
p
| {{_ 'import-user-select'}}
.js-map-member
+esInput(index="users")
+EasySearch.Input(index=searchIndex)
ul.pop-over-list
+esEach(index="users")
+EasySearch.Each(index=searchIndex)
li.item.js-member-item
a.name.js-select-import(title="{{profile.fullname}} ({{username}})" data-id="{{_id}}")
+userAvatar(userId=_id esSearch=true)
a.name.js-select-import(title="{{profile.fullname}} ({{username}})" data-id="{{__originalId}}")
+userAvatar(userId=__originalId)
span.full-name
= profile.fullname
| (<span class="username">{{username}}</span>)
+ifEsIsSearching(index='users')
+EasySearch.IfSearching(index=searchIndex)
+spinner
+ifEsHasNoResults(index="users")
+EasySearch.IfNoResults(index=searchIndex)
.manage-member-section
p.quiet {{_ 'no-results'}}

View file

@ -297,7 +297,7 @@ BlazeComponent.extendComponent({
},
onSelectUser() {
Popup.getOpenerComponent().mapSelectedMember(this.currentData()._id);
Popup.getOpenerComponent(5).mapSelectedMember(this.currentData().__originalId);
Popup.back();
},
@ -309,3 +309,7 @@ BlazeComponent.extendComponent({
];
},
}).register('importMapMembersAddPopup');
Template.importMapMembersAddPopup.helpers({
searchIndex: () => Users.search_index,
})

View file

@ -190,22 +190,19 @@ BlazeComponent.extendComponent({
Template.orgRow.helpers({
orgData() {
const orgCollection = this.esSearch ? ESSearchResults : Org;
return orgCollection.findOne(this.orgId);
return Org.findOne(this.orgId);
},
});
Template.teamRow.helpers({
teamData() {
const teamCollection = this.esSearch ? ESSearchResults : Team;
return teamCollection.findOne(this.teamId);
return Team.findOne(this.teamId);
},
});
Template.peopleRow.helpers({
userData() {
const userCollection = this.esSearch ? ESSearchResults : Users;
return userCollection.findOne(this.userId);
return Users.findOne(this.userId);
},
});

View file

@ -561,7 +561,7 @@ template(name="removeBoardTeamPopup")
template(name="addMemberPopup")
.js-search-member
+esInput(index="users")
+EasySearch.Input(index=searchIndex)
if loading.get
+spinner
@ -569,20 +569,20 @@ template(name="addMemberPopup")
.warning {{_ error.get}}
else
ul.pop-over-list
+esEach(index="users")
+EasySearch.Each(index=searchIndex)
li.item.js-member-item(class="{{#if isBoardMember}}disabled{{/if}}")
a.name.js-select-member(title="{{profile.fullname}} ({{username}})")
+userAvatar(userId=_id esSearch=true)
+userAvatar(userId=__originalId)
span.full-name
= profile.fullname
| (<span class="username">{{username}}</span>)
if isBoardMember
.quiet ({{_ 'joined'}})
+ifEsIsSearching(index='users')
+EasySearch.IfSearching(index=searchIndex)
+spinner
+ifEsHasNoResults(index="users")
+EasySearch.IfNoResults(index=searchIndex)
.manage-member-section
p.quiet {{_ 'no-results'}}
button.js-email-invite.primary.full {{_ 'email-invite'}}

View file

@ -1333,7 +1333,7 @@ BlazeComponent.extendComponent({
},
isBoardMember() {
const userId = this.currentData()._id;
const userId = this.currentData().__originalId;
const user = Users.findOne(userId);
return user && user.isBoardMember();
},
@ -1373,7 +1373,7 @@ BlazeComponent.extendComponent({
this.setError('');
},
'click .js-select-member'() {
const userId = this.currentData()._id;
const userId = this.currentData().__originalId;
const currentBoard = Boards.findOne(Session.get('currentBoard'));
if (!currentBoard.hasMember(userId)) {
this.inviteUser(userId);
@ -1390,6 +1390,10 @@ BlazeComponent.extendComponent({
},
}).register('addMemberPopup');
Template.addMemberPopup.helpers({
searchIndex: () => Users.search_index,
})
BlazeComponent.extendComponent({
onCreated() {
this.error = new ReactiveVar('');

View file

@ -7,13 +7,7 @@ import { formatFleURL } from 'meteor/ostrio:files/lib';
Template.userAvatar.helpers({
userData() {
// We need to handle a special case for the search results provided by the
// `matteodem:easy-search` package. Since these results gets published in a
// separate collection, and not in the standard Meteor.Users collection as
// expected, we use a component parameter ("property") to distinguish the
// two cases.
const userCollection = this.esSearch ? ESSearchResults : Users;
return userCollection.findOne(this.userId, {
return Users.findOne(this.userId, {
fields: {
profile: 1,
username: 1,
@ -95,8 +89,7 @@ BlazeComponent.extendComponent({
Template.boardOrgRow.helpers({
orgData() {
const orgCollection = this.esSearch ? ESSearchResults : Org;
return orgCollection.findOne(this.orgId);
return Org.findOne(this.orgId);
},
currentUser(){
return Meteor.user();
@ -158,8 +151,7 @@ BlazeComponent.extendComponent({
Template.boardTeamRow.helpers({
teamData() {
const teamCollection = this.esSearch ? ESSearchResults : Team;
return teamCollection.findOne(this.teamId);
return Team.findOne(this.teamId);
},
currentUser(){
return Meteor.user();

View file

@ -149,8 +149,8 @@ window.Popup = new (class {
}
}
getOpenerComponent() {
const { openerElement } = Template.parentData(4);
getOpenerComponent(n=4) {
const { openerElement } = Template.parentData(n);
return BlazeComponent.getComponentForElement(openerElement);
}

View file

@ -2,6 +2,7 @@
import { SyncedCron } from 'meteor/percolate:synced-cron';
import { TAPi18n } from '/imports/i18n';
import ImpersonatedUsers from './impersonatedUsers';
import { Index, MongoDBEngine } from 'meteor/easy:search'
// Sandstorm context is detected using the METEOR_SETTINGS environment variable
// in the package definition.
@ -537,9 +538,10 @@ Users.allow({
// Search a user in the complete server database by its name, username or emails adress. This
// is used for instance to add a new user to a board.
const searchInFields = ['username', 'profile.fullname', 'emails.address'];
Users.initEasySearch(searchInFields, {
use: 'mongo-db',
returnFields: [...searchInFields, 'profile.avatarUrl'],
Users.search_index = new Index({
collection: Users,
fields: searchInFields,
engine: new MongoDBEngine(),
});
Users.safeFields = {