Author: jdsn Date: Wed Aug 27 19:24:51 2008 New Revision: 50420 URL: http://svn.opensuse.org/viewcvs/yast?rev=50420&view=rev Log: group related functions Modified: branches/tmp/jdsn/edu-users/src/EduUsers.ycp branches/tmp/jdsn/edu-users/src/complex.ycp branches/tmp/jdsn/edu-users/src/dialogs.ycp branches/tmp/jdsn/edu-users/src/wizards.ycp Modified: branches/tmp/jdsn/edu-users/src/EduUsers.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/edu-users/src/EduUser... ============================================================================== --- branches/tmp/jdsn/edu-users/src/EduUsers.ycp (original) +++ branches/tmp/jdsn/edu-users/src/EduUsers.ycp Wed Aug 27 19:24:51 2008 @@ -112,9 +112,9 @@ `delete : $[] ]; -global map<symbol, map> Template = $[ `current : $[], - `change : $[], - `delete : $[] +global map<symbol, list> Template = $[ `current : [], + `change : [], + `delete : [] ]; /** @@ -220,7 +220,7 @@ * get table of templates * @return table of templates */ -global list<term> getTemplateItems() +global list<term> getTemplateItems() { //integer count=0; list<term> table_templates = []; @@ -242,7 +242,7 @@ * get table of groups * @return table of groups */ -global list<term> getGroupItems() +global list<term> getGroupItems() { integer count=0; list<term> table_groups = []; Modified: branches/tmp/jdsn/edu-users/src/complex.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/edu-users/src/complex... ============================================================================== --- branches/tmp/jdsn/edu-users/src/complex.ycp (original) +++ branches/tmp/jdsn/edu-users/src/complex.ycp Wed Aug 27 19:24:51 2008 @@ -19,10 +19,10 @@ */ /** - * File: include/edu-users/complex.ycp - * Package: Configuration of edu-users - * Summary: Dialogs definitions - * Authors: J. Daniel Schmidt <jdsn@suse.de> + * File: include/edu-users/complex.ycp + * Package: Configuration of edu-users + * Summary: Dialogs definitions + * Authors: J. Daniel Schmidt <jdsn@suse.de> * * $Id: complex.ycp 29363 2006-03-24 08:20:43Z mzugec $ */ @@ -172,26 +172,27 @@ term contents = `VBox( `Label(_("EduUsers to Configure"))); Wizard::SetContentsButtons(caption, contents, HELPS["summary"]:"", - Label::BackButton(), Label::FinishButton()); + Label::BackButton(), Label::FinishButton()); any ret = nil; while(true) { - ret = UI::UserInput(); + ret = UI::UserInput(); - /* abort? */ - if(ret == `abort || ret == `cancel || ret == `back) { - if(ReallyAbort()) break; - else continue; - } + /* abort? */ + if(ret == `abort || ret == `cancel || ret == `back) { + if(ReallyAbort()) break; + else continue; + } /* overview dialog */ else if(ret == `edit_button) { ret = `overview; break; } - /* configure the selected device */ + + /* configure the selected device */ else if(ret == `configure_button) { - // TODO FIXME: check for change of the configuration + // TODO FIXME: check for change of the configuration any selected = UI::QueryWidget(`id(`detected_selbox), `CurrentItem); if(selected == `other) { ret = `other; @@ -226,40 +227,37 @@ /* FIXME table header */ term contents = Wizard_hw::ConfiguredContent( - /* Table header */ - `header(_("Number"), _("EduUsers")), - overview, nil, nil, nil, nil ); + /* Table header */ + `header(_("Number"), _("EduUsers")), + overview, nil, nil, nil, nil ); contents = Wizard_hw::SpacingAround(contents, 1.5, 1.5, 1.0, 1.0); Wizard::SetContentsButtons(caption, contents, HELPS["overview"]:"", - Label::BackButton(), Label::FinishButton()); + Label::BackButton(), Label::FinishButton()); any ret = nil; while(true) { - ret = UI::UserInput(); + ret = UI::UserInput(); - /* abort? */ - if(ret == `abort || ret == `cancel) { - if(ReallyAbort()) break; - else continue; - } + /* abort? */ + if(ret == `abort || ret == `cancel) { + if(ReallyAbort()) break; + else continue; + } /* add */ - else if(ret == `add_button) { - /* FIXME */ + else if(ret == `add) { ret = `add; break; } /* edit */ - else if(ret == `edit_button) { - /* FIXME */ + else if(ret == `edit) { ret = `edit; break; } /* delete */ - else if(ret == `delete_button) { - /* FIXME */ + else if(ret == `delete) { continue; } else if(ret == `next || ret == `back) { Modified: branches/tmp/jdsn/edu-users/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/edu-users/src/dialogs... ============================================================================== --- branches/tmp/jdsn/edu-users/src/dialogs.ycp (original) +++ branches/tmp/jdsn/edu-users/src/dialogs.ycp Wed Aug 27 19:24:51 2008 @@ -156,7 +156,7 @@ y2milestone("USERSUSERSUSERS: %1", users); UI::ReplaceWidget(`id(`tabContent), `Table( `id(`edutable), `opt(`notify, `vstretch) , `header( _("Name"), _("Login"), _("Age") ), users ) ); - + UI::ChangeWidget(`id(`delete), `Enabled, true); any ret = nil; while(true) { @@ -229,13 +229,15 @@ return ret; } any TemplatesDialog() { - + // fill table with data //Popup::Notify(_("Templates")); list<term> templates = EduUsers::getTemplateItems(); UI::ReplaceWidget(`id(`tabContent), `Table( `id(`edutable), `opt(`notify, `vstretch) , `header( _("Templates") ), templates ) ); + UI::ChangeWidget(`id(`edit), `Enabled, false); + UI::ChangeWidget(`id(`delete), `Enabled, true); any ret = nil; while(true) { @@ -253,8 +255,8 @@ else if(ret == `templates) { continue; } - else if(ret == `add || ret == `edit || ret == `delete) { - continue; + else if(ret == `add || ret == `delete) { + break; } else { y2error("unexpected retcode: %1", ret); @@ -262,31 +264,123 @@ } } + UI::ChangeWidget(`id(`edit), `Enabled, true); return ret; } any UserDelete() { return `userdelete; } -any GroupAdd() { - return `groupadd; -} + any GroupEdit() { return `groupedit; } any GroupDelete() { return `groupdelete; } -any TemplateAdd() { - return `templateadd; + +symbol GroupMap(symbol toChange, string key, string value) +{ + //EduUsers::Group[toChange] = add(EduUsers::Group[toChange]:$[] , $[ key : value ] ); + EduUsers::Group[toChange, key] = value; + y2milestone("Mapped Group %1 to %2", key, value); + return `next; } -any TemplateEdit() { - return `templateedit; + + +symbol GroupAdd() +{ + UI::OpenDialog(`VBox( + `Label("Create a new group"), + `InputField(`id(`groupEnt),"Groupname"), + `ComboBox(`id(`templateCom),"Template",["Waschmaschine","Spuelmaschine","Dusche"] ), //EduUsers::getTemplateItems() + `HBox( + `PushButton( `id( `ok ), "OK" ), + `PushButton( `id( `cancel ), "Cancel" ) + ))); + while("hell" != "frozen up") + { + any ret = UI::UserInput(); + if(ret == `cancel || ret == `abort) + { + if(ReallyAbort()) break; + else continue; + } + else if(ret == `ok) + { + string key = (string) UI::QueryWidget(`id(`groupEnt), `Value); + string value = (string) UI::QueryWidget(`id(`templateCom), `CurrentItem); + GroupMap(`change, key, value); + y2milestone("Added group %1 with template %2", key, value); + break; + } + else + { + y2error("Unknown return code : %1", ret); + continue; + } + } + UI::CloseDialog(); + return `next; } -any TemplateDelete() { - return `templatedelete; + + + + + + + +boolean TemplateMap(symbol toChange, string templ) +{ + EduUsers::Template[toChange] = add(EduUsers::Template[toChange]:[], templ); + y2milestone("Template %1 mapped to %2 .", templ, toChange); + return true; } +symbol TemplateAdd() +{ + UI::OpenDialog(`VBox( + `Label("Enter or change the Template!"), + `InputField(`id(`templateEnt),"Template"), + `HBox( + `PushButton( `id( `ok ), "OK" ), + `PushButton( `id( `cancel ), "Cancel" ) + ))); + while("hell" != "frozen up") + { + any ret = UI::UserInput(); + if(ret == `cancel || ret == `abort) + { + if(ReallyAbort()) break; + else continue; + } + else if(ret == `ok) + { + string template = (string)UI::QueryWidget(`id(`templateEnt),`Value); + y2milestone("Added template : %1",template); + TemplateMap(`change,template); + break; + } + else + { + y2error("Unknown return code : %1",ret); + continue; + } + } + UI::CloseDialog(); + return `next; +} + + +symbol TemplateDelete() { + string val = (string) UI::QueryWidget(`id(`edutable),`CurrentItem); + if(Popup::YesNo (sformat("Are you sure you want to remove %1", val))) + { + y2milestone("Template %1 deleted.", val); + TemplateMap(`delete,val); + } + return `next; +} Modified: branches/tmp/jdsn/edu-users/src/wizards.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/jdsn/edu-users/src/wizards... ============================================================================== --- branches/tmp/jdsn/edu-users/src/wizards.ycp (original) +++ branches/tmp/jdsn/edu-users/src/wizards.ycp Wed Aug 27 19:24:51 2008 @@ -80,7 +80,6 @@ "groupedit" : ``( GroupEdit() ), "groupdelete" : ``( GroupDelete() ), "tmpladd" : ``( TemplateAdd() ), - "tmpledit" : ``( TemplateEdit() ), "tmpldelete" : ``( TemplateDelete() ) ]; @@ -110,46 +109,49 @@ `users : "users", `groups : "groups", `add : "tmpladd", - `edit : "tmpledit", `delete : "tmpldelete" ], "useradd" : $[ `abort : "users", - `next : "users" + `next : "users", + `back : "users" ], "useredit" : $[ `abort : "users", - `next : "users" + `next : "users", + `back : "users" ], "userdelete" : $[ `abort : "users", - `next : "users" + `next : "users", + `back : "users" ], "groupadd" : $[ `abort : `abort, - `next : "groups" + `next : "groups", + `back : "groups" ], "groupedit" : $[ `abort : `abort, - `next : "groups" + `next : "groups", + `back : "groups" ], "groupdelete" : $[ `abort : `abort, - `next : "groups" + `next : "groups", + `back : "groups" ], "tmpladd" : $[ - `abort : `abort, - `next : "templates" - ], - "tmpledit" : $[ - `abort : `abort, - `next : "templates" + `abort : "templates", + `next : "templates", + `back : "templates" ], "tmpldelete" : $[ - `abort : `abort, - `next : "templates" + `abort : "templates", + `next : "templates", + `back : "templates" ] ]; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org