Skip to content

Commit 53ebb96

Browse files
authored
Merge pull request #147 from AtlasOfLivingAustralia/hotfix/4.0.5
Hotfix/4.0.5
2 parents 7e9378f + 4ff3adc commit 53ebb96

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ buildscript {
1414
}
1515
}
1616

17-
version "4.0.4"
17+
version "4.0.5-SNAPSHOT"
1818
group "org.grails.plugins"
1919

2020
apply plugin:"eclipse"
@@ -83,7 +83,7 @@ dependencies {
8383

8484

8585
if (!inplace) {
86-
compile ("org.grails.plugins:ala-map-plugin:3.0") {
86+
compile ("org.grails.plugins:ala-map-plugin:3.0.1") {
8787
exclude group: 'com.bertramlabs.plugins', module: 'asset-pipeline-grails'
8888
}
8989
}

grails-app/taglib/au/org/ala/ecodata/forms/ModelJSTagLib.groovy

+2
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ class ModelJSTagLib {
275275
out << INDENT*4 << "self.load${mod.name}(${value});\n"
276276
}
277277
else if (mod.dataType == 'species') {
278+
out << INDENT*4 << "if (data['${mod.name}']) {\n"
278279
out << INDENT*4 << "${ctx.propertyPath}['${mod.name}'].loadData(${value});\n"
280+
out << INDENT*4 << "}\n"
279281
}
280282
else if (mod.dataType == 'document') {
281283
out << INDENT*4 << "var doc = _.find(context.documents || [], function(document) { if (data['${mod.name}']) \n return document.documentId == data['${mod.name}'] || document.documentId == data['${mod.name}'].documentId ;\n else \n return false });"

src/test/groovy/au/org/ala/ecodata/forms/ModelJSTagLibSpec.groovy

+14
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,20 @@ class ModelJSTagLibSpec extends Specification implements TagLibUnitTest<ModelJST
232232
compareWithoutWhiteSpace("data['test'].load(ecodata.forms.orDefault(data['test'],undefined));data['test'](ecodata.forms.orDefault(data['test'],undefined));", actualOut.toString())
233233
}
234234

235+
def "Input data is null/undefined checked before calling loadData() on SpeciesViewModel"() {
236+
setup:
237+
Map dataModel = [name:'test', dataType:'species']
238+
ctx.dataModel = dataModel
239+
ctx.propertyPath = 'self.data'
240+
ctx.attrs = [:]
241+
242+
when:
243+
tagLib.renderInitialiser(ctx)
244+
245+
then:
246+
compareWithoutWhiteSpace("if(data['test']){self.data['test'].loadData(ecodata.forms.orDefault(data['test'], {}));}", actualOut.toString())
247+
}
248+
235249
def "The lookup table data type is rendered correctly"() {
236250
setup:
237251
List lookupTable = [[input:'a', output:'1'], [input:'b', output:'2']]

0 commit comments

Comments
 (0)