mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-03-14 07:55:58 +00:00
Initial bootstrap port of asset_update
This commit is contained in:
@@ -4,9 +4,10 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h2 class="text-center">Asset List</h2>
|
||||
<div class="page-header">
|
||||
<h1 class="text-center">Asset List</h1>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
<form method="post" id="asset-filter-form">
|
||||
{% csrf_token %}
|
||||
<div class="input-group">
|
||||
@@ -15,7 +16,6 @@
|
||||
<span class="input-group-btn"><button type="submit" class="btn">Search</button></span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h4>
|
||||
<div class="page-header">
|
||||
<h1>
|
||||
{% if edit and object %}
|
||||
Edit Asset | {{ object.asset_id }}
|
||||
{% elif duplicate %}
|
||||
@@ -17,8 +18,8 @@
|
||||
Asset | {{ object.asset_id }}
|
||||
{% endif %}
|
||||
|
||||
</h4>
|
||||
<div class="divider"></div>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
@@ -26,88 +27,56 @@
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="id" value="{{ object.id|default:0 }}">
|
||||
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<div class="button-group right">
|
||||
{% if edit and object %}
|
||||
<!--edit-->
|
||||
<button type="button" class="btn" onclick="updateAsset()">Save</button>
|
||||
<a class="waves-effect waves-light btn" href="{% url 'asset_update' object.pk %}?duplicate=true">Duplicate</a>
|
||||
<a class="waves-effect waves-light btn modal-trigger" href="#confirm_delete_modal">Delete</a>
|
||||
{% elif duplicate %}
|
||||
<!--duplicate-->
|
||||
<button type="button" class="btn" onclick="updateAsset()">Create Duplicate</button>
|
||||
<a href="{% url 'asset_detail' previous_asset_pk %}" class="btn">Cancel</a>
|
||||
{% elif not object %}
|
||||
<!--create-->
|
||||
<button type="button" class="btn" onclick="updateAsset()">Save</button>
|
||||
{% else %}
|
||||
<!--detail-->
|
||||
<a href="{% url 'asset_update' object.pk %}" class="btn">Edit</a>
|
||||
<a class="waves-effect waves-light btn" href="{% url 'asset_update' object.pk %}?duplicate=true">Duplicate</a>
|
||||
<a class="waves-effect waves-light btn modal-trigger" href="#confirm_delete_modal">Delete</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="panel">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Asset Details
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
{% if edit or duplicate %}
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
{% if duplicate %}
|
||||
{% render_field form.asset_id value=object.asset_id %}
|
||||
{% elif object.asset_id %}
|
||||
{% render_field form.asset_id|attr:'readonly'|add_class:'disabled_input' value=object.asset_id %}
|
||||
{% else %}
|
||||
{% render_field form.asset_id %}
|
||||
{% endif %}
|
||||
<div class="form-group">
|
||||
<label for="{{ form.asset_id.id_for_label }}" class="bold-text">Asset ID</label>
|
||||
{% if edit or duplicate %}
|
||||
{% if duplicate %}
|
||||
{% render_field form.asset_id|add_class:'form-control' value=object.asset_id %}
|
||||
{% elif object.asset_id %}
|
||||
{% render_field form.asset_id|attr:'readonly'|add_class:'disabled_input form-control' value=object.asset_id %}
|
||||
{% else %}
|
||||
{% render_field form.asset_id|add_class:'form-control' %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="input-field col s12">
|
||||
{% render_field form.description value=object.description %}
|
||||
<div class="form-group">
|
||||
<label for="{{ form.description.id_for_label }}"
|
||||
class="bold-text">Description</label>
|
||||
{% render_field form.description|add_class:'form-control' value=object.description %}
|
||||
</div>
|
||||
|
||||
<div class="input-field col s12">
|
||||
<div class="form-group">
|
||||
<label for="{{ form.category.id_for_label }}" class="bold-text">Category</label>
|
||||
<select name="{{ form.category.name }}" id="{{ form.category.id_for_label }}"
|
||||
required>
|
||||
required class="form-control">
|
||||
{% for id, choice in form.category.field.choices %}
|
||||
<option value="{{ id }}"
|
||||
{% if object.category.id == id %}selected{% endif %}>{{ choice }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label for="{{ form.category.id_for_label }}" class="bold-text">Category</label>
|
||||
</div>
|
||||
|
||||
<div class="input-field col s12">
|
||||
<select name="{{ form.status.name }}" id="{{ form.status.id_for_label }}" required>
|
||||
<div class="form-group">
|
||||
<label for="{{ form.status.id_for_label }}" class="bold-text">Status</label>
|
||||
<select class="form-control" name="{{ form.status.name }}" id="{{ form.status.id_for_label }}" required>
|
||||
{% for id, choice in form.status.field.choices %}
|
||||
<option value="{{ id }}"
|
||||
{% if not object.status.id and choice == "Active" or object.status.id == id %}selected{% endif %}>{{ choice }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label for="{{ form.status.id_for_label }}" class="bold-text">Status</label>
|
||||
</div>
|
||||
|
||||
<div class="input-field col s12">
|
||||
{% render_field form.serial_number value=object.serial_number %}
|
||||
<div class="form-group">
|
||||
<label for="{{ form.serial_number.id_for_label }}">Serial Number</label>
|
||||
{% render_field form.serial_number|add_class:'form-control' value=object.serial_number %}
|
||||
</div>
|
||||
|
||||
<div class="input-field col s12">
|
||||
{% render_field form.comments|add_class:'materialize-textarea' %}
|
||||
<!---TODO: Lower default number of lines in comments box--->
|
||||
<div class="form-group">
|
||||
<label for="{{ form.comments.id_for_label }}">Comments</label>
|
||||
{% render_field form.comments|add_class:'form-control' %}
|
||||
</div>
|
||||
|
||||
{% else %}
|
||||
<dt>Asset ID</dt>
|
||||
<dd>{{ object.asset_id }}</dd>
|
||||
@@ -127,56 +96,58 @@
|
||||
<dt>Comments</dt>
|
||||
<dd>{{ object.comments|default:'-'|linebreaksbr }}</dd>
|
||||
{% endif %}
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="panel">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Purchase Details
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
{% if edit or duplicate %}
|
||||
<div class="row">
|
||||
<div class="input-field col s12">
|
||||
<select name="{{ form.purchased_from.name }}"
|
||||
|
||||
<div class="form-group">
|
||||
<label for="{{ form.purchased_from.id_for_label }}">Purchased From</label>
|
||||
<select class="form-control" name="{{ form.purchased_from.name }}"
|
||||
id="{{ form.purchased_from.id_for_label }}">
|
||||
{% for id, choice in form.purchased_from.field.choices %}
|
||||
<option value="{{ id }}"
|
||||
{% if object.purchased_from.id == id %}selected{% endif %}>{{ choice }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label for="{{ form.purchased_from.id_for_label }}">Purchased From</label>
|
||||
</div>
|
||||
|
||||
<div class="input-field col s12">
|
||||
{% render_field form.purchase_price value=object.purchase_price %}
|
||||
<div class="form-group">
|
||||
<label for="{{ form.purchase_price.id_for_label }}">Purchase Price</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">£</span>
|
||||
{% render_field form.purchase_price|add_class:'form-control' value=object.purchase_price %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-field col s12">
|
||||
{% render_field form.salvage_value value=object.salvage_value %}
|
||||
<div class="form-group">
|
||||
<label for="{{ form.salvage_value.id_for_label }}">Salvage Value</label>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">£</span>
|
||||
{% render_field form.salvage_value|add_class:'form-control' value=object.salvage_value %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="input-field col s12">
|
||||
{% if object.date_acquired %}
|
||||
{% render_field form.date_acquired|add_class:'datepicker' value=object.date_acquired|date %}
|
||||
{% else %}
|
||||
<input type="text" name="date_acquired" value="{% now "DATE_FORMAT" %}"
|
||||
class="datepicker" id="id_date_acquired">
|
||||
{% endif %}
|
||||
<div class="form-group">
|
||||
<label for="{{ form.date_acquired.id_for_label }}" class="bold-text">Date
|
||||
Acquired</label>
|
||||
|
||||
{% if object.date_acquired %}
|
||||
{% render_field form.date_acquired|add_class:'datepicker form-control' value=object.date_acquired|date %}
|
||||
{% else %}
|
||||
<input type="text" name="date_acquired" value="{% now "DATE_FORMAT" %}"
|
||||
class="datepicker form-control" id="id_date_acquired">
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="input-field col s12">
|
||||
{% render_field form.date_sold|add_class:'datepicker' value=object.date_sold|date %}
|
||||
<!---TODO: Presumably, this should only appear if the asset is in the sold category?--->
|
||||
<div class="form-group">
|
||||
<label for="{{ form.date_sold.id_for_label }}">Date Sold</label>
|
||||
{% render_field form.date_sold|add_class:'datepicker form-control' value=object.date_sold|date %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
@@ -198,10 +169,9 @@
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if object.is_cable %}
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<div class="panel">
|
||||
<div class="panel-heading">
|
||||
Cable Details
|
||||
@@ -222,37 +192,37 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="row">
|
||||
<div class="panel">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
Collection Details
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<dl class="dl-horizontal">
|
||||
{% if edit or duplicate %}
|
||||
<div class="row">
|
||||
|
||||
<div class="input-field col s10">
|
||||
<div class="form-group">
|
||||
<label for="parent_id">Parent</label>
|
||||
<input type="hidden" name="{{ form.parent.html_name }}" id="hidden_parent_id"
|
||||
value="{{ object.parent.id }}">
|
||||
<div class="input-group">
|
||||
<input type="text" id="parent_id" value="{{ object.parent|default:'' }}"
|
||||
disabled="">
|
||||
<label for="parent_id">Parent</label>
|
||||
disabled="" class="form-control">
|
||||
<span class="input-group-btn"><button type="button" class="btn btn-default" onclick="clearParent()">Clear
|
||||
</button></span>
|
||||
</div>
|
||||
<div class="col s2">
|
||||
<button type="button" class="btn btn-flat" onclick="clearParent()">
|
||||
<i class="material-icons">clear</i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="input-field col s10">
|
||||
<input type="text" id="parent_search">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="parent_search">Search for asset</label>
|
||||
{# {% render_field form.parent value=object.parent %}#}
|
||||
<div class="input-group">
|
||||
<input type="text" id="parent_search" class="form-control">
|
||||
<span class="input-group-btn"><button type="button" class="btn btn-default" onclick="formAssetSearch()">
|
||||
<i class="glyphicon glyphicon-search"></i> Search
|
||||
</button></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col s2">
|
||||
<button type="button" class="btn btn-flat" onclick="formAssetSearch()">
|
||||
<i class="material-icons">search</i>
|
||||
</button>
|
||||
|
||||
<br>
|
||||
</div>
|
||||
<div class="col s12" id="formAssetSearchResult">
|
||||
@@ -286,10 +256,29 @@
|
||||
{% endif %}
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="btn-group">
|
||||
{% if edit and object %}
|
||||
<!--edit-->
|
||||
<button type="button" class="btn btn-success" onclick="updateAsset()">Save</button>
|
||||
<a class="btn btn-default" href="{% url 'asset_update' object.pk %}?duplicate=true">Duplicate</a>
|
||||
<a class="btn btn-danger" href="#confirm_delete_modal">Delete</a>
|
||||
{% elif duplicate %}
|
||||
<!--duplicate-->
|
||||
<button type="button" class="btn btn-default" onclick="updateAsset()">Create Duplicate</button>
|
||||
<a href="{% url 'asset_detail' previous_asset_pk %}" class="btn">Cancel</a>
|
||||
{% elif not object %}
|
||||
<!--create-->
|
||||
<button type="button" class="btn btn-success" onclick="updateAsset()">Save</button>
|
||||
{% else %}
|
||||
<!--detail-->
|
||||
<a href="{% url 'asset_update' object.pk %}" class="btn btn-warning">Edit</a>
|
||||
<a class="btn btn-default" href="{% url 'asset_update' object.pk %}?duplicate=true">Duplicate</a>
|
||||
<a class="btn btn-danger" href="#confirm_delete_modal">Delete</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% include 'confirm_delete.html' with object=object %}
|
||||
|
||||
{% endblock %}
|
||||
@@ -313,7 +302,9 @@
|
||||
window.location.href = data['url'];
|
||||
},
|
||||
|
||||
error: function (xhr) { console.log(xhr.status + ": " + xhr.responseText) }
|
||||
error: function(xhr) {
|
||||
console.log(xhr.status + ": " + xhr.responseText)
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -336,10 +327,15 @@
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
{% if edit or duplicate %}
|
||||
{
|
||||
%
|
||||
if edit or duplicate %
|
||||
}
|
||||
var comments_id = '#{{ form.comments.id_for_label }}';
|
||||
$(comments_id).val('{{ object.comments|linebreaksn }}');
|
||||
{% endif %}
|
||||
$(comments_id).val('{{ object.comments|linebreaksn }}'); {
|
||||
%
|
||||
endif %
|
||||
}
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user