From cbffe1d65df222acf6eb26cdaa121932a01f9ba7 Mon Sep 17 00:00:00 2001 From: Adam Young Date: Wed, 22 Jun 2011 13:21:40 -0400 Subject: automountkey details Adds hooks for navigation to the show page due to the unusual way that keys are accessed. https://fedorahosted.org/freeipa/ticket/1257 --- install/ui/add.js | 24 +++++++++------- install/ui/automount.js | 75 ++++++++++++++++++++++++++++++++++++++++++++++--- install/ui/details.js | 18 ++++++++++-- install/ui/webui.js | 1 + 4 files changed, 102 insertions(+), 16 deletions(-) diff --git a/install/ui/add.js b/install/ui/add.js index cde6d335b..67e14eddc 100644 --- a/install/ui/add.js +++ b/install/ui/add.js @@ -33,8 +33,19 @@ IPA.add_dialog = function (spec) { that.title = spec.title; that._entity_name = spec.entity_name; that.method = spec.method || 'add'; - that.init = function() { + function show_edit_page(entity_name,result){ + var pkey_name = IPA.metadata.objects[entity_name].primary_key; + var pkey = result[pkey_name]; + if (pkey instanceof Array) { + pkey = pkey[0]; + } + IPA.nav.show_page(that.entity_name, 'default', pkey); + } + + that.show_edit_page = spec.show_edit_page || show_edit_page; + + that.init = function() { that.add_button(IPA.messages.buttons.add, function() { var record = {}; that.save(record); @@ -74,16 +85,9 @@ IPA.add_dialog = function (spec) { function(data, text_status, xhr) { that.close(); - var pkey_name = IPA.metadata.objects[that.entity_name].primary_key; - + var entity_name = that.entity_name; var result = data.result.result; - var pkey = result[pkey_name]; - - if (pkey instanceof Array) { - pkey = pkey[0]; - } - - IPA.nav.show_page(that.entity_name, 'default', pkey); + that.show_edit_page(entity_name,result); } ); }); diff --git a/install/ui/automount.js b/install/ui/automount.js index 3e031769c..6ef970544 100644 --- a/install/ui/automount.js +++ b/install/ui/automount.js @@ -66,8 +66,15 @@ IPA.entity_factories.automountmap = function() { label : IPA.metadata.objects.automountkey.label, name: 'keys', get_values: IPA.get_option_values, - columns:['automountkey','automountinformation'], - back_link_text: 'Back to Locations' + back_link_text: 'Back to Locations', + columns:[ + { + factory: IPA.automount_key_column, + name:'automountkey', + label:IPA.get_entity_param('automountkey', 'automountkey'). + label + }, + 'automountinformation'] }). details_facet({ sections:[ @@ -114,17 +121,77 @@ IPA.entity_factories.automountkey = function() { { name:'identity', label: IPA.messages.details.identity, - fields:['automountkey','automountinformation','description'] + fields:[ + { + factory: IPA.text_widget, + read_only: true, + name: 'automountkey' + }, + 'automountinformation'] } ], - back_link_text: 'Back to Locations' + disable_breadcrumb: false, + back_link_text: 'Back to Locations', + pre_execute_hook : function (command){ + var entity_name = this.entity_name; + var info = IPA.nav.get_state(entity_name + '-info'); + var key = IPA.nav.get_state(entity_name + '-pkey'); + + + if (command.args.length ==3){ + command.args.pop(); + } + if (command.method === 'mod'){ + command.options['newautomountinformation'] = + command.options['automountinformation']; + + } + command.options['automountkey'] = key; + command.options['automountinformation'] = info; + } }). adder_dialog({ + show_edit_page : function(entity_name, result){ + var key = result.automountkey[0]; + var info = result.automountinformation[0]; + var state = IPA.nav.get_path_state(entity_name); + state[entity_name + '-facet'] = 'default'; + state[entity_name + '-info'] = info; + state[entity_name + '-pkey'] = key; + IPA.nav.push_state(state); + return false; + }, fields:['automountkey','automountinformation'] }). build(); }; +IPA.automount_key_column = function(spec){ + var that = IPA.column(spec); + + that.setup = function(container, record) { + container.empty(); + var key = record.automountkey; + var info = record.automountinformation; + + $('', { + href: '#'+key, + html: key, + click: function() { + var state = IPA.nav.get_path_state(that.entity_name); + state[that.entity_name + '-facet'] = 'default'; + state[that.entity_name + '-info'] = info; + state[that.entity_name + '-pkey'] = key; + IPA.nav.push_state(state); + return false; + } + }).appendTo(container); + + }; + + return that; +}; + IPA.automountmap_adder_dialog = function(spec){ var that = IPA.add_dialog(spec); diff --git a/install/ui/details.js b/install/ui/details.js index 477857b20..2db80fbaa 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -266,6 +266,8 @@ IPA.details_facet = function(spec) { var that = IPA.facet(spec); + that.pre_execute_hook = spec.pre_execute_hook; + that.label = spec.label || IPA.messages && IPA.messages.facets && IPA.messages.facets.details; that.facet_group = spec.facet_group || 'settings'; @@ -336,8 +338,12 @@ IPA.details_facet = function(spec) { that.create = function(container) { if (that.entity.facets.length == 1) { - that.disable_breadcrumb = true; - that.disable_facet_tabs = true; + if (that.disable_breadcrumb === undefined) { + that.disable_breadcrumb = true; + } + if (that.disable_facet_tabs === undefined) { + that.disable_facet_tabs = true; + } } that.facet_create(container); @@ -617,6 +623,10 @@ IPA.details_facet = function(spec) { //alert(JSON.stringify(command.to_json())); + if (that.pre_execute_hook){ + that.pre_execute_hook(command); + } + command.execute(); }; @@ -653,6 +663,10 @@ IPA.details_facet = function(spec) { command.on_error = that.on_error; + if (that.pre_execute_hook){ + that.pre_execute_hook(command); + } + command.execute(); }; diff --git a/install/ui/webui.js b/install/ui/webui.js index cfbb9e69b..5dc2cead6 100644 --- a/install/ui/webui.js +++ b/install/ui/webui.js @@ -55,6 +55,7 @@ IPA.admin_navigation = function(spec) { ]}, {entity: 'automountlocation', label: IPA.messages.tabs.automount}, {entity: 'automountmap',hidden:true}, + {entity: 'automountkey',hidden:true}, {entity: 'pwpolicy'}, {entity: 'krbtpolicy'} ]}, -- cgit