131131 * Version 4.1 (TOPCODER - SUPPORT CUSTOM COPILOT FEE FOR CHALLENGE IN DIRECT APP):
132132 * - Add support for custom copilot fee
133133 *
134+ * Version 4.2 (Topcoder - Be Able To Lower the Prize After Activation)
135+ * - Add support for lowering prize after challenge being activated
136+ *
134137 * @author isv, minhu, pvmagacho, GreatKevin, Veve, GreatKevin, TCSCODER
135- * @version 4.1
138+ * @version 4.2
136139 */
137140// can edit multi round
138141var canEditMultiRound = true ;
@@ -1245,7 +1248,7 @@ function populateTypeSection() {
12451248 }
12461249 */
12471250 $ ( '#rContestTypeName' ) . text ( $ ( "#contestTypes option[value=" + mainWidget . competitionType + mainWidget . softwareCompetition . projectHeader . projectCategory . id + "]" ) . text ( ) ) ;
1248-
1251+
12491252 loadReviewScorecardList ( null ) ;
12501253
12511254 $ . each ( reviewScorecards , function ( ) {
@@ -1884,7 +1887,7 @@ function validateFieldsRoundSection() {
18841887
18851888 var subEndDateHours = $ ( '#endDateDay' ) . val ( ) * 24 + parseInt ( $ ( '#endDateHour' ) . val ( ) ) ;
18861889 if ( mainWidget . competitionType == "STUDIO" && ! isDesignF2F ( ) ) {
1887-
1890+
18881891 if ( subEndDateHours == 0 ) {
18891892 if ( isMultiRound ) {
18901893 errors . push ( 'Round 2 duration should be positive.' ) ;
@@ -1908,7 +1911,7 @@ function validateFieldsRoundSection() {
19081911 errors . push ( 'Registration length should be less than or equal to the sum of Round 1 and 2 Durations.' ) ;
19091912 }
19101913
1911-
1914+
19121915 }
19131916 } else if ( mainWidget . competitionType == "STUDIO" && ! isDesignF2F ( ) ) {
19141917 // set check point date hours for studio to 0 for single round contest
@@ -2336,16 +2339,64 @@ function savePrizeSection() {
23362339 } ) ;
23372340 } ;
23382341
2342+ var confirmPrizeSave = function ( ) {
2343+ if ( isPrizeDecreased ( ) ) {
2344+ showConfirmation ( "Decreased Prize" , "Are you sure you want to decrease the prize?" , "OK" , function ( ) {
2345+ saveDraftHandler ( ) ;
2346+ closeModal ( ) ;
2347+ } ) ;
2348+ } else {
2349+ saveDraftHandler ( ) ;
2350+ }
2351+ }
2352+
23392353 if ( showSaveChallengeConfirmation == false ) {
2340- saveDraftHandler ( ) ;
2354+ confirmPrizeSave ( ) ;
23412355 } else {
23422356 showChallengeSaveConfiguration ( function ( ) {
23432357 closeModal ( ) ;
2344- saveDraftHandler ( ) ;
2358+ confirmPrizeSave ( ) ;
23452359 } ) ;
23462360 }
23472361}
23482362
2363+ function isPrizeDecreased ( ) {
2364+ //checkpoint prize
2365+ var isMultiRound = ( 'multi' == $ ( '#roundTypes' ) . val ( ) ) ;
2366+ var checkpointPrizeInput ;
2367+ var checkpointPrize ;
2368+ if ( isMultiRound ) {
2369+ if ( mainWidget . competitionType == "STUDIO" ) {
2370+ checkpointPrizeInput = $ ( '#checkpointPrize' ) . val ( ) ;
2371+ } else {
2372+ checkpointPrizeInput = $ ( '#swCheckpointPrize' ) . val ( ) ;
2373+ }
2374+ checkpointPrize = parseFloat ( checkpointPrizeInput ) ;
2375+ if ( checkRequired ( checkpointPrizeInput ) && checkNumber ( checkpointPrizeInput ) && ! isNaN ( checkpointPrize ) ) {
2376+ // If registration is already started then check that the checkpoint prize is decreased
2377+ if ( phaseOpen ) {
2378+ if ( checkpointPrize < getCheckpointPrizes ( ) [ 0 ] ) {
2379+ return true ;
2380+ }
2381+ }
2382+ }
2383+ }
2384+ if ( mainWidget . competitionType == "SOFTWARE" ) {
2385+ if ( disablePrizeAdjustment ( ) ) {
2386+ var newFirstPlacePrize = $ ( '#swFirstPlace' ) . val ( ) ;
2387+ var newDigitalRun = $ ( '#swDigitalRun' ) . val ( ) ;
2388+ if ( checkNumber ( newFirstPlacePrize ) ) {
2389+ if ( checkNumber ( originalPrizes . prizes [ 0 ] ) ) {
2390+ if ( parseFloat ( newFirstPlacePrize ) < parseFloat ( originalPrizes . prizes [ 0 ] ) ) {
2391+ return true ;
2392+ }
2393+ }
2394+ }
2395+ }
2396+ }
2397+ return false ;
2398+ }
2399+
23492400function validateFieldsPrizeSection ( ) {
23502401 //validation
23512402 var errors = [ ] ;
@@ -2363,13 +2414,6 @@ function validateFieldsPrizeSection() {
23632414 checkpointPrize = parseFloat ( checkpointPrizeInput ) ;
23642415 if ( ! checkRequired ( checkpointPrizeInput ) || ! checkNumber ( checkpointPrizeInput ) || isNaN ( checkpointPrize ) ) {
23652416 errors . push ( 'Checkpoint prize is invalid.' ) ;
2366- } else {
2367- // If registration is already started then check that the checkpoint prize is not decreased
2368- if ( phaseOpen ) {
2369- if ( checkpointPrize < getCheckpointPrizes ( ) [ 0 ] ) {
2370- errors . push ( 'The checkpoint prize can not be decreased' ) ;
2371- }
2372- }
23732417 }
23742418
23752419 if ( mainWidget . competitionType == "STUDIO" ) {
@@ -2424,13 +2468,6 @@ function validateFieldsPrizeSection() {
24242468 if ( disablePrizeAdjustment ( ) ) {
24252469 var newFirstPlacePrize = $ ( '#swFirstPlace' ) . val ( ) ;
24262470 var newDigitalRun = $ ( '#swDigitalRun' ) . val ( ) ;
2427- if ( checkNumber ( newFirstPlacePrize ) ) {
2428- if ( checkNumber ( originalPrizes . prizes [ 0 ] ) ) {
2429- if ( parseFloat ( newFirstPlacePrize ) < parseFloat ( originalPrizes . prizes [ 0 ] ) ) {
2430- errors . push ( 'The prizes can not be decreased' ) ;
2431- }
2432- }
2433- }
24342471 if ( checkNumber ( newDigitalRun ) ) {
24352472 if ( checkNumber ( originalPrizes . digitalRun ) ) {
24362473 if ( parseFloat ( newDigitalRun ) < parseFloat ( originalPrizes . digitalRun ) ) {
0 commit comments