diff options
author | Pavel Vomacka <pvomacka@redhat.com> | 2016-08-11 15:58:23 +0200 |
---|---|---|
committer | Martin Babinsky <mbabinsk@redhat.com> | 2017-03-08 14:54:56 +0100 |
commit | e1dfc51e48050ac1ad431d56003dc26e17ca653e (patch) | |
tree | 622372a90f2d158acb3fab707fdfaaeb7bb1d96c /install/ui/src | |
parent | f78cc8932626de667c6e3a4461141a10a5d9c2e6 (diff) | |
download | freeipa-e1dfc51e48050ac1ad431d56003dc26e17ca653e.tar.gz freeipa-e1dfc51e48050ac1ad431d56003dc26e17ca653e.tar.xz freeipa-e1dfc51e48050ac1ad431d56003dc26e17ca653e.zip |
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>
Diffstat (limited to 'install/ui/src')
-rw-r--r-- | install/ui/src/freeipa/Application_controller.js | 50 | ||||
-rw-r--r-- | install/ui/src/freeipa/facet.js | 14 | ||||
-rw-r--r-- | install/ui/src/freeipa/widget.js | 4 | ||||
-rw-r--r-- | install/ui/src/freeipa/widgets/App.js | 7 |
4 files changed, 69 insertions, 6 deletions
diff --git a/install/ui/src/freeipa/Application_controller.js b/install/ui/src/freeipa/Application_controller.js index 43d5409ce..32add5f8f 100644 --- a/install/ui/src/freeipa/Application_controller.js +++ b/install/ui/src/freeipa/Application_controller.js @@ -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(); diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js index 06eca189f..ab5af1ff9 100644 --- a/install/ui/src/freeipa/facet.js +++ b/install/ui/src/freeipa/facet.js @@ -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]; diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 17b137628..8b3394dcf 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -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; diff --git a/install/ui/src/freeipa/widgets/App.js b/install/ui/src/freeipa/widgets/App.js index 21e51a705..68b78c7c4 100644 --- a/install/ui/src/freeipa/widgets/App.js +++ b/install/ui/src/freeipa/widgets/App.js @@ -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'); } @@ -265,6 +267,11 @@ define(['dojo/_base/declare', 'class': 'divider' }, { + name: 'configuration', + label: 'Customization', + icon: 'fa-gear' + }, + { name: 'about', label: 'About', icon: 'fa-question' |