Commit bb4dfc17 by Kálmán Viktor

dashboard: group rename without js

parent ebdf3b7e
...@@ -188,11 +188,15 @@ html { ...@@ -188,11 +188,15 @@ html {
display: none; display: none;
} }
.vm-details-home-name { #group-details-rename-form {
display: inline-block;
}
.vm-details-home-name, #group-details-rename-form .input-group {
max-width: 401px; max-width: 401px;
} }
#node-details-rename-name, #group-details-rename-name { #node-details-rename-name {
max-width: 160px; max-width: 160px;
} }
......
$(function() {
/* rename */ /* rename */
$("#group-details-h1-name, .group-details-rename-button").click(function() { $("#group-details-h1-name, .group-details-rename-button").click(function() {
$("#group-details-h1-name").hide(); $("#group-details-h1-name span").hide();
$("#group-details-rename").css('display', 'inline'); $("#group-details-rename-form").show().css('display', 'inline-block');
$("#group-details-rename-name").focus(); $("#group-details-rename-name").select();
}); });
/* rename ajax */ /* rename ajax */
$('#group-details-rename-submit').click(function() { $('#group-details-rename-submit').click(function() {
if(!$("#group-details-rename-name")[0].checkValidity()) {
return true;
}
var name = $('#group-details-rename-name').val(); var name = $('#group-details-rename-name').val();
$.ajax({ $.ajax({
method: 'POST', method: 'POST',
url: location.href, url: location.href,
data: {'new_name': name}, data: {'new_name': name},
headers: {"X-CSRFToken": getCookie('csrftoken')}, headers: {"X-CSRFToken": getCookie('csrftoken')},
success: function(data, textStatus, xhr) { success: function(data, textStatus, xhr) {
$("#group-details-h1-name").text(data['new_name']).show(); $("#group-details-h1-name span").text(data.new_name).show();
$('#group-details-rename').hide(); $('#group-details-rename-form').hide();
// addMessage(data['message'], "success");
}, },
error: function(xhr, textStatus, error) { error: function(xhr, textStatus, error) {
addMessage("Error during renaming!", "danger"); addMessage("Error during renaming.", "danger");
} }
}); });
return false; return false;
}); });
});
$(".group-details-help-button").click(function() {
$(".group-details-help").stop().slideToggle();
});
...@@ -9,43 +9,33 @@ ...@@ -9,43 +9,33 @@
<div class="body-content"> <div class="body-content">
<div class="page-header"> <div class="page-header">
<div class="pull-right" style="padding-top: 15px;"> <div class="pull-right" style="padding-top: 15px;">
<a title="{% trans "Rename" %}" href="#" class="btn btn-default btn-xs group-details-rename-button"> <a title="{% trans "Rename" %}" class="btn btn-default btn-xs group-details-rename-button">
<i class="fa fa-pencil"></i> <i class="fa fa-pencil"></i>
</a> </a>
<a title="{% trans "Delete" %}" data-group-pk="{{ group.pk }}" class="btn btn-default btn-xs real-link group-delete" href="{% url "dashboard.views.delete-group" pk=group.pk %}"> <a title="{% trans "Delete" %}" data-group-pk="{{ group.pk }}" class="btn btn-default btn-xs real-link group-delete" href="{% url "dashboard.views.delete-group" pk=group.pk %}">
<i class="fa fa-trash-o"></i> <i class="fa fa-trash-o"></i>
</a> </a>
<a title="{% trans "Help" %}" href="#" class="btn btn-default btn-xs group-details-help-button">
<i class="fa fa-question"></i>
</a>
</div> </div>
<h1> <h1>
<div id="group-details-rename"> <form action="" method="POST" id="group-details-rename-form" class="js-hidden">
<form action="" method="POST" id="group-details-rename-form"> {% csrf_token %}
{% csrf_token %} <div class="input-group">
<input id="group-details-rename-name" class="form-control" name="new_name" type="text" value="{{ group.name }}"/> <input id="group-details-rename-name" class="form-control" name="new_name"
<button type="submit" id="group-details-rename-submit" class="btn">{% trans "Rename" %}</button> type="text" value="{{ group.name }}" required />
</form> <span class="input-group-btn">
</div> <button type="submit" id="group-details-rename-submit" class="btn">
{% trans "Rename" %}
</button>
</span>
</div>
</form>
<div id="group-details-h1-name"> <div id="group-details-h1-name">
{{ group.name }} <span class="no-js-hidden">{{ group.name }}</span>
{% if group.groupprofile.org_id %} {% if group.groupprofile.org_id %}
<small>{{group.groupprofile.org_id}}</small> <small>{{group.groupprofile.org_id}}</small>
{% endif %} {% endif %}
</div> </div>
</h1> </h1>
<div class="group-details-help js-hidden">
<ul style="list-style: none;">
<li>
<strong>{% trans "Rename" %}:</strong>
{% trans "Change the name of the group." %}
</li>
<li>
<strong>{% trans "Delete" %}:</strong>
{% trans "Delete group." %}
</li>
</ul>
</div>
</div><!-- .page-header --> </div><!-- .page-header -->
<div class="row"> <div class="row">
<div class="col-md-12" id="group-detail-pane"> <div class="col-md-12" id="group-detail-pane">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment