web: Show amounts when displaying substances

This commit is contained in:
Tiffany Bennett 2016-10-07 19:42:52 -04:00
parent acdc0321a8
commit 71af018e18
4 changed files with 7 additions and 1 deletions

View file

@ -84,6 +84,7 @@ pub struct PropertyReply {
pub struct SubstanceReply {
pub name: String,
pub doc: Option<String>,
pub amount: NumberParts,
pub properties: Vec<PropertyReply>,
}

View file

@ -109,6 +109,7 @@ impl Substance {
Ok(SubstanceReply {
name: self.properties.name.clone(),
doc: context.docs.get(&self.properties.name).cloned(),
amount: self.amount.to_parts(context),
properties: try!(self.properties.properties.iter().map(|(k, v)| {
let (input, output) = if v.input.1.len() == 0 {
let res = (&v.output * &self.amount).unwrap();
@ -218,6 +219,7 @@ impl Substance {
Ok(SubstanceReply {
name: self.properties.name.clone(),
doc: context.docs.get(&self.properties.name).cloned(),
amount: self.amount.to_parts(context),
properties: try!(
once(Ok(Some(amount)))
.chain(self.properties.properties.iter().map(func))
@ -234,6 +236,7 @@ impl Substance {
Ok(SubstanceReply {
name: self.properties.name.clone(),
doc: context.docs.get(&self.properties.name).cloned(),
amount: self.amount.to_parts(context),
properties: try!(self.properties.properties.iter().map(|(k, v)| {
let (input, output) = if v.input.1.len() == 0 {
let res = (&v.output * &self.amount).unwrap();
@ -304,6 +307,7 @@ impl Substance {
Ok(SubstanceReply {
name: self.properties.name.clone(),
doc: context.docs.get(&self.properties.name).cloned(),
amount: self.amount.to_parts(context),
properties: try!(
once(Ok(Some(amount)))
.chain(self.properties.properties.iter().map(func))

View file

@ -7,6 +7,7 @@
{{else}}
{{dimensions}}
{{/if}}
{{insert}}
{{#if quantity}}
({{quantity}})
{{/if}}

View file

@ -142,7 +142,7 @@
{{#with Substance}}
<div class="panel panel-default">
<div class="panel-heading">
Substance: {{name}}
Substance: {{> number amount}} {{name}}
</div>
{{#with doc}}
<div class="panel-body">