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

UI improvements - forms #172

Open
wants to merge 10 commits into
base: 131-main-ui
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
30 changes: 22 additions & 8 deletions src/css/custom-bootstrap.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
/*!
* Generated using the Bootstrap Customizer (https://getbootstrap.com/docs/3.4/customize/)
*/
/*!
*/ /*!
* Bootstrap v3.4.1 (https://getbootstrap.com/)
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */

.badge {
*/ /*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
.badge {
display: inline-block;
min-width: 10px;
padding: 3px 7px;
Expand Down Expand Up @@ -54,7 +51,6 @@ a.badge:focus {
.nav-pills > li > a > .badge {
margin-left: 3px;
}

.tooltip {
position: absolute;
z-index: 1070;
Expand Down Expand Up @@ -168,4 +164,22 @@ a.badge:focus {
height: 0;
border-color: transparent;
border-style: solid;
}
}
.breadcrumb {
padding: 8px 15px;
margin-bottom: 20px;
list-style: none;
background-color: #f5f5f5;
border-radius: 4px;
}
.breadcrumb > li {
display: inline-block;
}
.breadcrumb > li + li:before {
padding: 0 5px;
color: inherit;
content: ">";
}
.breadcrumb > .active {
color: #777777;
}
14 changes: 5 additions & 9 deletions src/liquid/app/form_switch.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
{% capture header_caption %}
{% if op == "bulk" %} Bulk Load from CSV
{% elsif op == "replace"%} Replace Existing
{% elsif op == "move"%} Move
{% elsif op == "move"%} Move
{% elsif op == "edit" %} Edit
{% else %} New
{% endif %}
{% endcapture %}

<section class="hero is-small">
<div class="hero-body">
<p class="title">
{{header_caption}} {{contactType.contact_friendly | default: contactType.friendly }}
</p>
</div>
</section>

<h3 class="form-title">
{{header_caption}} {{contactType.contact_friendly | default: contactType.friendly }}
</h3>

{% if op == "bulk" %}
{% include "place/bulk_create_form.html" %}
Expand Down
2 changes: 1 addition & 1 deletion src/liquid/app/fragment_edit.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div id="place_form_parent" class="tile is-6 is-child pt-3">
<div id="place_form_parent">
{% include "place/create_form.html" %}
</div>
14 changes: 12 additions & 2 deletions src/liquid/app/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
<title>CHT User Management Tool</title>
<script src="/public/scripts/htmx.min.js"></script>
<script src="/public/scripts/sse.js"></script>
<script src="/public/scripts/bulma-calendar.min.js"></script>
<script src="/public/scripts/jquery-3.7.1.slim.min.js"></script>
<script src="/public/scripts/bootstrap.min.js"></script>
<script src="/public/scripts/datepicker.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/public/css/custom-bootstrap.min.css" />
<link rel="stylesheet" href="/public/css/styles.css" />
<link rel="stylesheet" href="/public/css/datepicker.min.css" />
</head>

<body>
Expand All @@ -31,4 +32,13 @@
</div>
</body>

</html>
</html>

<script>
function clearErrorMsg(elementID) {
const errMsg = document.getElementById(elementID);
if (errMsg){
errMsg.style.display = 'none';
}
}
</script>
2 changes: 1 addition & 1 deletion src/liquid/components/actions.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<div class="bottom" id="action_buttons_{{include.contactType.name}}">
{% if directiveModel.validationErrorCount > 0 or directiveModel.totalCount == 0 %}
<div data-toggle="tooltip" title="Fix invalid users">
<button class="clear-btn disabled" hx-post="/app/apply-changes?type={{ include.contactType.name }}" hx-swap="none"
<button class="clear-btn" hx-post="/app/apply-changes?type={{ include.contactType.name }}" hx-swap="none"
disabled>
<img src="/public/icons/upload-users.svg"> Upload All
</button>
Expand Down
32 changes: 22 additions & 10 deletions src/liquid/components/contact_type_dob.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
<div class="control">
<input
name="{{ include.prop_name }}"
{% if include.isInYears %} type="text" {%else%} type="date" {%endif%}
class="input"
<div>
<input
{% if include.isInYears %} type="number" min="0" max="120" {%else%} type="date-picker" readonly {%endif%}
name="{{ include.prop_name }}"
{% if data[include.prop_name] %} value="{{ data[include.prop_name] }}" {% endif %}
/>
</div>

<div class="field">
<div class="control">
<div class="check-box">
<input
type="checkbox"
name="option_dob_unknown"
Expand All @@ -18,4 +14,20 @@
/>
<label>Date of birth unknown</label>
</div>
</div>
</div>

<script>
/* vanillajs-datepicker */
var datePickerInput = document.querySelector('input[type="date-picker"]');
if (datePickerInput){
var datePicker = new Datepicker(datePickerInput, {
autohide: true,
clearButton: true,
enableOnReadonly: true,
format: 'yyyy-mm-dd',
maxDate: new Date(),
minDate: '1920',
showOnFocus: true
});
}
</script>
9 changes: 4 additions & 5 deletions src/liquid/components/contact_type_property.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{% if include.prop.type != 'generated' %}
{% capture prop_name %}{{ include.prefix }}{{include.prop.property_name}}{% endcapture %}

<div id="div_{{ include.prefix }}{{include.prop.property_name}}" class="field">
<label class="label">
{% if data['option_dob_unknown'] %}
<div id="div_{{ include.prefix }}{{include.prop.property_name}}">
<label>
{% if data['option_dob_unknown'] and include.prop.property_name == 'date_of_birth' %}
Age in Years
{%else%}
{{include.prop.friendly_name}}
Expand All @@ -20,7 +20,7 @@
data=data
%}
{% else %}
<div class="control">
<div>
{% if include.prop.type == 'select_one' or include.prop.type == 'select_multiple' %}
{%
include "components/contact_type_select.html"
Expand All @@ -32,7 +32,6 @@
<input
name="{{ prop_name }}"
type="{% if include.prop.type == 'dob' %}date{% else %}text{% endif %}"
class="input"
{% if false and include.prop.type == 'regex' %} pattern="{{ include.prop.parameter }}" {% endif %}
{% if data[prop_name] %} value="{{ data[prop_name] }}" {% endif %}
/>
Expand Down
3 changes: 1 addition & 2 deletions src/liquid/components/filter_tag.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

{%elsif include.count == 0 %}
<button class="badge tag
{% if not directiveModel.filter %} {{ include.class }} {%endif %}
disabled" disabled>
{% if not directiveModel.filter %} {{ include.class }} {%endif %}" disabled>
{{ include.count }} {{ include.filterName }}
</button>
{% else %}
Expand Down
64 changes: 31 additions & 33 deletions src/liquid/components/move_result.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
<nav class="breadcrumb has-succeeds-separator" aria-label="breadcrumbs">
<ul>
<li><span class="tag is-warning" style="margin: 0 10px;">Current</span></li>
{% for lineage in fromLineage %}
{% if lineage %}
<li><a href="https://{{ session.authInfo.domain }}/#/contacts/{{ lineage.id}}">{{ lineage.name }}</a></li>
{% endif %}
{% endfor %}
</ul>
<ul>
<li><span class="tag is-success" style="margin: 0 10px;">After</span></li>
{% for lineage in toLineage %}
{% if lineage %}
<li><a href="https://{{ session.authInfo.domain }}/#/contacts/{{ lineage.id}}">{{ lineage.name }}</a></li>
{% endif %}
{% endfor %}
<li><span style="margin: 0 10px;">{{ fromLineage.last.name }}</span></li>
</ul>
</nav>
<div class="directive">
<a href="/" class="close-btn"><img src="/public/icons/delete-all.svg" alt="close"></a>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="tag badge warning-bg">Current</li>
{% for lineage in fromLineage %}
{% if lineage %}
<li class="breadcrumb-item"><a href="https://{{ session.authInfo.domain }}/#/contacts/{{ lineage.id}}">
{{ lineage.name }}</a></li>
{% endif %}
{% endfor %}
</ol>
<ol class="breadcrumb">
<li class="tag badge success-bg">After</li>
{% for lineage in toLineage %}
{% if lineage %}
<li class="breadcrumb-item"><a href="https://{{ session.authInfo.domain }}/#/contacts/{{ lineage.id}}">
{{ lineage.name }}
</a></li>
{% endif %}
{% endfor %}
<li class="breadcrumb-item" active>{{ fromLineage.last.name }}</li>
</ol>
</nav>

<section class="hero {% if isError %}is-danger{% else %}is-info{% endif %}">
<div class="hero-body">
<div>
<button
class="button is-right"
style="float: right;"
onclick="navigator.clipboard.writeText(`{{ command }}`);"
>
<span class="material-symbols-outlined">content_copy</span>
</button>
{{ command }}
</div>
</div>
</section>
<pre class="{% if isError %}error-bg{% endif %}">
<button class="clear-btn" onclick="navigator.clipboard.writeText(`{{ command }}`);">
<span>copy content</span>
</button>
{{ command }}
</pre>
</div>
7 changes: 3 additions & 4 deletions src/liquid/components/search_input.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{% capture property_name %}{{ include.prefix | default: 'place_' }}{{ include.hierarchy.property_name }}{% endcapture %}
<div class="field">
<div>
<label class="label">
{{ include.hierarchy.friendly_name }}
{% if include.hierarchy.required %}*{% endif %}
</label>
<div class="control">
<div>
<input
id="{{ property_name }}"
name="{{ property_name }}"
type="search"
class="input"
hx-post="/search?place_id={{place.id}}&type={{ include.type }}&op={{op}}&level={{ include.hierarchy.level }}&prefix={{ include.prefix }}"
hx-vals=""
placeholder="start typing to see suggestions"
Expand All @@ -19,6 +18,6 @@
{% if include.data[property_name] %}value="{{ include.data[property_name] }}" {% endif %}
hx-encoding="application/x-www-form-urlencoded"
/>
<div id="search_results_{{ property_name }}" class="control"></div>
<div id="search_results_{{ property_name }}"></div>
</div>
</div>
29 changes: 11 additions & 18 deletions src/liquid/components/search_results.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
<div class="dropdown is-active">
<div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content">
{% for searchResult in searchResults %}
<a
class="dropdown-item"
hx-post="/search/select?place_id={{place.id}}&result_name={{searchResult.name}}&level={{level}}&op={{op}}&prefix={{ prefix }}"
hx-target="#place_form_parent"
hx-encoding="application/x-www-form-urlencoded"
>
{% if searchResult.type == 'local' %}
<span class="material-symbols-outlined">cloud_off</span>
{% endif %}
{{searchResult.name}}
</a>
{% endfor %}
</div>
</div>
<div class="autocomplete-dropdown" id="dropdown-menu" role="menu">
{% for searchResult in searchResults %}
<a class="dropdown-item"
hx-post="/search/select?place_id={{place.id}}&result_name={{searchResult.name}}&level={{level}}&op={{op}}&prefix={{ prefix }}"
hx-target="#place_form_parent" hx-encoding="application/x-www-form-urlencoded">
{% if searchResult.type == 'local' %}
<span>cloud_off</span>
{% endif %}
{{searchResult.name}}
</a>
{% endfor %}
</div>
Loading
Loading