mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-14 14:21:23 +00:00
[search] keep the query keyword when entering the independent search page via clicking the link icon in the top-right 'search'
This commit is contained in:
@@ -18,6 +18,7 @@ class Search extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.baseSearchPageURL = `${siteRoot}search/`;
|
||||
this.state = {
|
||||
width: 'default',
|
||||
value: '',
|
||||
@@ -28,6 +29,7 @@ class Search extends Component {
|
||||
isResultGetted: false,
|
||||
isCloseShow: false,
|
||||
isSearchInputShow: false, // for mobile
|
||||
searchPageUrl: this.baseSearchPageURL
|
||||
};
|
||||
this.inputValue = '';
|
||||
this.source = null; // used to cancel request;
|
||||
@@ -120,6 +122,7 @@ class Search extends Component {
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
} else {
|
||||
this.updateSearchPageURL(queryData);
|
||||
seafileAPI.searchFiles(queryData,cancelToken).then(res => {
|
||||
if (!res.data.total) {
|
||||
_this.setState({
|
||||
@@ -148,6 +151,14 @@ class Search extends Component {
|
||||
this.source.cancel('prev request is cancelled');
|
||||
}
|
||||
|
||||
updateSearchPageURL(queryData) {
|
||||
let params = '';
|
||||
for (let key in queryData) {
|
||||
params += key + '=' + encodeURIComponent(queryData[key]) + '&';
|
||||
}
|
||||
this.setState({searchPageUrl: `${this.baseSearchPageURL}?${params.substring(0, params.length - 1)}`});
|
||||
}
|
||||
|
||||
getValueLength(str) {
|
||||
var i = 0, code, len = 0;
|
||||
for (; i < str.length; i++) {
|
||||
@@ -253,13 +264,10 @@ class Search extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
onSearchPage = () => {
|
||||
window.location.href = siteRoot + 'search/';
|
||||
}
|
||||
|
||||
render() {
|
||||
let width = this.state.width !== 'default' ? this.state.width : '';
|
||||
let style = {'width': width};
|
||||
const { searchPageUrl } = this.state;
|
||||
return (
|
||||
<Fragment>
|
||||
<MediaQuery query="(min-width: 768px)">
|
||||
@@ -280,7 +288,7 @@ class Search extends Component {
|
||||
autoComplete="off"
|
||||
/>
|
||||
{(this.state.isCloseShow && username) &&
|
||||
<a href={`${siteRoot}search/`} className="search-icon-right input-icon-addon fas fa-external-link-alt search-icon-arrow"></a>
|
||||
<a href={searchPageUrl} className="search-icon-right input-icon-addon fas fa-external-link-alt search-icon-arrow"></a>
|
||||
}
|
||||
{this.state.isCloseShow &&
|
||||
<button type="button" className="search-icon-right input-icon-addon fas fa-times border-0 bg-transparent" onClick={this.onCloseHandler} aria-label={gettext('Close')}></button>
|
||||
@@ -314,7 +322,7 @@ class Search extends Component {
|
||||
autoComplete="off"
|
||||
/>
|
||||
{(this.state.isCloseShow && username) &&
|
||||
<a href={`${siteRoot}search/`} className="search-icon-right input-icon-addon fas fa-external-link-alt search-icon-arrow"></a>
|
||||
<a href={searchPageUrl} className="search-icon-right input-icon-addon fas fa-external-link-alt search-icon-arrow"></a>
|
||||
}
|
||||
{this.state.isCloseShow &&
|
||||
<button type="button" className="search-icon-right input-icon-addon fas fa-times border-0 bg-transparent" onClick={this.onCloseHandler} aria-label={gettext('Close')}></button>
|
||||
|
Reference in New Issue
Block a user