Skip to content

Commit c9072d7

Browse files
authored
Make links uniform in schedule (#1611)
1 parent 07508db commit c9072d7

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/JoinRpg.Portal/Views/ShowSchedule/_AppointmentPartial.cshtml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
classNames += " appointment-all-rooms";
1515
}
1616
classNames += Model.Users.Count == 0 ? " appointment-no-users" : " appointment-has-users";
17-
string url = Url.Action(Model.ErrorType.HasValue ? "Edit" : "Details", "Character", new { projectId = Model.ProjectId, characterId = Model.CharacterId });
17+
string url = Url.Action("Details", "Character", new { projectId = Model.ProjectId, characterId = Model.CharacterId });
1818
string style = Model.ErrorMode
1919
? string.Format("max-width: {0}px; height: {1}px;", Model.Width * 2, Model.ErrorType == AppointmentErrorType.NotLocated ? Model.Height + Model.Height / 2 : Model.Height)
2020
: string.Format("left: {0}px; top: {1}px; width: {2}px; height: {3}px", Model.Left, Model.Top, Model.Width - 1, Model.Height - 1);
@@ -34,7 +34,14 @@
3434
error-mode="@((Model.ErrorType == AppointmentErrorType.Intersection).ToString())"
3535
errors="@(Model.ErrorType.HasValue ? Model.ErrorType?.GetDisplayName() : "")">
3636
<div class="appointment-interior" title="@title">
37-
<div class="appointment-header"><a href="@url" target="@target">@Model.DisplayName</a></div>
37+
<div class="appointment-header">
38+
<a asp-action="Details" asp-controller="Character" asp-route-ProjectId="@Model.ProjectId" asp-route-characterId="@Model.CharacterId" target="@target">@Model.DisplayName</a>
39+
@if (Model.HasMasterAccess)
40+
{
41+
<a asp-action="Edit" asp-controller="Character" asp-route-ProjectId="@Model.ProjectId" asp-route-characterId="@Model.CharacterId">(ред.)</a>
42+
}
43+
</div>
44+
3845
@if (Model.ErrorType == AppointmentErrorType.NotLocated)
3946
{
4047
<div class="appointment-rooms"><b>Комнаты:</b> @if (Model.Rooms.Count > 0) { @(Model.AllRooms ? "все" : rooms) } else { <b class="text-danger">нет</b> }</div>

src/JoinRpg.WebPortal.Managers/Schedule/SchedulePageManager.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ public async Task<SchedulePageViewModel> GetSchedule()
4343
};
4444

4545
MergeSlots(viewModel);
46-
BuildAppointments(viewModel);
46+
BuildAppointments(project, viewModel);
4747

4848
return viewModel;
4949
}
5050

51-
private void BuildAppointments(SchedulePageViewModel viewModel)
51+
private void BuildAppointments(Project project, SchedulePageViewModel viewModel)
5252
{
5353
var result = new List<AppointmentViewModel>(64);
54+
var hasMasterAccess = project.HasMasterAccess(CurrentUserAccessor.UserId);
5455

5556
for (var i = 0; i < viewModel.Rows.Count; i++)
5657
{
@@ -65,6 +66,7 @@ private void BuildAppointments(SchedulePageViewModel viewModel)
6566

6667
var rowIndex = i;
6768
var colIndex = j;
69+
6870
var appointment = new AppointmentViewModel(() => new Rect
6971
{
7072
Left = colIndex * viewModel.ColumnWidth,
@@ -79,6 +81,7 @@ private void BuildAppointments(SchedulePageViewModel viewModel)
7981
AllRooms = slot.ColSpan == viewModel.Columns.Count,
8082
RoomIndex = colIndex,
8183
RoomCount = slot.ColSpan,
84+
HasMasterAccess = hasMasterAccess,
8285
TimeSlotIndex = rowIndex,
8386
TimeSlotsCount = slot.RowSpan,
8487
DisplayName = slot.Name,
@@ -118,7 +121,8 @@ private void BuildAppointments(SchedulePageViewModel viewModel)
118121
Description = source.Description.ToHtmlString(),
119122
ProjectId = source.ProjectId,
120123
CharacterId = source.Id,
121-
Users = source.Users
124+
Users = source.Users,
125+
HasMasterAccess = hasMasterAccess,
122126
})
123127
.ToList();
124128

@@ -140,7 +144,8 @@ private void BuildAppointments(SchedulePageViewModel viewModel)
140144
Description = source.Description.ToHtmlString(),
141145
ProjectId = source.ProjectId,
142146
CharacterId = source.Id,
143-
Users = source.Users
147+
Users = source.Users,
148+
HasMasterAccess = hasMasterAccess,
144149
})
145150
.ToList();
146151
}

src/JoinRpg.WebPortal.Models/Schedules/AppointmentViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public class AppointmentViewModel : AppointmentBaseViewModel
5151
public int Width => _bounds.Value.Width;
5252
public int Height => _bounds.Value.Height;
5353

54+
public bool HasMasterAccess { get; set; }
55+
5456
public AppointmentViewModel(Func<Rect> getBounds) => _bounds = new Lazy<Rect>(getBounds);
5557
}
5658
}

0 commit comments

Comments
 (0)