mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-03 04:01:27 -06:00
Refactored builder interface.
The IPA.entity_builder has been modified to take a 'factory' parameter in custom facet's and custom dialog's spec. The IPA.dialog has been modified to take an array of fields in the spec. The IPA.search_facet has been modified to take an array of columns in the spec.
This commit is contained in:
parent
f0f83a862e
commit
689fd30b52
@ -265,6 +265,25 @@ IPA.dialog = function(spec) {
|
||||
that.dialog_setup = that.setup;
|
||||
that.dialog_open = that.open;
|
||||
|
||||
var fields = spec.fields || [];
|
||||
for (var i=0; i<fields.length; i++) {
|
||||
var field_spec = fields[i];
|
||||
var field;
|
||||
|
||||
if (field_spec instanceof Object) {
|
||||
if (field_spec.factory) {
|
||||
field = field_spec.factory(field_spec);
|
||||
} else {
|
||||
field = IPA.text_widget(field_spec);
|
||||
}
|
||||
} else {
|
||||
var field_name = field_spec;
|
||||
field = IPA.text_widget({ name: field_name, undo: false });
|
||||
}
|
||||
|
||||
that.add_field(field);
|
||||
}
|
||||
|
||||
return that;
|
||||
};
|
||||
|
||||
|
@ -48,10 +48,11 @@ IPA.entity_factories.dnszone = function() {
|
||||
'dnsclass',
|
||||
'idnsallowdynupdate',
|
||||
'idnsupdatepolicy']}]}).
|
||||
facet(IPA.records_facet({
|
||||
facet({
|
||||
factory: IPA.records_facet,
|
||||
'name': 'records',
|
||||
'label': IPA.metadata.objects.dnsrecord.label
|
||||
})).
|
||||
}).
|
||||
standard_association_facets().
|
||||
build();
|
||||
};
|
||||
|
@ -539,7 +539,7 @@ IPA.entity_builder = function(){
|
||||
|
||||
var that = {};
|
||||
var entity = null;
|
||||
var current_facet = null;
|
||||
var facet = null;
|
||||
|
||||
function section(spec){
|
||||
var current_section = null;
|
||||
@ -555,7 +555,7 @@ IPA.entity_builder = function(){
|
||||
}else{
|
||||
current_section = IPA.details_list_section(spec);
|
||||
}
|
||||
current_facet.add_section(current_section);
|
||||
facet.add_section(current_section);
|
||||
var fields = spec.fields;
|
||||
if (fields){
|
||||
var i;
|
||||
@ -581,8 +581,14 @@ IPA.entity_builder = function(){
|
||||
return that;
|
||||
};
|
||||
|
||||
that.dialog = function(value){
|
||||
current_facet.dialog(value);
|
||||
that.dialog = function(spec) {
|
||||
var dialog;
|
||||
if (spec.factory) {
|
||||
dialog = spec.factory(spec);
|
||||
} else {
|
||||
dialog = IPA.dialog(spec);
|
||||
}
|
||||
facet.dialog(dialog);
|
||||
return that;
|
||||
};
|
||||
|
||||
@ -590,8 +596,8 @@ IPA.entity_builder = function(){
|
||||
var sections = spec.sections;
|
||||
spec.sections = null;
|
||||
spec.entity_name = entity.name;
|
||||
current_facet =IPA.details_facet(spec);
|
||||
entity.facet(current_facet);
|
||||
facet =IPA.details_facet(spec);
|
||||
entity.facet(facet);
|
||||
|
||||
var i;
|
||||
for ( i =0; i < sections.length; i += 1){
|
||||
@ -601,27 +607,19 @@ IPA.entity_builder = function(){
|
||||
return that;
|
||||
};
|
||||
|
||||
that.facet = function (facet){
|
||||
current_facet = facet;
|
||||
that.facet = function(spec) {
|
||||
facet = spec.factory(spec);
|
||||
entity.facet(facet);
|
||||
return that;
|
||||
};
|
||||
|
||||
that.search_facet = function (spec){
|
||||
current_facet = IPA.search_facet({
|
||||
entity_name:entity.name,
|
||||
search_all: spec.search_all || false
|
||||
facet = IPA.search_facet({
|
||||
entity_name: entity.name,
|
||||
search_all: spec.search_all || false,
|
||||
columns: spec.columns
|
||||
});
|
||||
|
||||
var columns = spec.columns;
|
||||
var i;
|
||||
for (i = 0; i < columns.length; i +=1){
|
||||
if(columns[i] instanceof Object){
|
||||
current_facet.column(columns[i]);
|
||||
}else{
|
||||
current_facet.column({name:columns[i]});
|
||||
}
|
||||
}
|
||||
var current_dialog =
|
||||
IPA.add_dialog({
|
||||
'name': 'add',
|
||||
@ -629,35 +627,38 @@ IPA.entity_builder = function(){
|
||||
entity_name: entity.name
|
||||
});
|
||||
|
||||
current_facet.dialog(current_dialog);
|
||||
facet.dialog(current_dialog);
|
||||
|
||||
var add_fields = spec.add_fields;
|
||||
for (i = 0; i < add_fields.length; i += 1){
|
||||
var field = add_fields[i];
|
||||
if (field instanceof Object){
|
||||
/* This is a bit of a hack ,and is here to support ACI
|
||||
permissions. The target section is a group of secveral
|
||||
widgets together. It makes more sense to do them as a
|
||||
seciont than as a widgit. However, since they can be mixed
|
||||
into the flow with the other widgets, the section needs to
|
||||
be definied here with the fields to get the order correct.*/
|
||||
var factory;
|
||||
if (field.section){
|
||||
factory = field.factory;
|
||||
field.factory = null;
|
||||
field.name = field.section;
|
||||
field.section = null;
|
||||
current_dialog.add_section(factory(field));
|
||||
if (add_fields) {
|
||||
for (var i = 0; i < add_fields.length; i += 1){
|
||||
var field = add_fields[i];
|
||||
if (field instanceof Object){
|
||||
/* This is a bit of a hack ,and is here to support ACI
|
||||
permissions. The target section is a group of secveral
|
||||
widgets together. It makes more sense to do them as a
|
||||
seciont than as a widgit. However, since they can be mixed
|
||||
into the flow with the other widgets, the section needs to
|
||||
be definied here with the fields to get the order correct.*/
|
||||
var factory;
|
||||
if (field.section){
|
||||
factory = field.factory;
|
||||
field.factory = null;
|
||||
field.name = field.section;
|
||||
field.section = null;
|
||||
current_dialog.add_section(factory(field));
|
||||
}else{
|
||||
field.entity_name = entity.name;
|
||||
factory = field.factory || IPA.text_widget;
|
||||
current_dialog.field(factory(field));
|
||||
}
|
||||
}else{
|
||||
field.entity_name = entity.name;
|
||||
factory = field.factory;
|
||||
current_dialog.field(factory(field));
|
||||
current_dialog.text(add_fields[i]);
|
||||
}
|
||||
}else{
|
||||
current_dialog.text(add_fields[i]);
|
||||
}
|
||||
}
|
||||
entity.facet(current_facet);
|
||||
|
||||
entity.facet(facet);
|
||||
return that;
|
||||
};
|
||||
|
||||
|
@ -47,8 +47,8 @@ IPA.entity_factories.group = function () {
|
||||
name:'details',
|
||||
fields:['cn','description','gidnumber']
|
||||
}]}).
|
||||
facet( IPA.association_facet({
|
||||
'name': 'member_user',
|
||||
association_facet({
|
||||
name: 'member_user',
|
||||
columns:[
|
||||
{
|
||||
name: 'uid',
|
||||
@ -72,7 +72,7 @@ IPA.entity_factories.group = function () {
|
||||
}
|
||||
]
|
||||
|
||||
})).
|
||||
}).
|
||||
association_facet({
|
||||
name: 'memberof_group',
|
||||
associator: IPA.serial_associator
|
||||
|
@ -42,9 +42,10 @@ IPA.entity_factories.hbacrule = function () {
|
||||
}],
|
||||
'undo': false
|
||||
}]}).
|
||||
facet(IPA.hbacrule_details_facet({
|
||||
facet({
|
||||
factory: IPA.hbacrule_details_facet,
|
||||
'name': 'details'
|
||||
})).
|
||||
}).
|
||||
build();
|
||||
};
|
||||
|
||||
|
@ -70,9 +70,10 @@ IPA.entity_factories.host = function () {
|
||||
}
|
||||
]
|
||||
}]}).
|
||||
facet(IPA.host_managedby_host_facet({
|
||||
facet({
|
||||
factory: IPA.host_managedby_host_facet,
|
||||
name: 'managedby_host'
|
||||
})).
|
||||
}).
|
||||
association_facet({
|
||||
name: 'memberof_hostgroup',
|
||||
associator: IPA.serial_associator
|
||||
|
@ -410,6 +410,16 @@ IPA.search_facet = function(spec) {
|
||||
that.search_facet_create_content = that.create_content;
|
||||
that.search_facet_setup = that.setup;
|
||||
|
||||
var columns = spec.columns || [];
|
||||
for (var i=0; i<columns.length; i++) {
|
||||
var column = columns[i];
|
||||
if (column instanceof Object) {
|
||||
var factory = column.factory || IPA.column;
|
||||
that.add_column(factory(column));
|
||||
} else {
|
||||
that.create_column({ name: column });
|
||||
}
|
||||
}
|
||||
|
||||
return that;
|
||||
};
|
||||
|
@ -27,15 +27,15 @@ IPA.entity_factories.service = function() {
|
||||
|
||||
return IPA.entity_builder().
|
||||
entity('service').
|
||||
facet(
|
||||
IPA.search_facet().
|
||||
column({name: 'krbprincipalname'}).
|
||||
dialog(
|
||||
IPA.service_add_dialog({
|
||||
name: 'add',
|
||||
title: IPA.messages.objects.service.add,
|
||||
width: '450px'
|
||||
}))).
|
||||
search_facet({
|
||||
columns: [ 'krbprincipalname' ]
|
||||
}).
|
||||
dialog({
|
||||
factory: IPA.service_add_dialog,
|
||||
name: 'add',
|
||||
title: IPA.messages.objects.service.add,
|
||||
width: '450px'
|
||||
}).
|
||||
details_facet({sections:[
|
||||
{
|
||||
name: 'details',
|
||||
@ -69,11 +69,12 @@ IPA.entity_factories.service = function() {
|
||||
label: IPA.messages.objects.service.status
|
||||
}]
|
||||
}]}).
|
||||
facet(IPA.service_managedby_host_facet({
|
||||
name: 'managedby_host',
|
||||
add_method: 'add_host',
|
||||
remove_method: 'remove_host'
|
||||
})).
|
||||
facet({
|
||||
factory: IPA.service_managedby_host_facet,
|
||||
name: 'managedby_host',
|
||||
add_method: 'add_host',
|
||||
remove_method: 'remove_host'
|
||||
}).
|
||||
standard_association_facets().
|
||||
build();
|
||||
};
|
||||
|
@ -31,9 +31,10 @@ IPA.entity_factories.sudorule = function () {
|
||||
columns:['cn','description','cmdcategory'],
|
||||
add_fields:['cn']
|
||||
}).
|
||||
facet(IPA.sudorule_details_facet({
|
||||
facet({
|
||||
factory: IPA.sudorule_details_facet,
|
||||
'name': 'details'
|
||||
})).
|
||||
}).
|
||||
build();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user