Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tags field to Score domain #852 #853

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion grails-app/assets/javascripts/score.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ var ScoreModel = function (score, config) {
self.displayType = ko.observable(score.displayType);
self.isOutputTarget = ko.observable(score.isOutputTarget);
self.entity = ko.observable(score.entity || 'Activity');
self.tags = ko.observableArray(score.tags);
self.tagOptions = ko.observableArray(score.tags);

var editorPane = document.getElementById(config.scoreEditorId);

Expand Down Expand Up @@ -45,7 +47,7 @@ var ScoreModel = function (score, config) {

self.save = function () {
var model = ko.toJS(self);

delete model.tagOptions;
try {
model.configuration = editor.get();
delete model.configurationText;
Expand Down
10 changes: 8 additions & 2 deletions grails-app/domain/au/org/ala/ecodata/Score.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class Score {
/** In the case that the score is derived from an Activity, this contains the activity types used */
List<String> entityTypes

/** Can be used to categorize scores */
List<String> tags


/** Embedded document describing how the score should be calculated */
Map configuration
Expand All @@ -45,6 +48,7 @@ class Score {
description nullable:true
entityTypes nullable:true
externalId nullable:true
tags: nullable:true
label unique: true
scoreId unique: true
}
Expand Down Expand Up @@ -74,12 +78,14 @@ class Score {
category:category,
outputType:outputType,
isOutputTarget:isOutputTarget,
label:label,
label:label,
description:description,
displayType:displayType,
entity:entity,
externalId:externalId,
entityTypes:entityTypes]
entityTypes:entityTypes,
tags:tags
]
if (includeConfig) {
scoreMap.configuration = configuration
}
Expand Down
8 changes: 8 additions & 0 deletions grails-app/views/admin/editScore.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
<label class="form-label">External ID:</label> <input class="form-control" type="text" data-bind="value:externalId"/>
</div>

<div>
<label class="form-label" for="tags">Tags:</label>
<select id="tags" multiple="multiple" class="form-control" data-bind="options:tagOptions, selectedOptions:tags">
</select>
</div>

<div class="my-2">
<label class="form-label">Display type: </label>
<select class="form-control" data-bind="value:displayType">
Expand Down Expand Up @@ -63,7 +69,9 @@
var updateScoreUrl = '${g.createLink(controller: 'admin', action:'updateScore', id:score.scoreId?:'')}';
var editScoreUrl = '${g.createLink(action:'editScore')}';
var model = new ScoreModel(score, {updateScoreUrl:updateScoreUrl, editScoreUrl:editScoreUrl, scoreEditorId:'score-configuration'});

ko.applyBindings(model);
$('#tags').select2({tags:true});

</asset:script>
</body>
Expand Down
Loading