-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
243 lines (229 loc) · 9.29 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<!DOCTYPE html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=Edge;chrome=1' >
<title>OpenSpending model editor</title>
<link rel='stylesheet' href='css/forms.css'>
<link rel='stylesheet' href='css/style.css'>
</head>
<body>
<textarea id="debug" style='float:right;width:28%'>
</textarea>
<div class='content' style='width: 70%'>
<div id='m1' class='modeleditor'>
<div class='steps'>
<ul>
<li>
<a href='#'><span>1</span> Dimension mapping</a>
<ul class='steps_dimensions'>
</ul>
</li>
<li><a href='#'><span>2</span> Dataset metadata</a></li>
<li><a href='#'><span>3</span> Views & visualisation</a></li>
</ul>
</div>
<div class='forms'>
<form action='#'>
<!-- Dimension mapping -->
<div class='formpart dimensions_widget'>
<h2>Dimension mapping</h2>
<p>
The first and most important step in the creation of a model is
the mapping of columns in the data file to "dimensions", the logical
divisions of the dataset. The four required dimensions, <code>amount</code>,
<code>time</code>, <code>from</code>, and <code>to</code> are laid
out below, and you can add your own dimensions using the links at
the bottom of the page.
</p>
<div class='dimensions'>
</div>
<p>
<a class='add_value_dimension' href='#'>Add single-column dimension</a>
<a class='add_classifier_dimension' href='#'>Add multi-column dimension</a>
</p>
</div>
<!-- Dataset metadata -->
<div class='formpart'>
<h2>Dataset metadata</h2>
<dl>
<dt><label for='dataset[name]'>Name:</label></dt>
<dd><input type='text' name='dataset[name]'></dd>
<dd class='hints'>
Choose a uniquely identifying name, comprising letters,
dashes and underscores only. Examples: <code>eu-budget</code>,
<code>epsrc-grants</code>, <code>country-regional-analysis</code>.
</dd>
<dt><label for='dataset[label]'>Label:</label></dt>
<dd><input type='text' name='dataset[label]'></dd>
<dd class='hints'>
A human-readable, short representation of the package name:
<code>European Union Budget</code>, <code>Country Regional Analysis</code>,
etc.
</dd>
<dt><label for='dataset[currency]'>Currency:</label></dt>
<dd><input type='text' name='dataset[currency]' maxlength='3' class='short'></dd>
<dd class='hints'>
A 3-letter currency code. Examples: <code>USD</code>, <code>GBP</code>,
etc. See <a href='http://en.wikipedia.org/wiki/ISO_4217'>ISO 4217</a>.
</dd>
<dt><label for='dataset[unique_keys]'>Unique keys:</label></dt>
<dd class='unique_keys_widget'></dd>
<dd class='hints'>
Every dataset needs a set of columns from the data file which will
<em>uniquely identify</em> any given spending entry in the data.
</dd>
<dt><label for='dataset[description]'>Description:</label></dt>
<dd><textarea name='dataset[description]' class='short'></textarea></dd>
<dd class='hints'>
A longer description of the dataset, including (for example)
information on its provenance, data quality. This will be
processed as <a href='http://daringfireball.net/projects/markdown'>
Markdown</a>.
</dd>
<dt><label for='dataset[entry_custom_html]'>Entry Custom HTML:</label></dt>
<dd><textarea name='dataset[entry_custom_html]' class='short'></textarea></dd>
<dd class='hints'>
An HTML template that will be displayed on the page for an entry,
which can incorporate properties of that entry. e.g.
<pre><code><a href="http://example.com/entry/${entry.id}">
${entry.label}
</a></code></pre>
</dd>
</dl>
</div>
<!-- Views & visualisation -->
<div class='formpart'>
<h2>Views and visualisation</h2>
</div>
</form>
</div> <!-- /.forms -->
<!-- Unique keys template -->
<script id='tpl_unique_keys' type='text/x-jquery-tmpl'>
{{if keys.length == 0}}
<em>No dimensions available yet.</em>
{{/if}}
{{each(i, key) keys}}
{{if key.used}}
<input type='hidden' name='dataset[unique_keys][]' value='${key.name}'>
<span class='active'>
{{else}}
<span>
{{/if}}
${key.name}
</span>
{{/each}}
</script>
<!-- Dimension column field template -->
<script id='tpl_dimension_field' type='text/x-jquery-tmpl'>
<tr data-field-name='${fieldName}'>
<td>${fieldName}</td>
<td><select class='column' name='${prefix(fieldName)}[column]'></select></td>
<td>
<select name='${prefix(fieldName)}[datatype]'>
<option value=''></option>
<option value='float'>float</option>
<option value='string'>string</option>
</select>
</td>
<td>
<a href='#' class='field_switch_constant'>→ const</a>
{{if required(fieldName) != true}}
<a href='#' class='field_rm'>×</a>
{{/if}}
</td>
</tr>
</script>
<!-- Dimension constant field template -->
<script id='tpl_dimension_field_const' type='text/x-jquery-tmpl'>
<tr data-field-name='${fieldName}'>
<td>
${fieldName}
<input type='hidden' name='${prefix(fieldName)}[datatype]' value='constant'>
</td>
<td><input type='text' name='${prefix(fieldName)}[constant]'></td>
<td>constant</td>
<td>
<a href='#' class='field_switch_column'>→ column</a>
{{if required(fieldName) != true}}
<a href='#' class='field_rm'>×</a>
{{/if}}
</td>
</tr>
</script>
<!-- Dimension template -->
<script id='tpl_dimension' type='text/x-jquery-tmpl'>
<input type='hidden' name='mapping[${name}][type]' value='${data.type}'>
{{if meta.fixedDataType}}
<input type='hidden' name='mapping[${name}][datatype]' value='${data.datatype}'>
{{/if}}
<legend>${name}</legend>
{{if meta.helpText}}<p>${meta.helpText}</p>{{/if}}
<dl>
{{if data.type === 'value'}}
<dt><label>Column:</label></dt>
<dd>
<select class='column' name='mapping[${name}][column]'></select>
</dd>
{{if !meta.fixedDataType}}
<dt><label>Data type:</label></dt>
<dd>
<select name='mapping[${name}][datatype]'>
<option value='float'>float</option>
<option value='string'>string</option>
</select>
</dd>
{{/if}}
{{/if}}
<dt><label>Label:</label></dt>
<dd>
<input type='text' name='mapping[${name}][label]' value='${data.label}'>
</dd>
<dt><label>Description:</label></dt>
<dd>
<textarea class='short' name='mapping[${name}][description]'>${data.description}</textarea>
</dd>
</dl>
{{if data.type !== 'value' }}
<table class='fields'>
<thead>
<tr>
<td>Field name</td>
<td>Column/Const</td>
<td>Type</td>
<td> </td>
</tr>
</thead>
<tbody>
{{each(n, f) data.fields}}
{{if f.datatype === 'constant'}}
{{tmpl({'fieldName': n, 'prefix': formFieldPrefix, 'required': formFieldRequired}) '#tpl_dimension_field_const'}}
{{else}}
{{tmpl({'fieldName': n, 'prefix': formFieldPrefix, 'required': formFieldRequired}) '#tpl_dimension_field'}}
{{/if}}
{{/each}}
</tbody>
</table>
<p><a class='add_field' href='#'>Add a field</a></p>
{{/if}}
</script>
</div> <!-- /.modeleditor -->
</div> <!-- /.content -->
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js'></script>
<script src='http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js'></script>
<script src='lib/extensions.js'></script>
<script src='lib/delegator.js'></script>
<script src='lib/modeleditor.js'></script>
<script>
jQuery(function($) {
$('#m1').modelEditor({
'columns': ['date', 'value', 'dept_id', 'dept_name', 'dept_transaction_id', 'recipient', 'cofog_code_l1']
});
var me = $('#m1').data('modelEditor')
$('#debug').change(function () {
me.data = JSON.parse($(this).val())
$('#m1').trigger('modelChange')
})
})
</script>
</body>
</html>