Skip to content

Commit

Permalink
fix owner display + add requester comment to impl task
Browse files Browse the repository at this point in the history
  • Loading branch information
abarz722 committed Jun 3, 2024
1 parent 8d9a890 commit 5c6bb3e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 20 deletions.
2 changes: 2 additions & 0 deletions roles/database/files/sql/idempotent/fworch-texts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1385,6 +1385,8 @@ INSERT INTO txt VALUES ('created_by', 'German', 'Erstellt von');
INSERT INTO txt VALUES ('created_by', 'English', 'Created by');
INSERT INTO txt VALUES ('requested_by', 'German', 'Beantragt von');
INSERT INTO txt VALUES ('requested_by', 'English', 'Requested by');
INSERT INTO txt VALUES ('for', 'German', 'für');
INSERT INTO txt VALUES ('for', 'English', 'for');
INSERT INTO txt VALUES ('log_change', 'German', 'Änderung loggen');
INSERT INTO txt VALUES ('log_change', 'English', 'Log Change');
INSERT INTO txt VALUES ('show_history', 'German', 'Änderungshistorie');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
else
{
<label class="col-sm-4 col-form-label col-form-label-sm">@(userConfig.GetText("owner"))*:</label>
<label class="col-sm-8 border bg-secondary">@actOwner?.Name</label>
<label class="col-sm-8 border bg-secondary">@actOwner?.Display()</label>
}
</div>
</div>
Expand Down
57 changes: 38 additions & 19 deletions roles/ui/files/FWO.UI/Services/TicketCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public async Task<long> CreateRequestNewInterfaceTicket(FwoOwner owner, string r
await reqHandler.AddApproval(JsonSerializer.Serialize(new ApprovalParams(){StateId = reqHandler.MasterStateMatrix.LowestEndState}));
reqHandler.ActTicket.Tasks.Add(reqHandler.ActReqTask);
reqHandler.AddTicketMode = true;
return await reqHandler.SaveTicket(reqHandler.ActTicket);
long ticketId = await reqHandler.SaveTicket(reqHandler.ActTicket);
await AddRequesterInfoToImplTask(ticketId, owner);
return ticketId;
}

public async Task SetInterfaceId(long ticketId, long connId, FwoOwner owner)
Expand All @@ -69,27 +71,17 @@ public async Task SetInterfaceId(long ticketId, long connId, FwoOwner owner)
public async Task<bool> PromoteTicket(FwoOwner owner, long ticketId, string comment = "")
{
await reqHandler.Init([owner.Id]);
RequestTicket? ticket = await reqHandler.ResolveTicket(ticketId);
if(ticket != null)
RequestImplTask? implTask = await FindNewInterfaceImplTask(ticketId);
if(implTask != null)
{
reqHandler.SetTicketEnv(ticket);
RequestReqTask? reqTask = ticket.Tasks.FirstOrDefault(x => x.TaskType == TaskType.new_interface.ToString());
if(reqTask != null)
await reqHandler.ContinueImplPhase(implTask);
if(comment != "")
{
reqHandler.SetReqTaskEnv(reqTask);
RequestImplTask? implTask = reqTask.ImplementationTasks.FirstOrDefault(x => x.ReqTaskId == reqTask.Id);
if(implTask != null)
{
await reqHandler.ContinueImplPhase(implTask);
if(comment != "")
{
await reqHandler.ConfAddCommentToImplTask(comment);
}
int newState = reqHandler.MasterStateMatrix.LowestEndState;
await reqHandler.PromoteImplTask(new(){ StateId = newState });
return true;
}
await reqHandler.ConfAddCommentToImplTask(comment);
}
int newState = reqHandler.MasterStateMatrix.LowestEndState;
await reqHandler.PromoteImplTask(new(){ StateId = newState });
return true;
}
return false;
}
Expand Down Expand Up @@ -152,6 +144,33 @@ private async Task CreateRuleDeleteTicket(int deviceId, List<string> ruleUids, s
await reqHandler.SaveTicket(reqHandler.ActTicket);
}

private async Task AddRequesterInfoToImplTask(long ticketId, FwoOwner owner)
{
RequestImplTask? implTask = await FindNewInterfaceImplTask(ticketId);
if(implTask != null)
{
reqHandler.SetImplTaskEnv(implTask);
string comment = $"{userConfig.GetText("requested_by")}: {userConfig.User.Name} {userConfig.GetText("for")} {owner.Display()}";
await reqHandler.ConfAddCommentToImplTask(comment);
}
}

private async Task<RequestImplTask?> FindNewInterfaceImplTask(long ticketId)
{
RequestTicket? ticket = await reqHandler.ResolveTicket(ticketId);
if(ticket != null)
{
reqHandler.SetTicketEnv(ticket);
RequestReqTask? reqTask = ticket.Tasks.FirstOrDefault(x => x.TaskType == TaskType.new_interface.ToString());
if(reqTask != null)
{
reqHandler.SetReqTaskEnv(reqTask);
return reqTask.ImplementationTasks.FirstOrDefault(x => x.ReqTaskId == reqTask.Id);
}
}
return null;
}

private void LogMessage(Exception? exception = null, string title = "", string message = "", bool ErrorFlag = false)
{
if (exception == null)
Expand Down

0 comments on commit 5c6bb3e

Please sign in to comment.