Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
Add basic support for hierarchies, fixes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Bjwebb committed Nov 28, 2013
1 parent 18f7eb6 commit ba6de8b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion csviatimodeleditor/__init__.py
Expand Up @@ -47,7 +47,7 @@ def generate_csrf_token():
return session['_csrf_token']
app.jinja_env.globals['csrf_token'] = generate_csrf_token

app.jinja_env.globals['version'] = '2.3-beta'
app.jinja_env.globals['version'] = '2.3'


class IATIModel(db.Model):
Expand Down
7 changes: 4 additions & 3 deletions csviatimodeleditor/static/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion csviatimodeleditor/templates/model.html
Expand Up @@ -289,6 +289,17 @@ <h2>Organisation information</h2>
<dd class='hints'>
<p>The encoding of your data.</p>
</dd>

<dt>
Hierarchies (optional)
</dt>
<dd>
<input type="hidden" name="mapping[hierarchy][iati-field]" value="hierarchy" />
<input type="hidden" name="mapping[hierarchy][datatype]" value="column" />
<select name="mapping[hierarchy][column]" id="hierarchy_select">
<option value=""></option></select>
</dd>

<dt><label for='organisation[data-structure]'>Data structure:</label></dt>
<dd class='hints'>
<p>How is your data structured? You can have one row per activity, or multiple rows per activity.
Expand Down Expand Up @@ -352,7 +363,6 @@ <h2>Mapping</h2>
<div class='dimensions'>
</div>
</dl>
<p>
<!-- show all IATI fields -->
<select id="iati_field_add" class="iati_field_add">
</select>
Expand Down
1 change: 1 addition & 0 deletions docs/CHANGELOG.rst
Expand Up @@ -9,6 +9,7 @@ Version 2.3
XML file
- Add encoding override
- Support for more than one element having multiple rows per activity
- Contact information is populated correctly in the XML

UI Changes

Expand Down
9 changes: 6 additions & 3 deletions src/modeleditor.coffee
Expand Up @@ -440,6 +440,7 @@ class DimensionsWidget extends Delegator

@element.trigger('doFieldSelectors', 'iatifield')
@element.trigger('doFieldSelectors', 'column')

addDimension: (name) ->
w = new DimensionWidget(name, @dimsEl)
@widgets.push(w)
Expand Down Expand Up @@ -475,7 +476,8 @@ class DimensionsWidget extends Delegator

# Any keys left in dims need to be added
for name, obj of dims
this.addDimension(name).deserialize(data)
if obj['datatype'] != 'column'
this.addDimension(name).deserialize(data)

@element.trigger('fillIATIfieldsRequest', [$(document).find('select.iati_field_add')])

Expand Down Expand Up @@ -560,10 +562,8 @@ class ModelEditor extends Delegator
constructor: (element, options) ->
super

console.log(@options.iatifields)
common_multiples = [ 'transaction', 'sector', 'recipient-country', 'recipient-region' ]
other_multiples = (x for x in @options.iatifields when not (x in common_multiples))
console.log(other_multiples)

$('#multiple_rows_selector').html(
'Common choices:<br/>'+
Expand Down Expand Up @@ -668,6 +668,9 @@ class ModelEditor extends Delegator
return false;

onModelChange: () ->
#FIXME
@onFillColumnsRequest($('#hierarchy_select'))

# Populate straightforward bits
for k, v of util.flattenObject(@data)
# FIXME? this may not deal with complex form elements such as radio
Expand Down

0 comments on commit ba6de8b

Please sign in to comment.