Skip to content

Commit

Permalink
Issue 311 - Allow for hiding user issued assets (cryptonomex#397)
Browse files Browse the repository at this point in the history
* Issue 311 - Allow for hiding user issued assets

* Fix missing inputs to getFlag for regular flags

* Add 'visible' flag to asset creation as well
  • Loading branch information
calvinfroedge authored and svk31 committed Sep 14, 2017
1 parent bbd2714 commit c1736ff
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 44 deletions.
3 changes: 2 additions & 1 deletion app/assets/locales/locale-en.json
Expand Up @@ -209,7 +209,8 @@
"error_precision": "That asset does not have the same precision as %(asset)s",
"error_invalid": "That asset may not be used",
"market": "Preferred market pairing",
"precision_warning": "Warning: The number of decimals may not be changed after creation"
"precision_warning": "Warning: The number of decimals may not be changed after creation",
"visible": "Hide asset from search and markets"
},
"connections": {
"known": "Known by",
Expand Down
77 changes: 48 additions & 29 deletions app/components/Account/AccountAssetCreate.jsx
Expand Up @@ -251,6 +251,10 @@ class AccountAssetCreate extends React.Component {
update.description[value] = e;
break;

case "visible":
update.description[value] = !update.description[value];
break;

default:
update.description[value] = e.target.value;
break;
Expand Down Expand Up @@ -493,44 +497,59 @@ class AccountAssetCreate extends React.Component {

// Loop over flags
let flags = [];
let getFlag = (key, onClick, isChecked)=>{
return <table key={"table_" + key} className="table">
<tbody>
<tr>
<td style={{border: "none", width: "80%"}}><Translate content={`account.user_issued_assets.${key}`} />:</td>
<td style={{border: "none"}}>
<div className="switch" style={{marginBottom: "10px"}} onClick={onClick}>
<input type="checkbox" checked={isChecked} />
<label />
</div>
</td>
</tr>
</tbody>
</table>;
};
for (let key in permissionBooleans) {
if (permissionBooleans[key] && key !== "charge_market_fee") {
flags.push(
<table key={"table_" + key} className="table">
<tbody>
<tr>
<td style={{border: "none", width: "80%"}}><Translate content={`account.user_issued_assets.${key}`} />:</td>
<td style={{border: "none"}}>
<div className="switch" style={{marginBottom: "10px"}} onClick={this._onFlagChange.bind(this, key)}>
<input type="checkbox" checked={flagBooleans[key]} />
<label />
</div>
</td>
</tr>
</tbody>
</table>
)
getFlag(
key,
this._onFlagChange.bind(this, key),
flagBooleans[key]
)
);
}
}

flags.push(
getFlag(
"visible",
this._onUpdateDescription.bind(this, "visible"),
update.description.visible ? false : (update.description.visible === false ? true : false)
)
);

// Loop over permissions
let permissions = [];
for (let key in permissionBooleans) {
permissions.push(
<table key={"table_" + key} className="table">
<tbody>
<tr>
<td style={{border: "none", width: "80%"}}><Translate content={`account.user_issued_assets.${key}`} />:</td>
<td style={{border: "none"}}>
<div className="switch" style={{marginBottom: "10px"}} onClick={this._onPermissionChange.bind(this, key)}>
<input type="checkbox" checked={permissionBooleans[key]} onChange={() => {}}/>
<label />
</div>
</td>
</tr>
</tbody>
</table>
)
permissions.push(
<table key={"table_" + key} className="table">
<tbody>
<tr>
<td style={{border: "none", width: "80%"}}><Translate content={`account.user_issued_assets.${key}`} />:</td>
<td style={{border: "none"}}>
<div className="switch" style={{marginBottom: "10px"}} onClick={this._onPermissionChange.bind(this, key)}>
<input type="checkbox" checked={permissionBooleans[key]} onChange={() => {}}/>
<label />
</div>
</td>
</tr>
</tbody>
</table>
)
}

return (
Expand Down
48 changes: 34 additions & 14 deletions app/components/Account/AccountAssetUpdate.jsx
Expand Up @@ -175,6 +175,10 @@ class AccountAssetUpdate extends React.Component {
update.description[value] = e;
break;

case "visible":
update.description[value] = !update.description[value];
break;

default:
update.description[value] = e.target.value;
break;
Expand Down Expand Up @@ -421,26 +425,42 @@ class AccountAssetUpdate extends React.Component {

// Loop over flags
let flags = [];
let getFlag = (key, onClick, isChecked)=>{
return <table key={"table_" + key} className="table">
<tbody>
<tr>
<td style={{border: "none", width: "80%"}}><Translate content={`account.user_issued_assets.${key}`} />:</td>
<td style={{border: "none"}}>
<div className="switch" style={{marginBottom: "10px"}} onClick={onClick}>
<input type="checkbox" checked={isChecked} />
<label />
</div>
</td>
</tr>
</tbody>
</table>;
};

for (let key in originalPermissions) {
if (originalPermissions[key] && key !== "charge_market_fee") {
flags.push(
<table key={"table_" + key} className="table">
<tbody>
<tr>
<td style={{border: "none", width: "80%"}}><Translate content={`account.user_issued_assets.${key}`} />:</td>
<td style={{border: "none"}}>
<div className="switch" style={{marginBottom: "10px"}} onClick={this._onFlagChange.bind(this, key)}>
<input type="checkbox" checked={flagBooleans[key]} />
<label />
</div>
</td>
</tr>
</tbody>
</table>
)
getFlag(
key,
this._onFlagChange.bind(this, key),
flagBooleans[key]
)
);
}
}

flags.push(
getFlag(
"visible",
this._onUpdateDescription.bind(this, "visible"),
update.description.visible ? false : (update.description.visible === false ? true : false)
)
);

// Loop over permissions
let permissions = [];
for (let key in originalPermissions) {
Expand Down
9 changes: 9 additions & 0 deletions app/components/Exchange/MyMarkets.jsx
Expand Up @@ -539,6 +539,15 @@ class MyMarkets extends React.Component {
if (searchAssets.size) {
searchAssets
.filter(a => {
try {
if(a.options.description){
let description = JSON.parse(a.options.description);
if("visible" in description){
if(!description.visible) return false;
}
}
} catch(e){}

return (
a.symbol.indexOf(lookupQuote) !== -1 &&
a.symbol.length >= lookupQuote.length
Expand Down

0 comments on commit c1736ff

Please sign in to comment.