use gadjo code for popup dialogs (#5132)
This commit is contained in:
parent
903d54c183
commit
29cf4e009a
|
@ -0,0 +1,19 @@
|
|||
{% extends "hobo/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block appbar %}
|
||||
<h2>{% blocktrans with title=object.name %}Removal of "{{ title }}"{% endblocktrans %}</h2>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<p>
|
||||
{% trans 'Are you sure you want to delete this element ?' %}
|
||||
</p>
|
||||
<div class="buttons">
|
||||
<button>{% trans 'Delete' %}</button>
|
||||
<a class="cancel" href="{% url 'environment-home' %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -19,32 +19,31 @@
|
|||
|
||||
<form class="small">
|
||||
{% for variable in variables %}
|
||||
<p>
|
||||
<label class="update-variable" data-variable-id="{{ variable.id }}">{{ variable.name }}</label>
|
||||
<p class="variable">
|
||||
<label data-variable-id="{{ variable.id }}">{{ variable.name }}</label>
|
||||
<input type="text" size="80" value="{{ variable.value }}" readonly>
|
||||
<a href="delete-variable/{{ variable.id }}" class="delete-variable" title="{% trans 'Delete variable' %}"></a>
|
||||
<a rel="popup" class="update-variable" href="{% url 'update-variable' pk=variable.id %}" title="{% trans 'Update variable' %}">{% trans 'edit' %}</a>
|
||||
<a rel="popup" class="icon-remove-sign" href="{% url 'delete-variable' pk=variable.id %}" title="{% trans 'Delete variable' %}"></a>
|
||||
</p>
|
||||
{% endfor %}
|
||||
<button id="new-variable">{% trans 'Add new variable' %}</button>
|
||||
<a rel="popup" class="button" href="{% url 'new-variable' %}">{% trans 'Add new variable' %}</a>
|
||||
</form>
|
||||
|
||||
<h2>{% trans 'Services' %}</h2>
|
||||
|
||||
<p>
|
||||
<span>{% trans 'Add new service:' %}</span>
|
||||
<select id="new-service">
|
||||
<option value=""></option>
|
||||
{% for service in available_services %}
|
||||
<option value="{{ service.id }}">{{ service.label }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<span id="new-service">
|
||||
{% for service in available_services %}
|
||||
<a rel="popup" data-service="{{ service.id }}" href="{% url 'create-service' service=service.id %}">{{ service.label }}</a>
|
||||
{% endfor %}
|
||||
</span>
|
||||
</p>
|
||||
|
||||
{% for service in installed_services %}
|
||||
<div data-service-id="{{ service.Extra.service_id }}"
|
||||
data-slug="{{ service.slug }}"
|
||||
{% if service.wants_frequent_checks %}data-wants-check="true"{% endif %}>
|
||||
<a href="{{ service|delete_url }}" class="delete-service" title="{% trans 'Delete service' %}"></a>
|
||||
<h3>{{ service.title }}</h3>
|
||||
{% if not service.is_operational %}
|
||||
{% if service.wants_frequent_checks %}
|
||||
|
@ -78,7 +77,6 @@ jQuery.fn.extend({
|
|||
var p_info = $(div).find('p.info');
|
||||
var url = 'check_operational/' + $(div).data('service-id') + '/' + $(div).data('slug');
|
||||
$.getJSON(url, function(data) {
|
||||
console.log('div:', $(div));
|
||||
if (data.operational == true) {
|
||||
$(p_info).hide('size');
|
||||
} else {
|
||||
|
@ -90,52 +88,25 @@ jQuery.fn.extend({
|
|||
});
|
||||
|
||||
$(function() {
|
||||
|
||||
$('#new-variable').click(function() {
|
||||
$.get('new-variable', function(data) {
|
||||
var form = $(data).find('form');
|
||||
$(form).attr('action', 'new-variable');
|
||||
$(form).dialog({modal: true, title: '{% trans "Add new variable" %}', width: 'auto'});
|
||||
});
|
||||
event.preventDefault();
|
||||
/* turn the new service links into a select box */
|
||||
var select_new_service = $('<select><option></option></select>').insertAfter($('#new-service'));
|
||||
$('#new-service').hide();
|
||||
$('#new-service a').each(function(index, element) {
|
||||
var text = $(element).text();
|
||||
var option = $('<option value="' + $(element).data('service') + '">' + text + "</option>"
|
||||
).appendTo(select_new_service);
|
||||
});
|
||||
$(select_new_service).change(function() {
|
||||
var service_id = $(this).val();
|
||||
if (service_id) {
|
||||
$('#new-service a[data-service=' + service_id + ']').click();
|
||||
$(this).val('');
|
||||
}
|
||||
});
|
||||
|
||||
$('.update-variable').click(function() {
|
||||
var variable_id = $(this).data('variable-id');
|
||||
$.get('update-variable/' + variable_id, function(data) {
|
||||
var form = $(data).find('form');
|
||||
$(form).attr('action', 'update-variable/' + variable_id);
|
||||
$(form).dialog({modal: true, title: '{% trans "Update variable" %}', width: 'auto'});
|
||||
});
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$('a.delete-variable').click(function() {
|
||||
var url = $(this).attr('href');
|
||||
$.get($(this).attr('href'), function(data) {
|
||||
var form = $(data).find('form');
|
||||
$(form).dialog({modal: true, title: '{% trans "Variable deletion" %}', width: 'auto'});f
|
||||
});
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
$('#new-service').change(function() {
|
||||
var service_id = $(this).val();
|
||||
$.get('new-' + service_id, function(data) {
|
||||
var title = $(data).find('h2').text();
|
||||
var form = $(data).find('form');
|
||||
$(form).attr('action', 'new-' + service_id);
|
||||
$(form).dialog({modal: true, title: title, width: 'auto'});
|
||||
});
|
||||
});
|
||||
|
||||
$('a.delete-service').click(function() {
|
||||
var url = $(this).attr('href');
|
||||
$.get($(this).attr('href'), function(data) {
|
||||
var form = $(data).find('form');
|
||||
$(form).dialog({modal: true, title: '{% trans "Service deletion" %}', width: 'auto'});f
|
||||
});
|
||||
event.preventDefault();
|
||||
$('a.update-variable').hide();
|
||||
$('p.variable label, p.variable input').click(function() {
|
||||
$(this).parent().find('a.update-variable').click();
|
||||
});
|
||||
|
||||
$("div[data-wants-check='true']").each(function(index, element) {
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
{% extends "hobo/base.html" %}
|
||||
{% load i18n service %}
|
||||
|
||||
{% block content %}
|
||||
<form action="{{ object|delete_url }}" method="post">
|
||||
{% csrf_token %}
|
||||
{% blocktrans with title=object.title %}
|
||||
Are you sure you want to delete "{{ title }}"?
|
||||
{% endblocktrans %}
|
||||
<div>
|
||||
<input type="submit" value="{% trans 'Yes' %}" >
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
|
@ -14,7 +14,10 @@
|
|||
{{ form.as_p }}
|
||||
</div>
|
||||
{% block buttons %}
|
||||
<button class="enable-on-change">Enregistrer</button>
|
||||
<div class="buttons">
|
||||
<button>{% trans 'Save' %}</button>
|
||||
<a class="cancel" href="{% url 'environment-home' %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
{% endblock %}
|
||||
</form>
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
{% extends "hobo/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<form action="{% url 'delete-variable' object.id %}" method="post">
|
||||
{% csrf_token %}
|
||||
{% blocktrans with title=object.name %}
|
||||
Are you sure you want to delete "{{ title }}"?
|
||||
{% endblocktrans %}
|
||||
<button class="enable-on-change">{% trans 'Delete' %}</button>
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -2,8 +2,7 @@
|
|||
{% load i18n %}
|
||||
|
||||
{% block appbar %}
|
||||
<h2>Variable</h2>
|
||||
<span><a href="./">{% trans 'Back to settings' %}</a></span>
|
||||
<h2>{% trans 'Variable' %}</h2>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@ -14,7 +13,10 @@
|
|||
{{ form.as_p }}
|
||||
</div>
|
||||
{% block buttons %}
|
||||
<button class="enable-on-change">{% trans 'Save' %}</button>
|
||||
<div class="buttons">
|
||||
<button>{% trans 'Save' %}</button>
|
||||
<a class="cancel" href="{% url 'environment-home' %}">{% trans 'Cancel' %}</a>
|
||||
</div>
|
||||
{% endblock %}
|
||||
</form>
|
||||
|
||||
|
|
|
@ -4,14 +4,14 @@ from .views import *
|
|||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', HomeView.as_view(), name='environment-home'),
|
||||
url(r'^new-variable$', VariableCreateView.as_view()),
|
||||
url(r'^new-variable$', VariableCreateView.as_view(), name='new-variable',),
|
||||
url(r'^update-variable/(?P<pk>\w+)$', VariableUpdateView.as_view(),
|
||||
name='update-variable'),
|
||||
url(r'^delete-variable/(?P<pk>\w+)$', VariableDeleteView.as_view(),
|
||||
name='delete-variable'),
|
||||
url(r'^check_operational/(?P<service>\w+)/(?P<slug>[\w-]+)$',
|
||||
operational_check_view, name='operational-check'),
|
||||
url(r'^new-(?P<service>\w+)$', ServiceCreateView.as_view()),
|
||||
url(r'^new-(?P<service>\w+)$', ServiceCreateView.as_view(), name='create-service'),
|
||||
url(r'^save-(?P<service>\w+)/(?P<slug>[\w-]+)$', ServiceUpdateView.as_view(), name='save-service'),
|
||||
url(r'^delete-(?P<service>\w+)/(?P<slug>[\w-]+)$', ServiceDeleteView.as_view(), name='delete-service'),
|
||||
url(r'^installed_services.json$', installed_services_json_view),
|
||||
|
|
|
@ -46,6 +46,7 @@ class VariableUpdateView(UpdateView):
|
|||
class VariableDeleteView(DeleteView):
|
||||
model = Variable
|
||||
success_url = reverse_lazy('environment-home')
|
||||
template_name = 'environment/generic_confirm_delete.html'
|
||||
|
||||
|
||||
class ServiceCreateView(CreateView):
|
||||
|
@ -113,7 +114,7 @@ class ServiceUpdateView(UpdateView):
|
|||
|
||||
class ServiceDeleteView(DeleteView):
|
||||
success_url = reverse_lazy('environment-home')
|
||||
template_name = 'environment/service_delete_confirm.html'
|
||||
template_name = 'environment/generic_confirm_delete.html'
|
||||
context_object_name = 'object'
|
||||
|
||||
def get_object(self):
|
||||
|
|
Loading…
Reference in New Issue