[yast-commit] r48626 - in /trunk/ldap-server/src: agent/SlapdConfigAgent.cc tree_structure.ycp widgets.ycp
Author: rhafer Date: Fri Jun 27 15:59:09 2008 New Revision: 48626 URL: http://svn.opensuse.org/viewcvs/yast?rev=48626&view=rev Log: Allow to edit already defined Indexes Modified: trunk/ldap-server/src/agent/SlapdConfigAgent.cc trunk/ldap-server/src/tree_structure.ycp trunk/ldap-server/src/widgets.ycp Modified: trunk/ldap-server/src/agent/SlapdConfigAgent.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/agent/SlapdConfig... ============================================================================== --- trunk/ldap-server/src/agent/SlapdConfigAgent.cc (original) +++ trunk/ldap-server/src/agent/SlapdConfigAgent.cc Fri Jun 27 15:59:09 2008 @@ -647,7 +647,12 @@ { idx.push_back(Sub); } - (*i)->addIndex(attr, idx); + if ( ( idx.empty()) || ( ! (*i)->getDatabaseIndex(attr).empty() ) ) { + (*i)->deleteIndex( attr ); + } + if ( ! idx.empty() ) { + (*i)->addIndex(attr, idx); + } } } break; Modified: trunk/ldap-server/src/tree_structure.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/tree_structure.yc... ============================================================================== --- trunk/ldap-server/src/tree_structure.ycp (original) +++ trunk/ldap-server/src/tree_structure.ycp Fri Jun 27 15:59:09 2008 @@ -1011,6 +1011,7 @@ substrIdx = _("Yes"); } newItems = add( newItems, `item( `id(i), attr, presIdx, eqIdx, substrIdx, approxIdx ) ); + i = i+1; } ); UI::ChangeWidget( `tab_idx, `Items , newItems ); @@ -1021,16 +1022,27 @@ { y2milestone("cb_input_bdb_index, handlercmd: %1", handler_cmd); integer index = (integer) widget_map[current_tree_item, "index"]:nil; - if ( handler_cmd == `pb_idx_add ) + if ( handler_cmd == `pb_idx_add || handler_cmd == `pb_idx_edit ) { + list<string> skip = []; + string editAttr = ""; + map<string, boolean> idx = $[]; map<string, map<string, boolean> > idxMap = LdapServer::GetDatabaseIndexes( index ); - list<string> skip = []; // skip attribute that already have an index defined - foreach( string attr, map<string, boolean> idx, idxMap, - { - skip = add( skip, attr ); - } - ); - map<string, any> newIdx = AddIndexPopup(skip); + if (handler_cmd == `pb_idx_add ) { + // skip attribute that already have an index defined + foreach( string attr, map<string, boolean> idx, idxMap, + { + skip = add( skip, attr ); + } + ); + } else { + any current_item_id = UI::QueryWidget(`tab_idx, `CurrentItem ); + editAttr = (string)UI::QueryWidget(`tab_idx, `Cell( current_item_id, 0 ) ); + idx = idxMap[editAttr]:$[]; + y2milestone("Selected Attr: %1 %2 %3", current_item_id, editAttr, idx ); + } + + map<string, any> newIdx = DatabaseIndexPopup(skip, editAttr, idx); if ( size(newIdx) > 0 ) { LdapServer::ChangeDatabaseIndex( index, newIdx ); Modified: trunk/ldap-server/src/widgets.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/widgets.ycp?rev=4... ============================================================================== --- trunk/ldap-server/src/widgets.ycp (original) +++ trunk/ldap-server/src/widgets.ycp Fri Jun 27 15:59:09 2008 @@ -390,13 +390,16 @@ ) ); - define map<string,any> AddIndexPopup( list<string> skipAttrs ) + define map<string,any> DatabaseIndexPopup( list<string> skipAttrs, string editAttr, + map<string, boolean> currentIdx ) { y2milestone("AddIndexPopup skipAttrs: %1", skipAttrs ); term content = `VBox( `Heading( _("Add Index") ), - `ComboBox( `id( `cb_attrs ), `opt( `hstretch, `notify ), "Attributetypes" ), + `ReplacePoint( `id( `rp_attrs ), + `ComboBox( `id( `cb_attrs ), `opt( `hstretch, `notify ), "Attributetypes" ) + ), `Left( `CheckBox( `id( `cb_idx_pres ), _("Presence") ) ), @@ -411,19 +414,44 @@ `PushButton( `id( `pb_cancel ), Label::CancelButton() ) ) ); + map <string, map<string,boolean> > attrTypes = (map<string, map <string,boolean> >) SCR::Read( .ldapserver.schema.attributeTypes ); - list<string> items = []; - foreach(string key, map<string,boolean> idx, attrTypes, { - if ( nil == find( string elem, skipAttrs, ``( tolower(elem) == tolower(key) ) ) ) { - items = add( items, key ); - } - } ); - items = lsort(items); - UI::OpenDialog( `opt(`decorated), content ); - UI::ChangeWidget( `cb_attrs, `Items, items ); + if ( editAttr == "" ) { + list<string> items = []; + foreach(string key, map<string,boolean> idx, attrTypes, { + if ( nil == find( string elem, skipAttrs, ``( tolower(elem) == tolower(key) ) ) ) { + items = add( items, key ); + } + } ); + items = lsort(items); + UI::OpenDialog( `opt(`decorated), content ); + UI::ChangeWidget( `cb_attrs, `Items, items ); + } else { + UI::OpenDialog( `opt(`decorated), content ); + UI::ReplaceWidget(`rp_attrs, + `Label( `id( `attr ), editAttr) + ); + y2milestone("Current IDX: %1", currentIdx ); + if ( currentIdx["eq"]:false ) { + UI::ChangeWidget( `cb_idx_eq, `Value, true ); + } + if ( currentIdx["pres"]:false ) { + UI::ChangeWidget( `cb_idx_pres, `Value, true ); + } + if ( currentIdx["substr"]:false ) { + UI::ChangeWidget( `cb_idx_substr, `Value, true ); + } + } + + string selectedAttr = ""; + if ( editAttr == "" ) + { + selectedAttr = (string) UI::QueryWidget( `cb_attrs, `Value ); + } else { + selectedAttr = editAttr; + } - string selectedAttr = (string) UI::QueryWidget( `cb_attrs, `Value ); y2milestone("selected Attribute \"%1\"", selectedAttr ); map <string, boolean> idxOpt = attrTypes[selectedAttr]:nil ; y2milestone("index opts: %1", idxOpt ); @@ -455,8 +483,11 @@ { break; } - selectedAttr = (string) UI::QueryWidget( `cb_attrs, `Value ); - y2milestone("selected Attribute \"%1\"", selectedAttr ); + if ( editAttr == "" ) + { + selectedAttr = (string) UI::QueryWidget( `cb_attrs, `Value ); + y2milestone("selected Attribute \"%1\"", selectedAttr ); + } if ( ret == `cb_attrs ) // Attribute selected in the Combobox { map <string, boolean> idxOpt = attrTypes[selectedAttr]:nil ; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
rhafer@svn.opensuse.org