2011-01-14 12:16:25 -05:00
|
|
|
/*jsl:import ipa.js */
|
|
|
|
|
|
2010-09-16 10:28:07 -04:00
|
|
|
/* Authors:
|
|
|
|
|
* Pavel Zuna <pzuna@redhat.com>
|
|
|
|
|
* Adam Young <ayoung@redhat.com>
|
2010-11-09 14:22:31 -06:00
|
|
|
* Endi S. Dewata <edewata@redhat.com>
|
2012-03-22 17:03:57 +01:00
|
|
|
* Petr Vobornik <pvoborni@redhat.com>
|
2010-09-16 10:28:07 -04:00
|
|
|
*
|
|
|
|
|
* Copyright (C) 2010 Red Hat
|
|
|
|
|
* see file 'COPYING' for use and warranty information
|
|
|
|
|
*
|
2010-12-09 13:59:11 +01:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
2010-09-16 10:28:07 -04:00
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2010-12-09 13:59:11 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-09-16 10:28:07 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* REQUIRES: ipa.js */
|
|
|
|
|
|
2012-04-17 16:25:20 +02:00
|
|
|
IPA.search_facet = function(spec, no_init) {
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
spec = spec || {};
|
2010-10-27 22:32:30 -05:00
|
|
|
|
2011-01-19 21:10:18 -05:00
|
|
|
spec.name = spec.name || 'search';
|
2011-11-07 14:21:45 -06:00
|
|
|
spec.managed_entity = spec.managed_entity ? IPA.get_entity(spec.managed_entity) : spec.entity;
|
2010-11-15 16:41:21 -05:00
|
|
|
|
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name.
Replacing entity_name with entity.name in most places.
The one exception is columns for table_widget.
Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies.
cleanup entity assignment.
removed template and layout,
merged setup into create
adder dialogs adjust height for external
removed init from widget, isection, association, facet, host and service
Make unit tests use factory.
fix functional tests to click find link correctly.
tweak to activation test, but still broken.
moved initialization code to the end
use --all for hbacrule find, so the type shows up now
fixed dns exception code and exception handling for get_entity
replace metadata look up with value from entity.
fixed author lines
removed duplicate columns in managed by facets.
tweak to nav fix in order to initialize tab.
more defensive code
update metadata for true false
one line init for entity_name in widget
move init code to end of constructor functions
moved constants to start of function for adder_dialog
external fields for dialogs initialized at dialog creation
sudo sections: move add fields and columns to widget definition.
The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function.
decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables
return false at the end of click handler
removed blank labels in sudo command section
fix radio buttons for sudo category
fixed table side for adder dialogs with external fields
comments for future direction with add_columns
https://fedorahosted.org/freeipa/ticket/1451
https://fedorahosted.org/freeipa/ticket/1462
https://fedorahosted.org/freeipa/ticket/1493
https://fedorahosted.org/freeipa/ticket/1497
https://fedorahosted.org/freeipa/ticket/1532
https://fedorahosted.org/freeipa/ticket/1534
2011-07-25 12:15:14 -04:00
|
|
|
spec.disable_breadcrumb =
|
|
|
|
|
spec.disable_breadcrumb === undefined ? true : spec.disable_breadcrumb;
|
|
|
|
|
spec.disable_facet_tabs =
|
|
|
|
|
spec.disable_facet_tabs === undefined ? true : spec.disable_facet_tabs;
|
2011-06-21 15:05:44 -05:00
|
|
|
|
2012-04-17 16:25:20 +02:00
|
|
|
spec.control_buttons = spec.control_buttons || {};
|
2010-10-13 13:07:43 -04:00
|
|
|
|
2012-04-17 16:25:20 +02:00
|
|
|
var cb = spec.control_buttons;
|
|
|
|
|
cb.factory = cb.factory || IPA.control_buttons_widget;
|
|
|
|
|
cb.buttons = cb.buttons || [];
|
|
|
|
|
cb.state_listeners = cb.state_listeners || [];
|
|
|
|
|
cb.buttons.unshift(
|
|
|
|
|
{
|
|
|
|
|
name: 'refresh',
|
|
|
|
|
label: IPA.messages.buttons.refresh,
|
|
|
|
|
icon: 'reset-icon',
|
|
|
|
|
action: {
|
|
|
|
|
handler: function(facet) {
|
|
|
|
|
facet.refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'remove',
|
|
|
|
|
label: IPA.messages.buttons.remove,
|
|
|
|
|
icon: 'remove-icon',
|
2012-04-25 14:28:17 +02:00
|
|
|
needs_confirm: true,
|
|
|
|
|
hide_cond: ['self-service'],
|
2012-04-17 16:25:20 +02:00
|
|
|
action: {
|
|
|
|
|
enable_cond: ['item-selected'],
|
|
|
|
|
handler: function(facet) {
|
|
|
|
|
facet.show_remove_dialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'add',
|
|
|
|
|
label: IPA.messages.buttons.add,
|
|
|
|
|
icon: 'add-icon',
|
2012-04-25 14:28:17 +02:00
|
|
|
hide_cond: ['self-service'],
|
2012-04-17 16:25:20 +02:00
|
|
|
action: {
|
|
|
|
|
handler: function(facet) {
|
|
|
|
|
facet.show_add_dialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
cb.state_listeners.push(
|
|
|
|
|
{
|
|
|
|
|
factory: IPA.selected_state_listener
|
2012-04-25 14:28:17 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
factory: IPA.self_service_state_listener
|
2012-04-17 16:25:20 +02:00
|
|
|
}
|
|
|
|
|
);
|
2012-01-24 15:31:18 +01:00
|
|
|
|
2012-04-17 16:25:20 +02:00
|
|
|
//TODO: make buttons invisible on self-service. Currently regression.
|
2011-11-04 20:43:39 -05:00
|
|
|
|
2012-04-17 16:25:20 +02:00
|
|
|
var that = IPA.table_facet(spec, true);
|
|
|
|
|
|
|
|
|
|
that.deleter_dialog = spec.deleter_dialog || IPA.search_deleter_dialog;
|
2011-04-08 00:14:16 -05:00
|
|
|
|
2011-04-28 19:17:58 -05:00
|
|
|
that.create_header = function(container) {
|
2011-04-11 14:49:36 -04:00
|
|
|
|
2011-04-28 19:17:58 -05:00
|
|
|
that.facet_create_header(container);
|
2011-04-11 14:49:36 -04:00
|
|
|
|
2012-01-16 14:17:46 +01:00
|
|
|
var div = $('<div/>', {
|
2011-06-21 15:05:44 -05:00
|
|
|
'class': 'right-aligned-facet-controls'
|
|
|
|
|
}).appendTo(that.controls);
|
|
|
|
|
|
2012-01-16 14:17:46 +01:00
|
|
|
div.append(IPA.create_network_spinner());
|
2011-11-16 21:07:20 -06:00
|
|
|
|
2011-07-15 12:18:59 -05:00
|
|
|
var filter_container = $('<div/>', {
|
|
|
|
|
'class': 'search-filter'
|
2012-01-16 14:17:46 +01:00
|
|
|
}).appendTo(div);
|
2011-07-15 12:18:59 -05:00
|
|
|
|
2011-04-28 19:17:58 -05:00
|
|
|
that.filter = $('<input/>', {
|
|
|
|
|
type: 'text',
|
|
|
|
|
name: 'filter'
|
2011-07-15 12:18:59 -05:00
|
|
|
}).appendTo(filter_container);
|
2011-04-11 14:49:36 -04:00
|
|
|
|
2011-04-28 19:17:58 -05:00
|
|
|
that.filter.keypress(function(e) {
|
|
|
|
|
/* if the key pressed is the enter key */
|
|
|
|
|
if (e.which == 13) {
|
|
|
|
|
that.find();
|
|
|
|
|
}
|
|
|
|
|
});
|
2011-04-11 14:49:36 -04:00
|
|
|
|
2011-06-13 16:40:36 -04:00
|
|
|
that.find_button = IPA.action_button({
|
2011-06-21 15:05:44 -05:00
|
|
|
name: 'find',
|
2011-06-13 16:40:36 -04:00
|
|
|
icon: 'search-icon',
|
2011-04-28 19:17:58 -05:00
|
|
|
click: function() {
|
|
|
|
|
that.find();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-07-15 12:18:59 -05:00
|
|
|
}).appendTo(filter_container);
|
2011-04-11 14:49:36 -04:00
|
|
|
|
2012-04-17 16:25:20 +02:00
|
|
|
that.create_control_buttons(that.controls);
|
2011-04-28 19:17:58 -05:00
|
|
|
};
|
2011-04-08 00:14:16 -05:00
|
|
|
|
2011-04-28 19:17:58 -05:00
|
|
|
that.show = function() {
|
|
|
|
|
that.facet_show();
|
2011-04-08 00:14:16 -05:00
|
|
|
|
2011-10-24 14:53:29 +02:00
|
|
|
var filter = IPA.nav.get_state(that.entity.name+'-filter');
|
|
|
|
|
that.old_filter = filter || '';
|
2012-03-22 17:03:57 +01:00
|
|
|
that.old_pkeys = that.managed_entity.get_primary_key_prefix();
|
2011-10-24 14:53:29 +02:00
|
|
|
|
2011-04-28 19:17:58 -05:00
|
|
|
if (that.filter) {
|
|
|
|
|
that.filter.val(filter);
|
|
|
|
|
}
|
2011-04-08 00:14:16 -05:00
|
|
|
};
|
|
|
|
|
|
2012-03-22 17:03:57 +01:00
|
|
|
that.needs_update = function() {
|
|
|
|
|
if (that._needs_update !== undefined) return that._needs_update;
|
|
|
|
|
|
|
|
|
|
var needs_update = that.facet_needs_update();
|
|
|
|
|
|
|
|
|
|
//check if state changed
|
|
|
|
|
var pkeys = that.managed_entity.get_primary_key_prefix();
|
|
|
|
|
needs_update = needs_update || IPA.array_diff(pkeys, that.old_pkeys);
|
|
|
|
|
|
|
|
|
|
return needs_update;
|
|
|
|
|
};
|
|
|
|
|
|
2011-11-04 20:43:39 -05:00
|
|
|
that.show_add_dialog = function() {
|
2011-05-06 17:04:09 -04:00
|
|
|
var dialog = that.managed_entity.get_dialog('add');
|
2011-04-08 00:14:16 -05:00
|
|
|
dialog.open(that.container);
|
|
|
|
|
};
|
|
|
|
|
|
2011-11-04 20:43:39 -05:00
|
|
|
that.show_remove_dialog = function() {
|
2011-04-08 00:14:16 -05:00
|
|
|
|
2012-01-12 11:11:47 -06:00
|
|
|
var values = that.get_selected_values();
|
2011-04-08 00:14:16 -05:00
|
|
|
|
|
|
|
|
var title;
|
|
|
|
|
if (!values.length) {
|
|
|
|
|
title = IPA.messages.dialogs.remove_empty;
|
|
|
|
|
alert(title);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-19 13:46:09 -05:00
|
|
|
var dialog = that.managed_entity.get_dialog('remove');
|
2011-04-08 00:14:16 -05:00
|
|
|
|
2011-07-19 13:46:09 -05:00
|
|
|
if (!dialog) {
|
2012-01-24 15:31:18 +01:00
|
|
|
dialog = that.deleter_dialog();
|
2011-07-19 13:46:09 -05:00
|
|
|
}
|
2011-05-06 17:04:09 -04:00
|
|
|
|
2011-11-04 20:43:39 -05:00
|
|
|
dialog.entity_name = that.managed_entity.name;
|
|
|
|
|
dialog.entity = that.managed_entity;
|
2011-07-19 13:46:09 -05:00
|
|
|
dialog.facet = that;
|
2011-05-06 17:04:09 -04:00
|
|
|
|
2011-07-19 13:46:09 -05:00
|
|
|
title = IPA.messages.dialogs.remove_title;
|
2011-11-04 20:43:39 -05:00
|
|
|
var label = that.managed_entity.metadata.label;
|
2011-07-19 13:46:09 -05:00
|
|
|
dialog.title = title.replace('${entity}', label);
|
2011-04-08 00:14:16 -05:00
|
|
|
|
2011-07-19 13:46:09 -05:00
|
|
|
dialog.set_values(values);
|
2011-04-08 00:14:16 -05:00
|
|
|
|
|
|
|
|
dialog.open(that.container);
|
2011-02-08 15:41:24 -06:00
|
|
|
};
|
2010-11-09 14:22:31 -06:00
|
|
|
|
2011-04-28 19:17:58 -05:00
|
|
|
that.find = function() {
|
|
|
|
|
var filter = that.filter.val();
|
2012-03-22 17:03:57 +01:00
|
|
|
var old_filter = IPA.nav.get_state(that.managed_entity.name+'-filter');
|
2011-04-28 19:17:58 -05:00
|
|
|
var state = {};
|
2011-11-07 14:21:45 -06:00
|
|
|
state[that.managed_entity.name + '-filter'] = filter;
|
2012-03-22 17:03:57 +01:00
|
|
|
|
|
|
|
|
if (filter !== old_filter) that.set_expired_flag();
|
|
|
|
|
|
2011-04-28 19:17:58 -05:00
|
|
|
IPA.nav.push_state(state);
|
|
|
|
|
};
|
|
|
|
|
|
2011-11-04 20:43:39 -05:00
|
|
|
that.get_search_command_name = function() {
|
2012-01-17 15:50:49 -06:00
|
|
|
var name = that.managed_entity.name + '_find';
|
|
|
|
|
if (that.pagination && !that.search_all_entries) {
|
|
|
|
|
name += '_pkeys';
|
|
|
|
|
}
|
|
|
|
|
return name;
|
2011-11-04 20:43:39 -05:00
|
|
|
};
|
|
|
|
|
|
2012-01-17 15:50:49 -06:00
|
|
|
that.create_refresh_command = function() {
|
2011-04-08 00:14:16 -05:00
|
|
|
|
2012-03-22 17:03:57 +01:00
|
|
|
var filter = that.managed_entity.get_primary_key_prefix();
|
|
|
|
|
filter.push(IPA.nav.get_state(that.managed_entity.name+'-filter'));
|
2011-05-06 17:04:09 -04:00
|
|
|
|
2011-04-08 00:14:16 -05:00
|
|
|
var command = IPA.command({
|
2011-11-04 20:43:39 -05:00
|
|
|
name: that.get_search_command_name(),
|
|
|
|
|
entity: that.managed_entity.name,
|
2011-04-12 02:13:30 -05:00
|
|
|
method: 'find',
|
2011-05-06 17:04:09 -04:00
|
|
|
args: filter,
|
2011-04-08 00:14:16 -05:00
|
|
|
options: {
|
2012-01-17 15:50:49 -06:00
|
|
|
all: that.search_all_attributes
|
2011-11-18 19:47:39 -06:00
|
|
|
}
|
2011-04-08 00:14:16 -05:00
|
|
|
});
|
|
|
|
|
|
2011-11-04 20:43:39 -05:00
|
|
|
if (that.pagination) {
|
2012-01-17 15:50:49 -06:00
|
|
|
if (!that.search_all_entries) command.set_option('pkey_only', true);
|
2011-11-04 20:43:39 -05:00
|
|
|
command.set_option('sizelimit', 0);
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-17 15:50:49 -06:00
|
|
|
return command;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
that.refresh = function() {
|
|
|
|
|
|
|
|
|
|
var command = that.create_refresh_command();
|
|
|
|
|
|
2011-11-18 19:47:39 -06:00
|
|
|
command.on_success = function(data, text_status, xhr) {
|
|
|
|
|
that.filter.focus();
|
|
|
|
|
that.load(data);
|
2012-03-16 14:44:11 +01:00
|
|
|
that.show_content();
|
2011-11-18 19:47:39 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
command.on_error = function(xhr, text_status, error_thrown) {
|
|
|
|
|
that.report_error(error_thrown);
|
|
|
|
|
};
|
|
|
|
|
|
2011-04-08 00:14:16 -05:00
|
|
|
command.execute();
|
2011-02-08 15:41:24 -06:00
|
|
|
};
|
2010-09-16 10:28:07 -04:00
|
|
|
|
2011-10-24 14:53:29 +02:00
|
|
|
that.clear = function() {
|
2011-11-04 20:43:39 -05:00
|
|
|
if (that.needs_clear()) {
|
2011-10-24 14:53:29 +02:00
|
|
|
that.table.clear();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
that.needs_clear = function() {
|
2012-03-22 17:03:57 +01:00
|
|
|
var clear = false;
|
2011-10-24 14:53:29 +02:00
|
|
|
var filter = IPA.nav.get_state(that.entity.name+'-filter') || '';
|
2012-03-22 17:03:57 +01:00
|
|
|
clear = that.old_filter !== '' || that.old_filter !== filter;
|
|
|
|
|
|
|
|
|
|
var pkeys = that.managed_entity.get_primary_key_prefix();
|
|
|
|
|
clear = clear || IPA.array_diff(pkeys, that.old_pkeys);
|
|
|
|
|
|
|
|
|
|
return clear;
|
2011-10-24 14:53:29 +02:00
|
|
|
};
|
|
|
|
|
|
2012-04-17 16:25:20 +02:00
|
|
|
that.init_search_facet = function() {
|
|
|
|
|
|
|
|
|
|
that.init_facet();
|
|
|
|
|
that.init_table_columns();
|
|
|
|
|
that.init_table(that.managed_entity);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!no_init) that.init_search_facet();
|
2011-11-04 20:43:39 -05:00
|
|
|
|
2011-02-08 15:41:24 -06:00
|
|
|
// methods that should be invoked by subclasses
|
2011-11-04 20:43:39 -05:00
|
|
|
that.search_facet_refresh = that.refresh;
|
2012-01-17 15:50:49 -06:00
|
|
|
that.search_facet_create_refresh_command = that.create_refresh_command;
|
2011-10-10 13:34:15 +02:00
|
|
|
|
2010-11-09 14:22:31 -06:00
|
|
|
return that;
|
2011-01-14 12:16:25 -05:00
|
|
|
};
|
2011-05-06 17:04:09 -04:00
|
|
|
|
2011-07-19 13:46:09 -05:00
|
|
|
IPA.search_deleter_dialog = function(spec) {
|
|
|
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
|
|
|
|
|
var that = IPA.deleter_dialog(spec);
|
|
|
|
|
|
|
|
|
|
that.create_command = function() {
|
2011-08-11 10:28:50 +02:00
|
|
|
var batch = IPA.batch_command({
|
|
|
|
|
error_message: IPA.messages.search.partial_delete
|
|
|
|
|
});
|
2011-07-19 13:46:09 -05:00
|
|
|
|
|
|
|
|
var pkeys = that.entity.get_primary_key_prefix();
|
|
|
|
|
|
|
|
|
|
for (var i=0; i<that.values.length; i++) {
|
|
|
|
|
var command = IPA.command({
|
|
|
|
|
entity: that.entity.name,
|
|
|
|
|
method: 'del'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (var j=0; j<pkeys.length; j++) {
|
|
|
|
|
command.add_arg(pkeys[j]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var value = that.values[i];
|
|
|
|
|
if (value instanceof Object) {
|
|
|
|
|
for (var key in value) {
|
|
|
|
|
if (value.hasOwnProperty(key)) {
|
|
|
|
|
if (key === 'pkey'){
|
|
|
|
|
command.add_arg(value[key]);
|
|
|
|
|
} else {
|
|
|
|
|
command.set_option(key, value[key]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
command.add_arg(value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
batch.add_command(command);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return batch;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
that.execute = function() {
|
|
|
|
|
|
|
|
|
|
var batch = that.create_command();
|
|
|
|
|
|
|
|
|
|
batch.on_success = function() {
|
|
|
|
|
that.facet.refresh();
|
|
|
|
|
that.close();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
batch.on_error = function() {
|
|
|
|
|
that.facet.refresh();
|
|
|
|
|
that.close();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
batch.execute();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
that.search_deleter_dialog_create_command = that.create_command;
|
|
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
};
|
2011-05-06 17:04:09 -04:00
|
|
|
|
|
|
|
|
/*TODO. this has much copied code from above. Refactor the search_facet
|
|
|
|
|
To either be nested or not nested. */
|
2011-06-21 15:05:44 -05:00
|
|
|
IPA.nested_search_facet = function(spec) {
|
|
|
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
|
2011-11-07 14:21:45 -06:00
|
|
|
spec.managed_entity = IPA.get_entity(spec.nested_entity);
|
2011-06-21 15:05:44 -05:00
|
|
|
|
2011-06-22 21:54:28 -05:00
|
|
|
spec.disable_breadcrumb = false;
|
2011-06-21 15:05:44 -05:00
|
|
|
spec.disable_facet_tabs = false;
|
|
|
|
|
|
2011-05-06 17:04:09 -04:00
|
|
|
var that = IPA.search_facet(spec);
|
|
|
|
|
|
|
|
|
|
that.show = function() {
|
|
|
|
|
that.facet_show();
|
|
|
|
|
|
2011-06-21 15:05:44 -05:00
|
|
|
that.header.set_pkey(
|
2011-06-28 13:39:10 -04:00
|
|
|
IPA.nav.get_state(IPA.current_entity.name+'-pkey'));
|
2011-05-23 17:48:37 -05:00
|
|
|
|
2012-03-22 17:03:57 +01:00
|
|
|
var filter = IPA.nav.get_state(that.managed_entity.name+'-filter');
|
|
|
|
|
that.old_filter = filter || '';
|
|
|
|
|
that.old_pkeys = that.managed_entity.get_primary_key_prefix();
|
|
|
|
|
|
2011-05-06 17:04:09 -04:00
|
|
|
if (that.filter) {
|
|
|
|
|
that.filter.val(filter);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2011-11-04 20:43:39 -05:00
|
|
|
that.refresh = function() {
|
2011-05-06 17:04:09 -04:00
|
|
|
|
2011-06-28 13:39:10 -04:00
|
|
|
var pkey = IPA.nav.get_state(that.entity.name+'-pkey');
|
2011-05-06 17:04:09 -04:00
|
|
|
|
|
|
|
|
if ((!pkey) && (that.entity.redirect_facet)) {
|
2011-06-23 11:44:44 -05:00
|
|
|
that.redirect();
|
2011-05-06 17:04:09 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-04 20:43:39 -05:00
|
|
|
that.search_facet_refresh();
|
2011-05-06 17:04:09 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
};
|
2012-04-30 15:47:24 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Calls entity's disable command for each selected item in a batch.
|
|
|
|
|
* Usable in table facets.
|
|
|
|
|
*/
|
|
|
|
|
IPA.batch_items_action = function(spec) {
|
|
|
|
|
|
|
|
|
|
spec = spec || {};
|
|
|
|
|
|
|
|
|
|
var that = IPA.action(spec);
|
|
|
|
|
|
|
|
|
|
that.method = spec.method || 'disable';
|
|
|
|
|
|
|
|
|
|
that.execute = function(facet, on_success, on_error) {
|
|
|
|
|
|
|
|
|
|
var entity = facet.managed_entity;
|
|
|
|
|
var pkeys = facet.get_selected_values();
|
|
|
|
|
|
|
|
|
|
var batch = IPA.batch_command({
|
|
|
|
|
name: entity.name + '_batch_'+ that.method,
|
|
|
|
|
on_success: function() {
|
|
|
|
|
facet.refresh();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (var i=0; i<pkeys.length; i++) {
|
|
|
|
|
var pkey = pkeys[i];
|
|
|
|
|
|
|
|
|
|
var command = IPA.command({
|
|
|
|
|
entity: entity.name,
|
|
|
|
|
method: that.method,
|
|
|
|
|
args: [pkey]
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
batch.add_command(command);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
batch.execute();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return that;
|
|
|
|
|
};
|