Skip to content

Commit

Permalink
HDX-9232 wrong resource to be previewed on dataset page and on contri…
Browse files Browse the repository at this point in the history
…bute form
  • Loading branch information
danmihaila committed Oct 5, 2023
1 parent 4b552d8 commit e2211a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ckanext-hdx_package/ckanext/hdx_package/views/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def read(id):
dataset_preview_disabled_list = []
if _dataset_preview == vd._DATASET_PREVIEW_RESOURCE_ID:
for r in view_enabled_resources:
if r.get('dataset_preview_enabled'):
if r.get('dataset_preview_enabled') in ['True', 'true', True]:
dataset_preview_enabled_list.append(r)
else:
dataset_preview_disabled_list.append(r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,19 +427,17 @@
var selectOptions = $('#field_dataset_preview_value').prop('options');
selectOptions[0] = new Option('Default (first resource with preview)', 'first_resource');
var i = 'first_resource';
$.each(newOptions, function(index, value) {
var resName = value.get('name') ? value.get('name') : 'Resource '+(index+1);
if (value.get('dataset_preview_enabled') === true){
selectOptions[selectOptions.length] = new Option(resName, index+'', true, true);
i = index+'';
}
else {
selectOptions[selectOptions.length] = new Option(resName, index+'');
}
});
$.each(newOptions, function (index, value) {
var resName = value.get('name') ? value.get('name') : 'Resource ' + (index + 1);
if (value.get('dataset_preview_enabled') === true || value.get('dataset_preview_enabled') === 'True' || value.get('dataset_preview_enabled') === 'true') {
selectOptions[selectOptions.length] = new Option(resName, index + '', true, true);
i = index + '';
} else {
selectOptions[selectOptions.length] = new Option(resName, index + '');
}
});
$("#field_dataset_preview_value").val(i).trigger('change');


},
'generateResourcePostData': function() {
var resourceModelList = this.resourceModelList.models;
Expand Down

0 comments on commit e2211a8

Please sign in to comment.