[UPDT] ASSET: Updated asset report adding form and submit js function
This commit is contained in:
@@ -1,34 +1,22 @@
|
||||
{% load i18n %}
|
||||
{% if messages %}
|
||||
<div class="oh-wrapper">
|
||||
{% for message in messages %}
|
||||
<div class="oh-alert-container">
|
||||
<div class="oh-alert oh-alert--animated {{ message.tags }}">{{ message }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<script>
|
||||
{% if requests_ids %}
|
||||
setTimeout(function () {
|
||||
$('.oh-modal__close--custom').click()
|
||||
}, 1000);
|
||||
{% else %}
|
||||
setTimeout(function () {
|
||||
$('.oh-modal__close').click()
|
||||
}, 1000);
|
||||
{% endif %}
|
||||
</script>
|
||||
</div>
|
||||
<script>
|
||||
setTimeout(function () {
|
||||
$('#dynamicCreateModalHeader').children(".oh-modal__close--custom").click();
|
||||
reloadMessage();
|
||||
}, 500);
|
||||
</script>
|
||||
{% endif %}
|
||||
<div class="oh-modal__dialog-header">
|
||||
<div class="oh-modal__dialog-header" id="dynamicCreateModalHeader">
|
||||
<h2 class="oh-modal__dialog-title" id="addAssetReportLabel">{% trans 'Add Asset Report' %}</h2>
|
||||
<button type="button" class="oh-modal_close--custom"
|
||||
<button type="button" class="oh-modal__close--custom"
|
||||
onclick="$(this).closest('.oh-modal--show').removeClass('oh-modal--show');"><ion-icon name="close-outline"
|
||||
role="img" aria-label="close outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
<div class="oh-modal__dialog-body">
|
||||
<form id="add-form" hx-post="{% url 'add-asset-report' %}" hx-target="#dynamicCreateModalTarget"
|
||||
hx-encoding="multipart/form-data" onsubmit="return handleFormSubmit();">
|
||||
hx-encoding="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
<input type="text" hidden name="asset_id" value="{{ asset_id }}" />
|
||||
<div class="oh-profile-section pt-0">
|
||||
@@ -57,9 +45,9 @@
|
||||
<input name="file" multiple="True" type="file" id="fileUpload" />
|
||||
</div>
|
||||
<div class="oh-modal__dialog-footer p-0">
|
||||
<input type="submit" value="{% trans 'Save' %}"
|
||||
class="oh-btn oh-btn--secondary oh-btn--shadow pl-5 pr-5"
|
||||
onclick="$('.oh-modal_close--custom').click()" />
|
||||
<button type="submit" class="oh-btn oh-btn--secondary oh-btn--shadow">
|
||||
{% trans "Save" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -209,21 +209,18 @@
|
||||
<button type="submit" class="oh-btn oh-btn--secondary oh-btn--shadow">
|
||||
{% trans "Save" %}
|
||||
</button>
|
||||
{% if asset_form.instance.assetassignment_set.all %}
|
||||
<button class=" oh-btn oh-btn--info oh-btn--shadow mr-2" data-toggle="oh-modal-toggle"
|
||||
data-target="#dynamicCreateModal" onclick="event.preventDefault();event.stopPropagation()"
|
||||
hx-get="{% url 'add-asset-report' asset_form.instance.id %}?asset_list=true"
|
||||
hx-target="#dynamicCreateModalTarget">
|
||||
{% trans "Add Report" %}
|
||||
</button>
|
||||
{% else %}
|
||||
<button class=" oh-btn oh-btn--info oh-btn--shadow mr-2" disabled
|
||||
onclick="event.preventDefault();event.stopPropagation()" data-toggle="oh-modal-toggle"
|
||||
data-target="#dynamicCreateModal" hx-get="{% url 'add-asset-report' asset_form.instance.id %}?asset_list=true"
|
||||
hx-target="#dynamicCreateModalTarget">
|
||||
{% trans "Add Report" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
<button class="oh-btn oh-btn--info oh-btn--shadow mr-2"
|
||||
data-toggle="oh-modal-toggle"
|
||||
data-target="#dynamicCreateModal"
|
||||
onclick="event.preventDefault();event.stopPropagation()"
|
||||
hx-get="{% url 'add-asset-report' asset_form.instance.id %}?asset_list=true"
|
||||
hx-target="#dynamicCreateModalTarget"
|
||||
{% if not asset_form.instance.assetassignment_set.all %}
|
||||
disabled
|
||||
title="{% trans 'Assign asset before adding a report' %}"
|
||||
{% endif %}>
|
||||
{% trans "Add Report" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -236,15 +233,4 @@
|
||||
})
|
||||
})
|
||||
$("#id_expiry_date").change()
|
||||
|
||||
function handleFormSubmit() {
|
||||
|
||||
$('#successMessage').show();
|
||||
|
||||
setTimeout(function () {
|
||||
$('#successMessage').hide();
|
||||
}, 3000);
|
||||
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -3,109 +3,103 @@
|
||||
{% load basefilters %}
|
||||
{% include 'filter_tags.html' %}
|
||||
{% if asset_assignments %}
|
||||
<div class="oh-table_sticky--wrapper" id="historyTable">
|
||||
<div class="oh-sticky-dropdown--header">
|
||||
<div class="oh-dropdown" x-data="{open: false}">
|
||||
<button class="oh-sticky-dropdown_btn " @click="open = !open"><ion-icon name="ellipsis-vertical-sharp"
|
||||
role="img" class="md hydrated" aria-label="ellipsis vertical sharp"></ion-icon></button>
|
||||
<div class="oh-dropdown__menu oh-sticky-table_dropdown" x-show="open" @click.outside="open = false">
|
||||
<ul class="oh-dropdown__items" id="asset_history_button">
|
||||
</ul>
|
||||
<div class="oh-table_sticky--wrapper">
|
||||
<div class="oh-sticky-dropdown--header">
|
||||
<div class="oh-dropdown" x-data="{open: false}">
|
||||
<button class="oh-sticky-dropdown_btn " @click="open = !open"><ion-icon name="ellipsis-vertical-sharp"
|
||||
role="img" class="md hydrated" aria-label="ellipsis vertical sharp"></ion-icon></button>
|
||||
<div class="oh-dropdown__menu oh-sticky-table_dropdown" x-show="open" @click.outside="open = false">
|
||||
<ul class="oh-dropdown__items" id="asset_history_button">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id='asset-table' data-table-name="asset_history_table">
|
||||
<div class="oh-sticky-table">
|
||||
<div class="oh-sticky-table__table">
|
||||
<div class="oh-sticky-table__thead" >
|
||||
<div class="oh-sticky-table__tr">
|
||||
<div data-cell-index="1" data-cell-title="{% trans "Asset" %}" class="oh-sticky-table__th {% if request.sort_option.order == '-asset_id__asset_name' %}arrow-up {% elif request.sort_option.order == 'asset_id__asset_name' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'asset-history-search' %}?{{pd}}&sortby=asset_id__asset_name" hx-target="#historyTable">{% trans "Asset" %}</div>
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-assigned_to_employee_id__employee_first_name' %}arrow-up {% elif request.sort_option.order == 'assigned_to_employee_id__employee_first_name' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'asset-history-search' %}?{{pd}}&sortby=assigned_to_employee_id__employee_first_name" hx-target="#historyTable">{% trans "Employee" %}</div>
|
||||
<div data-cell-index="2" data-cell-title="{% trans "Assigned Date" %}" class="oh-sticky-table__th {% if request.sort_option.order == '-assigned_date' %}arrow-up {% elif request.sort_option.order == 'assigned_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'asset-history-search' %}?{{pd}}&sortby=assigned_date" hx-target="#historyTable">{% trans "Assigned Date" %}</div>
|
||||
<div data-cell-index="3" data-cell-title="{% trans "Returned date" %}" class="oh-sticky-table__th {% if request.sort_option.order == '-return_date' %}arrow-up {% elif request.sort_option.order == 'return_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'asset-history-search' %}?{{pd}}&sortby=return_date" hx-target="#historyTable">{% trans "Returned Date" %}</div>
|
||||
<div class="oh-sticky-table__th">{% trans "Return Status" %}</div>
|
||||
<div id='asset-table' data-table-name="asset_history_table">
|
||||
<div class="oh-sticky-table">
|
||||
<div class="oh-sticky-table__table">
|
||||
<div class="oh-sticky-table__thead" >
|
||||
<div class="oh-sticky-table__tr">
|
||||
<div data-cell-index="1" data-cell-title="{% trans 'Asset' %}" class="oh-sticky-table__th {% if request.sort_option.order == '-asset_id__asset_name' %}arrow-up {% elif request.sort_option.order == 'asset_id__asset_name' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'asset-history-search' %}?{{pd}}&sortby=asset_id__asset_name" hx-target="#historyTable">{% trans "Asset" %}</div>
|
||||
<div class="oh-sticky-table__th {% if request.sort_option.order == '-assigned_to_employee_id__employee_first_name' %}arrow-up {% elif request.sort_option.order == 'assigned_to_employee_id__employee_first_name' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'asset-history-search' %}?{{pd}}&sortby=assigned_to_employee_id__employee_first_name" hx-target="#historyTable">{% trans "Employee" %}</div>
|
||||
<div data-cell-index="2" data-cell-title="{% trans 'Assigned Date' %}" class="oh-sticky-table__th {% if request.sort_option.order == '-assigned_date' %}arrow-up {% elif request.sort_option.order == 'assigned_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'asset-history-search' %}?{{pd}}&sortby=assigned_date" hx-target="#historyTable">{% trans "Assigned Date" %}</div>
|
||||
<div data-cell-index="3" data-cell-title="{% trans 'Returned date' %}" class="oh-sticky-table__th {% if request.sort_option.order == '-return_date' %}arrow-up {% elif request.sort_option.order == 'return_date' %}arrow-down {% else %}arrow-up-down {% endif %}" hx-get="{% url 'asset-history-search' %}?{{pd}}&sortby=return_date" hx-target="#historyTable">{% trans "Returned Date" %}</div>
|
||||
<div class="oh-sticky-table__th">{% trans "Return Status" %}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table__tbody">
|
||||
{% for asset_assignement in asset_assignments %}
|
||||
<div class="oh-sticky-table__tr" hx-get="{% url 'asset-history-single-view' asset_assignement.id %}?requests_ids={{requests_ids}}" hx-target="#objectDetailsModalTarget" data-toggle="oh-modal-toggle", data-target= "#objectDetailsModal">
|
||||
<div class="oh-sticky-table__sd" data-cell-index="1">
|
||||
<div class="oh-profile oh-profile--md">
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img
|
||||
src="https://ui-avatars.com/api/?name={{asset_assignement.asset_id.asset_name}}&background=random"
|
||||
class="oh-profile__image"
|
||||
alt=""
|
||||
/>
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark">{{asset_assignement.asset_id}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table__td">
|
||||
{{asset_assignement.assigned_to_employee_id}}
|
||||
</div>
|
||||
<div class="oh-sticky-table__td dateformat_changer" data-cell-index="2">{{asset_assignement.assigned_date}} </div>
|
||||
<div class="oh-sticky-table__td dateformat_changer" data-cell-index="3">{{asset_assignement.return_date}}</div>
|
||||
<div class="oh-sticky-table__td">{{asset_assignement.return_status}}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table__tbody">
|
||||
{% for asset_assignement in asset_assignments %}
|
||||
<div class="oh-sticky-table__tr" hx-get="{% url 'asset-history-single-view' asset_assignement.id %}?requests_ids={{requests_ids}}" hx-target="#objectDetailsModalTarget" data-toggle="oh-modal-toggle", data-target= "#objectDetailsModal">
|
||||
<div class="oh-sticky-table__sd" data-cell-index="1">
|
||||
<div class="oh-profile oh-profile--md">
|
||||
<div class="oh-profile__avatar mr-1">
|
||||
<img
|
||||
src="https://ui-avatars.com/api/?name={{asset_assignement.asset_id.asset_name}}&background=random"
|
||||
class="oh-profile__image"
|
||||
alt=""
|
||||
/>
|
||||
</div>
|
||||
<span class="oh-profile__name oh-text--dark">{{asset_assignement.asset_id}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-sticky-table__td">
|
||||
{{asset_assignement.assigned_to_employee_id}}
|
||||
</div>
|
||||
<div class="oh-sticky-table__td dateformat_changer" data-cell-index="2">{{asset_assignement.assigned_date}} </div>
|
||||
<div class="oh-sticky-table__td dateformat_changer" data-cell-index="3">{{asset_assignement.return_date}}</div>
|
||||
<div class="oh-sticky-table__td">{{asset_assignement.return_status}}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-pagination">
|
||||
<span class="oh-pagination__page">
|
||||
{% trans "Page" %} {{ asset_assignments.number }} {% trans "of" %} {{ asset_assignments.paginator.num_pages }}.
|
||||
</span>
|
||||
<nav class="oh-pagination__nav">
|
||||
<div class="oh-pagination__input-container me-3">
|
||||
<span class="oh-pagination__label me-1">{% trans "Page" %}</span>
|
||||
<input
|
||||
type="number"
|
||||
name="page"
|
||||
class="oh-pagination__input"
|
||||
value="{{asset_assignments.number}}"
|
||||
hx-get="{% url 'asset-history-search' %}?{{pd}}"
|
||||
hx-target="#historyTable"
|
||||
min="1"
|
||||
/>
|
||||
<span class="oh-pagination__label">{% trans "of" %} {{asset_assignments.paginator.num_pages}}</span>
|
||||
</div>
|
||||
<ul class="oh-pagination__items">
|
||||
{% if asset_assignments.has_previous %}
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a hx-target='#historyTable' hx-get="{% url 'asset-history-search' %}?{{pd}}&page=1" class="oh-pagination__link" onclick="tickCheckboxes();">{% trans "First" %}</a>
|
||||
</li>
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a hx-target='#historyTable' hx-get="{% url 'asset-history-search' %}?{{pd}}&page={{ asset_assignments.previous_page_number }}" class="oh-pagination__link" onclick="tickCheckboxes();">{% trans "Previous" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if asset_assignments.has_next %}
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a hx-target='#historyTable' hx-get="{% url 'asset-history-search' %}?{{pd}}&page={{ asset_assignments.next_page_number }}" class="oh-pagination__link" onclick="tickCheckboxes();">{% trans "Next" %}</a>
|
||||
</li>
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a hx-target='#historyTable' hx-get="{% url 'asset-history-search' %}?{{pd}}&page={{ asset_assignments.paginator.num_pages }}" class="oh-pagination__link" onclick="tickCheckboxes();">{% trans "Last" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oh-pagination">
|
||||
<span class="oh-pagination__page">
|
||||
{% trans "Page" %} {{ asset_assignments.number }} {% trans "of" %} {{ asset_assignments.paginator.num_pages }}.
|
||||
</span>
|
||||
<nav class="oh-pagination__nav">
|
||||
<div class="oh-pagination__input-container me-3">
|
||||
<span class="oh-pagination__label me-1">{% trans "Page" %}</span>
|
||||
<input
|
||||
type="number"
|
||||
name="page"
|
||||
class="oh-pagination__input"
|
||||
value="{{asset_assignments.number}}"
|
||||
hx-get="{% url 'asset-history-search' %}?{{pd}}"
|
||||
hx-target="#historyTable"
|
||||
min="1"
|
||||
/>
|
||||
<span class="oh-pagination__label">{% trans "of" %} {{asset_assignments.paginator.num_pages}}</span>
|
||||
</div>
|
||||
<ul class="oh-pagination__items">
|
||||
{% if asset_assignments.has_previous %}
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a hx-target='#historyTable' hx-get="{% url 'asset-history-search' %}?{{pd}}&page=1" class="oh-pagination__link" onclick="tickCheckboxes();">{% trans "First" %}</a>
|
||||
</li>
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a hx-target='#historyTable' hx-get="{% url 'asset-history-search' %}?{{pd}}&page={{ asset_assignments.previous_page_number }}" class="oh-pagination__link" onclick="tickCheckboxes();">{% trans "Previous" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if asset_assignments.has_next %}
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a hx-target='#historyTable' hx-get="{% url 'asset-history-search' %}?{{pd}}&page={{ asset_assignments.next_page_number }}" class="oh-pagination__link" onclick="tickCheckboxes();">{% trans "Next" %}</a>
|
||||
</li>
|
||||
<li class="oh-pagination__item oh-pagination__item--wide">
|
||||
<a hx-target='#historyTable' hx-get="{% url 'asset-history-search' %}?{{pd}}&page={{ asset_assignments.paginator.num_pages }}" class="oh-pagination__link" onclick="tickCheckboxes();">{% trans "Last" %}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<!-- start of empty page -->
|
||||
<div style="display: flex; flex-direction: column; justify-content: center; align-items: center; height: 100%;" >
|
||||
<img
|
||||
style="width: 150px; height: 150px"
|
||||
src="{% static 'images/ui/no-results.png' %}"
|
||||
class="oh-404__image mb-4"
|
||||
/>
|
||||
<h5 class="oh-404__subtitle">
|
||||
{% trans "No result found!" %}
|
||||
</h5>
|
||||
</div>
|
||||
<!-- end of empty page -->
|
||||
<!-- start of empty page -->
|
||||
<div class="oh-empty">
|
||||
<img src="{% static 'images/ui/search.svg' %}" class="oh-404__image" alt="Page not found. 404." />
|
||||
<h1 class="oh-empty__title">{% trans "No Records found." %}</h1>
|
||||
<p class="oh-empty__subtitle">{% trans "No asset history available." %}</p>
|
||||
</div>
|
||||
<!-- end of empty page -->
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
{% trans "Selected Assets" %}
|
||||
</div>
|
||||
|
||||
<div class="oh-wrapper">
|
||||
<div class="oh-wrapper" id="historyTable">
|
||||
{% include 'asset_history/asset_history_list.html' %}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -224,18 +224,6 @@
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
<script>
|
||||
function handleFormSubmit() {
|
||||
|
||||
$('#successMessage').show();
|
||||
|
||||
setTimeout(function () {
|
||||
$('#successMessage').hide();
|
||||
}, 3000);
|
||||
|
||||
return false; // Prevent the default form submission
|
||||
}
|
||||
</script>
|
||||
<script src="{% static '/base/filter.js' %}"></script>
|
||||
<script src="{% static 'src/asset_category/assetCategoryView.js' %}"></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -299,16 +299,6 @@
|
||||
});
|
||||
});
|
||||
});
|
||||
function handleFormSubmit() {
|
||||
|
||||
$('#successMessage').show();
|
||||
|
||||
setTimeout(function() {
|
||||
$('#successMessage').hide();
|
||||
}, 3000);
|
||||
|
||||
return false; // Prevent the default form submission
|
||||
}
|
||||
</script>
|
||||
<script src="{% static '/base/filter.js' %}"></script>
|
||||
|
||||
|
||||
@@ -162,9 +162,6 @@ def add_asset_report(request, asset_id=None):
|
||||
for file in request.FILES.getlist("file"):
|
||||
AssetDocuments.objects.create(asset_report=asset_report, file=file)
|
||||
|
||||
return HttpResponseRedirect(request.META.get("HTTP_REFERER", "/"))
|
||||
# return HttpResponse("<script>window.location.reload()</script>")
|
||||
|
||||
return render(
|
||||
request,
|
||||
"asset/asset_report_form.html",
|
||||
|
||||
@@ -422,18 +422,6 @@
|
||||
if (!localStorage.getItem("employee_tab")) {
|
||||
$("#fieldContainerTable").find("[type=checkbox]").prop("checked", true).change()
|
||||
}
|
||||
|
||||
function handleFormSubmit() {
|
||||
|
||||
$('#successMessage').show();
|
||||
|
||||
setTimeout(function () {
|
||||
$('#successMessage').hide();
|
||||
}, 3000);
|
||||
|
||||
return false; // Prevent the default form submission
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function submitForm(elem) {
|
||||
|
||||
Reference in New Issue
Block a user