Add support for custom table pagination size
New customization button opens dialog with field for setting the number of lines in tables. After saving the new value there is new topic which starts refreshing current table facet (if shown) and set all other facets expired. Therefore all tables are immediately regenerated. https://fedorahosted.org/freeipa/ticket/5742 Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
This commit is contained in:
1 parent
f78cc89326
commit
e1dfc51e48
6 files changed
+77
-6
No files matched your search
@@ -32,6 +32,8 @@ define([
|
||||
'./widgets/FacetContainer',
|
||||
'./ipa',
|
||||
'./reg',
|
||||
'./config',
|
||||
'./widget',
|
||||
'./navigation/Menu',
|
||||
'./navigation/Router',
|
||||
'./navigation/routing',
|
||||
@@ -39,7 +41,8 @@ define([
|
||||
'./plugins/load_page'
|
||||
],
|
||||
function(declare, array, Deferred, on, topic, query, dom_class, auth,
|
||||
JSON, App_widget, FacetContainer, IPA, reg, Menu, Router, routing, menu_spec) {
|
||||
JSON, App_widget, FacetContainer, IPA, reg, config, widget_mod,
|
||||
Menu, Router, routing, menu_spec) {
|
||||
|
||||
/**
|
||||
* Application controller
|
||||
@@ -110,6 +113,7 @@ define([
|
||||
on(this.app_widget, 'profile-click', this.on_profile.bind(this));
|
||||
on(this.app_widget, 'logout-click', this.on_logout.bind(this));
|
||||
on(this.app_widget, 'password-reset-click', this.on_password_reset.bind(this));
|
||||
on(this.app_widget, 'configuration-click', this.on_configuration.bind(this));
|
||||
on(this.app_widget, 'about-click', this.on_about.bind(this));
|
||||
|
||||
on(this.router, 'facet-show', this.on_facet_show.bind(this));
|
||||
@@ -173,7 +177,6 @@ define([
|
||||
|
||||
IPA.update_password_expiration();
|
||||
|
||||
|
||||
// now we are ready for displaying a facet,
|
||||
// it can match a facet if hash is set
|
||||
this.router.startup();
|
||||
@@ -239,6 +242,49 @@ define([
|
||||
IPA.password_selfservice();
|
||||
},
|
||||
|
||||
on_configuration: function() {
|
||||
var dialog = IPA.dialog({
|
||||
title: '@i18n:customization.customization',
|
||||
fields: [
|
||||
{
|
||||
$type: 'text',
|
||||
name: 'pagination_size',
|
||||
label: '@i18n:customization.table_pagination',
|
||||
validators: ['integer']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
dialog.create_button({
|
||||
name: 'save',
|
||||
label: '@i18n:buttons.save',
|
||||
click: function () {
|
||||
if (!dialog.validate()) {
|
||||
widget_mod.focus_invalid(dialog);
|
||||
return;
|
||||
}
|
||||
var widget = dialog.get_field('pagination_size').widget;
|
||||
var new_value = widget.get_value()[0];
|
||||
config.set('table_page_size', new_value, true);
|
||||
topic.publish('change-pagination');
|
||||
dialog.close();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.create_button({
|
||||
name: 'cancel',
|
||||
label: '@i18n:buttons.cancel',
|
||||
click: function () {
|
||||
dialog.close();
|
||||
}
|
||||
});
|
||||
|
||||
dialog.open();
|
||||
|
||||
var size = config.get('table_page_size').toString();
|
||||
dialog.get_field('pagination_size').set_value([size]);
|
||||
},
|
||||
|
||||
on_about: function() {
|
||||
var dialog = IPA.about_dialog();
|
||||
dialog.open();
|
||||
|
||||
@@ -25,12 +25,14 @@ define([
|
||||
'dojo/_base/declare',
|
||||
'dojo/_base/lang',
|
||||
'dojo/dom-construct',
|
||||
'dojo/topic',
|
||||
'dojo/on',
|
||||
'dojo/Stateful',
|
||||
'dojo/Evented',
|
||||
'./_base/Singleton_registry',
|
||||
'./_base/construct',
|
||||
'./builder',
|
||||
'./config',
|
||||
'./ipa',
|
||||
'./jquery',
|
||||
'./navigation',
|
||||
@@ -43,8 +45,8 @@ define([
|
||||
'./dialog',
|
||||
'./field',
|
||||
'./widget'
|
||||
], function(declare, lang, construct, on, Stateful, Evented,
|
||||
Singleton_registry, construct_utils, builder, IPA, $,
|
||||
], function(declare, lang, construct, topic, on, Stateful, Evented,
|
||||
Singleton_registry, construct_utils, builder, config, IPA, $,
|
||||
navigation, phases, reg, rpc, su, text, ActionDropdownWidget) {
|
||||
|
||||
/**
|
||||
@@ -2359,6 +2361,14 @@ exp.table_facet = IPA.table_facet = function(spec, no_init) {
|
||||
selectable: that.selectable && !that.read_only
|
||||
});
|
||||
|
||||
topic.subscribe("change-pagination", function() {
|
||||
that.table.page_length = config.get('table_page_size');
|
||||
|
||||
that.set_expired_flag();
|
||||
|
||||
if (that.is_shown) that.refresh();
|
||||
});
|
||||
|
||||
var columns = that.columns.values;
|
||||
for (var i=0; i<columns.length; i++) {
|
||||
var column = columns[i];
|
||||
|
||||
@@ -3584,7 +3584,7 @@ IPA.column = function (spec) {
|
||||
* @param {boolean} [spec.save_values=true]
|
||||
* @param {string} [spec.class] css class
|
||||
* @param {boolean} [spec.pagination] render pagination
|
||||
* @param {number} [spec.page_length=20]
|
||||
* @param {number} [spec.page_length=config.table_page_size]
|
||||
* @param {boolean} [spec.multivalued=true]
|
||||
* @param {Array} columns columns or columns specs
|
||||
* @param {string} [value_attr_name=name]
|
||||
@@ -3609,7 +3609,7 @@ IPA.table_widget = function (spec) {
|
||||
that.pagination = spec.pagination;
|
||||
that.current_page = 1;
|
||||
that.total_pages = 1;
|
||||
that.page_length = spec.page_length || 20;
|
||||
that.page_length = spec.page_length || config.get('table_page_size');
|
||||
|
||||
that.multivalued = spec.multivalued === undefined ? true : spec.multivalued;
|
||||
|
||||
|
||||
@@ -234,6 +234,8 @@ define(['dojo/_base/declare',
|
||||
this.emit('logout-click');
|
||||
} else if (item.name == 'password_reset') {
|
||||
this.emit('password-reset-click');
|
||||
} else if (item.name == 'configuration') {
|
||||
this.emit('configuration-click');
|
||||
} else if (item.name == 'about') {
|
||||
this.emit('about-click');
|
||||
}
|
||||
@@ -264,6 +266,11 @@ define(['dojo/_base/declare',
|
||||
{
|
||||
'class': 'divider'
|
||||
},
|
||||
{
|
||||
name: 'configuration',
|
||||
label: 'Customization',
|
||||
icon: 'fa-gear'
|
||||
},
|
||||
{
|
||||
name: 'about',
|
||||
label: 'About',
|
||||
|
||||
@@ -101,6 +101,10 @@
|
||||
"update": "Update",
|
||||
"view": "View"
|
||||
},
|
||||
"customization": {
|
||||
"customization": "Customization",
|
||||
"table_pagination": "Table Pagination Size",
|
||||
},
|
||||
"details": {
|
||||
"collapse_all": "Collapse All",
|
||||
"expand_all": "Expand All",
|
||||
|
||||
@@ -250,6 +250,10 @@ class i18n_messages(Command):
|
||||
"update": _("Update"),
|
||||
"view": _("View"),
|
||||
},
|
||||
"customization": {
|
||||
"customization": _("Customization"),
|
||||
"table_pagination": _("Pagination Size"),
|
||||
},
|
||||
"details": {
|
||||
"collapse_all": _("Collapse All"),
|
||||
"expand_all": _("Expand All"),
|
||||
|
||||
Reference in new issue
Block a user