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

disable and hide csv import button when request in flight #142

Merged
merged 24 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 11 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
152 changes: 150 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"main": "dist/index.js",
"dependencies": {
"@fastify/autoload": "^5.8.0",
"@fastify/compress": "^7.0.3",
"@fastify/cookie": "^9.2.0",
"@fastify/env": "^4.2.0",
"@fastify/formbody": "^7.4.0",
Expand Down Expand Up @@ -34,8 +35,8 @@
"devDependencies": {
"@medic/eslint-config": "^1.1.0",
"@types/chai": "^4.3.11",
"@types/commander": "^2.12.2",
"@types/chai-as-promised": "^7.1.8",
"@types/commander": "^2.12.2",
"@types/mocha": "^10.0.6",
"@types/rewire": "^2.5.30",
"@types/sinon": "^17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion src/liquid/app/fragment_home.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
hx-trigger="sse:place_state_change"
>
{% include "place/directive.html" %}
{% include "place/list.html" %}
{% include "place/list_lazy.html" %}
</div>
</div>
2 changes: 1 addition & 1 deletion src/liquid/components/button_upload.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<a class="{{ include.className | default: "button is-primary" }}" hx-post="/app/apply-changes" hx-swap="none">
<a class="{{ include.className | default: "button is-primary" }}" hx-post="/app/apply-changes" hx-target="div#hero_directive_model" hx-swap="innerHTML">
<span class="material-symbols-outlined">group_add</span> Upload
</a>
22 changes: 22 additions & 0 deletions src/liquid/components/table_header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<thead>
<tr>
{% for hierarchy in contactType.hierarchy %}
<th id="hierarchy_{{ hierarchy.property_name }}">{{ hierarchy.friendly_name }}</th>
{% endfor %}
{% for property in contactType.place_properties %}
{% if property.type != 'generated' %}
<th id="place_{{property.property_name}}">{{property.friendly_name}}</th>
{% endif %}
{% endfor %}
{% for contact_property in contactType.contact_properties %}
{% if contact_property.type != 'generated' %}
<th id="contact_{{contact_property.property_name}}">{{contact_property.friendly_name}}</th>
{% endif %}
{% endfor %}
{% if contactType.user_role.size > 1 %}
<th id="{{userRoleProperty.property_name}}">{{ contactType.userRoleProperty.friendly_name }}</th>
{% endif %}
<th></th>
<th></th>
</tr>
</thead>
8 changes: 6 additions & 2 deletions src/liquid/place/bulk_create_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
hx-encoding='multipart/form-data'
autocomplete="off"
hx-post="/place?op=bulk&type={{contactType.name}}"
hx-target="this"
hx-swap="outerHTML"
hx-disabled-elt="button#place_create_submit"
freddieptf marked this conversation as resolved.
Show resolved Hide resolved
hx-indicator="#place_create_submit_progress"
hx-swap="none"
>
<input name="place_type" value="{{contactType.name}}" hidden />

Expand Down Expand Up @@ -39,6 +40,9 @@
<a href="/" id="cancel" class="button">Cancel</a>
</div>
</div>
<div>
<progress id="place_create_submit_progress" class="progress is-small is-primary htmx-indicator" max="100"></progress>
</div>

<div class="tile box">
<table class="table is-fullwidth is-striped is-hoverable">
Expand Down
2 changes: 1 addition & 1 deletion src/liquid/place/directive.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="columns is-3 is-variable is-multiline" id="directive" hx-swap-oob="true">
<div class="column has-background-light is-9">
<section class="hero is-small is-light">
<div class="hero-body">
<div class="hero-body" id="hero_directive_model">
{% if directiveModel.inProgressCount > 0 %}
{% include "place/directive_3_in_progress.html" %}
{% elsif directiveModel.stagedCount > 0 %}
Expand Down
2 changes: 1 addition & 1 deletion src/liquid/place/directive_2_prompt_upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<div class="columns is-centered">
<div class="column is-4 has-text-centered">
<a class="button is-primary" data-target="progress-modal" hx-post="/app/apply-changes" hx-swap="none">
<a class="button is-primary" data-target="progress-modal" hx-target="div#hero_directive_model" hx-swap="innerHTML" hx-post="/app/apply-changes">
kennsippell marked this conversation as resolved.
Show resolved Hide resolved
<span class="material-symbols-outlined">group_add</span> Upload
</a>
</div>
Expand Down
23 changes: 1 addition & 22 deletions src/liquid/place/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,7 @@ <h2 class="title is-4">{{contactType.friendly}}</h2>
id="table_places"
class="table is-fullwidth is-striped is-hoverable"
>
<thead>
<tr>
{% for hierarchy in contactType.hierarchy %}
<th id="hierarchy_{{ hierarchy.property_name }}">{{ hierarchy.friendly_name }}</th>
{% endfor %}
{% for property in contactType.place_properties %}
{% if property.type != 'generated' %}
<th id="place_{{property.property_name}}">{{property.friendly_name}}</th>
{% endif %}
{% endfor %}
{% for contact_property in contactType.contact_properties %}
{% if contact_property.type != 'generated' %}
<th id="contact_{{contact_property.property_name}}">{{contact_property.friendly_name}}</th>
{% endif %}
{% endfor %}
{% if contactType.user_role.size > 1 %}
<th id="{{userRoleProperty.property_name}}">{{ contactType.userRoleProperty.friendly_name }}</th>
{% endif %}
<th></th>
<th></th>
</tr>
</thead>
{% include "components/table_header.html" contactType=contactType %}
<tbody>
{% for place in contactType.places %}
<tr>
Expand Down
15 changes: 15 additions & 0 deletions src/liquid/place/list_lazy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div id="place_list" hx-trigger="load" hx-get="/app/list" hx-target="this" hx-swap="outerHTML">
{% for contactType in contactTypes %}
<div id="{{contactType.name}}" class="mb-6">
<h2 class="title is-4">{{contactType.friendly}}</h2>
<div>
<table id="table_places" class="table is-fullwidth is-striped is-hoverable">
freddieptf marked this conversation as resolved.
Show resolved Hide resolved
{% include "components/table_header.html" contactType=contactType %}
</table>
<div class="container p-6 is-flex is-justify-content-center is-align-content-center">
<img src="/public/spinner.gif" alt="Loading data" />
</div>
</div>
{% endfor %}
</div>
</div>
Binary file added src/public/spinner.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions src/routes/add-place.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ export default async function addPlace(fastify: FastifyInstance) {
},
});
}

// back to places list
resp.header('HX-Redirect', `/`);
resp.header('HX-Redirect', '/');
return;
}

Expand Down
Loading
Loading