Skip to content

Commit b30f404

Browse files
committed
Merge pull request #333 from unepwcmc/review-indicator-fields
Review indicator properties
2 parents f550281 + b3c8ced commit b30f404

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+526
-528
lines changed

client/src/collections/indicator_collection.coffee

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ class Backbone.Collections.IndicatorCollection extends Backbone.Collection
1313
url += "?withData=true"
1414
url
1515

16-
filterByTitle: (title='') ->
17-
title = title.trim()
16+
filterByName: (name='') ->
17+
name = name.trim()
1818

19-
regexp = new RegExp(".*#{title}.*", 'i')
19+
regexp = new RegExp(".*#{name}.*", 'i')
2020
@filter( (indicator) ->
21-
regexp.test indicator.get('title')
21+
regexp.test indicator.get('name')
2222
)
2323

2424
filterByTheme: (theme) ->
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<h4>{{short_name}}</h4>
2-
<p>{{title}}</p>
1+
<h4>{{shortName}}</h4>
2+
<p>{{name}}</p>

client/src/templates/report_edit_visualisation.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="editor">
22
<span class="close">{{{t "report/modal/close"}}}<i class="icon-remove-circle"></i></span>
33
<header>
4-
<h2>{{indicator.title}}</h2>
4+
<h2>{{indicator.name}}</h2>
55
</header>
66
<div class="visualisation">
77
<div class='controls'>

client/src/templates/table.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<table>
2-
<caption>{{indicatorTitle}}</caption>
2+
<caption>{{indicatorName}}</caption>
33
<thead>
44
<tr>
55
<th>{{xAxis}}</th>

client/src/templates/visualisation.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<h4>{{indicator.title}}</h4>
1+
<h4>{{indicator.name}}</h4>
22

33
{{#if isEditable}}
44
<button class="delete delete-visualisation">

client/src/views/indicator_selector_view.coffee

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Backbone.Views.IndicatorSelectorView extends Backbone.Diorama.NestingView
88
events:
99
"click .close": "close"
1010
"click .clear-search": "clearSearch"
11-
"keyup input": "filterByTitle"
11+
"keyup input": "filterByName"
1212

1313
initialize: (options = {}) ->
1414
@currentIndicator = options.currentIndicator
@@ -55,7 +55,7 @@ class Backbone.Views.IndicatorSelectorView extends Backbone.Diorama.NestingView
5555

5656
@filterIndicators()
5757

58-
filterByTitle: (event) =>
58+
filterByName: (event) =>
5959
searchTerm = $(event.target).val()
6060

6161
@updateClearSearchButton()
@@ -75,7 +75,7 @@ class Backbone.Views.IndicatorSelectorView extends Backbone.Diorama.NestingView
7575
results = @indicators.filterBySource(@filter.sourceName)
7676
@results.set(results)
7777

78-
results = @results.filterByTitle(@filter.searchTerm)
78+
results = @results.filterByName(@filter.searchTerm)
7979
@textFilteredIndicators.reset(results)
8080
@results.set(results)
8181

client/src/views/section_navigation_view.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class Backbone.Views.SectionNavigationView extends Backbone.View
1717
sections: @sections.map (section)->
1818
title = section.get('title')
1919
if section.get('indicator')?
20-
title = section.get('indicator').get('title')
21-
20+
title = section.get('indicator').get('name')
21+
2222
return {
2323
cid: section.cid
2424
_id: section.get('_id')

client/src/views/table_view.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Backbone.Views.TableView extends Backbone.View
2424
xAxis: @visualisation.getXAxis()
2525
yAxis: @visualisation.getYAxis()
2626
dataRows: @visualisation.mapDataToXAndY()
27-
indicatorTitle: @visualisation.get('indicator').get('title')
27+
indicatorName: @visualisation.get('indicator').get('name')
2828
))
2929

3030
onClose: ->

client/test/src/models/section_model.coffee

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test("When intialising a section with a nested visualisation,
1717

1818
test("When calling .toJSON on a section with an indicator model attribute,
1919
the indicator model should be deserialized to the indicator _id", ->
20-
indicatorAttributes = _id: 5, title: 'hat'
20+
indicatorAttributes = _id: 5, name: 'hat'
2121

2222
section = new Backbone.Models.Section(indicator: indicatorAttributes)
2323
assert.equal section.toJSON().indicator, indicatorAttributes._id
@@ -56,7 +56,7 @@ test(".hasTitleOrIndicator returns true if there is a title present", ->
5656
)
5757

5858
test(".hasTitleOrIndicator returns true if there is an indicator present", ->
59-
section = new Backbone.Models.Section(indicator: {title: 'an indicator'})
59+
section = new Backbone.Models.Section(indicator: {name: 'an indicator'})
6060

6161
assert.ok section.hasTitleOrIndicator()
6262
)
@@ -81,12 +81,12 @@ test("When initialised with narrative attributes,
8181

8282
test("When setting 'indicator' with indicator attributes,
8383
it creates a Backbone.Models.Indicator model in the indicator attribute", ->
84-
indicatorAttributes = title: "I'm an indicator"
84+
indicatorAttributes = name: "I'm an indicator"
8585
section = new Backbone.Models.Section()
8686
section.set('indicator', indicatorAttributes)
8787

8888
assert.equal section.get('indicator').constructor.name, 'Indicator'
89-
assert.equal section.get('indicator').get('title'), indicatorAttributes.title
89+
assert.equal section.get('indicator').get('name'), indicatorAttributes.name
9090
)
9191

9292
test(".save should actually call save on the parent page model", (done)->

client/test/src/models/visualisation_model.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ test('.toJSON returns the indicator: as indicator._id instead of the model attri
2222
visualisation = new Backbone.Models.Visualisation(
2323
indicator: {
2424
_id: indicatorId
25-
title: 'hey'
25+
name: 'hey'
2626
}
2727
)
2828

@@ -200,7 +200,7 @@ test(".mapDataToXAndY should return data as an array of X and Y objects, with
200200
"Expected the formatted attribute to include the y axis"
201201
)
202202

203-
test('.setFilterParameter when filter is undefined
203+
test('.setFilterParameter when filter is undefined
204204
creates the object and insert the correct values', ->
205205
visualisation = Factory.visualisation()
206206

client/test/src/views/indicator_selector_results_view.coffee

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ assert = chai.assert
33
suite('IndicatorSelectorResultsView')
44

55
test('renders an IndicatorSelectorItem sub view for each result in the given collection ', ->
6-
indicator = Factory.indicator(title: 'test indicator')
6+
indicator = Factory.indicator(name: 'test indicator')
77
indicators = new Backbone.Collections.IndicatorCollection([indicator])
88

99
view = new Backbone.Views.IndicatorSelectorResultsView(indicators: indicators)
1010

11-
assert.match view.$el.text(), new RegExp(indicator.get('title')),
12-
"Expected to see the indicator title"
11+
assert.match view.$el.text(), new RegExp(indicator.get('name')),
12+
"Expected to see the indicator name"
1313

1414
for key, v of view.subViews
1515
subView = v
@@ -23,7 +23,7 @@ test('renders an IndicatorSelectorItem sub view for each result in the given col
2323
)
2424

2525
test('re-renders when the indicator collection resets', ->
26-
indicator = Factory.indicator(title: 'test indicator')
26+
indicator = Factory.indicator(name: 'test indicator')
2727
indicators = new Backbone.Collections.IndicatorCollection([])
2828

2929
view = new Backbone.Views.IndicatorSelectorResultsView(indicators: indicators)
@@ -33,8 +33,8 @@ test('re-renders when the indicator collection resets', ->
3333

3434
indicators.reset([indicator])
3535

36-
assert.match view.$el.text(), new RegExp(indicator.get('title')),
37-
"Expected to see the indicator title"
36+
assert.match view.$el.text(), new RegExp(indicator.get('name')),
37+
"Expected to see the indicator name"
3838

3939
for key, v of view.subViews
4040
subView = v

client/test/src/views/indicator_selector_view.coffee

+26-26
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dummyFetch = ->
1010
test('populateCollections populates indicators from the server', (done)->
1111
server = sinon.fakeServer.create()
1212

13-
indicators = [title: 'hat']
13+
indicators = [name: 'hat']
1414

1515
indicatorSelector =
1616
indicators: new Backbone.Collections.IndicatorCollection([], withData: true)
@@ -20,7 +20,7 @@ test('populateCollections populates indicators from the server', (done)->
2020
Helpers.Assertions.assertPathVisited(server, new RegExp("/api/indicators"))
2121

2222
assert.strictEqual(
23-
indicatorSelector.indicators.at(0).get('title'), indicators[0].title
23+
indicatorSelector.indicators.at(0).get('name'), indicators[0].name
2424
)
2525

2626
done()
@@ -46,8 +46,8 @@ test('.initialize populates the indicators collection,
4646
_id: Factory.findNextFreeId('Section')
4747
)
4848

49-
indicatorTitle = 'An indicator'
50-
indicators = [{_id: 1, title: indicatorTitle}]
49+
indicatorName = 'An indicator'
50+
indicators = [{_id: 1, name: indicatorName}]
5151

5252
@stub(Backbone.Collections.IndicatorCollection::, 'fetch', ->
5353
Helpers.promisify(=>
@@ -86,7 +86,7 @@ test('Renders a ThemeFilters sub view with the collection of indicators', sinon.
8686
_id: Factory.findNextFreeId('Section')
8787
)
8888

89-
indicators = [{_id: 1, title: "Such Theme"}]
89+
indicators = [{_id: 1, name: "Such Indicator"}]
9090

9191
@stub(Backbone.Collections.IndicatorCollection::, 'fetch', ->
9292
Helpers.promisify(=>
@@ -154,10 +154,10 @@ test("When 'indicator_selector:theme_selected' is triggered,
154154

155155
test('When `indicator_selector:indicator_selected` event is fired on backbone
156156
it triggers the `indicatorSelected` event on itself', (done)->
157-
indicatorText = 'hats'
157+
indicatorName = 'hats'
158158
indicatorAttributes = [{
159159
type: 'cartodb'
160-
title: indicatorText
160+
name: indicatorName
161161
}]
162162

163163
sandbox = sinon.sandbox.create()
@@ -177,7 +177,7 @@ test('When `indicator_selector:indicator_selected` event is fired on backbone
177177

178178
indicatorSelectedCallback = (indicator) ->
179179
try
180-
assert.strictEqual indicator.get('title'), indicatorText
180+
assert.strictEqual indicator.get('name'), indicatorName
181181
done()
182182
catch err
183183
done(err)
@@ -223,8 +223,8 @@ test(".filterByTheme given a theme sets the results object to only
223223
assert.isTrue collectionFilterByThemeStub.calledWith(filterTheme)
224224
)
225225

226-
test(".filterByTitle given an input event sets the results object to only
227-
indicators with a matching title", ->
226+
test(".filterByName given an input event sets the results object to only
227+
indicators with a matching name", ->
228228
view =
229229
indicators: new Backbone.Collections.IndicatorCollection([])
230230
results: new Backbone.Collections.IndicatorCollection()
@@ -234,30 +234,30 @@ test(".filterByTitle given an input event sets the results object to only
234234

235235
event = target: '<input value="hats and boats and cats">'
236236

237-
filterTitleIndicator = Factory.indicator()
238-
collectionFilterByTitleStub = sinon.stub(
239-
Backbone.Collections.IndicatorCollection::, 'filterByTitle', ->
240-
return [filterTitleIndicator]
237+
filterNameIndicator = Factory.indicator()
238+
collectionfilterByNameStub = sinon.stub(
239+
Backbone.Collections.IndicatorCollection::, 'filterByName', ->
240+
return [filterNameIndicator]
241241
)
242242

243-
Backbone.Views.IndicatorSelectorView::filterByTitle.call(
243+
Backbone.Views.IndicatorSelectorView::filterByName.call(
244244
view, event
245245
)
246246

247247
try
248248
assert.ok(
249-
collectionFilterByTitleStub.calledOnce,
250-
"Expected filterByTitle to be called once but was called
251-
#{collectionFilterByTitleStub.callCount} times"
249+
collectionfilterByNameStub.calledOnce,
250+
"Expected filterByName to be called once but was called
251+
#{collectionfilterByNameStub.callCount} times"
252252
)
253253

254254
assert.lengthOf view.results.models, 1,
255255
"Expected the collection to be filtered to only the correct indicator"
256256

257-
assert.deepEqual view.results.at(0), filterTitleIndicator,
257+
assert.deepEqual view.results.at(0), filterNameIndicator,
258258
"Expected the result indicator to be the correct one for the given theme"
259259
finally
260-
collectionFilterByTitleStub.restore()
260+
collectionfilterByNameStub.restore()
261261
)
262262

263263
test('.filterBySource sets a sourceName attribute on the @filter', ->
@@ -276,7 +276,7 @@ test('.filterBySource sets a sourceName attribute on the @filter', ->
276276
"Expected filterIndicators to be called with the new filters"
277277
)
278278

279-
test("When the data origin sub view triggers 'selected',
279+
test("When the data origin sub view triggers 'selected',
280280
filterBySource is triggered", sinon.test(->
281281

282282
section = new Backbone.Models.Section(
@@ -345,22 +345,22 @@ sinon.test(->
345345

346346
theme = Factory.theme()
347347
matchingIndicator = Factory.indicator(
348-
title: "Matching title, theme and type"
348+
name: "Matching name, theme and type"
349349
theme: theme.get('_id')
350350
source: name: 'cygnet'
351351
)
352352

353353
indicators = [
354354
matchingIndicator
355355
{
356-
title: "Matching title and theme only", theme: theme.get('_id')}
356+
name: "Matching name and theme only", theme: theme.get('_id')}
357357
{
358-
title: "Matches theme and source only",
358+
name: "Matches theme and source only",
359359
theme: theme.get('_id'),
360360
source: name: 'cygnet'
361361
},
362362
{
363-
title: "Matching title and source only",
363+
name: "Matching name and source only",
364364
theme: Factory.findNextFreeId('Theme'),
365365
source: name: 'cygnet'
366366
}
@@ -378,7 +378,7 @@ sinon.test(->
378378
)
379379

380380
view.filterByTheme(theme)
381-
view.filterByTitle({target: '<input value="Matching">'})
381+
view.filterByName({target: '<input value="Matching">'})
382382
view.filterBySource('cygnet')
383383

384384
try

client/test/src/views/report_edit_visualisation_view.coffee

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ createAndShowVisualisationViewForOptions = (options) ->
88

99
suite('ReportEditVisualisationView')
1010

11-
test("Shows the given indicator title", ->
12-
indicatorTitle = "my lovely indicator"
11+
test("Shows the given indicator name", ->
12+
indicatorName = "my lovely indicator"
1313
indicator = Factory.indicator()
14-
indicator.set('title', indicatorTitle)
14+
indicator.set('name', indicatorName)
1515

1616
section = new Backbone.Models.Section(
1717
indicator: indicator
@@ -26,7 +26,7 @@ test("Shows the given indicator title", ->
2626

2727
assert.match(
2828
$('#test-container').text(),
29-
new RegExp(".*#{indicatorTitle}.*")
29+
new RegExp(".*#{indicatorName}.*")
3030
)
3131
view.close()
3232
)

client/test/src/views/table_view.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ test('Should render formatted visualisation data into a table', ->
6060
indicatorDefinition:
6161
xAxis: 'year'
6262
yAxis: 'value'
63-
title: 'An indicatr'
63+
name: 'An indicator'
6464
)
6565

6666
view = new Backbone.Views.TableView(visualisation: visualisation)
6767
Helpers.renderViewToTestContainer(view)
6868

6969
assert.strictEqual(
7070
$('#test-container').find('table caption').text(),
71-
indicator.get('title')
71+
indicator.get('name')
7272
)
7373

7474
headerText = $('#test-container').find('table thead').text()

client/test/src/views/visualisation_view.coffee

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ createAndShowVisualisationViewForVisualisation = (visualisation) ->
88

99
suite('Visualisation View')
1010

11-
test("Shows the title of the indicator", ->
11+
test("Shows the name of the indicator", ->
1212
indicator = Factory.indicator(
13-
title: "Such indicator"
13+
name: "Such indicator"
1414
)
1515

1616
view = new Backbone.Views.VisualisationView(
@@ -23,8 +23,8 @@ test("Shows the title of the indicator", ->
2323

2424
assert.match(
2525
view.$el.find('h4').text(),
26-
new RegExp(".*#{indicator.get('title')}.*"),
27-
"Expected to see the indicator title"
26+
new RegExp(".*#{indicator.get('name')}.*"),
27+
"Expected to see the indicator name"
2828
)
2929

3030
view.close()

0 commit comments

Comments
 (0)