1
0
mirror of https://github.com/dkmstr/openuds.git synced 2024-12-22 13:34:04 +03:00

Done multi tab forms

Advancing on Transport new/edit (this & network will server as base for other tabs)
This commit is contained in:
Adolfo Gómez 2013-11-27 00:41:03 +00:00
parent fa2335efd4
commit d46400c1f7
7 changed files with 54 additions and 21 deletions

View File

@ -56,12 +56,12 @@ class Transports(ModelHandlerMixin, Handler):
'comments': item.comments,
'priority': item.priority,
'nets_positive': item.nets_positive,
'networks': [ {'id': k.id} for k in item.networks.all() ],
'deployed_count': item.deployedServices.count(),
'type': type_.type(),
}
class Types(ModelTypeHandlerMixin, Handler):
path = 'transports'
has_comments = True
@ -78,7 +78,7 @@ class Types(ModelTypeHandlerMixin, Handler):
'label': ugettext('Priority'),
'tooltip': ugettext('Priority of this transport'),
'type': 'numeric',
'order': 100, # At end
'order': -50, # At end
})
except:
raise NotFound('type not found')

View File

@ -226,7 +226,7 @@ class ModelTypeHandlerMixin(object):
'required': True,
'label': _('Name'),
'tooltip': _('Name of this element'),
'order': -2,
'order': -100,
})
# And maybe comments (only if model has this field)
if 'comments' in flds:
@ -235,7 +235,7 @@ class ModelTypeHandlerMixin(object):
'label': _('Comments'),
'tooltip': _('Comments for this element'),
'length': 256,
'order': -1,
'order': -99,
})
return gui

View File

@ -32,7 +32,7 @@
'''
from __future__ import unicode_literals
#from django.utils import simplejson
#from django.utils import simplejson as json
import ujson as json
from django import http

View File

@ -145,7 +145,19 @@ gui.connectivity.link = function(event) {
onEdit: function(value, event, table, refreshFnc) {
gui.connectivity.transports.rest.gui(value.type, function(itemGui){
gui.connectivity.transports.rest.item(value.id, function(item) {
var form = gui.form.fromFields(itemGui, item);
var tabs = {
tabs: [
{
title: 'General',
fields: itemGui,
},
{
title: 'Networks',
fields: [],
},
]
};
var form = gui.form.fromFields(tabs, item);
gui.launchModalForm(gettext('Edit transport')+' '+value.name,form, function(form_selector, closeFnc) {
var fields = gui.form.read(form_selector);
fields.data_type = value.type;
@ -162,7 +174,19 @@ gui.connectivity.link = function(event) {
},
onNew: function(type, table, refreshFnc) {
gui.connectivity.transports.rest.gui(type, function(itemGui) {
var form = gui.form.fromFields(itemGui);
var tabs = {
tabs: [
{
title: 'General',
fields: itemGui,
},
{
title: 'Networks',
fields: [],
},
]
};
var form = gui.form.fromFields(tabs);
gui.launchModalForm(gettext('New transport'), form, function(form_selector, closeFnc) {
var fields = gui.form.read(form_selector);
// Append "own" fields, in this case data_type

View File

@ -38,7 +38,16 @@
var form = '<form class="form-horizontal" role="form">' +
'<input type="hidden" name="id" class="modal_field_data" value="' + item.id + '">';
if( fields.tabs ) {
var id = 'tab-' + Math.random().toString().split('.')[1]; // Get a random base ID for tab entries
var tabs = [];
var tabsContent = [];
var active = ' active in' ;
$.each(fields.tabs, function(index, tab){
tabsContent.push('<div class="tab-pane fade' + active + '" id="' + id + index + '">' + gui.fieldsToHtml(tab.fields, item) + '</div>' );
tabs.push('<li><a href="#' + id + index + '" data-toggle="tab">' + tab.title + '</a></li>' );
active = '';
});
form += '<ul class="nav nav-tabs">' + tabs.join('\n') + '</ul><div class="tab-content">' + tabsContent.join('\n') + '</div>';
} else {
form += gui.fieldsToHtml(fields, item, editing);
}

View File

@ -119,7 +119,7 @@
};
gui.launchModalForm = function(title, form, onSuccess) {
var id = Math.random().toString().split('.')[1]; // Get a random ID for this modal
var id = 'modal-' + Math.random().toString().split('.')[1]; // Get a random ID for this modal
gui.appendToWorkspace(gui.modal(id, title, form));
id = '#' + id; // for jQuery