Scarab commit: svn commit: r10769 - trunk: . src/java/org/tigris/scarab/actions src/java/org/tigris/scarab/om src/java/org/tigris/scarab/tools src/webapp/WEB-INF/templates/screens/admin src/webapp/WEB-INF/templates/viewIssue xdocs
Hussayn Dabbous <[email protected]>
| Newsgroups | gmane.comp.java.scarab.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: dabbous
Date: 2009-07-05 06:42:37-0700
New Revision: 10769
Modified:
trunk/project.properties
trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java
trunk/src/java/org/tigris/scarab/om/Issue.java
trunk/src/java/org/tigris/scarab/tools/ScarabUserTool.java
trunk/src/webapp/WEB-INF/templates/screens/admin/ModuleAttributeEdit.vm
trunk/src/webapp/WEB-INF/templates/viewIssue/ViewIssueTab1.vm
trunk/xdocs/scarab_properties.xml
Log:
SCB2978: introduce smart edit mode
Modified: trunk/project.properties
Url: http://scarab.tigris.org/source/browse/scarab/trunk/project.properties?view=diff&pathrev=10769&r1=10768&r2=10769
==============================================================================
--- trunk/project.properties (original)
+++ trunk/project.properties 2009-07-05 06:42:37-0700
@@ -1143,6 +1143,41 @@
# ==================
+# ================
+# Group: behaviour
+# ================
+#
+# scarab.edit.behaviour
+#
+# The property scarab.edit.behaviour tells scarab, if an assigned user
+# shall open the issue editor in edit mode by default.
+# Note: This an experimental feature.
+#
+#
+
+
+# ---------------------
+# scarab.edit.behaviour
+# ---------------------
+#
+#
+# scarab.edit.behaviour=[default|smart]
+# A user assigned to an issue typically opens the assigned issue
+# for edit and not for view, while all observers typically behave
+# in the opposite way, i.e. they watch the issue, but do not edit it.
+# If this property is set to "smart", then Scarab will automatically
+# determine the default entry mode from the value of the associated
+# user attribute. Hence, if the user is assigned to the issue,
+# the attributes editor will open in edit mode, otherwise in view-mode.
+#
+
+scarab.edit.behaviour=default
+
+# ======================
+# End of Group behaviour
+# ======================
+
+
# ======================
# Group: site-decoration
# ======================
Modified: trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java?view=diff&pathrev=10769&r1=10768&r2=10769
==============================================================================
--- trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java (original)
+++ trunk/src/java/org/tigris/scarab/actions/ModifyIssue.java 2009-07-05 06:42:37-0700
@@ -264,15 +264,15 @@
if (intake.isAllValid() && attributeValuesValid && !localFieldErrors)
{
- submitattributesPerform(context, user, reasonSaveMode);
+ submitattributesPerform(context, user, data, reasonSaveMode);
}
else
{
scarabR.setAlertMessage(ERROR_MESSAGE);
// were obviously in editing mode
- data.getParameters().add("edit_attributes", "true");
+ data.getParameters().setString("edit_attributes", "true");
// preserve fullcomments mode
- data.getParameters().add("fullcomments", data.getParameters().get("fullcomments"));
+ data.getParameters().setString("fullcomments", data.getParameters().get("fullcomments"));
}
}
@@ -402,6 +402,7 @@
private void submitattributesPerform(
final TemplateContext context,
final ScarabUser user,
+ RunData runData,
REASON_SAVE_MODE saveMode)
throws Exception
{
@@ -483,6 +484,7 @@
if (!modifiedAttribute && saveMode!=REASON_SAVE_MODE.NONE)
{
scarabR.setAlertMessage(L10NKeySet.MustModifyAttribute);
+ runData.getParameters().setString("edit_attributes", "true"); // force edit
return;
}
final Attachment attachment = AttachmentManager.getInstance();
@@ -679,8 +681,8 @@
scarabR.setAlertMessage(NO_PERMISSION_MESSAGE);
return;
}
- data.getParameters().add("edit_attributes", "true");
- data.getParameters().add("fullcomments", data.getParameters().get("fullcomments"));
+ data.getParameters().setString("edit_attributes", "true");
+ data.getParameters().setString("fullcomments", data.getParameters().get("fullcomments"));
return;
}
Modified: trunk/src/java/org/tigris/scarab/om/Issue.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/om/Issue.java?view=diff&pathrev=10769&r1=10768&r2=10769
==============================================================================
--- trunk/src/java/org/tigris/scarab/om/Issue.java (original)
+++ trunk/src/java/org/tigris/scarab/om/Issue.java 2009-07-05 06:42:37-0700
@@ -1353,8 +1353,20 @@
*/
public List getUserAttributeValues() throws TorqueException
{
+ return getUserAttributeValues(null);
+ }
+
+ /**
+ * Returns attribute values for user attributes.
+ * If user is not null, only return attributes of the
+ * given user.
+ */
+ public List getUserAttributeValues(final ScarabUser user) throws TorqueException
+ {
List result = null;
- Object obj = getCachedObject(GET_USER_ATTRIBUTEVALUES);
+ Object obj = null;
+ obj = getCachedUserAttributeValues(user);
+
if (obj == null)
{
List attributeList = getModule().getUserAttributes(getIssueType(), true);
@@ -1372,13 +1384,18 @@
.addIn(AttributeValuePeer.ATTRIBUTE_ID, attributeIdList)
.add(AttributeValuePeer.ISSUE_ID, getIssueId())
.add(AttributeValuePeer.DELETED, 0);
+ if(user != null)
+ {
+ crit.add(AttributeValuePeer.USER_ID, user.getUserId());
+ }
result = AttributeValuePeer.doSelect(crit);
}
else
{
result = new ArrayList(0);
}
- putCachedObject(result, GET_USER_ATTRIBUTEVALUES);
+
+ putCachedUserAttributeValues(user, result);
}
else
{
@@ -1387,6 +1404,32 @@
return result;
}
+ // helper method to allow null user (interpret as "all users")
+ private void putCachedUserAttributeValues(final ScarabUser user, List result) {
+ if(user == null)
+ {
+ putCachedObject(result, GET_USER_ATTRIBUTEVALUES);
+ }
+ else
+ {
+ putCachedObject(result, GET_USER_ATTRIBUTEVALUES, user);
+ }
+ }
+
+ // helper method to allow null user (interpret as "all users")
+ private Object getCachedUserAttributeValues(final ScarabUser user) {
+ Object obj;
+ if(user == null)
+ {
+ obj = getCachedObject(GET_USER_ATTRIBUTEVALUES);
+ }
+ else
+ {
+ obj = getCachedObject(GET_USER_ATTRIBUTEVALUES, user);
+ }
+ return obj;
+ }
+
/**
* The initial activity set from issue creation.
Modified: trunk/src/java/org/tigris/scarab/tools/ScarabUserTool.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/tools/ScarabUserTool.java?view=diff&pathrev=10769&r1=10768&r2=10769
==============================================================================
--- trunk/src/java/org/tigris/scarab/tools/ScarabUserTool.java (original)
+++ trunk/src/java/org/tigris/scarab/tools/ScarabUserTool.java 2009-07-05 06:42:37-0700
@@ -2,10 +2,15 @@
import java.util.Collections;
import java.util.Comparator;
+import java.util.Iterator;
import java.util.List;
import org.apache.torque.TorqueException;
import org.apache.turbine.RunData;
+import org.tigris.scarab.om.Attribute;
+import org.tigris.scarab.om.AttributeValue;
+import org.tigris.scarab.om.GlobalParameterManager;
+import org.tigris.scarab.om.Issue;
import org.tigris.scarab.om.Module;
import org.tigris.scarab.om.NotificationStatusManager;
import org.tigris.scarab.om.ScarabUser;
@@ -122,5 +127,58 @@
return NotificationStatusManager.getNotificationCount(module, user);
}
+ /**
+ * Check, if the user wants to edit this issue.
+ * Scarab first looks if the user has pushed the edit button.
+ * Then Scarab checks, if it should behave "smart". If smart
+ * behaviour is enabled (experimental feature), then Scarab
+ * will open the issue in edit-mode per default.
+ * Note:[HD] I am not sure, if this is a good idea. But it is
+ * a wanted feature. I will try it out for a while. If it turns
+ * out to be unusefull, it will be removed agin. Any opinions ?
+ * @param user
+ * @param issue
+ * @param data
+ * @return
+ * @throws TorqueException
+ */
+ public static boolean wantEdit(ScarabUser user, Issue issue, RunData data) throws TorqueException
+ {
+ Object testExists = data.getParameters().get("edit_attributes");
+ if(testExists != null)
+ {
+ boolean wantToOpenEditor = data.getParameters().getBoolean("edit_attributes");
+ return wantToOpenEditor;
+ }
+
+ // Now check for condition
+ String behaviour = GlobalParameterManager.getStringFromHierarchy(
+ "scarab.edit.behaviour",
+ issue.getModule(),
+ "default");
+ if(behaviour.equals("smart"))
+ {
+ // Check if user is assigned to issue.
+ // If that is the case, open the issue
+ // in edit mode per default.
+ List<AttributeValue> userAttributeValues = issue.getUserAttributeValues(user);
+ Iterator<AttributeValue> iter = userAttributeValues.iterator();
+ while(iter.hasNext())
+ {
+ AttributeValue attributeValue = iter.next();
+ Attribute attribute = attributeValue.getAttribute();
+ String permission = attribute.getPermission();
+ if("Issue | Edit".equals(permission))
+ {
+ return true; // if can edit and want edit, lets edit ...
+ }
+ }
+ }
+ else
+ {
+ // Scarab default behaviour: Open issue in view mode.
+ }
+ return false;
+ }
}
Modified: trunk/src/webapp/WEB-INF/templates/screens/admin/ModuleAttributeEdit.vm
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/WEB-INF/templates/screens/admin/ModuleAttributeEdit.vm?view=diff&pathrev=10769&r1=10768&r2=10769
==============================================================================
--- trunk/src/webapp/WEB-INF/templates/screens/admin/ModuleAttributeEdit.vm (original)
+++ trunk/src/webapp/WEB-INF/templates/screens/admin/ModuleAttributeEdit.vm 2009-07-05 06:42:37-0700
@@ -61,7 +61,7 @@
<tr>
<th>Multi Value </th>
- <td>attribute.MultiValue</td>
+ <td>$attribute.MultiValue</td>
</tr>
Modified: trunk/src/webapp/WEB-INF/templates/viewIssue/ViewIssueTab1.vm
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/webapp/WEB-INF/templates/viewIssue/ViewIssueTab1.vm?view=diff&pathrev=10769&r1=10768&r2=10769
==============================================================================
--- trunk/src/webapp/WEB-INF/templates/viewIssue/ViewIssueTab1.vm (original)
+++ trunk/src/webapp/WEB-INF/templates/viewIssue/ViewIssueTab1.vm 2009-07-05 06:42:37-0700
@@ -1,5 +1,6 @@
-#set ($canAddComment = $scarabR.hasPermission($scarabG.Permission.ISSUE__COMMENT, $module) && $rmit.Active)
-#set ($isEditAttributes = $canEdit && $data.Parameters.getBoolean("edit_attributes"))
+#set ($canAddComment = $scarabR.hasPermission($scarabG.Permission.ISSUE__COMMENT, $module) && $rmit.Active)
+#set ($wantEdit = $scarabU.wantEdit($user,$currentIssue,$data))
+#set ($isEditAttributes = $canEdit && $wantEdit)
<h3 onClick=smartToggleVisibility('properties')><img name="properties.state" src="$staticLink.setPath($iconCollapse)"/>$l10n.IssueAttributesNavi</h3>
<div id='properties'>
@@ -174,8 +175,9 @@
<input type="submit" value="$l10n.Edit" name="eventSubmit_doEditattributespage" />
#end
#if($isEditAttributes)
- <input type="submit" value="$l10n.Done" name="eventSubmit_doSubmitattributes" />
+ <input type="submit" value="$l10n.Done" name="eventSubmit_doSubmitattributes" />
<input type="submit" value="$l10n.Cancel" name="eventSubmit_doCancel" />
+ <input type="hidden" value="false" name="edit_attributes" />
#end
</div>
#end
Modified: trunk/xdocs/scarab_properties.xml
Url: http://scarab.tigris.org/source/browse/scarab/trunk/xdocs/scarab_properties.xml?view=diff&pathrev=10769&r1=10768&r2=10769
==============================================================================
--- trunk/xdocs/scarab_properties.xml (original)
+++ trunk/xdocs/scarab_properties.xml 2009-07-05 06:42:37-0700
@@ -1330,6 +1330,35 @@
</property>
</group>
+ <group name="behaviour">
+ <details>
+ The property scarab.edit.behaviour tells scarab, if an assigned user
+ shall open the issue editor in edit mode by default.
+ Note: This an experimental feature.
+
+ </details>
+
+ <property>
+ <name>scarab.edit.behaviour</name>
+ <default>default</default>
+ <comment/>
+ <details>
+ scarab.edit.behaviour=[default|smart]
+ A user assigned to an issue typically opens the assigned issue
+ for edit and not for view, while all observers typically behave
+ in the opposite way, i.e. they watch the issue, but do not edit it.
+ If this property is set to "smart", then Scarab will automatically
+ determine the default entry mode from the value of the associated
+ user attribute. Hence, if the user is assigned to the issue,
+ the attributes editor will open in edit mode, otherwise in view-mode.
+ </details>
+ <type>Runtime</type>
+ <customization modification="optional">advanced</customization>
+ <file/>
+ </property>
+
+ </group>
+
<group name="site-decoration">
<details>
The scarab.site.name is a text snippet, which will be placed into the top
------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2368127