Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 3c44910

Browse files
committed
Save Draft Challenge Confirmation Prompt
1 parent 33089f4 commit 3c44910

File tree

15 files changed

+634
-231
lines changed

15 files changed

+634
-231
lines changed

conf/web/WEB-INF/applicationContext.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,11 @@
583583
<property name="milestoneService" ref="milestoneService"/>
584584
</bean>
585585

586+
<bean id="saveChallengeConfirmation"
587+
class="com.topcoder.direct.services.view.action.setting.ChallengeConfirmationPreferenceAction"
588+
scope="prototype" parent="baseDirectStrutsAction">
589+
</bean>
590+
586591
<bean id="contestSubmissionsAction"
587592
class="com.topcoder.direct.services.view.action.contest.ContestSubmissionsAction"
588593
scope="prototype" parent="baseDirectStrutsAction">

conf/web/WEB-INF/struts.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,6 +1666,12 @@
16661666
<result name="error" type="json"/>
16671667
</action>
16681668

1669+
<action name="saveChallengeConfirmation" method="updateChallengeConfirmationPreference" class="saveChallengeConfirmation">
1670+
<interceptor-ref name="securedDefaultStack"/>
1671+
<result name="success" type="json"/>
1672+
<result name="error" type="json"/>
1673+
</action>
1674+
16691675
</package>
16701676

16711677
<package name="my" namespace="/my" extends="base">

src/java/main/com/topcoder/direct/services/view/action/contest/launch/GetContestAction.java

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.topcoder.direct.services.project.milestone.model.SortOrder;
1111
import com.topcoder.direct.services.view.action.analytics.longcontest.MarathonMatchHelper;
1212
import com.topcoder.direct.services.view.action.analytics.longcontest.services.MarathonMatchAnalyticsService;
13+
import com.topcoder.direct.services.view.action.setting.ChallengeConfirmationPreferenceAction;
1314
import com.topcoder.direct.services.view.dto.cloudvm.VMInstanceData;
1415
import com.topcoder.direct.services.view.dto.cloudvm.VMInstanceStatus;
1516
import com.topcoder.direct.services.view.dto.contest.ContestCopilotDTO;
@@ -30,6 +31,9 @@
3031
import com.topcoder.service.project.CompetionType;
3132
import com.topcoder.service.project.ProjectData;
3233
import com.topcoder.service.project.SoftwareCompetition;
34+
import com.topcoder.shared.util.DBMS;
35+
import com.topcoder.web.common.RowNotFoundException;
36+
import com.topcoder.web.ejb.user.UserPreference;
3337
import org.apache.struts2.ServletActionContext;
3438

3539
import org.apache.commons.lang.math.NumberUtils;
@@ -242,8 +246,16 @@
242246
* load these data via ajax instead after the page finishes loading.
243247
* </p>
244248
*
245-
* @author fabrizyo, FireIce, isv, morehappiness, GreatKevin, minhu, Veve, Ghost_141, GreatKevin, Veve
246-
* @version 3.0
249+
* <p>
250+
* Version 3.1 (TopCoder Direct - Draft Challenge Creation/Saving Prompt)
251+
* <ul>
252+
* <li>Adds the {@link #showSaveChallengeConfirmation} and its getter</li>
253+
* <li>Updates {@link #executeAction()} to populate the {@link #showSaveChallengeConfirmation}</li>
254+
* </ul>
255+
* </p>
256+
*
257+
* @author fabrizyo, FireIce, isv, morehappiness, GreatKevin, minhu, Veve, Ghost_141, GreatKevin, Veve, GreatKevin
258+
* @version 3.1
247259
*/
248260
public class GetContestAction extends ContestAction {
249261
/**
@@ -359,6 +371,13 @@ public class GetContestAction extends ContestAction {
359371
*/
360372
private int timelineInterval;
361373

374+
/**
375+
* The preference value of whether to show the save challenge confirmation.
376+
*
377+
* @since 3.1
378+
*/
379+
private boolean showSaveChallengeConfirmation;
380+
362381
/**
363382
* <p>
364383
* Creates a <code>GetContestAction</code> instance.
@@ -524,6 +543,17 @@ protected void executeAction() throws Exception {
524543
billingAccountsForProject.add(billingAccount);
525544
}
526545

546+
UserPreference userPreference = this.getUserPreferenceHome().create();
547+
548+
try {
549+
String value = userPreference.getValue(DirectUtils.getTCSubjectFromSession().getUserId(),
550+
ChallengeConfirmationPreferenceAction.CHALLENGE_CONFIRMATION_PREFERENCE_ID,
551+
DBMS.COMMON_OLTP_DATASOURCE_NAME);
552+
this.showSaveChallengeConfirmation = Boolean.valueOf(value);
553+
} catch (RowNotFoundException rfe) {
554+
this.showSaveChallengeConfirmation = true;
555+
}
556+
527557
// Set current project context based on selected contest
528558
getSessionData().setCurrentProjectContext(contestStats.getContest().getProject());
529559
getSessionData().setCurrentSelectDirectProjectID(contestStats.getContest().getProject().getId());
@@ -968,4 +998,14 @@ public static enum TYPE {
968998
COPILOT_CONTEST, CONTEST, CONTEST_JSON
969999
}
9701000

1001+
/**
1002+
* Gets whether to show the save challenge confirmation.
1003+
*
1004+
* @return true if show, false otherwise.
1005+
* @since 3.1
1006+
*/
1007+
public boolean isShowSaveChallengeConfirmation() {
1008+
return showSaveChallengeConfirmation;
1009+
}
1010+
9711011
}

src/java/main/com/topcoder/direct/services/view/action/contest/launch/LaunchContestAction.java

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@
66
import com.topcoder.direct.services.project.milestone.model.Milestone;
77
import com.topcoder.direct.services.project.milestone.model.MilestoneStatus;
88
import com.topcoder.direct.services.project.milestone.model.SortOrder;
9+
import com.topcoder.direct.services.view.action.setting.ChallengeConfirmationPreferenceAction;
910
import com.topcoder.direct.services.view.dto.CommonDTO;
1011
import com.topcoder.direct.services.view.dto.IdNamePair;
1112
import com.topcoder.direct.services.view.dto.contest.ContestCopilotDTO;
1213
import com.topcoder.direct.services.view.util.DataProvider;
1314
import com.topcoder.direct.services.view.util.DirectUtils;
1415
import com.topcoder.direct.services.view.util.SessionData;
1516
import com.topcoder.security.TCSubject;
17+
import com.topcoder.shared.util.DBMS;
18+
import com.topcoder.web.common.RowNotFoundException;
19+
import com.topcoder.web.ejb.user.UserPreference;
1620
import org.apache.struts2.ServletActionContext;
1721

1822
import javax.servlet.http.HttpServletRequest;
@@ -67,8 +71,16 @@
6771
* load these data via ajax instead after the page finishes loading.
6872
* </p>
6973
*
70-
* @author BeBetter, duxiaoyang, GreatKevin, Veve, Veve
71-
* @version 1.5
74+
* <p>
75+
* Version 1.6 (TopCoder Direct - Draft Challenge Creation/Saving Prompt)
76+
* <ul>
77+
* <li>Adds the {@link #showSaveChallengeConfirmation} and its getter</li>
78+
* <li>Updates {@link #executeAction()} to populate the {@link #showSaveChallengeConfirmation}</li>
79+
* </ul>
80+
* </p>
81+
*
82+
* @author BeBetter, duxiaoyang, GreatKevin, Veve, Veve, GreatKevin
83+
* @version 1.6
7284
*/
7385
public class LaunchContestAction extends ContestAction {
7486
private CommonDTO viewData = new CommonDTO();
@@ -94,6 +106,13 @@ public class LaunchContestAction extends ContestAction {
94106
*/
95107
private IdNamePair cmcBillingAccount;
96108

109+
/**
110+
* The preference value of whether to show the save challenge confirmation.
111+
*
112+
* @since 1.6
113+
*/
114+
private boolean showSaveChallengeConfirmation;
115+
97116
/**
98117
* <p>
99118
* Executes the action. Does nothing for now.
@@ -116,6 +135,18 @@ protected void executeAction() throws Exception {
116135
if(getCmcAccountId() != null && getCmcAccountId().trim().length() > 0) {
117136
setCmcBillingAccount(DataProvider.getBillingAccountFromCMCAccountID(getCmcAccountId()));
118137
}
138+
139+
UserPreference userPreference = this.getUserPreferenceHome().create();
140+
141+
try {
142+
String value = userPreference.getValue(DirectUtils.getTCSubjectFromSession().getUserId(),
143+
ChallengeConfirmationPreferenceAction.CHALLENGE_CONFIRMATION_PREFERENCE_ID,
144+
DBMS.COMMON_OLTP_DATASOURCE_NAME);
145+
this.showSaveChallengeConfirmation = Boolean.valueOf(value);
146+
} catch (RowNotFoundException rfe) {
147+
this.showSaveChallengeConfirmation = true;
148+
}
149+
119150
}
120151

121152
public CommonDTO getViewData() {
@@ -253,4 +284,14 @@ public IdNamePair getCmcBillingAccount() {
253284
public void setCmcBillingAccount(IdNamePair cmcBillingAccount) {
254285
this.cmcBillingAccount = cmcBillingAccount;
255286
}
287+
288+
/**
289+
* Gets whether to show the save challenge confirmation.
290+
*
291+
* @return true if show, false otherwise.
292+
* @since 1.6
293+
*/
294+
public boolean isShowSaveChallengeConfirmation() {
295+
return showSaveChallengeConfirmation;
296+
}
256297
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* Copyright (C) 2014 TopCoder Inc., All Rights Reserved.
3+
*/
4+
package com.topcoder.direct.services.view.action.setting;
5+
6+
import com.topcoder.direct.services.view.action.BaseDirectStrutsAction;
7+
import com.topcoder.direct.services.view.util.DirectUtils;
8+
import com.topcoder.shared.util.DBMS;
9+
import com.topcoder.web.common.RowNotFoundException;
10+
import com.topcoder.web.ejb.user.UserPreference;
11+
12+
import java.util.HashMap;
13+
import java.util.Map;
14+
15+
/**
16+
* This action gets and saves the save challenge confirmation preference of direct preferences.
17+
*
18+
* @author TCSASSEMBLER
19+
* @version 1.0 (TopCoder Direct - Draft Challenge Creation/Saving Prompt)
20+
*/
21+
public class ChallengeConfirmationPreferenceAction extends BaseDirectStrutsAction {
22+
23+
/**
24+
* The preference value flag. True to show confirmation, false not show confirmation.
25+
*/
26+
private Boolean flag;
27+
28+
/**
29+
* The preference id of the save challenge confirmation preference.
30+
*/
31+
public static final int CHALLENGE_CONFIRMATION_PREFERENCE_ID = 50;
32+
33+
/**
34+
* Gets the save challenge confirmation preference value of the current user.
35+
*
36+
* @throws Exception if any error.
37+
*/
38+
@Override
39+
protected void executeAction() throws Exception {
40+
UserPreference userPreference = this.getUserPreferenceHome().create();
41+
42+
try {
43+
String value = userPreference.getValue(DirectUtils.getTCSubjectFromSession().getUserId(),
44+
CHALLENGE_CONFIRMATION_PREFERENCE_ID, DBMS.COMMON_OLTP_DATASOURCE_NAME);
45+
Map<String, String> result = new HashMap<String, String>();
46+
result.put("value", value);
47+
setResult(result);
48+
} catch (RowNotFoundException rfe) {
49+
setResult(false);
50+
}
51+
52+
}
53+
54+
/**
55+
* Updates the user's save challenge confirmation preference value.
56+
*
57+
* @return the result code.
58+
*/
59+
public String updateChallengeConfirmationPreference() {
60+
if (this.flag != null) {
61+
62+
try {
63+
UserPreference userPreference = this.getUserPreferenceHome().create();
64+
65+
// try get the user preference to see if it exists
66+
try {
67+
userPreference.getValue(DirectUtils.getTCSubjectFromSession().getUserId(),
68+
CHALLENGE_CONFIRMATION_PREFERENCE_ID, DBMS.COMMON_OLTP_DATASOURCE_NAME);
69+
} catch (RowNotFoundException rfe) {
70+
// if the user preference does not exist, create first
71+
userPreference.createUserPreference(DirectUtils.getTCSubjectFromSession().getUserId(),
72+
CHALLENGE_CONFIRMATION_PREFERENCE_ID, DBMS.COMMON_OLTP_DATASOURCE_NAME);
73+
}
74+
75+
userPreference.setValue(DirectUtils.getTCSubjectFromSession().getUserId(),
76+
CHALLENGE_CONFIRMATION_PREFERENCE_ID, flag.toString(), DBMS.COMMON_OLTP_DATASOURCE_NAME);
77+
78+
Map<String, String> result = new HashMap<String, String>();
79+
result.put("value", this.flag.toString());
80+
setResult(result);
81+
} catch (Throwable e) {
82+
if (getModel() != null) {
83+
setResult(e);
84+
}
85+
}
86+
87+
}
88+
89+
return SUCCESS;
90+
}
91+
92+
/**
93+
* Sets the preference value.
94+
*
95+
* @param flag the boolean flag to indicate the preference value.
96+
*/
97+
public void setFlag(Boolean flag) {
98+
this.flag = flag;
99+
}
100+
}

src/web/WEB-INF/contest-details2.jsp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
<c:if test="${hasRoundId}">
7272
var timeLineData = ${viewData.timeLineGraphData};
7373
</c:if>
74+
75+
var showSaveChallengeConfirmation = <s:property value="showSaveChallengeConfirmation"/>;
7476
</script>
7577
</head>
7678

src/web/WEB-INF/includes/modalWindows.jsp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,41 @@
2929
</div>
3030
<!-- end .modalFooter -->
3131
</div>
32+
33+
<div id="saveChallengeConfirmation" class="outLay">
34+
<div class="modalHeader">
35+
<div class="modalHeaderRight">
36+
<div class="modalHeaderCenter">
37+
<h2>Errors</h2>
38+
<a href="javascript:;" class="closeModal" title="Close">Close</a>
39+
</div>
40+
</div>
41+
</div>
42+
<!-- end .modalHeader -->
43+
44+
<div class="modalBody">
45+
<ul class="modalContent">
46+
<li></li>
47+
</ul>
48+
<div class="modalCommandBox">
49+
<span class="checkbox">
50+
<input type="checkbox"/>
51+
Don't show this message again
52+
</span>
53+
<a href="javascript:;" class="newButton1 newButtonBlue defaultBtn"><span class="btnR"><span
54+
class="btnC">Save As Draft</span></span></a>
55+
<a href="javascript:;" class="newButton1 newButtonOrange noBtn"><span class="btnR"><span
56+
class="btnC">Cancel</span></span></a>
57+
</div>
58+
</div>
59+
<!-- end .modalBody -->
60+
61+
<div class="modalFooter">
62+
<div class="modalFooterRight">
63+
<div class="modalFooterCenter"></div>
64+
</div>
65+
</div>
66+
<!-- end .modalFooter -->
67+
</div>
3268
<!-- end #demoModal -->
3369
</div>

src/web/WEB-INF/launch-contest.jsp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
<script type="text/javascript" src="/scripts/launch/pages/overview.js?v=207440"></script>
3535
<script type="text/javascript" src="/scripts/launch/pages/review.js?v=210691"></script>
3636
<script type="text/javascript" src="/scripts/launch/pages/orderReview.js?v=214861"></script>
37+
<script type="text/javascript">
38+
var showSaveChallengeConfirmation = <s:property value="showSaveChallengeConfirmation"/>;
39+
</script>
3740
</head>
3841

3942
<body id="page">

src/web/css/direct/dashboard.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14058,3 +14058,13 @@ a.clearDates {
1405814058
a.clearDates:hover {
1405914059
text-decoration: none;
1406014060
}
14061+
14062+
#saveChallengeConfirmation .checkbox {
14063+
float: left;
14064+
padding-left: 20px;
14065+
line-height: 30px
14066+
}
14067+
14068+
#saveChallengeConfirmation .checkbox input {
14069+
margin-right:3px;
14070+
}

0 commit comments

Comments
 (0)