Search logic; relates to #18

This commit is contained in:
viktor 2017-12-26 15:12:37 +03:00
parent e4f1ac8a3f
commit ec0c4edab8
7 changed files with 57 additions and 18 deletions

View File

@ -6,7 +6,7 @@
## MetaMask plugin setup
* Connect to POA Network in MetaMask plugin (See [Connect to Oracles network via MetaMask](https://github.com/poanetwork/wiki/blob/master/MetaMask-connect.md#connect-to-poa-network-via-metamask))
* Connect to POA Network in MetaMask plugin (See [Connect to POA Network via MetaMask](https://github.com/poanetwork/wiki/blob/master/MetaMask-connect.md#connect-to-poa-network-via-metamask))
* Import your voting key to MetaMask Plugin (See [Governance section from wiki](https://github.com/poanetwork/wiki/blob/master/governance.md)).

View File

@ -11,13 +11,13 @@ import { inject, observer } from 'mobx-react';
class App extends Component {
onBallotsRender = () => {
const { commonStore } = this.props;
commonStore.filtered = false;
commonStore.isActiveFilter = false;
return <Ballots/>;
}
onActiveBallotsRender = () => {
const { commonStore } = this.props;
commonStore.filtered = true;
commonStore.isActiveFilter = true;
return <Ballots/>;
}

View File

@ -264,15 +264,25 @@ export class BallotKeysCard extends React.Component {
this.getIsFinalized();
}
checkFilter = () => {
hideCard = () => {
let { commonStore } = this.props;
let filtered = commonStore.filtered && this.isFinalized;
return filtered;
let hideCard = commonStore.isActiveFilter && this.isFinalized;
if (commonStore.searchTerm) {
if (commonStore.searchTerm.length == 0) return hideCard;
if (String(this.affectedKey).toLowerCase().includes(commonStore.searchTerm)) return (hideCard && false);
if (String(this.affectedKeyTypeDisplayName).toLowerCase().includes(commonStore.searchTerm)) return (hideCard && false);
if (String(this.ballotTypeDisplayName).toLowerCase().includes(commonStore.searchTerm)) return (hideCard && false);
if (String(this.creator).toLowerCase().includes(commonStore.searchTerm)) return (hideCard && false);
} else {
return hideCard;
}
return true;
}
render () {
let { contractsStore } = this.props;
let ballotClass = this.checkFilter() ? "ballots-i display-none" : "ballots-i";
let ballotClass = this.hideCard() ? "ballots-i display-none" : "ballots-i";
return (
<div className={ballotClass}>
<div className="ballots-about">

View File

@ -200,9 +200,23 @@ export class BallotMinThresholdCard extends React.Component {
this.getIsFinalized(this.props.id);
}
hideCard = () => {
let { commonStore } = this.props;
let hideCard = commonStore.isActiveFilter && this.isFinalized;
if (commonStore.searchTerm) {
if (commonStore.searchTerm.length == 0) return hideCard;
if (String(this.proposedValue).toLowerCase().includes(commonStore.searchTerm)) return (hideCard && false);
if (String(this.creator).toLowerCase().includes(commonStore.searchTerm)) return (hideCard && false);
} else {
return hideCard;
}
return true;
}
render () {
let { commonStore, contractsStore } = this.props;
let ballotClass = (commonStore.filtered && this.isFinalized) ? "ballots-i display-none" : "ballots-i";
let ballotClass = this.hideCard() ? "ballots-i display-none" : "ballots-i";
return (
<div className={ballotClass}>
<div className="ballots-about">

View File

@ -209,9 +209,24 @@ export class BallotProxyCard extends React.Component {
this.getIsFinalized();
}
hideCard = () => {
let { commonStore } = this.props;
let hideCard = commonStore.isActiveFilter && this.isFinalized;
if (commonStore.searchTerm) {
if (commonStore.searchTerm.length == 0) return hideCard;
if (String(this.proposedAddress).toLowerCase().includes(commonStore.searchTerm)) return (hideCard && false);
if (String(this.contractType).toLowerCase().includes(commonStore.searchTerm)) return (hideCard && false);
if (String(this.creator).toLowerCase().includes(commonStore.searchTerm)) return (hideCard && false);
} else {
return hideCard;
}
return true;
}
render () {
const { commonStore, contractsStore, ballotStore } = this.props;
let ballotClass = (commonStore.filtered && this.isFinalized) ? "ballots-i display-none" : "ballots-i";
let ballotClass = this.hideCard() ? "ballots-i display-none" : "ballots-i";
return (
<div className={ballotClass}>
<div className="ballots-about">

View File

@ -1,9 +1,9 @@
module.exports = {
KEYS_MANAGER_ADDRESS: '0xfc90125492e58dbfe80c0bfb6a2a759c4f703ca8',
VOTING_TO_CHANGE_KEYS_ADDRESS: '0x49df4ec19243263e5db22da5865b4f482b8323a0',
VOTING_TO_CHANGE_MIN_THRESHOLD: '0x8829ebe113535826e8af17ed51f83755f675789a',
VOTING_TO_CHANGE_PROXY: '0x6b728399b41a38d4109f7af2213d4cc31ca87812',
METADATA_ADDRESS: '0xcBB2912666c7e8023B7ec78B6842702eB26336aC',
POA_ADDRESS: '0x8bf38d4764929064f2d4d3a56520a76ab3df415b',
BALLOTS_STORAGE_ADDRESS: '0x0d7590c7aedf1e7e85fc9a1ee88f6f17d3ba762f'
KEYS_MANAGER_ADDRESS: '0x0e4a78ba651fcf2058e1326e16fc9160553ca467',
VOTING_TO_CHANGE_KEYS_ADDRESS: '0x534165101c5eec16c4a18102b98b8a903644e513',
VOTING_TO_CHANGE_MIN_THRESHOLD: '0xf7ee04d7e85ecf98ad62f96b0a40ab82de1eb0e3',
VOTING_TO_CHANGE_PROXY: '0x13d3c35d9947d77c677a648b9916998c4393622f',
METADATA_ADDRESS: '0x1ada723e24f414a72bac6a127f4b2a8d91dfec38',
POA_ADDRESS: '0xf472e0e43570b9afaab67089615080cf7c20018d',
BALLOTS_STORAGE_ADDRESS: '0x886cc61ef0ec40300378104eb547c2e86117b819'
}

View File

@ -3,12 +3,12 @@ import { observable, action } from 'mobx';
class CommonStore {
@observable loading;
@observable rootPath;
@observable filtered;
@observable isActiveFilter;
@observable searchTerm;
constructor() {
this.loading = false;
this.filtered = false;
this.isActiveFilter = false;
this.rootPath = '/poa-dapps-voting'
}