Skip to content

Commit

Permalink
Fix file uploader
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansberry committed Dec 10, 2024
1 parent 06dbde8 commit ccb868a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
4 changes: 0 additions & 4 deletions ckanext/dms/schemas/dataset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ dataset_fields:

resource_fields:

- field_name: url
label: URL
preset: resource_url_upload

- field_name: name
label: Name
form_placeholder: eg. Malawi HTC Scale Up Plan
Expand Down
48 changes: 48 additions & 0 deletions ckanext/dms/templates/scheming/package/snippets/resource_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% ckan_extends %}

{% block basic_fields %}
{% asset 'dms/FileInputComponentStyles' %}
{% set dataset = h.get_dataset_from_id(pkg_name) %}
<div
id="FileInputComponent"
data-lfsServer="{{ h.blob_storage_server_url() }}"
data-maxResourceSize="{{ h.max_resource_size() }}"
data-orgId="{{ dataset.organization.name }}"
data-datasetName="{{ dataset.name }}"
data-existingUrlType="{{ data.url_type if data else '' }}"
data-existingUrl="{{ data.url if data else '' }}"
data-existingSha256="{{ data.sha256 if data else '' }}"
data-existingFileName="{{ h.blob_storage_resource_filename(data) if data else '' }}"
data-existingSize="{{ data.size if data else '' }}"
>
{% if data.url %}
{% if data.url_type == 'upload' %}
<h3 class="text-muted">
<span><i class="fa fa-spinner fa-spin"></i> {{ _('Loading') }}</span>
</h3>
{% else %}
<div>
<label class="control-label">{{ _('URL')}}</label>
<div class="input-group field-url-input-group">
<input
type="text"
placeholder="{{ _('Loading') }}..."
class="form-control"
/>
<span class="input-group-btn">
<button class="btn btn-danger" type="button">{{ _('Remove') }}</button>
</span>
</div>
</div>
{% endif %}
{% else %}
<div class="dropzone text-muted">
<h3><i class="fa fa-spinner fa-spin"></i> {{ _('Loading') }}</h3>
</div>
{% endif %}
</div>
{% asset 'dms/FileInputComponentScripts' %}

{{ super() }}

{% endblock %}

0 comments on commit ccb868a

Please sign in to comment.