mirror of
https://github.com/documize/community.git
synced 2025-07-24 15:49:44 +02:00
new search options and schema
This commit is contained in:
parent
6c3042fd4e
commit
2c5f73a486
14 changed files with 283 additions and 118 deletions
|
@ -16,39 +16,16 @@ export default Ember.Component.extend({
|
|||
resultPhrase: "",
|
||||
|
||||
didReceiveAttrs() {
|
||||
let results = this.get('results');
|
||||
let temp = _.groupBy(results, 'documentId');
|
||||
let documents = [];
|
||||
|
||||
_.each(temp, function (document) {
|
||||
let refs = [];
|
||||
|
||||
if (document.length > 1) {
|
||||
refs = document.slice(1);
|
||||
}
|
||||
|
||||
_.each(refs, function (ref, index) {
|
||||
ref.comma = index === refs.length - 1 ? "" : ", ";
|
||||
});
|
||||
|
||||
let hasRefs = refs.length > 0;
|
||||
|
||||
documents.pushObject({
|
||||
doc: document[0],
|
||||
ref: refs,
|
||||
hasReferences: hasRefs
|
||||
});
|
||||
});
|
||||
|
||||
let docs = this.get('results');
|
||||
let phrase = 'Nothing found';
|
||||
|
||||
if (results.length > 0) {
|
||||
let references = results.length === 1 ? "reference" : "references";
|
||||
let i = results.length;
|
||||
if (docs.length > 0) {
|
||||
let references = docs.length === 1 ? "reference" : "references";
|
||||
let i = docs.length;
|
||||
phrase = `${i} ${references}`;
|
||||
}
|
||||
|
||||
this.set('resultPhrase', phrase);
|
||||
this.set('documents', documents);
|
||||
this.set('documents', docs);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
|
||||
//
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// This software (Documize Community Edition) is licensed under
|
||||
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
|
||||
//
|
||||
// You can operate outside the AGPL restrictions by purchasing
|
||||
// Documize Enterprise Edition and obtaining a commercial license
|
||||
// by contacting <sales@documize.com>.
|
||||
// by contacting <sales@documize.com>.
|
||||
//
|
||||
// https://documize.com
|
||||
|
||||
|
@ -13,19 +13,51 @@ import Ember from 'ember';
|
|||
|
||||
export default Ember.Controller.extend({
|
||||
searchService: Ember.inject.service('search'),
|
||||
queryParams: ['filter'],
|
||||
filter: "",
|
||||
results: [],
|
||||
matchDoc: true,
|
||||
matchContent: true,
|
||||
matchFile: true,
|
||||
matchTag: true,
|
||||
|
||||
onKeywordChange: function () {
|
||||
Ember.run.debounce(this, this.fetch, 750);
|
||||
}.observes('filter'),
|
||||
|
||||
onMatchDoc: function () {
|
||||
Ember.run.debounce(this, this.fetch, 750);
|
||||
}.observes('matchDoc'),
|
||||
onMatchContent: function () {
|
||||
Ember.run.debounce(this, this.fetch, 750);
|
||||
}.observes('matchContent'),
|
||||
onMatchTag: function () {
|
||||
Ember.run.debounce(this, this.fetch, 750);
|
||||
}.observes('matchTag'),
|
||||
onMatchFile: function () {
|
||||
Ember.run.debounce(this, this.fetch, 750);
|
||||
}.observes('matchFile'),
|
||||
|
||||
fetch() {
|
||||
let self = this;
|
||||
let payload = {
|
||||
keywords: this.get('filter'),
|
||||
doc: this.get('matchDoc'),
|
||||
attachment: this.get('matchFile'),
|
||||
tag: this.get('matchTag'),
|
||||
content: this.get('matchContent')
|
||||
};
|
||||
|
||||
this.get('searchService').find(this.get('filter')).then(function (response) {
|
||||
payload.keywords = payload.keywords.trim();
|
||||
|
||||
if (payload.keywords.length == 0) {
|
||||
return;
|
||||
}
|
||||
if (!payload.doc && !payload.tag && !payload.content && !payload.attachment) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.get('searchService').find(payload).then(function(response) {
|
||||
self.set('results', response);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,15 +1,26 @@
|
|||
{{layout/zone-navigation}}
|
||||
|
||||
{{#layout/zone-container}}
|
||||
{{#layout/zone-sidebar}}
|
||||
<div class="sidebar-toolbar">
|
||||
</div>
|
||||
<div class="sidebar-common">
|
||||
{{layout/sidebar-intro title="Search" message='#tag, keyword, "some phrase", this AND that, this OR that'}}
|
||||
{{layout/sidebar-intro title="Search" message='Search across document name, contents, tags and attachment filenames'}}
|
||||
</div>
|
||||
<div class="sidebar-wrapper">
|
||||
<div class="page-search">
|
||||
<div class="input-control">
|
||||
{{focus-input type="text" value=filter placeholder='type search phrase (case sensitive)'}}
|
||||
{{focus-input type="text" value=filter placeholder='type search phrase'}}
|
||||
{{#ui/ui-checkbox selected=matchDoc}}document name{{/ui/ui-checkbox}}
|
||||
{{#ui/ui-checkbox selected=matchContent}}document content{{/ui/ui-checkbox}}
|
||||
{{#ui/ui-checkbox selected=matchFile}}attachment name{{/ui/ui-checkbox}}
|
||||
{{#ui/ui-checkbox selected=matchTag}}tag name{{/ui/ui-checkbox}}
|
||||
</div>
|
||||
<div class="examples">
|
||||
<p>a OR b</p>
|
||||
<p>x AND y</p>
|
||||
<p>"phrase match"</p>
|
||||
<p>* for wildcard match</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -19,12 +19,12 @@ export default Ember.Service.extend({
|
|||
sessionService: service('session'),
|
||||
ajax: service(),
|
||||
|
||||
// getUsers returns all users for organization.
|
||||
find(keywords) {
|
||||
let url = "search?keywords=" + encodeURIComponent(keywords);
|
||||
|
||||
return this.get('ajax').request(url, {
|
||||
method: "GET"
|
||||
// find all matching documents.
|
||||
find(payload) {
|
||||
return this.get('ajax').request("search", {
|
||||
method: "POST",
|
||||
data: JSON.stringify(payload),
|
||||
contentType: 'json'
|
||||
});
|
||||
},
|
||||
});
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
.examples {
|
||||
color: $color-gray;
|
||||
}
|
||||
|
||||
.search-results {
|
||||
> .heading {
|
||||
font-size: 2rem;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
<div class="search-results">
|
||||
<div class="heading">{{resultPhrase}}</div>
|
||||
<ul class="list">
|
||||
{{#each documents key="doc.id" as |result index|}}
|
||||
{{#each documents key="id" as |result index|}}
|
||||
<li class="item">
|
||||
<a class="link" href="s/{{result.doc.folderId}}/{{result.doc.folderSlug}}/d/{{ result.doc.documentId }}/{{result.doc.documentSlug}}?page={{ result.doc.id }}">
|
||||
<div class="title">{{ result.doc.documentTitle }}</div>
|
||||
<div class="folder">{{ result.doc.folderName }}</div>
|
||||
<div class="excerpt">{{ result.doc.documentExcerpt }}</div>
|
||||
<div class="chips">{{search/tag-list documentTags=result.doc.documentTags}}</div>
|
||||
<a class="link" href="s/{{result.spaceId}}/{{result.spaceSlug}}/d/{{ result.documentId }}/{{result.documentSlug}}?page={{ result.itemId }}">
|
||||
<div class="title">{{ result.document }}</div>
|
||||
<div class="folder">{{ result.space }}</div>
|
||||
<div class="excerpt">{{ result.excerpt }}</div>
|
||||
<div class="chips">{{search/tag-list documentTags=result.tags}}</div>
|
||||
</a>
|
||||
</li>
|
||||
{{/each}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue