start to fix for arrays
This commit is contained in:
parent
c33818bd32
commit
88c610208c
|
@ -68,7 +68,7 @@ class ScaffoldingReact {
|
|||
throw new Error("file '" + filePath + "' already exists");
|
||||
}
|
||||
|
||||
const templatePath = fs.embarkPath('lib/modules/scaffolding-react/templates/' + templateFilename);
|
||||
const templatePath = utils.joinPath(__dirname, 'templates/' + templateFilename);
|
||||
const source = fs.readFileSync(templatePath).toString();
|
||||
const template = Handlebars.compile(source);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class {{capitalize name}}Form{{@index}} extends Component {
|
|||
{{else}}
|
||||
{{#each inputs}}
|
||||
{{#ifarr type}}
|
||||
input.{{trim name}} = input.{{trim name}}.split(',').map(x => trim(x.toString()));
|
||||
input.{{trim name}} = input.{{trim name}}.split(',').map(x => x.toString().trim());
|
||||
{{/ifarr}}
|
||||
{{/each}}
|
||||
|
||||
|
@ -154,7 +154,7 @@ class {{capitalize name}}Form{{@index}} extends Component {
|
|||
{
|
||||
receipt &&
|
||||
<Fragment>
|
||||
<Alert bsStyle={receipt.status == "0x1" ? 'success' : 'danger'}>{receipt.status == "0x1" ? 'Success' : 'Failure / Revert'} - Transaction Hash: {receipt.transactionHash}</Alert>
|
||||
<Alert bsStyle={receipt.status === "0x1" ? 'success' : 'danger'}>{receipt.status === "0x1" ? 'Success' : 'Failure / Revert'} - Transaction Hash: {receipt.transactionHash}</Alert>
|
||||
</Fragment>
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ contract {{contractName}} {
|
|||
{{/each}}
|
||||
}
|
||||
|
||||
{{structName}}[] public items;
|
||||
{{structName}}[] items;
|
||||
|
||||
event ItemCreated(uint id, address createdBy);
|
||||
event ItemDeleted(uint id, address deletedBy);
|
||||
|
@ -42,4 +42,9 @@ contract {{contractName}} {
|
|||
emit ItemDeleted(_id, msg.sender);
|
||||
}
|
||||
|
||||
function get(uint _id) public view returns ({{#each fields}}{{type}}{{#unless @last}},{{/unless}}{{/each}}) {
|
||||
require(_id < items.length, "Invalid ArrayContractStruct id");
|
||||
return ({{#each fields}}items[_id].{{name}}{{#unless @last}},{{/unless}}{{/each}});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue