Permalink
Browse files

Add option to hide field info for a single-field concept

This is prevent redundant information being rendered in the UI since
it is common to create single-field concepts with the same name and
description.
  • Loading branch information...
1 parent 2c5b09d commit a40da28512cc740fbad72d85055bb1545f3bb2b9 @bruth bruth committed May 9, 2013
Showing with 16 additions and 6 deletions.
  1. +1 −0 coffee/cilantro/ui/concept/form.coffee
  2. +13 −4 coffee/cilantro/ui/field/form.coffee
  3. +2 −2 templates/views/field-form.html
@@ -46,6 +46,7 @@ define [
fields = new field.FieldFormCollection
collection: @model.fields
context: @context
+ hideSingleFieldInfo: true
@fields.show(fields)
@setDefaultState()
@@ -36,7 +36,7 @@ define [
update: '.field-actions [data-toggle=update]'
regions:
- main: '.field-main'
+ info: '.field-info'
stats: '.field-stats'
control: '.field-control'
chart: '.field-chart'
@@ -45,25 +45,28 @@ define [
# easier to extend. This can also be a function that returns
# an object.
regionViews:
- main: item.Field
+ info: item.Field
stats: stats.FieldStats
control: controls.FieldControl
onRender: ->
for key, klass of c._.result @, 'regionViews'
+ if key is 'info' and @options.hideInfo
+ continue
+
view = new klass
model: @model
context: @context
+
@[key].show view
# Only represent for fields that support distributions
if @options.showChart and @model.links.distribution?
- chart = new charts.FieldChart
+ @chart.show new charts.FieldChart
model: @model
context: @context
chart:
height: 200
- @chart.show chart
@setDefaultState()
@@ -114,6 +117,12 @@ define [
,
create: 'condition'
+ # This collection is used by a concept, therefore if only one
+ # field is present, the concept name and description take
+ # precedence
+ if @options.hideSingleFieldInfo and @collection.length < 2
+ options.hideInfo = true
+
if not @fieldChartIndex? and model.links.distribution?
@fieldChartIndex = index
options.showChart = true
@@ -1,6 +1,6 @@
-<div class=field-main></div>
-<div class=field-stats></div>
+<div class=field-info></div>
<div class=field-chart></div>
+<div class=field-stats></div>
<div class=field-control></div>
<div class=field-actions>
<button data-toggle=add class="btn btn-success btn-mini">Add</button>

0 comments on commit a40da28

Please sign in to comment.