Author: husted
Date: Fri Jun 24 19:22:32 2005
New Revision: 201709

URL: http://svn.apache.org/viewcvs?rev=201709&view=rev
Log:
OVR-5
* Supress editing column if user is not an editor. 
* TODO: Change Edit column to a checkbox. Add Editor filter.

Added:
    struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs
Modified:
    struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj
    struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Web/AppGridHelper.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Web.config
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/Catalog.xml
    struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Query/SelectAll.xml

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs?rev=201709&r1=201708&r2=201709&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/App.cs Fri Jun 24 19:22:32 
2005
@@ -79,7 +79,7 @@
                /// Token for select all command.
                /// </summary>
                /// 
-               public const string FILTER = "filter";
+               public const string ENTRY_LIST = "entry_list";
 
                /// <summary>
                /// Token for List Last Names command.

Added: struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs?rev=201709&view=auto
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs (added)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Commands/BaseEntry.cs Fri Jun 
24 19:22:32 2005
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System.Collections;
+using Nexus.Core;
+
+namespace PhoneBook.Core.Commands
+{
+       /// <summary>
+       /// Execute database statement for QueryID for a single object, 
+       /// returning each attribute in the main context.
+       /// </summary>
+       /// 
+       public class BaseEntry : AppCommand
+       {
+               public override bool RequestExecute (IRequestContext context)
+               {
+                       object o = Mapper ().QueryForObject (QueryID, context);
+                       context [ID] = o;
+                       IDictionary entry = o as IDictionary;
+                       foreach (DictionaryEntry e in entry)
+                       {
+                               context [e.Key] = e.Value;
+                       }
+                       return CONTINUE;
+               }
+       }
+}
\ No newline at end of file

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj?rev=201709&r1=201708&r2=201709&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Core/Core.csproj Fri Jun 24 
19:22:32 2005
@@ -140,6 +140,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "Commands\BaseEntry.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "Commands\BaseFilterList.cs"
                     SubType = "Code"
                     BuildAction = "Compile"

Modified: 
struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs?rev=201709&r1=201708&r2=201709&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Test/Commands/SelectAllTest.cs Fri 
Jun 24 19:22:32 2005
@@ -54,7 +54,7 @@
                [Test]
                public void SelectAll_Pass ()
                {
-                       IRequestContext context = catalog.ExecuteRequest 
(App.FILTER);
+                       IRequestContext context = catalog.ExecuteRequest 
(App.ENTRY_LIST);
                        SelectAll_Result (context);
                }
 

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/AppGridHelper.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/AppGridHelper.cs?rev=201709&r1=201708&r2=201709&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/AppGridHelper.cs (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/AppGridHelper.cs Fri Jun 24 
19:22:32 2005
@@ -10,5 +10,13 @@
                {
                        return new AppEntryList ();
                }
+
+               private bool _HasEditColumn = true;
+               public override bool HasEditColumn
+               {
+                       get { return _HasEditColumn; }
+                       set { _HasEditColumn = value; }
+               }
+
        }
 }

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs?rev=201709&r1=201708&r2=201709&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Directory2.aspx.cs Fri 
Jun 24 19:22:32 2005
@@ -48,31 +48,28 @@
                {
                        set
                        {
-                               if (value==null) 
-                                       _Profile = NewProfile();
-                               else 
+                               if (value == null)
+                                       _Profile = NewProfile ();
+                               else
                                        _Profile = value;
 
                        }
-                       get
-                       {
-                               return _Profile;
-                       }
+                       get { return _Profile; }
                }
 
-               protected AppUserProfile NewProfile()   {
-                       
+               protected AppUserProfile NewProfile ()
+               {
                        WindowsIdentity id = WindowsIdentity.GetCurrent ();
                        AppUserProfile profile = new AppUserProfile (id);
                        Session [UserProfile.USER_PROFILE] = profile;
 
-                       UserHelper.Criteria[App.USER_NAME] = profile.UserId;
-                       UserHelper.Execute();
+                       UserHelper.Criteria [App.USER_NAME] = profile.UserId;
+                       UserHelper.Execute ();
                        if (UserHelper.IsNominal)
                        {
-                               string editor = UserHelper.Criteria[App.EDITOR] 
as string;
-                               bool isEditor = ((editor!=null) && 
(editor=="1"));
-                               profile.IsEditor = isEditor;                    
        
+                               string editor = UserHelper.Criteria 
[App.EDITOR] as string;
+                               bool isEditor = ((editor != null) && 
(editor.Equals ("1")));
+                               profile.IsEditor = isEditor;
                        }
 
                        return profile;
@@ -186,10 +183,11 @@
                        base.Page_Init ();
                        pnlList.Visible = true;
                        pnlError.Visible = false;
-                       if (!IsPostBack) 
+                       Profile = Session [UserProfile.USER_PROFILE] as 
AppUserProfile;
+                       GridHelper.HasEditColumn = Profile.IsEditor;
+                       if (!IsPostBack)
                        {
                                Page_Prompt = msg_FILTER;
-                               Profile = Session [UserProfile.USER_PROFILE] as 
AppUserProfile;
                                lblUser.Text = Profile.UserId;
                        }
                }

Modified: struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Web.config
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Web.config?rev=201709&r1=201708&r2=201709&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Web.config (original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Forms/Web.config Fri Jun 24 
19:22:32 2005
@@ -22,7 +22,7 @@
               
                <object id="Directory2" type="Directory2.aspx">
                        <property name="GridHelper"><ref 
object="directory_grid_helper"/></property>
-                       <property name="UserHelper"><ref 
object="directory_list_helper"/></property>
+                       <property name="UserHelper"><ref 
object="directory_entry_helper"/></property>
                </object>
 
    </objects>

Modified: 
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml?rev=201709&r1=201708&r2=201709&view=diff
==============================================================================
--- 
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml 
(original)
+++ 
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/AppConfig.xml 
Fri Jun 24 19:22:32 2005
@@ -14,7 +14,7 @@
                                <ref object="user_name"/> 
                                <ref object="hired"/> 
                                <ref object="hours"/>                           
-                               <ref object="_filter"/> 
+                               <ref object="_entry_list"/> 
                                <ref object="_extension_list"/>
                                <ref object="_hired_list"/>
                        </list>
@@ -69,8 +69,8 @@
        </object>
 
        <!-- We need to "hash" the name with "_" to avoid conflict with the 
filter Command -->
-       <object id="_filter" parent="BaseFieldContext">
-               <property name="ID"><value>filter</value></property>
+       <object id="_entry_list" parent="BaseFieldContext">
+               <property name="ID"><value>entry_list</value></property>
                <property 
name="ProcessorID"><value>EntryListProcessor</value></property>
        </object>
                

Modified: 
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/Catalog.xml
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/Catalog.xml?rev=201709&r1=201708&r2=201709&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/Catalog.xml 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Command/Catalog.xml 
Fri Jun 24 19:22:32 2005
@@ -3,12 +3,14 @@
   "http://www.springframework.net/dtd/spring-objects.dtd";>
 <objects>
 
-       <!-- filter command -->
+       <!-- entry commands -->
 
-  <object id="filter" type="PhoneBook.Core.Commands.BaseList, PhoneBook.Core">
+  <object id="entry_list" type="PhoneBook.Core.Commands.BaseList, 
PhoneBook.Core">
+               <property name="ID"><value>entry_list</value></property>
+               <property name="QueryID"><value>entry</value></property>
                <property name="RelatedIDs">
                        <list>
-                               <value>filter</value>
+                               <value>entry_list</value>
                                <value>entry_key</value>
                                <value>last_name</value>
                                <value>first_name</value>
@@ -19,8 +21,25 @@
                                <value>editor</value>
                        </list>
                </property>
-               <property name="ID"><value>filter</value></property>
   </object>
+  
+  <object id="entry" type="PhoneBook.Core.Commands.BaseEntry, PhoneBook.Core">
+               <property name="ID"><value>entry</value></property>
+               <property name="RelatedIDs">
+                       <list>
+                               <value>entry</value>
+                               <value>entry_key</value>
+                               <value>last_name</value>
+                               <value>first_name</value>
+                               <value>extension</value>
+                               <value>user_name</value>
+                               <value>hired</value>
+                               <value>hours</value>
+                               <value>editor</value>
+                       </list>
+               </property>
+  </object>
+  
        
        <!-- filter list commands -->
                
@@ -84,7 +103,7 @@
 
   <object id="directory_list_helper" parent="BaseHelper" singleton="false">
                <property name="Command">
-                       <ref object="filter" />
+                       <ref object="entry_list" />
                </property>
   </object>
   
@@ -161,5 +180,11 @@
                        </list>
                </property>
        </object>
+
+  <object id="directory_entry_helper" parent="BaseHelper" singleton="false">
+               <property name="Command">
+                       <ref object="entry" />
+               </property>
+  </object>
          
 </objects>

Modified: 
struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Query/SelectAll.xml
URL: 
http://svn.apache.org/viewcvs/struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Query/SelectAll.xml?rev=201709&r1=201708&r2=201709&view=diff
==============================================================================
--- struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Query/SelectAll.xml 
(original)
+++ struts/sandbox/trunk/overdrive/PhoneBook/Web/Resources/Query/SelectAll.xml 
Fri Jun 24 19:22:32 2005
@@ -21,7 +21,7 @@
       </parameterMaps>
                
        <statements>
-               <select id="filter" paramClass="Hashtable" 
resultClass="Hashtable">
+               <select id="entry" paramClass="Hashtable" 
resultClass="Hashtable">
                        SELECT 
                                last_name,
                                first_name,



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to