/*jsl:import ipa.js */
/* Authors:
* Endi Sukma Dewata ').appendTo(table);
var td = $(' ', {
'style': 'width: 100px; text-align: right;'
}).appendTo(tr);
var param_info = IPA.get_entity_param('hbacrule', 'cn');
td.append(param_info.label+':');
td = $(' ').appendTo(tr);
var field = that.get_field('cn');
var span = $('', { 'name': 'cn' }).appendTo(td);
$('', {
name: 'cn',
style: 'display: none;'
}).appendTo(span);
$('', {
'type': 'text',
'name': 'cn',
'size': 30
}).appendTo(span);
span.append(' ');
field.create_undo(span);
td = $(' ', {
'style': 'text-align: right;'
}).appendTo(tr);
param_info = IPA.get_entity_param('hbacrule', 'accessruletype');
td.append(param_info.label+':');
field = that.get_field('accessruletype');
span = $('', { 'name': 'accessruletype' }).appendTo(td);
$('', {
'type': 'radio',
'name': 'accessruletype',
'value': 'allow'
}).appendTo(span);
span.append(' ');
span.append(IPA.messages.objects.hbacrule.allow);
span.append(' ');
$('', {
'type': 'radio',
'name': 'accessruletype',
'value': 'deny'
}).appendTo(span);
span.append(' ');
span.append(IPA.messages.objects.hbacrule.deny);
span.append(' ');
field.create_undo(span);
tr = $(' ').appendTo(table);
td = $(' ', {
'style': 'text-align: right; vertical-align: top;'
}).appendTo(tr);
param_info = IPA.get_entity_param('hbacrule', 'description');
td.append(param_info.label+':');
td = $(' ', {
'colspan': 2
}).appendTo(tr);
field = that.get_field('description');
span = $('', { 'name': 'description' }).appendTo(td);
$('', {
'name': 'description',
'rows': 5,
'style': 'width: 100%'
}).appendTo(span);
span.append(' ');
field.create_undo(span);
tr = $(' ').appendTo(table);
td = $(' ', {
'style': 'text-align: right; vertical-align: top;'
}).appendTo(tr);
td.append(IPA.messages.objects.hbacrule.ipaenabledflag+':');
td = $(' ', {
'colspan': 2
}).appendTo(tr);
field = that.get_field('ipaenabledflag');
span = $('', { 'name': 'ipaenabledflag' }).appendTo(td);
$('', {
'type': 'radio',
'name': 'ipaenabledflag',
'value': 'TRUE'
}).appendTo(span);
span.append(' ');
span.append(IPA.messages.objects.hbacrule.active);
span.append(' ');
$('', {
'type': 'radio',
'name': 'ipaenabledflag',
'value': 'FALSE'
}).appendTo(span);
span.append(' ');
span.append(IPA.messages.objects.hbacrule.inactive);
span.append(' ');
field.create_undo(span);
};
return that;
};
IPA.hbacrule_accesstime_widget = function (spec) {
spec = spec || {};
var that = IPA.widget(spec);
that.text = spec.text;
that.options = spec.options || [];
that.init = function() {
that.widget_init();
that.table = IPA.table_widget({
'id': 'accesstime-table',
'name': 'table', 'label': that.label
});
that.table.create_column({
'name': that.name,
'label': that.label,
'primary_key': true
});
that.table.init();
};
that.create = function(container) {
that.widget_create(container);
var span = $('', { 'name': 'text' }).appendTo(container);
span.append(that.text);
for (var i=0; i
');
span = $('', { 'name': 'table' }).appendTo(container);
that.table.create(span);
var buttons = $('span[name=buttons]', span);
$('', {
'type': 'button',
'name': 'remove',
'value': IPA.messages.buttons.remove
}).appendTo(buttons);
$('', {
'type': 'button',
'name': 'add',
'value': IPA.messages.buttons.add
}).appendTo(buttons);
};
that.setup = function(container) {
that.widget_setup(container);
var span = $('span[name="table"]', that.container);
that.table.setup(span);
var button = $('input[name=remove]', span);
button.replaceWith(IPA.button({
'label': button.val(),
'icon': 'ui-icon-trash',
'click': function() { that.remove(that.container); }
}));
button = $('input[name=add]', span);
button.replaceWith(IPA.button({
'label': button.val(),
'icon': 'ui-icon-plus',
'click': function() { that.add(that.container); }
}));
var input = $('input[name="'+that.name+'"]', that.container);
input.change(function() {
that.set_dirty(true);
});
var undo = that.get_undo();
undo.click(function() {
that.reset();
});
};
that.save = function() {
var value = $('input[name="'+that.name+'"]:checked', that.container).val();
if (value === '') {
return that.table.save();
} else {
return [];
}
};
that.load = function(record) {
that.values = record[that.name] || [];
that.reset();
};
that.update = function() {
that.set_category(that.container, that.values && that.values.length ? '' : 'all');
that.table.tbody.empty();
for (var i=0; that.values && i').appendTo(table);
var td = $(' ', {
'style': 'vertical-align: top;'
}).appendTo(tr);
td.append(that.label+': ');
td = $(' ').appendTo(tr);
var span = $('', { 'name': that.name }).appendTo(td);
$('', {
'type': 'text',
'name': that.name,
'size': 40
}).appendTo(span);
tr = $(' ').appendTo(table);
td = $(' ', {
'style': 'vertical-align: top;'
}).appendTo(tr);
td.append('Example:');
td = $(' ').appendTo(tr);
td.append('Every day between 0800 and 1400:
');
td.append('periodic daily 0800-1400
');
td.append('December 16, 2010 from 10:32 until 10:33:
');
td.append('absolute 201012161032 ~ 201012161033');
};
function add(on_success, on_error) {
var field = dialog.get_field(that.name);
var value = field.save()[0];
var command = IPA.command({
entity: that.entity_name,
method: 'add_'+that.name,
args: [pkey],
on_success: function() {
that.refresh();
if (on_success) on_success();
},
on_error: function() {
that.refresh();
if (on_error) on_error();
}
});
command.set_option(that.name, value);
command.execute();
}
dialog.add_button(IPA.messages.buttons.add, function() {
add(
function() { dialog.reset(); }
);
});
dialog.add_button(IPA.messages.buttons.add_and_close, function() {
add(
function() { dialog.close(); },
function() { dialog.close(); }
);
});
dialog.add_button(IPA.messages.buttons.cancel, function() {
dialog.close();
});
dialog.init();
dialog.open(that.container);
};
that.remove = function() {
var values = that.table.get_selected_values();
var title;
if (!values.length) {
title = IPA.messages.dialogs.remove_empty;
title = title.replace('${entity}', that.label);
alert(title);
return;
}
var pkey = $.bbq.getState(that.entity_name+'-pkey');
title = IPA.messages.association.remove;
title = title.replace('${entity}', IPA.metadata.objects[that.entity_name].label);
title = title.replace('${primary_key}', pkey);
title = title.replace('${other_entity}', that.label);
var dialog = IPA.deleter_dialog({
'title': title,
'values': values
});
dialog.execute = function() {
var batch = IPA.batch_command({
'on_success': function() {
that.refresh();
dialog.close();
},
'on_error': function() {
that.refresh();
dialog.close();
}
});
for (var i=0; i
'+error_thrown.message+'
'); } var pkey = $.bbq.getState(that.entity_name+'-pkey'); IPA.command({ entity: that.entity_name, method: 'show', args: [pkey], options: {'rights': true}, on_success: on_success, on_error: on_error }).execute(); }; return that; };