Skip to content

Commit

Permalink
Merge pull request #226 from qld-gov-au/develop
Browse files Browse the repository at this point in the history
Develop to master - hide size field for uploads
  • Loading branch information
ThrawnCA authored Nov 10, 2023
2 parents 54e625e + 5be9088 commit c3b091b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Retrieve logs
if: always()
run: bin/get-logs.sh
timeout-minutes: 5
timeout-minutes: 1

- name: Retrieve screenshots
if: always()
Expand Down
2 changes: 1 addition & 1 deletion ckanext/data_qld/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def filesize_converter(value, context):
value = value.upper()

# If the size is not all digits then get size converted into bytes
if re.search(r'^\d+$', value) is None:
if value and re.search(r'^\d+$', value) is None:
value = filesize_bytes(value)

return value
Expand Down
20 changes: 10 additions & 10 deletions ckanext/data_qld/fanstatic/resource_file_upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,38 @@ jQuery(document).ready(function () {
}

// Hide resource size element on loading of a resource edit form if the resource file was uploaded
if (jQuery('.image-upload[data-module="image-upload"]').data('module-is_upload') == true) {
if (jQuery('#resource-url-upload').prop('checked') === true) {
jQuery('#field-size').parent().parent().hide();
}
// Show field-size element on loading of a resource edit form if the resource file was a url link
else if (jQuery('.image-upload[data-module="image-upload"]').data('module-is_url') == true) {
else {
jQuery('#field-size').parent().parent().show();
}

// Hide the resource element if a file was selected to upload
jQuery('#field-image-upload').change(function () {
jQuery('#field-resource-upload').change(function () {
jQuery('#field-size').parent().parent().fadeOut();
show_nature_of_change()
});

// Show the resource element if a url link was entered
jQuery('#field-image-url').change(function () {
jQuery('#field-resource-url').change(function () {
jQuery('#field-size').parent().parent().fadeIn();
show_nature_of_change()
});

// Insert field is required asterisk for labels
jQuery('.control-label[for="field-image-upload"]').parent().prepend('<span title="This field is required" class="control-required">*</span> ')
jQuery('.control-label[for="field-image-url"]').parent().prepend('<span title="This field is required" class="control-required">*</span> ')
// Insert field is required asterisk for labels
jQuery('.control-label[for="field-resource-upload"]').parent().prepend('<span title="This field is required" class="control-required">*</span> ')
jQuery('.control-label[for="field-resource-url"]').parent().prepend('<span title="This field is required" class="control-required">*</span> ')
jQuery('.control-label[for="field-nature_of_change"]').parent().prepend('<span title="This field is required" class="control-required">*</span> ')

function show_nature_of_change() {
// Only show nature of change when editing a resource
// id value will be null for new resource
// Only show nature of change when editing a resource
// id value will be null for new resource
// Dont show the field if the update_frequency for dataset is not in defined values
if (jQuery('input[name="id"]').val().length > 0 && UPDATE_FREQUENCY in UPDATE_FREQUENCY_DAYS) {
jQuery('#field-nature_of_change').val("");
jQuery('#field-nature_of_change').parent().parent().show();
}
}
});
});

0 comments on commit c3b091b

Please sign in to comment.