Improvements to enrollments in the webUI.

TAKE 1

- Enrollement links in the action panel are now sorted by relationships.
- You can only enroll members.
  (The webUI made the impression you can enroll parents as well, but it was
   broken.)
- When enrolling new members, you can choose not to display already enrolled
  ones. (On by default.)
- Couple cosmetic changes.
This commit is contained in:
Pavel Zuna
2011-01-04 15:21:18 -05:00
committed by Adam Young
parent d6d579ead4
commit 2f2c67cb59
5 changed files with 124 additions and 33 deletions

View File

@@ -140,6 +140,7 @@ function ipa_association_adder_dialog(spec) {
that.entity_name = spec.entity_name;
that.pkey = spec.pkey;
that.other_entity = spec.other_entity;
that.attribute_member = spec.attribute_member;
that.init = function() {
if (!that.columns.length) {
@@ -152,6 +153,9 @@ function ipa_association_adder_dialog(spec) {
});
}
/* FIXME: event not firing? */
$('input[name=hidememb]', that.container).click(that.search);
that.adder_dialog_init();
};
@@ -166,7 +170,31 @@ function ipa_association_adder_dialog(spec) {
}
}
ipa_cmd('find', [that.get_filter()], {'all': true}, on_success, null, that.other_entity);
var hide_checkbox = $('input[name=hidememb]', that.container);
var options = {'all': true};
if (hide_checkbox.attr('checked')) {
var relationships = IPA.metadata[that.other_entity].relationships;
/* TODO: better generic handling of different relationships! */
var other_attribute_member = '';
if (that.attribute_member == 'member')
other_attribute_member = 'memberof';
else if (that.attribute_member == 'memberuser')
other_attribute_member = 'memberof';
else if (that.attribute_member == 'memberhost')
other_attribute_member = 'memberof';
else if (that.attribute_member == 'memberof')
other_attribute_member = 'member';
var relationship = relationships[other_attribute_member];
if (relationship) {
var param_name = relationship[2] + that.entity_name;
options[param_name] = that.pkey;
}
}
ipa_cmd('find', [that.get_filter()], options, on_success, null, that.other_entity);
};
that.association_adder_dialog_init = that.init;
@@ -234,6 +262,7 @@ function ipa_association_table_widget(spec) {
var that = ipa_table_widget(spec);
that.other_entity = spec.other_entity;
that.attribute_member = spec.attribute_member;
that.associator = spec.associator || bulk_associator;
that.add_method = spec.add_method || 'add_member';
@@ -398,7 +427,8 @@ function ipa_association_table_widget(spec) {
'title': title,
'entity_name': that.entity_name,
'pkey': pkey,
'other_entity': that.other_entity
'other_entity': that.other_entity,
'attribute_member': that.attribute_member,
});
};
@@ -513,6 +543,8 @@ function ipa_association_facet(spec) {
var that = ipa_facet(spec);
that.other_entity = spec.other_entity;
that.facet_group = spec.facet_group;
that.attribute_member = spec.attribute_member;
that.associator = spec.associator || bulk_associator;
that.add_method = spec.add_method || 'add_member';
@@ -636,9 +668,20 @@ function ipa_association_facet(spec) {
that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
//TODO I18N
var header_message = that.other_entity + '(s) enrolled in ' +
that.entity_name + ' ' + that.pkey;
var relationships = IPA.metadata[that.entity_name].relationships;
var relationship = relationships[that.attribute_member];
if (!relationship)
relationship = ['', '', ''];
/* TODO: I18N and some generic handling of different relationships */
var header_message = '';
if (relationship[0] == 'Member') {
header_message = that.other_entity + '(s) enrolled in ' +
that.entity_name + ' ' + that.pkey;
} else if (relationship[0] == 'Parent') {
header_message = that.entity_name + ' ' + that.pkey +
' is enrolled in the following ' + that.other_entity + '(s)';
}
$('<div/>', {
'id': that.entity_name+'-'+that.other_entity,
@@ -659,12 +702,14 @@ function ipa_association_facet(spec) {
'value': IPA.messages.button.remove
}).appendTo(li);
$('<input/>', {
'type': 'button',
'name': 'add',
'value': IPA.messages.button.enroll
}).appendTo(li);
/* TODO: genering handling of different relationships */
if (relationship[0] == 'Member') {
$('<input/>', {
'type': 'button',
'name': 'add',
'value': IPA.messages.button.enroll
}).appendTo(li);
}
};
that.setup = function(container) {
@@ -697,13 +742,14 @@ function ipa_association_facet(spec) {
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var label = IPA.metadata[that.other_entity] ? IPA.metadata[that.other_entity].label : that.other_entity;
var title = 'Enroll '+that.entity_name+' '+pkey+' in '+label;
var title = 'Enroll ' + label + ' in ' + that.entity_name + ' ' + pkey;
var dialog = ipa_association_adder_dialog({
'title': title,
'entity_name': that.entity_name,
'pkey': pkey,
'other_entity': that.other_entity
'other_entity': that.other_entity,
'attribute_member': that.attribute_member,
});
if (that.adder_columns.length) {

View File

@@ -137,7 +137,7 @@ function ipa_entity(spec) {
return config;
};
that.create_association_facet = function(attribute_member, other_entity, label) {
that.create_association_facet = function(attribute_member, other_entity, label, facet_group) {
if (!attribute_member) {
attribute_member = ipa_get_member_attribute(
@@ -148,7 +148,9 @@ function ipa_entity(spec) {
return ipa_association_facet({
'name': attribute_member+'_'+other_entity,
'label': label,
'other_entity': other_entity
'other_entity': other_entity,
'facet_group': facet_group,
'attribute_member': attribute_member,
});
};
@@ -170,18 +172,19 @@ function ipa_entity(spec) {
var label = other_entity_name;
if (attribute_member.match(/^memberof$/)) {
label = IPA.messages.association.membershipin+' '+other_entity_name;
var relationships = IPA.metadata[that.name].relationships;
} else if (attribute_member.match(/^member/)) {
label = other_entity_name+' '+IPA.messages.association.members;
var relationship = relationships[attribute_member];
if (!relationship)
relationship = ['Member', '', 'no_'];
var facet_group = relationship[0];
} else if (attribute_member.match(/^managedby$/)) {
label = IPA.messages.association.managedby+' '+other_entity_name;
}
var facet = that.create_association_facet(
attribute_member, other_entity, label, facet_group
);
var facet = that.create_association_facet(attribute_member, other_entity, label);
if (that.get_facet(facet.name)) continue;
that.add_facet(facet);
}
}
@@ -488,10 +491,30 @@ function ipa_facet_create_action_panel(container) {
main_facet.appendTo(ul);
ul.append($('<li><span class="action-controls"/></li>'));
var facet_groups = {};
for (var i=1; i<entity.facets.length; i++) {
other_facet = entity.facets[i];
other_facet_name = other_facet.name;
ul.append(build_link(other_facet,other_facet.label));
if (other_facet.facet_group) {
var facet_group = other_facet.facet_group;
if (!facet_groups[facet_group]) {
var li = $('<li/>', {
'class': 'entity-facet-relation-label',
'text': other_facet.facet_group,
'title': other_facet.facet_group,
})
ul.append(li);
facet_groups[facet_group] = li;
}
var li = facet_groups[facet_group];
li.after(
build_link(other_facet, other_facet.label)
);
facet_groups[facet_group] = li.next();
} else {
ul.append(build_link(other_facet, other_facet.label));
}
}
}else{
$('<li/>', {

View File

@@ -62,13 +62,6 @@ function ipa_group() {
});
that.add_facet(facet);
facet = ipa_group_member_user_facet({
'name': 'member_user',
'label': IPA.metadata['user'].label+' '+IPA.messages.association.members,
'other_entity': 'user'
});
that.add_facet(facet);
that.create_association_facets();
that.entity_init();
@@ -195,4 +188,4 @@ function ipa_group_member_user_facet(spec) {
};
return that;
}
}

View File

@@ -485,6 +485,14 @@ span.main-separator{
text-transform: none;
}
.action-panel li.entity-facet-relation-label {
font-family: "FreeWayBold", "Liberation Sans", Arial, Sans;
color: #333333;
cursor: default;
text-transform: uppercase;
font-size: 1.2em;
}
.action-button {
background: none;
background-image:none;
@@ -687,4 +695,4 @@ table.scrollable tbody {
bottom: 0px;
width: 250px;
height: 40px;
}
}

View File

@@ -1023,6 +1023,23 @@ function ipa_adder_dialog(spec) {
value: 'Find'
}).appendTo(search_panel);
$('<input/>', {
type: 'checkbox',
name: 'hidememb',
id: 'hidememb',
checked: 'checked',
style: 'margin-left: 5px; vertical-align: middle',
}).appendTo(search_panel);
var label = $('<label/>', {
'for': 'hidememb',
style: 'margin-left: 3px',
});
label.text('Hide already enrolled.');
label.appendTo(search_panel);
var results_panel = $('<div/>', {
'class': 'adder-dialog-results'
}).appendTo(that.container);
@@ -1141,6 +1158,10 @@ function ipa_adder_dialog(spec) {
return that.filter_field.val();
};
that.get_hide_checkbox = function() {
return that.hide_checkbox.checked;
};
that.clear_available_values = function() {
that.available_table.empty();
};