Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/Payments.Mvc/ClientApp/src/css/_vendor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,11 @@ input[type=number]::-webkit-outer-spin-button {

// fix spacing on checkboxes
.form-check {
padding-left: 2rem;
padding-left: 2rem;

.form-check-input {
margin-top: 0.6rem;
margin-left: -2rem;
}
.form-check-input {
margin-left: -2rem;
}
}

.progress-bar {
Expand Down
86 changes: 45 additions & 41 deletions src/Payments.Mvc/Controllers/SettingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,16 @@ public async Task<IActionResult> Index()

var model = new TeamDetailsModel
{
Name = team.Name,
Slug = team.Slug,
ContactName = team.ContactName,
ContactEmail = team.ContactEmail,
Name = team.Name,
Slug = team.Slug,
ContactName = team.ContactName,
ContactEmail = team.ContactEmail,
ContactPhoneNumber = team.ContactPhoneNumber,
ApiKey = userCanEdit ? team.ApiKey : "",
IsActive = team.IsActive,
UserCanEdit = userCanEdit,
WebHookApiKey = team.WebHookApiKey
ApiKey = userCanEdit ? team.ApiKey : "",
IsActive = team.IsActive,
UserCanEdit = userCanEdit,
WebHookApiKey = team.WebHookApiKey,
AllowedInvoiceType = team.AllowedInvoiceType
};

return View(model);
Expand All @@ -91,13 +92,14 @@ public async Task<IActionResult> Edit()

var model = new EditTeamViewModel()
{
Name = team.Name,
Slug = team.Slug,
ContactName = team.ContactName,
ContactEmail = team.ContactEmail,
Name = team.Name,
Slug = team.Slug,
ContactName = team.ContactName,
ContactEmail = team.ContactEmail,
ContactPhoneNumber = team.ContactPhoneNumber,
IsActive = team.IsActive,
WebHookApiKey = team.WebHookApiKey
IsActive = team.IsActive,
WebHookApiKey = team.WebHookApiKey,
AllowedInvoiceType = team.AllowedInvoiceType
};

return View(model);
Expand Down Expand Up @@ -126,17 +128,19 @@ public async Task<IActionResult> Edit(EditTeamViewModel model)
return View(model);
}

team.Name = model.Name;
team.Slug = model.Slug;
team.ContactName = model.ContactName;
team.ContactEmail = model.ContactEmail;
team.Name = model.Name;
team.Slug = model.Slug;
team.ContactName = model.ContactName;
team.ContactEmail = model.ContactEmail;
team.ContactPhoneNumber = model.ContactPhoneNumber;
team.WebHookApiKey = model.WebHookApiKey;
team.WebHookApiKey = model.WebHookApiKey;


// only admins can change active
if (User.IsInRole(ApplicationRoleCodes.Admin))
{
team.IsActive = model.IsActive;
team.AllowedInvoiceType = model.AllowedInvoiceType;
}

await _context.SaveChangesAsync();
Expand Down Expand Up @@ -165,14 +169,14 @@ public async Task<IActionResult> Roles()

var model = new TeamDetailsModel
{
Name = team.Name,
Slug = team.Slug,
ContactName = team.ContactName,
ContactEmail = team.ContactEmail,
Name = team.Name,
Slug = team.Slug,
ContactName = team.ContactName,
ContactEmail = team.ContactEmail,
ContactPhoneNumber = team.ContactPhoneNumber,
IsActive = team.IsActive,
Permissions = permissions,
UserCanEdit = userCanEdit
IsActive = team.IsActive,
Permissions = permissions,
UserCanEdit = userCanEdit
};

return View(model);
Expand Down Expand Up @@ -246,10 +250,10 @@ public async Task<IActionResult> CreatePermission(CreateTeamPermissionViewModel
{
var userToCreate = new User
{
Email = user.Mail,
UserName = user.Mail,
Email = user.Mail,
UserName = user.Mail,
CampusKerberos = user.Kerberos,
Name = user.FullName
Name = user.FullName
};

var userPrincipal = new ClaimsPrincipal();
Expand Down Expand Up @@ -427,11 +431,11 @@ public async Task<IActionResult> CreateWebHook(CreateWebHookViewModel model)
// create webhook and add it
var webHook = new WebHook()
{
Team = team,
Url = model.Url,
ContentType = model.ContentType,
IsActive = model.IsActive,
TriggerOnPaid = model.TriggerOnPaid,
Team = team,
Url = model.Url,
ContentType = model.ContentType,
IsActive = model.IsActive,
TriggerOnPaid = model.TriggerOnPaid,
TriggerOnReconcile = model.TriggerOnReconcile,
};

Expand Down Expand Up @@ -460,9 +464,9 @@ public async Task<IActionResult> EditWebHook(int id)

var model = new EditWebHookViewModel()
{
Id = webHook.Id,
Url = webHook.Url,
IsActive = webHook.IsActive,
Id = webHook.Id,
Url = webHook.Url,
IsActive = webHook.IsActive,
TriggerOnPaid = webHook.TriggerOnPaid,
};

Expand Down Expand Up @@ -494,10 +498,10 @@ public async Task<IActionResult> EditWebHook(int id, EditWebHookViewModel model)
}

// update model
webHook.Url = model.Url;
webHook.ContentType = model.ContentType;
webHook.IsActive = model.IsActive;
webHook.TriggerOnPaid = model.TriggerOnPaid;
webHook.Url = model.Url;
webHook.ContentType = model.ContentType;
webHook.IsActive = model.IsActive;
webHook.TriggerOnPaid = model.TriggerOnPaid;
webHook.TriggerOnReconcile = model.TriggerOnReconcile;

await _context.SaveChangesAsync();
Expand Down
17 changes: 9 additions & 8 deletions src/Payments.Mvc/Controllers/TeamsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,19 @@ public async Task<IActionResult> Create(CreateTeamViewModel model)
if (!ModelState.IsValid)
{
return View(model);
}
}

var team = new Team()
{
Name = model.Name,
Slug = model.Slug,
ContactName = model.ContactName,
ContactEmail = model.ContactEmail,
Name = model.Name,
Slug = model.Slug,
ContactName = model.ContactName,
ContactEmail = model.ContactEmail,
ContactPhoneNumber = model.ContactPhoneNumber,
IsActive = true,
ApiKey = Guid.NewGuid().ToString("N").ToUpper(),
WebHookApiKey = model.WebHookApiKey,
IsActive = true,
ApiKey = Guid.NewGuid().ToString("N").ToUpper(),
WebHookApiKey = model.WebHookApiKey,
AllowedInvoiceType = model.AllowedInvoiceType,
};

// add user to team
Expand Down
6 changes: 6 additions & 0 deletions src/Payments.Mvc/Models/TeamViewModels/BaseTeamViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using static Payments.Core.Domain.Team;

namespace Payments.Mvc.Models.TeamViewModels
{
Expand Down Expand Up @@ -38,5 +39,10 @@ public class BaseTeamViewModel
[Display(Name = "WebHook API Key")]
[RegularExpression(@"^[a-zA-Z0-9\-._~]*$", ErrorMessage = "WebHook API Key may only contain URL-safe characters. (a-z A-Z 0-9 - . _ ~)")]
public string WebHookApiKey { get; set; }

[Required]
[StringLength(10)]
[Display(Name = "Allowed Invoice Type")]
public string AllowedInvoiceType { get; set; } = AllowedInvoiceTypes.CreditCard;
}
}
19 changes: 11 additions & 8 deletions src/Payments.Mvc/Models/TeamViewModels/TeamDetailsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,26 @@ public class TeamDetailsModel
public string ContactPhoneNumber { get; set; }

[Display(Name = "ApiKey")]
public string ApiKey { get; set; }
[Display(Name = "WebHook API Key")]
public string ApiKey { get; set; }

[Display(Name = "WebHook API Key")]
public string WebHookApiKey { get; set; }

[Display(Name = "Active?")]
public bool IsActive { get; set; }

[Display(Name = "Allowed Invoice Type")]
public string AllowedInvoiceType { get; set; }

public IList<FinancialAccount> Accounts { get; set; }

public IList<TeamPermission> Permissions { get; set; }

public bool UserCanEdit { get; set; }
public bool ShowCoa { get; set; }
public bool UseCoa { get; set; }
public bool UserCanEdit { get; set; }

public bool ShowCoa { get; set; }
public bool UseCoa { get; set; }

public string WarningMessage { get; set; } //Because the temp data isn't showing this right.
}
}
40 changes: 37 additions & 3 deletions src/Payments.Mvc/Views/Settings/Edit.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@using Payments.Mvc.Models.Roles
@using Payments.Core.Domain
@model Payments.Mvc.Models.TeamViewModels.EditTeamViewModel

@{
Expand Down Expand Up @@ -45,10 +46,43 @@
<label asp-for="WebHookApiKey" class="control-label"></label>
<input asp-for="WebHookApiKey" class="form-control" />
<span asp-validation-for="WebHookApiKey" class="text-danger"></span>
<div class="text-muted">Leave blank if you don't want to pass authorization to your webhook URL</div>
<div class="text-muted">Leave blank if you don't want to pass authorization to your webhook URL
</div>
</div>

@if (User.IsInRole(ApplicationRoleCodes.Admin))
@{
bool isAdmin = User.IsInRole(ApplicationRoleCodes.Admin);
string labelClass = isAdmin ? "form-check-label ms-2" : "form-check-label ms-2 text-muted";
}

<div class="form-group">
<label asp-for="AllowedInvoiceType" class="control-label"></label>
<div class="ms-3">
<div class="form-check d-flex">
<input asp-for="AllowedInvoiceType" class="form-check-input" type="radio"
value="@Team.AllowedInvoiceTypes.CreditCard" disabled="@(!isAdmin)" />
<label class="@labelClass" asp-for="AllowedInvoiceType">Credit Card Only</label>
</div>
<div class="form-check d-flex">
<input asp-for="AllowedInvoiceType" class="form-check-input" type="radio"
value="@Team.AllowedInvoiceTypes.Recharge" disabled="@(!isAdmin)" />
<label class="@labelClass" asp-for="AllowedInvoiceType">Recharge Only</label>
</div>
<div class="form-check d-flex">
<input asp-for="AllowedInvoiceType" class="form-check-input" type="radio"
value="@Team.AllowedInvoiceTypes.Both" disabled="@(!isAdmin)" />
<label class="@labelClass" asp-for="AllowedInvoiceType">Both</label>
</div>
</div>
@if (!isAdmin)
{
<div class="text-muted small mt-1">If you need to change the allowed invoice type, please submit
a help ticket.</div>
}
<span asp-validation-for="AllowedInvoiceType" class="text-danger"></span>
</div>

@if (isAdmin)
{
<div class="form-group">
<div class="checkbox">
Expand Down Expand Up @@ -103,4 +137,4 @@
}
});
</script>
}
}
34 changes: 32 additions & 2 deletions src/Payments.Mvc/Views/Settings/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
@Html.DisplayNameFor(model => model.WebHookApiKey)
</dt>
<dd>
@if(!string.IsNullOrWhiteSpace(Model.WebHookApiKey))
@if (!string.IsNullOrWhiteSpace(Model.WebHookApiKey))
{
@Html.DisplayFor(model => model.WebHookApiKey)
}
Expand Down Expand Up @@ -71,6 +71,36 @@
<dd>
@Html.DisplayFor(model => model.ContactPhoneNumber)
</dd>
<dt>
@Html.DisplayNameFor(model => model.AllowedInvoiceType)
</dt>
<dd>
@{
string displayText = "";
string badgeClass = "";

switch (Model.AllowedInvoiceType)
{
case "CC":
displayText = "Credit Card Only";
badgeClass = "badge bg-primary";
break;
case "Recharge":
displayText = "Recharge Only";
badgeClass = "badge bg-success";
break;
case "Both":
displayText = "Both Credit Card and Recharge";
badgeClass = "badge bg-info";
break;
default:
displayText = Model.AllowedInvoiceType;
badgeClass = "badge bg-secondary";
break;
}
}
<span class="@badgeClass">@displayText</span>
</dd>
</dl>
</div>
</div>
Expand Down Expand Up @@ -113,4 +143,4 @@

<div>
<a asp-controller="Teams" asp-action="Index"><i class="fas fa-chevron-left me-3"></i>Back to List of Teams</a>
</div>
</div>
Loading