Hi, I’m having the search field for folder finding, when the enter the corresponding folder names, it will show the corresponding folder files on the below. If the folder name having 100 result means, it will only show the first 24 search result as like I wrote in the below code:
Core.controller.ManagedObjectLocations = Ember.Object.extend({
searchResults: null,
searchResultSize: 0,
searching: Ember.computed(function () {
return ( 'loaded' !== this.get('searchLoadState'));
}).property('searchLoadState'),
searchResultPageSizeBinding: 'Core.model.resultsConfig.resultsPerPage',
init: function () {
this._super();
this.set('searchResultSize', this.get('searchResultPageSize') || 24);`
},
query: '',
queryChanged: Ember.observer(function () {
var model, name, resultSet,
query = this.get('query'),
isEmpty = !query.trim(),
isXPath = query.substr(0, 1) === '/',
ctl = this;
if (isEmpty) {
return;
}
if (ctl.get('searchFlight')) {
return;
}
if (isXPath) {
model = Core.model.search.builtin['core:xpath'];
name = "xpath";
} else {
model = Core.model.search.FacetedForm.getBasic();
name = "query-text";
}
console.log("Creating resultSet.");
resultSet = model.send([{ name: name, value: query }], null);
resultSet.set('loading', true);
ctl.set('searchResults', resultSet);
resultSet.done(function () {
resultSet.set('loading', false);
});
}, 'query'),
subcontainersOnly: null,
recentLocationsBinding: 'Core.model.recentLocations.objects',
briefcaseBinding: 'Core.model.briefcase',
systemRoot: function () {
if (this.get('subcontainersOnly')) {
return Core.rootNode.get('subcontainers');
} else {
return Core.rootNode.get('children');
}
}.property('subcontainersOnly')
});
The result message will be taken from below code:
message: function () {
var count = this.get('count'),
total = this.get('parentObjectView.model.length'),
fetching = Core.messageTable.get('chrome/object-table/fetching'),
showing = Core.messageTable.get('chrome/object-table/showing-x-of-y').fmt(count, total);
return total === null ? fetching : (this.get('loading') ? fetching : showing);
}.property('loading', 'count', 'parentObjectView.model.length'),
The above message will show after the 24 result folder name as like “showing 24 of 100”. After that if we click on that message it will show another 24 result folder name.
The corresponding function happening as like below:
addSearchPage: function (event) {
var ctl = this.get('controller'),
rs = ctl.get('searchResultSize'),
rl = ctl.get('searchResults.length') || 0,
ps = ctl.get('searchResultPageSize');
ctl.set('searchResultSize', Math.min(rl, rs + ps));
},
The corresponding Hbr file having the below code:
{{#if searchResults}}
<div class="managed-object-group search-results">
<h1 {{action "toggleSearch" target="view"}}>{{message "/dialog/select-managed-object/search-results"}}</h1>
<group-content {{bind-attr class="view.showSearch:show-content"}}>
{{#if searchResults.length}}
{{view view.MOList model=searchResults}}
{{else}}
{{#if searchResults.loading}}
{{icon "spinner" size=20}} "Loading..."
{{else}}
"No results"
{{/if}}
{{/if}}
</group-content>
</div>
{{/if}}
If the folder names having below 24 means also the above message is showing. It need not to show the message as like “showing x of y” for below 24 search result. It only applicable for above 24 results. If the result is not available means it have to show “No Results”. I’m using ember 1.4.0.