From 859e309afbb86b1ca506a276803a5d82bce1d236 Mon Sep 17 00:00:00 2001 From: deedee Date: Thu, 10 Aug 2017 10:03:02 +0700 Subject: [PATCH] move project permission and notification input to use magicsuggest --- src/web/WEB-INF/contest-details2.jsp | 7 +- src/web/WEB-INF/editCockpitProject.jsp | 15 ++- src/web/WEB-INF/includes/jq_1_11_1.jsp | 8 +- .../project/edit/editProjectPageModals.jsp | 83 +------------ src/web/WEB-INF/launch-contest.jsp | 8 +- src/web/css/direct/editProject.css | 27 ++++- src/web/scripts/editCockpitProject.js | 114 ++++++++++-------- src/web/scripts/launch/entity.js | 10 +- src/web/scripts/launch/main.js | 19 ++- 9 files changed, 146 insertions(+), 145 deletions(-) diff --git a/src/web/WEB-INF/contest-details2.jsp b/src/web/WEB-INF/contest-details2.jsp index 0ecd42a51..9a2f23a23 100644 --- a/src/web/WEB-INF/contest-details2.jsp +++ b/src/web/WEB-INF/contest-details2.jsp @@ -1,6 +1,6 @@ <%-- - Author: BeBetter, isv, GreatKevin, Ghost_141, Veve, TCSCODER - - Version: 1.11 + - Version: 1.13 - Copyright (C) 2010 - 2017 TopCoder Inc., All Rights Reserved. - - Description: Contest Detail page @@ -32,6 +32,8 @@ - - Add CANCEL and CLOSE button on active private challenge - Version 1.12 (TOPCODER - SUPPORT TYPEAHEAD FOR TASK ASSIGNEES IN DIRECT APP): - - Split jquery import to other file + - Version 1.13 (TOPCODER - IMPROVE USER MANAGEMENT BEHAVIOR FOR PROJECT PERMISSIONS & NOTIFICATIONS) + - - Move redundant code --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ include file="/WEB-INF/includes/taglibs.jsp" %> @@ -40,9 +42,6 @@ - - - - -
-
-
-
-
- Add Users To Permission List - Close -
-
-
- - - -
-
-
- -
-

Users

- Select All -
- - - - - -
-
    - -
-
- -
-
- Add -
-
- -
-

Existing Users

-
- - -
-
    - -
-
- -
-
-
-
- SAVE - CANCEL -
-
-
- - -
-
-
-
-
- -
-
- -
diff --git a/src/web/WEB-INF/launch-contest.jsp b/src/web/WEB-INF/launch-contest.jsp index aa3803005..94837956e 100644 --- a/src/web/WEB-INF/launch-contest.jsp +++ b/src/web/WEB-INF/launch-contest.jsp @@ -1,6 +1,6 @@ <%-- - Author: bugbuka, TCSCODER - - Version: 1.4 + - Version: 1.5 - Copyright (C) 2011 - 2017 TopCoder Inc., All Rights Reserved. - - Description: This page provides function of creating project in dashboard. @@ -15,6 +15,9 @@ - - Version 1.4 (TOPCODER - SUPPORT TYPEAHEAD FOR TASK ASSIGNEES IN DIRECT APP): - - Split jquery import to other file + - + - Version 1.5 (TOPCODER - IMPROVE USER MANAGEMENT BEHAVIOR FOR PROJECT PERMISSIONS & NOTIFICATIONS) + - - Move redundant code --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ include file="/WEB-INF/includes/taglibs.jsp" %> @@ -23,9 +26,6 @@ - - - diff --git a/src/web/css/direct/editProject.css b/src/web/css/direct/editProject.css index 2dee8528d..ccbe62ea0 100644 --- a/src/web/css/direct/editProject.css +++ b/src/web/css/direct/editProject.css @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 - 2014 TopCoder Inc., All Rights Reserved. + * Copyright (C) 2011 - 2017 TopCoder Inc., All Rights Reserved. * * This css used to render edit project page. * @@ -21,8 +21,11 @@ * Version 1.6 (TC Direct Rebranding Assembly Project and Contest related pages) * - Rebranding the edit direct project page * - * Author: GreatKevin, Ghost_141, TCSASSEMBLER - * Version 1.6 + * Version 1.7 (TOPCODER - IMPROVE USER MANAGEMENT BEHAVIOR FOR PROJECT PERMISSIONS & NOTIFICATIONS) + * - Add style for magicsuggest control + * + * Author: GreatKevin, Ghost_141, TCSASSEMBLER, TCSCODER + * Version 1.7 */ .editPage #header .logo { font-size: 18px; @@ -2384,3 +2387,21 @@ a.saveSetting:hover, border-bottom: 3px solid #81bc02; } +.permissionsNotifications .userInputRow{ + border: 1px solid #CCC; + border-radius: 4px; + margin-bottom: 10px; + width: 372px; +} + +.permissionsNotifications .ms-stacked{ + display: none; +} + +.permissionsNotifications td sup{ + background-color: #ff0001; + color: #fff; + border-radius: 4px; + padding: 0px 2px 1px 2px; + margin-left: 5px; +} \ No newline at end of file diff --git a/src/web/scripts/editCockpitProject.js b/src/web/scripts/editCockpitProject.js index 413bf8793..730f5ab83 100644 --- a/src/web/scripts/editCockpitProject.js +++ b/src/web/scripts/editCockpitProject.js @@ -1,5 +1,5 @@ /** - * Copyright (C) 2011 - 2015 TopCoder Inc., All Rights Reserved. + * Copyright (C) 2011 - 2017 TopCoder Inc., All Rights Reserved. * * The JS script for edit project page.. * @@ -43,8 +43,11 @@ * Version 2.9 (TC Direct - Update Edit Project Budget Controls) * - Update the slider control to allow input box to input exact value * - * @author GreatKevin, Ghost_141, GreatKevin, freegod, TCSASSEMBLER - * @version 2.9 + * Version 2.10 (TOPCODER - IMPROVE USER MANAGEMENT BEHAVIOR FOR PROJECT PERMISSIONS & NOTIFICATIONS) + * - Project permission and notiification move to use magicsuggest + * + * @author GreatKevin, Ghost_141, GreatKevin, freegod, TCSASSEMBLER, TCSCODER + * @version 2.10 */ Date.format = 'mm/dd/yyyy'; @@ -269,60 +272,65 @@ $(document).ready(function (e) { //scroll - $('#addUserModal .addUserForm .addUserLeft .addUserList').css('overflow-y','scroll'); $('#addGroupModal .addUserForm .addUserLeft .addUserList').css('overflow-y','scroll'); ///////////////// START: Add user permission modal - var currentUserPermissionModalCache = {}; - - $("#addUser").click(function(){ - modalLoad('#' + $(this).attr('name')); - var modal = $("#addUserModal"); - modal.find(".searchBox input").val(''); - var leftSide = modal.find('.addUserLeft ul'); - leftSide.find('li').remove(); - modal.find('.addUserRight .addUserList ul li').remove(); - - // pre-populate the left side of the modal - $(".permissionsNotifications td.permissionUser").each(function () { - var handle = $(this).find("a").text(); - var userId = $(this).find("input").val(); - var entry = {}; - entry.name = handle; - entry.id = userId; - currentUserPermissionModalCache[userId] = entry; - - modal.find('.addUserRight .addUserList ul').append($('
  • ' + handle + '
  • ')); - var lis = $('li:contains(' + handle + ')', leftSide); - lis.remove(); - }); - + jQuery_1_11_1("#permissionsNotificationsInput").magicSuggest({ + placeholder: "To add new user, type user's handle here", + allowFreeEntries: false, + hideTrigger: true, + selectionStacked: true, + selectionPosition: 'bottom', + selectionRenderer: function(data){ + //add to table + var currentList = $(".permissionsNotifications tbody tr td a.useName").map(function(){return $(this).text()}).get(); + if ($.inArray(data.name, currentList) < 0) { + var oddClass = $('.permissionsNotifications table tbody tr').length % 2 == 0 ? "" : "odd"; + var item = '' + data.name + + 'new
    SettingRemove' + + $('.permissionsNotifications table tbody').append(item); + } + return data.name; + }, + data: function (q) { + var members = []; + var currentList = $(".permissionsNotifications tbody tr td a.useName").map(function(){return $(this).text()}).get(); + if (typeof(q) === 'string' && q.length > 0) { + $.ajax({ + type: 'GET', + url: member_api_url, + cache: false, + dataType: 'json', + contentType: 'application/json; charset=utf-8', + data: {'handle': q}, + async: false, + success: function (result) { + $.each(result['result']['content'], function (index, member) { + if ($.inArray(member['handle'], currentList) < 0){ + members.push({'id': member['userId'].toString(), 'name': member['handle']}); + } }); - - $("#addUserModal .saveButton").click(function () { - for (var i = 0; i < $('#addUserModal .addUserRight li').length; i++) { - var handle = $('#addUserModal .addUserRight li').eq(i).text(); - var userId = $('#addUserModal .addUserRight li').eq(i).attr('name'); - - if(currentUserPermissionModalCache[userId] == null) { - $('.permissionsNotifications table tbody').append('' + handle - + '
    SettingRemove'); + }, + error: function () { + throw("Problem getting members"); } - + }) + } + return members.sort(function (A, B){ + var a = A.name.toLowerCase(); + var b = B.name.toLowerCase(); + return a < b ? -1 : ((a > b) ? 1 : 0); + }); } - - $('.permissionsNotifications tbody tr').removeClass('odd'); - $('.permissionsNotifications tbody tr:odd').addClass('odd'); - modalAllClose(); }); - ///////////////// END: Add user permission modal $("#addGroup").click(function () { modalLoad('#' + $(this).attr('name')); @@ -419,6 +427,8 @@ $(document).ready(function (e) { handleJsonResult( jsonResult, function (result) { + $(".permissionsNotifications tbody tr td sup").remove(); + jQuery_1_11_1("#permissionsNotificationsInput").magicSuggest().clear(); showSuccessfulMessage("Project Permissions and Notifications are successfully updated.") }, function (errorMessage) { @@ -433,6 +443,16 @@ $(document).ready(function (e) { // remove user permission from project $(".permissionsNotifications a.remove").live('click', function(){ var row = $(this).parents("tr"); + var isNew = row.find("td sup").length > 0 ? true : false; + if (isNew){ + var removedItem = {'id': row.find("td.permissionUser input").val(), + 'name': row.find("td.permissionUser a.useName").text()} + jQuery_1_11_1("#permissionsNotificationsInput").magicSuggest().removeFromSelection(removedItem, true); + row.remove(); + $('.permissionsNotifications tbody tr').removeClass('odd'); + $('.permissionsNotifications tbody tr:odd').addClass('odd'); + return false; + } var formData = {}; formData.projectId = $("input[name='editProjectId']").val(); formData.projectPermissions = []; diff --git a/src/web/scripts/launch/entity.js b/src/web/scripts/launch/entity.js index 1af66e93c..699eadca8 100644 --- a/src/web/scripts/launch/entity.js +++ b/src/web/scripts/launch/entity.js @@ -64,8 +64,11 @@ * Version 1.9 (Module Assembly - TC Direct Studio Design First2Finish Challenge Type) * - Add new Design First2Finish contest to studio group * - * @author duxiaoyang, bugbuka, GreatKevin - * @version 1.9 + * Version 1.10(TOPCODER - IMPROVE USER MANAGEMENT BEHAVIOR FOR PROJECT PERMISSIONS & NOTIFICATIONS) + * - Refactor constant for copilot posting + * + * @author duxiaoyang, bugbuka, GreatKevin, TCSCODER + * @version 1.10 */ if(!com) { var com = {}; @@ -190,6 +193,7 @@ var STUDIO_CATEGORY_ID_DESIGN_F2F = 40; var SOFTWARE_CATEGORY_ID_BUG_HUNT = 9; var ALGORITHM_CATEGORY_ID_MARATHON = 37; var STUDIO_IDEA_GENERATION = 22; +var COPILOT_POSTING = 29; var DRAFT_STATUS = "Draft"; var ACTIVE_STATUS = "Active"; @@ -209,7 +213,7 @@ var projectCategoryArray = [ {id:SOFTWARE_CATEGORY_ID_ASSEMBLY, name:'SOFTWARE ASSEMBLY', label:'Software Assembly', typeId:2, typeName:'Application', hasMulti:true, hideInDropdown: false}, {id:13, name:'TESTSUITES', label:'Test Suites', typeId:2, typeName:'Application', hasMulti:true, hideInDropdown: false}, {id:26, name:'TESTSCENARIOS', label:'Test Scenarios', typeId:2, typeName:'Application', hasMulti:true, hideInDropdown: true}, - {id:29, name:'Copilot Posting', label:'Copilot Posting', typeId:2, typeName:'Application', hasMulti:false, hideInDropdown: true}, + {id:COPILOT_POSTING, name:'Copilot Posting', label:'Copilot Posting', typeId:2, typeName:'Application', hasMulti:false, hideInDropdown: true}, {id:SOFTWARE_CATEGORY_ID_CONTENT, name:'Content Creation', label:'Content Creation', typeId:2, typeName:'Application', hasMulti:true, hideInDropdown: true}, {id:17, name:'Web Design', label:'Web Design', typeId:3, typeName:'Studio', hasMulti:true, hideInDropdown: false}, {id:STUDIO_CATEGORY_ID_DESIGN_F2F, name:'Design First2Finish', label:'Design First2Finish', typeId:3, typeName:'Studio', hasMulti:false, hideInDropdown: false}, diff --git a/src/web/scripts/launch/main.js b/src/web/scripts/launch/main.js index 72e2898ed..ffaaf56df 100644 --- a/src/web/scripts/launch/main.js +++ b/src/web/scripts/launch/main.js @@ -121,8 +121,11 @@ * Version 4.2 (TOPCODER - SUPPORT TYPEAHEAD FOR TASK ASSIGNEES IN DIRECT APP): * - Move task assign member to use magicSuggest * + * Version 4.3 (TOPCODER - IMPROVE USER MANAGEMENT BEHAVIOR FOR PROJECT PERMISSIONS & NOTIFICATIONS) + * - Exclude copilot posting on #technologyAndPlatformSelectsChanged + * * @author isv, GreatKevin, bugbuka, GreatKevin, Veve, TCSCODER, TCSASSEMBER - * @version 4.2 + * @version 4.3 */ /** @@ -3379,6 +3382,14 @@ function isDesignType(categoryId) { return (getProjectCategoryById(categoryId).typeName == 'Studio'); } +function isCopilotPosting(categoryId) { + if(mainWidget.softwareCompetition.projectHeader.projectCategory) { + categoryId = mainWidget.softwareCompetition.projectHeader.projectCategory.id; + } + + return (categoryId == COPILOT_POSTING); +} + function isDevelopmentType(categoryId) { if(mainWidget.softwareCompetition.projectHeader.projectCategory) { categoryId = mainWidget.softwareCompetition.projectHeader.projectCategory.id; @@ -3536,13 +3547,17 @@ function sortByname(A, B){ function technologyAndPlatformSelectsChanged() { var hasJavaTech = false; + var hasSalesforcePlatform = false; + if (isCopilotPosting()){ + return {hasJavaTech: hasJavaTech, hasSalesforcePlatform: hasSalesforcePlatform}; + } + var selectedTechnologies = jQuery_1_11_1("#technologies").magicSuggest().getSelection(); $(selectedTechnologies).each(function (val, i) { if (val.name == 'Java') hasJavaTech=true; }); - var hasSalesforcePlatform = false; var selectedPlatforms = jQuery_1_11_1("#platforms").magicSuggest().getSelection(); $(selectedPlatforms).each(function (val, i) { if (val.name == 'Salesforce.com')