private async void UpdateDisplay() { upButton.enabled = false; downButton.enabled = false; ClearRequirementDisplayElements(); // get the current page and the next page // the next page is required to check if we are on the last page and to enable/disable downButton accordingly currentPage = await RequirementsBazaar.GetCategoryRequirements(categoryId, page, requirementsPerPage); nextPage = await RequirementsBazaar.GetCategoryRequirements(categoryId, page + 1, requirementsPerPage); if (page == 0) { upButton.enabled = false; } else { upButton.enabled = true; } if (nextPage.Length == 0) { downButton.enabled = false; } else { downButton.enabled = true; } for (int i = 0; i < currentPage.Length; i++) { CreateRequirementsDisplayElement(currentPage[i]); } }
/// <summary> /// Deserializes the given SerializedObject and applies its values /// Expects the keys "source", "issueId", "projectId" in order to load the issue /// </summary> /// <param name="serializedObject">The SerializedObject with the save data</param> public async void Deserialize(SerializedObject serializedObject) { DataSource source = (DataSource)serializedObject.Integers[sourceKey]; int issueId = serializedObject.Integers[issueIdKey]; int projectId = serializedObject.Integers[projectIdKey]; Issue issue = null; ApiResult <Issue> res = null; switch (source) { case DataSource.REQUIREMENTS_BAZAAR: res = await RequirementsBazaar.GetRequirement(issueId); break; case DataSource.GITHUB: res = await GitHub.GetIssue(projectId, issueId); break; } if (res != null && res.Successful) { issue = res.Value; } dataDisplay.Setup(issue); }
private async void UpdateDisplay() { upButton.enabled = false; downButton.enabled = false; ClearProjectTiles(); // get the current page and the next page // the next page is required to check if currentPage = await RequirementsBazaar.GetProjects(page, projectsPerPage); nextPage = await RequirementsBazaar.GetProjects(page + 1, projectsPerPage); if (page == 0) { upButton.enabled = false; } else { upButton.enabled = true; } if (nextPage.Length == 0) { downButton.enabled = false; } else { downButton.enabled = true; } for (int i = 0; i < currentPage.Length; i++) { CreateProjectTile(currentPage[i]); } }
private async void ShowExistingRequirement() { if (requirementId < 0) { return; } requirement = await RequirementsBazaar.GetRequirement(requirementId); projectId = requirement.ProjectId; await GetCategories(); titleInputField.text = requirement.Name; descriptionInputField.text = requirement.Description; if (availableCategories != null && requirement.Categories.Length > 0) { for (int i = 0; i < availableCategories.Length; i++) { if (availableCategories[i].Name == requirement.Categories[0].Name) { categoryDropdown.value = i; categoryDropdown.RefreshShownValue(); break; } } } else { Debug.LogWarning("Categories have not been loaded yet but trying to set requirement category"); } }
// Use this for initialization async void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Requirement res = await RequirementsBazaar.UndoVote(2101); Debug.Log("Posting"); } }
private async Task GetCategories() { availableCategories = await RequirementsBazaar.GetProjectCategories(projectId, 0, 20); categoryDropdown.options = new List <Dropdown.OptionData>(); for (int i = 0; i < availableCategories.Length; i++) { categoryDropdown.options.Add(new Dropdown.OptionData(availableCategories[i].Name)); } categoryDropdown.RefreshShownValue(); }
private async void Start() { // in case that the card was already setup, e.g. in the local instance => do not setup again if (issueDataDisplay.Content != null) { Debug.Log("Card was already setup"); return; } if (photonView.CreatorActorNr == PhotonNetwork.LocalPlayer.ActorNumber) { Debug.Log("Card created by local player; will not set up"); return; } int issueId; if (photonView.InstantiationData.Length == 1) // requirements bazaar => only id was sent { issueId = (int)photonView.InstantiationData[0]; ApiResult <Issue> result = await RequirementsBazaar.GetRequirement(issueId); if (result.Successful) { issueDataDisplay.Setup(result.Value); } else { Debug.LogError("Card synchronizer could not fetch requirement with id " + issueId + ": " + result.ErrorMessage); } } else if (photonView.InstantiationData.Length == 2) // GitHub => id and project id was sent { issueId = (int)photonView.InstantiationData[0]; int projectId = (int)photonView.InstantiationData[1]; ApiResult <Issue> result = await GitHub.GetIssue(projectId, issueId); if (result.Successful) { issueDataDisplay.Setup(result.Value); } else { Debug.LogError("Card synchronizer could not fetch GitHub issue of project " + projectId + " and id " + issueId + ": " + result.ErrorMessage); } } else { Debug.Log("Unexpected number of instantiation data on issue"); return; } }
public async void OnVoteClick() { voteButton.interactable = false; if (requirement.UserVoted != UserVoted.NO_VOTE) // if user already voted => undo by voting down { SetVoteIcon(false); // delete vote Requirement = await RequirementsBazaar.UndoVote(Requirement.Id); } else // if user did not yet vote => vote up; this is the standard case; no voting down possible with this UI { SetVoteIcon(true); Requirement = await RequirementsBazaar.VoteForRequirement(Requirement.Id); } voteButton.interactable = true; }
/// <summary> /// If the user presses space, a request to the Requirements Bazaar is started /// </summary> private async void Update() { if (Input.GetKeyDown(KeyCode.Space)) { ApiResult <Issue> res = await RequirementsBazaar.GetRequirement(requirementId); if (res.Successful) { dataDisplay.Setup(res.Value); } else { Debug.LogError("Error fetching the requirement: (Code " + res.ResponseCode + ") " + res.ErrorMessage); dataDisplay.Setup(null); } } }
/// <summary> /// Deserializes the given serializedObject and applies the found relevant properties to the visualization /// </summary> /// <param name="serializedObject">A serialized object which contains the properties for the visualization</param> public async void Deserialize(SerializedObject serializedObject) { visualization.Title = serializedObject.Strings[titleKey]; if (visualization == null) { Debug.LogWarning("No visualization found. Cannot deserialize sava data", gameObject); return; } List <int> projectIds = SerializedObject.GetList(projectIdKey, serializedObject.Integers); List <int> ids = SerializedObject.GetList(idsKey, serializedObject.Integers); if (projectIds.Count != ids.Count) { Debug.LogWarning("Project IDs and issue ID lists have a different lenght. Cannot reconstruct visualization content.", gameObject); return; } List <Issue> issues = new List <Issue>(); for (int i = 0; i < projectIds.Count; i++) { if (projectIds[i] < 0) { ApiResult <Issue> networkResult = await RequirementsBazaar.GetRequirement(ids[i]); if (networkResult.Successful) { issues.Add(networkResult.Value); } } else { ApiResult <Issue> networkResult = await GitHub.GetIssue(projectIds[i], ids[i]); if (networkResult.Successful) { issues.Add(networkResult.Value); } } } visualization.ContentProvider = new SingleIssuesProvider(); visualization.ContentProvider.Issues = issues; }
public async void PostRequirement() { if (IsNewRequirement) { requirement = new Requirement(); } requirement.Name = titleInputField.text; requirement.Description = descriptionInputField.text; requirement.ProjectId = projectId; requirement.Categories = new Category[] { availableCategories[categoryDropdown.value] }; if (IsNewRequirement) { await RequirementsBazaar.CreateRequirement(requirement.ProjectId, requirement.Name, requirement.Description, requirement.Categories); } else { await RequirementsBazaar.UpdateRequirement(requirement); } Close(); }
private async void UpdateDisplay() { // disable all interactive controls so that the user cannot invoke multiple asynchronous commands at once upButton.enabled = false; downButton.enabled = false; // delete the currently shown category elements so that new category display can be shown instead ClearCategoryDisplayElements(); // get the current page and the next page // the next page is required to check if we are on the last page and to enable/disable downButton accordingly currentPage = await RequirementsBazaar.GetProjectCategories(projectId, page, categoriesPerPage); nextPage = await RequirementsBazaar.GetProjectCategories(projectId, page + 1, categoriesPerPage); if (page == 0) { upButton.enabled = false; } else { upButton.enabled = true; } if (nextPage.Length == 0) { downButton.enabled = false; } else { downButton.enabled = true; } for (int i = 0; i < currentPage.Length; i++) { CreateCategoryDisplayElement(currentPage[i]); } }