MDL-55582 core_message: show message when there are no search results

This commit is contained in:
Mark Nelson 2016-08-29 17:48:18 +08:00
parent b6723f5b22
commit c9ead36a92
5 changed files with 30 additions and 4 deletions

View File

@ -233,7 +233,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
return promises[0];
}.bind(this)).then(function(data) {
numberreceived = data.contacts.length;
return templates.render('core_message/message_area_contacts', data);
return templates.render('core_message/message_area_message_search_results', data);
}).then(function(html, js) {
// Remove the loading icon.
this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA + " " +
@ -244,13 +244,15 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
templates.appendNodeContents(this.messageArea.SELECTORS.SEARCHRESULTSAREA, html, js);
// Increment the number of contacts displayed.
this._numMessagesDisplayed += numberreceived;
} else if (this._numMessagesDisplayed == 0) { // Must have nothing to begin with.
// Replace the new content.
templates.replaceNodeContents(this.messageArea.SELECTORS.SEARCHRESULTSAREA, html, js);
}
// Mark that we are no longer busy loading data.
this._isLoading = false;
}.bind(this)).fail(notification.exception);
};
/**
* Handles searching for people.
*
@ -330,6 +332,9 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
templates.appendNodeContents(this.messageArea.SELECTORS.SEARCHRESULTSAREA, html, js);
// Increment the number of contacts displayed.
this._numPeopleDisplayed += numberreceived;
} else if (this._numPeopleDisplayed == 0) { // Must have nothing to begin with.
// Replace the new content.
templates.replaceNodeContents(this.messageArea.SELECTORS.SEARCHRESULTSAREA, html, js);
}
// Mark that we are no longer busy loading data.
this._isLoading = false;
@ -349,7 +354,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
}.bind(this));
};
/**
* Sets filter for search input.
*

View File

@ -0,0 +1,6 @@
{{#contacts}}
{{> core_message/message_area_contact }}
{{/contacts}}
{{^contacts}}
<div class="noresults">{{#str}}noresults{{/str}}</div>
{{/contacts}}

View File

@ -16,4 +16,11 @@
{{#noncontacts}}
{{> core_message/message_area_contact }}
{{/noncontacts}}
{{/hasnoncontacts}}
{{/hasnoncontacts}}
{{^hascontacts}}
{{^hascourses}}
{{^hasnoncontacts}}
<div class="noresults">{{#str}}noresults{{/str}}</div>
{{/hasnoncontacts}}
{{/hascourses}}
{{/hascontacts}}

View File

@ -132,6 +132,11 @@
cursor: pointer;
}
}
.noresults {
padding-top: 20px;
text-align: center;
}
}
.contacts {

View File

@ -5859,6 +5859,10 @@ a.ygtvspacer:hover {
border: none;
cursor: pointer;
}
.messaging-area-container .messaging-area .contacts-area .searcharea .noresults {
padding-top: 20px;
text-align: center;
}
.messaging-area-container .messaging-area .contacts-area .contacts {
height: 500px;
overflow-y: auto;