/*jsl:import ipa.js */
/* Authors:
* Endi Sukma Dewata ').appendTo(table);
var td = $(' ', {
'style': 'width: 100px; text-align: right;',
'html': 'Name:'
}).appendTo(tr);
td = $(' ').appendTo(tr);
var span = $('', { 'name': 'cn' }).appendTo(td);
$('', {
'type': 'text',
'name': 'cn',
'size': 30
}).appendTo(span);
span.append(' ');
$('', {
'name': 'undo',
'class': 'ui-state-highlight ui-corner-all',
'style': 'display: none;',
'html': 'undo'
}).appendTo(span);
td = $(' ', {
'style': 'text-align: right;'
}).appendTo(tr);
td.append('Rule type:');
span = $('', { 'name': 'accessruletype' }).appendTo(td);
$('', {
'type': 'radio',
'name': 'accessruletype',
'value': 'allow'
}).appendTo(span);
span.append(' ');
// TODO: i18n
span.append('Allow');
span.append(' ');
$('', {
'type': 'radio',
'name': 'accessruletype',
'value': 'deny'
}).appendTo(span);
span.append(' ');
// TODO: i18n
span.append('Deny');
span.append(' ');
$('', {
'name': 'undo',
'class': 'ui-state-highlight ui-corner-all',
'style': 'display: none;',
'html': 'undo'
}).appendTo(span);
tr = $(' ').appendTo(table);
td = $(' ', {
'style': 'text-align: right; vertical-align: top;',
'html': 'Description:'
}).appendTo(tr);
td = $(' ', {
'colspan': 2
}).appendTo(tr);
span = $('', { 'name': 'description' }).appendTo(td);
$('', {
'name': 'description',
'rows': 5,
'style': 'width: 100%'
}).appendTo(span);
span.append(' ');
$('', {
'name': 'undo',
'class': 'ui-state-highlight ui-corner-all',
'style': 'display: none;',
'html': 'undo'
}).appendTo(span);
tr = $(' ').appendTo(table);
td = $(' ', {
'style': 'text-align: right; vertical-align: top;',
'html': 'Rule status:'
}).appendTo(tr);
td = $(' ', {
'colspan': 2
}).appendTo(tr);
span = $('', { 'name': 'ipaenabledflag' }).appendTo(td);
$('', {
'type': 'radio',
'name': 'ipaenabledflag',
'value': 'TRUE'
}).appendTo(span);
span.append(' ');
// TODO: i18n
span.append('Active');
span.append(' ');
$('', {
'type': 'radio',
'name': 'ipaenabledflag',
'value': 'FALSE'
}).appendTo(span);
span.append(' ');
// TODO: i18n
span.append('Inactive');
span.append(' ');
$('', {
'name': 'undo',
'class': 'ui-state-highlight ui-corner-all',
'style': 'display: none;',
'html': 'undo'
}).appendTo(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': 'Remove '+that.label
}).appendTo(buttons);
$('', {
'type': 'button',
'name': 'add',
'value': 'Add '+that.label
}).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.show_undo();
});
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({
'method': that.entity_name+'_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('Add', function() {
add(
function() { dialog.reset(); }
);
});
dialog.add_button('Add and Close', function() {
add(
function() { dialog.close(); },
function() { dialog.close(); }
);
});
dialog.add_button('Cancel', function() {
dialog.close();
});
dialog.init();
dialog.open(that.container);
};
that.remove = function() {
var values = that.table.get_selected_values();
if (!values.length) {
alert('Select '+that.label+' to be removed.');
return;
}
var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || '';
var title = 'Remove '+that.label+' from '+that.entity_name+' '+pkey;
var dialog = IPA.deleter_dialog({
'title': title,
'values': values
});
dialog.remove = 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.title+'
'); summary.append(''+error_thrown.message+'
'); } var pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; IPA.cmd('show', [pkey], {'rights': true}, on_success, on_error, that.entity_name); }; return that; };