Skip to content

Commit

Permalink
feat: show schema suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinslin committed Jul 4, 2020
1 parent 102b997 commit 1313e79
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/plugin-core/src/components/lookup/LookupProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import { node2Uri } from "./utils";
const L = createLogger("LookupProvider");

class QueryStringUtils {
static getSchema(_qs: string, engineResp: Note[]): Schema[] {
/**
* Get all schema matches for current query
* @param _qs
* @param engineResp
*/
static getAllSchemaAtLevel(_qs: string, engineResp: Note[]): Schema[] {
const maybeSchema = engineResp[0]?.schema;
return maybeSchema?.parent?.children as Schema[] || [];
}
Expand Down Expand Up @@ -119,13 +124,13 @@ export class LookupProvider {
}


// apply schemas to the results
// const schemas = QueryStringUtils.getSchema(querystring, updatedItems as Note[]);
// updatedItems = _.uniqBy(updatedItems.concat(schemas.map(schema => {
// return Note.fromSchema(DNodeUtils.dirName(querystring), schema);
// })), (ent) => {
// return ent.fname;
// });
// show schema suggestions
const schemas = QueryStringUtils.getAllSchemaAtLevel(querystring, updatedItems as Note[]);
updatedItems = _.uniqBy(updatedItems.concat(schemas.map(schema => {
return Note.fromSchema(DNodeUtils.dirName(querystring), schema);
})), (ent) => {
return ent.fname;
});


// check if perfect match, remove @noActiveItem result if that's the case
Expand Down

0 comments on commit 1313e79

Please sign in to comment.