Skip to content

Commit 2ec939e

Browse files
authored
Merge pull request #179 from AtlasOfLivingAustralia/feature/issue176
Add score/behaviour support to species fields. #176
2 parents d9137c6 + e08d0a4 commit 2ec939e

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

grails-app/assets/javascripts/speciesModel.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,11 @@ var speciesSearchEngines = function() {
221221
* Manages the species data type in the output model.
222222
* Allows species information to be searched for and displayed.
223223
*/
224-
var SpeciesViewModel = function(data, options) {
224+
var SpeciesViewModel = function(data, options, context) {
225225

226226
var self = this;
227+
ecodata.forms.DataModelItem.apply(self, [options.metadata || {}, context, options]);
228+
227229
var params = [];
228230
var species = data;
229231
var populate = options.populate || false;
@@ -285,6 +287,10 @@ var SpeciesViewModel = function(data, options) {
285287
}
286288
};
287289

290+
self.toJSON = function() {
291+
return self.toJS();
292+
}
293+
288294
self.loadData = function(data) {
289295
if (!data) data = {};
290296

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -712,8 +712,8 @@ class ModelJSTagLib {
712712
def attrs = ctx.attrs
713713
def model = ctx.dataModel
714714
String configVarName = ctx.dataModel.name+"Config"
715-
ctx.out << INDENT*3 << "var ${configVarName} = _.extend(config, {printable:'${ctx.attrs.printable?:''}', dataFieldName:'${model.name}', output: '${attrs.output}', surveyName: '${attrs.surveyName?:""}' });\n"
716-
ctx.out << INDENT*3 << "${ctx.propertyPath}.${ctx.dataModel.name} = new SpeciesViewModel({}, ${configVarName});\n"
715+
ctx.out << INDENT*3 << "var ${configVarName} = _.extend(config, {printable:'${ctx.attrs.printable?:''}', dataFieldName:'${model.name}', output: '${attrs.output}', surveyName: '${attrs.surveyName?:""}', metadata:self.dataModel['${model.name}']});\n"
716+
ctx.out << INDENT*3 << "${ctx.propertyPath}.${ctx.dataModel.name} = new SpeciesViewModel({}, ${configVarName}, self.\$context);\n"
717717
}
718718

719719
def imageModel(JSModelRenderContext ctx) {

src/main/groovy/au/org/ala/ecodata/forms/ViewModelWidgetRenderer.groovy

+1-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ class ViewModelWidgetRenderer implements ModelWidgetRenderer {
184184

185185
private void renderReadOnlySpecies(WidgetRenderContext context) {
186186
context.databindAttrs.add 'with', context.source
187-
context.writer << """<span data-bind="${context.databindAttrs.toString()}"><span${context.attributes.toString()} data-bind='text:name'></span>
187+
context.writer << """<span data-bind='${context.databindAttrs.toString()}'><span${context.attributes.toString()} data-bind='text:name'></span>
188188
<a href="#" data-bind="popover: {title: name, content: transients.speciesInformation}"><i class="icon-info-sign"></i></a>
189189
</span>"""
190190
}

0 commit comments

Comments
 (0)