Skip to content

Commit 6427066

Browse files
authored
Merge pull request #807 from AtlasOfLivingAustralia/feature/#800_1
#800_1 : fix category option issue
2 parents 580ae4c + a5bf33d commit 6427066

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

grails-app/assets/javascripts/profileEditor/controllers/AttachmentController.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,17 @@ profileEditor.controller("AttachmentUploadController", function (profileService,
9191
var pdfType = {key: "PDF", title: "PDF Document"};
9292
self.types = [pdfType, urlType];
9393

94+
self.metadata = angular.isDefined(attachment) ? _.clone(attachment) : {};
95+
9496
if (self.categories == null) {
9597
profileService.getCategories().then(function (data) {
9698
self.categories = data.resp;
99+
if (self.metadata.category == null) {
100+
self.metadata.category = self.categories[0].value;
101+
}
97102
});
98103
}
99104

100-
self.metadata = angular.isDefined(attachment) ? _.clone(attachment) : {};
101105
self.files = null;
102106
self.error = null;
103107
self.type = angular.isDefined(attachment.url) && attachment.url ? urlType.key : pdfType.key;

grails-app/assets/javascripts/profileEditor/templates/attachmentUpload.tpl.htm

+3-2
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ <h4 class="modal-title">Add an attachment</h4>
8282
<label for="category" class="col-sm-3 control-label">Category</label>
8383

8484
<div class="col-sm-9">
85-
<select id="category" ng-model="attachmentUploadCtrl.metadata.category"
86-
ng-options="category.key as category.value for category in attachmentUploadCtrl.categories" class="form-control">
85+
<select id="category" ng-model="attachmentUploadCtrl.metadata.category" class="form-control">
8786
<option value="">Select a category</option>
87+
<option ng-repeat="category in attachmentUploadCtrl.categories | orderBy:'toString()'" value="{{category.key}}"
88+
ng-selected="attachmentUploadCtrl.metadata.category == category.key">{{category.key}}</option>
8889
</select>
8990
</div>
9091
</div>

0 commit comments

Comments
 (0)