diff --git a/backend/src/main/java/io/diveni/backend/service/projectmanagementproviders/azuredevops/AzureDevOpsService.java b/backend/src/main/java/io/diveni/backend/service/projectmanagementproviders/azuredevops/AzureDevOpsService.java index 6ce87234f..4525f8992 100644 --- a/backend/src/main/java/io/diveni/backend/service/projectmanagementproviders/azuredevops/AzureDevOpsService.java +++ b/backend/src/main/java/io/diveni/backend/service/projectmanagementproviders/azuredevops/AzureDevOpsService.java @@ -208,9 +208,14 @@ public void updateIssue(String tokenIdentifier, UserStory story) { if (story.getEstimation() != null) { try { Map updateEstimation = new HashMap<>(); - updateEstimation.put("op", "replace"); - updateEstimation.put("path", fieldPrefix + API_FIELD_ESTIMATION); - updateEstimation.put("value", Double.parseDouble(story.getEstimation())); + if (story.getEstimation().equals("?")) { + updateEstimation.put("op", "remove"); + updateEstimation.put("path", fieldPrefix + API_FIELD_ESTIMATION); + } else { + updateEstimation.put("op", "replace"); + updateEstimation.put("path", fieldPrefix + API_FIELD_ESTIMATION); + updateEstimation.put("value", Double.parseDouble(story.getEstimation())); + } content.add(updateEstimation); } catch (NumberFormatException e) { LOGGER.error("Failed to parse estimation into double!"); diff --git a/backend/src/main/java/io/diveni/backend/service/projectmanagementproviders/jiraserver/JiraServerService.java b/backend/src/main/java/io/diveni/backend/service/projectmanagementproviders/jiraserver/JiraServerService.java index d6fc978ea..dad62f693 100644 --- a/backend/src/main/java/io/diveni/backend/service/projectmanagementproviders/jiraserver/JiraServerService.java +++ b/backend/src/main/java/io/diveni/backend/service/projectmanagementproviders/jiraserver/JiraServerService.java @@ -6,25 +6,25 @@ package io.diveni.backend.service.projectmanagementproviders.jiraserver; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import com.google.api.client.http.*; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.api.client.auth.oauth.OAuthAuthorizeTemporaryTokenUrl; import com.google.api.client.auth.oauth.OAuthParameters; -import com.google.api.client.http.GenericUrl; -import com.google.api.client.http.HttpContent; -import com.google.api.client.http.HttpRequest; -import com.google.api.client.http.HttpRequestFactory; -import com.google.api.client.http.HttpResponse; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.http.json.JsonHttpContent; import com.google.api.client.json.gson.GsonFactory; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import io.diveni.backend.Utils; import io.diveni.backend.model.JiraRequestToken; import io.diveni.backend.model.Project; @@ -250,7 +250,11 @@ public void updateIssue(String tokenIdentifier, UserStory story) { fields.put("description", story.getDescription()); if (story.getEstimation() != null) { try { - fields.put(ESTIMATION_FIELD, Double.parseDouble(story.getEstimation())); + if (story.getEstimation().equals("?")) { + fields.put(ESTIMATION_FIELD, null); + } else { + fields.put(ESTIMATION_FIELD, Double.parseDouble(story.getEstimation())); + } } catch (NumberFormatException e) { LOGGER.error("Failed to parse estimation into double!"); throw new ResponseStatusException( @@ -259,6 +263,14 @@ public void updateIssue(String tokenIdentifier, UserStory story) { } content.put("fields", fields); try { + + GsonBuilder builder = new GsonBuilder(); + builder.serializeNulls(); + Gson gson = builder.create(); + HttpContent httpContent = + new ByteArrayContent( + "application/json", gson.toJson(content).getBytes(StandardCharsets.UTF_8)); + JiraOAuthClient jiraOAuthClient = new JiraOAuthClient(JIRA_HOME); OAuthParameters parameters = jiraOAuthClient.getParameters( @@ -268,7 +280,7 @@ public void updateIssue(String tokenIdentifier, UserStory story) { parameters, new GenericUrl(getJiraUrl() + "/issue/" + story.getId()), "PUT", - new JsonHttpContent(GsonFactory.getDefaultInstance(), content)); + httpContent); LOGGER.debug("<-- updateIssue() {}", response.parseAsString()); } catch (Exception e) { diff --git a/frontend/src/components/UserStoryDescriptions.vue b/frontend/src/components/UserStoryDescriptions.vue index 2a72fed08..16a97f521 100644 --- a/frontend/src/components/UserStoryDescriptions.vue +++ b/frontend/src/components/UserStoryDescriptions.vue @@ -25,7 +25,7 @@ :text="(userStories[idx].estimation ? userStories[idx].estimation : '?') + ' '" > , }; }, - computed: { - filteredCardSet(): Array { - return this.cardSet.filter((card) => card !== "?"); - }, - }, watch: { initialStories() { this.userStories = this.initialStories as Array<{ diff --git a/frontend/src/views/SessionPage.vue b/frontend/src/views/SessionPage.vue index ab9f74bb4..cad2b169e 100644 --- a/frontend/src/views/SessionPage.vue +++ b/frontend/src/views/SessionPage.vue @@ -456,7 +456,6 @@ export default defineComponent({ }, }, async created() { - this.copyPropsToData(); this.store.clearStoreWithoutUserStories(); if (!this.sessionID || !this.adminID) { //check for cookie @@ -477,6 +476,7 @@ export default defineComponent({ } if (this.voteSetJson) { this.voteSet = JSON.parse(this.voteSetJson); + this.voteSet = ["?"].concat(this.voteSet); } if (this.sessionState === Constants.memberUpdateCommandStartVoting) { this.planningStart = true; @@ -527,17 +527,6 @@ export default defineComponent({ } } }, - copyPropsToData() { - // if (this.adminID) { - // this.session_adminID = this.adminID; - // this.session_sessionID = this.sessionID; - // this.session_sessionState = this.sessionState; - // this.session_timerSecondsString = this.timerSecondsString; - // this.session_voteSetJson = this.voteSetJson; - // this.session_userStoryMode = this.userStoryMode; - // this.session_hostVoting = String(this.hostVoting).toLowerCase() === "true"; - // } - }, assignSessionToData(session) { if (Object.keys(session).length !== 0) { this.adminID = session.adminID;