[FIX] ASSET: Fixed modal issues in the dashboard and assign image not saving when asset is allocated
This commit is contained in:
@@ -311,6 +311,10 @@ class AssetAllocationForm(ModelForm):
|
||||
},
|
||||
),
|
||||
}
|
||||
|
||||
# def clean(self):
|
||||
# cleaned_data = super.clean()
|
||||
|
||||
|
||||
|
||||
class AssetReturnForm(ModelForm):
|
||||
|
||||
@@ -58,7 +58,10 @@ $(document).ready(function() {
|
||||
console.log("Error", error);
|
||||
},
|
||||
});
|
||||
|
||||
// $("#asset_request_view").on("click",function () {
|
||||
// localStorage.setItem("activeTabAsset", "#tab_1");
|
||||
// window.location.replace("/asset/asset-request-allocation-view/?asset_request_status=Requested");
|
||||
// })
|
||||
});
|
||||
|
||||
function emptyAssetAvialabeChart(assetAvailableChartChart,args,options){
|
||||
|
||||
@@ -40,9 +40,11 @@
|
||||
</div>
|
||||
<div class="col-12 col-sm-12 col-md-6 col-lg-4 filter">
|
||||
<div class="oh-card-dashboard oh-card-dashboard--warning"
|
||||
hx-get="{% url 'asset-request-allocation-view-search-filter' %}?asset_request_status=Requested"
|
||||
hx-target="#dashboard"
|
||||
id="candidate_view"
|
||||
{% comment %} hx-get="{% url 'asset-request-allocation-view-search-filter' %}?asset_request_status=Requested"
|
||||
hx-target="#dashboard" {% endcomment %}
|
||||
onclick = 'localStorage.setItem("activeTabAsset", "#tab_1");
|
||||
window.location.href="/asset/asset-request-allocation-view/?asset_request_status=Requested";'
|
||||
id="asset_request_view"
|
||||
>
|
||||
<div class="oh-card-dashboard__header">
|
||||
<span class="oh-card-dashboard__title">{% trans "Asset request" %}</span>
|
||||
@@ -156,6 +158,29 @@
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="oh-modal"
|
||||
id="asset-request-allocation-modal"
|
||||
role="dialog"
|
||||
aria-labelledby="AssetRequestModal"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<div class="oh-modal__dialog oh-modal__dialog-relative" style="max-width: 550px">
|
||||
<div class="oh-modal__dialog-header">
|
||||
<button type="button" class="oh-modal__close" aria-label="Close">
|
||||
<ion-icon name="close-outline"></ion-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- htmx form -->
|
||||
<div
|
||||
class="oh-modal__dialog-body"
|
||||
id="asset-request-allocation-modal-target"
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
<script src="{% static 'src/asset/dashboard.js' %}"></script>
|
||||
{% endblock content %}
|
||||
@@ -1,7 +1,9 @@
|
||||
{% load i18n %}
|
||||
<h5 >{% trans "Asset Approve" %}</h5>
|
||||
<form hx-post="{%url 'asset-request-approve' req_id=id %}">
|
||||
<form hx-post="{%url 'asset-request-approve' req_id=id %}" hx-target="#asset-request-allocation-modal-target" hx-encoding="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{asset_allocation_form.non_field_errors}}
|
||||
{{asset_allocation_form.errors}}
|
||||
<div class=" m-3">
|
||||
<div class="oh-input__group ">
|
||||
<label class="oh-input__label" for="objective">{% trans "Asset" %}</label>
|
||||
|
||||
@@ -567,13 +567,18 @@ def asset_request_approve(request, req_id):
|
||||
# Add additional fields to the dictionary
|
||||
post_data["assigned_to_employee_id"] = asset_request.requested_employee_id
|
||||
post_data["assigned_by_employee_id"] = request.user.employee_get
|
||||
form = AssetAllocationForm(post_data)
|
||||
form = AssetAllocationForm(post_data,request.FILES)
|
||||
print("------------------------------------")
|
||||
print(post_data)
|
||||
print("------------------------------------")
|
||||
if form.is_valid():
|
||||
asset = form.instance.asset_id.id
|
||||
asset = Asset.objects.filter(id=asset).first()
|
||||
asset.asset_status = "In use"
|
||||
asset.save()
|
||||
form = form.save()
|
||||
form = form.save(commit=False)
|
||||
form.assigned_by_employee_id = request.user.employee_get
|
||||
form.save()
|
||||
asset_request.asset_request_status = "Approved"
|
||||
asset_request.save()
|
||||
messages.success(request, _("Asset request approved successfully!."))
|
||||
|
||||
Reference in New Issue
Block a user