Merge pull request #104 from vbaranov/search-fix

(Fix) Search by mining key, memo
This commit is contained in:
Victor Baranov 2018-03-21 09:22:47 +03:00 committed by GitHub
commit 1c78eaf22a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View File

@ -29,6 +29,7 @@ export class BallotCard extends React.Component {
displayValue: zeroTimeTo,
title: "To close"
};
@observable creatorMiningKey;
@observable creator;
@observable progress;
@observable totalVoters;
@ -220,6 +221,7 @@ export class BallotCard extends React.Component {
lastName = toAscii(validator.lastName);
fullName = `${firstName} ${lastName}`;
}
this.creatorMiningKey = _miningKey;
this.creator = fullName ? fullName : _miningKey;
}
@ -382,8 +384,20 @@ export class BallotCard extends React.Component {
let { commonStore } = this.props;
if (commonStore.searchTerm) {
if (commonStore.searchTerm.length > 0) {
const isCreatorPattern = String(this.creator).toLowerCase().includes(commonStore.searchTerm);
return isCreatorPattern;
const _isCreatorPattern = String(this.creator).toLowerCase().includes(commonStore.searchTerm);
const _isCreatorMiningKeyPattern = String(this.creatorMiningKey).toLowerCase().includes(commonStore.searchTerm);
return _isCreatorPattern || _isCreatorMiningKeyPattern;
}
}
return true;
}
isMemoPattern = () => {
let { commonStore } = this.props;
if (commonStore.searchTerm) {
if (commonStore.searchTerm.length > 0) {
const _isMemoPattern = String(this.memo).toLowerCase().includes(commonStore.searchTerm);
return _isMemoPattern;
}
}
return true;
@ -405,7 +419,7 @@ export class BallotCard extends React.Component {
render () {
let { contractsStore, votingType, children, isSearchPattern } = this.props;
console.log(votingType);
let ballotClass = (this.showCard() && (this.isCreatorPattern() || isSearchPattern)) ? "ballots-i" : "ballots-i display-none";
let ballotClass = (this.showCard() && (this.isCreatorPattern() || this.isMemoPattern() || isSearchPattern)) ? "ballots-i" : "ballots-i display-none";
const threshold = this.getThreshold(contractsStore, votingType);
return (
<div className={ballotClass}>

View File

@ -117,10 +117,11 @@ export class BallotKeysCard extends React.Component {
isSearchPattern = () => {
let { commonStore } = this.props;
if (commonStore.searchTerm) {
const isMiningKeyPattern = String(this.miningKey).toLowerCase().includes(commonStore.searchTerm);
const isAffectedKeyPattern = String(this.affectedKey).toLowerCase().includes(commonStore.searchTerm);
const isAffectedKeyTypeDisplayNamePattern = String(this.affectedKeyTypeDisplayName).toLowerCase().includes(commonStore.searchTerm);
const isBallotTypeDisplayNamePattern = String(this.ballotTypeDisplayName).toLowerCase().includes(commonStore.searchTerm);
return (isAffectedKeyPattern || isAffectedKeyTypeDisplayNamePattern || isBallotTypeDisplayNamePattern);
return (isMiningKeyPattern || isAffectedKeyPattern || isAffectedKeyTypeDisplayNamePattern || isBallotTypeDisplayNamePattern);
}
return true;
}