mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Fixed the ability to edit/create vaults from the main site.
This commit is contained in:
parent
c17637ccad
commit
cae2d6b639
@ -29,7 +29,7 @@
|
||||
<ul class="dropdown-menu pull-right" id="add-to-vault-menu">
|
||||
@foreach (Vault item in Model.Vaults)
|
||||
{
|
||||
<li><a href="#" class="add-to-vault" data-add-to-vault-url="@Url.SubRouteUrl("v", "Vault.EditVault", new { url = item.Url, type = "Paste" })" data-paste-url="@Model.Url" data-paste-title="@((string.IsNullOrEmpty(Model.Title)) ? "Untitled" : Model.Title)">@item.Title</a></li>
|
||||
<li><a href="#" class="add-to-vault" data-add-to-vault-url="@Url.SubRouteUrl("vault", "Vault.EditVault", new { url = item.Url, type = "Paste" })" data-paste-url="@Model.Url" data-paste-title="@((string.IsNullOrEmpty(Model.Title)) ? "Untitled" : Model.Title)">@item.Title</a></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
@ -60,7 +60,7 @@
|
||||
<ul class="dropdown-menu" id="add-to-vault-menu">
|
||||
@foreach (Vault item in Model.Vaults)
|
||||
{
|
||||
<li><a href="#" class="add-to-vault" data-add-to-vault-url="@Url.SubRouteUrl("v", "Vault.EditVault", new { url = item.Url, type = "Upload" })">@item.Title</a></li>
|
||||
<li><a href="#" class="add-to-vault" data-add-to-vault-url="@Url.SubRouteUrl("vault", "Vault.EditVault", new { url = item.Url, type = "Upload" })">@item.Title</a></li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ namespace Teknik.Areas.Vault.Controllers
|
||||
ViewBag.Title = foundVault.Title + " - Teknik Vault";
|
||||
|
||||
VaultViewModel model = new VaultViewModel();
|
||||
model.CurrentSub = Subdomain;
|
||||
|
||||
model.Url = foundVault.Url;
|
||||
model.UserId = foundVault.UserId;
|
||||
@ -103,6 +104,7 @@ namespace Teknik.Areas.Vault.Controllers
|
||||
{
|
||||
ViewBag.Title = "Create Vault";
|
||||
ModifyVaultViewModel model = new ModifyVaultViewModel();
|
||||
model.CurrentSub = Subdomain;
|
||||
return View("~/Areas/Vault/Views/Vault/ModifyVault.cshtml", model);
|
||||
}
|
||||
|
||||
@ -112,6 +114,7 @@ namespace Teknik.Areas.Vault.Controllers
|
||||
{
|
||||
ViewBag.Title = "Create Vault";
|
||||
ModifyVaultViewModel model = new ModifyVaultViewModel();
|
||||
model.CurrentSub = Subdomain;
|
||||
|
||||
string decodedItems = HttpUtility.UrlDecode(items);
|
||||
string[] allURLs = decodedItems.Split(',');
|
||||
@ -154,6 +157,7 @@ namespace Teknik.Areas.Vault.Controllers
|
||||
ViewBag.Title = "Edit Vault - " + foundVault.Title;
|
||||
|
||||
ModifyVaultViewModel model = new ModifyVaultViewModel();
|
||||
model.CurrentSub = Subdomain;
|
||||
model.isEdit = true;
|
||||
model.vaultId = foundVault.VaultId;
|
||||
model.title = foundVault.Title;
|
||||
|
@ -56,6 +56,10 @@
|
||||
type: "POST",
|
||||
url: validateItemURL,
|
||||
data: AddAntiForgeryToken({ type: type, url: url }),
|
||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.result) {
|
||||
itemCount++;
|
||||
@ -153,13 +157,21 @@
|
||||
type: "POST",
|
||||
url: modifyVaultURL,
|
||||
data: AddAntiForgeryToken({ vaultId: vaultId, title: title, description: description, items: items }),
|
||||
headers: { 'X-Requested-With': 'XMLHttpRequest' },
|
||||
xhrFields: {
|
||||
withCredentials: true
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.result) {
|
||||
window.location = response.result.url;
|
||||
}
|
||||
else {
|
||||
var err = response;
|
||||
if (response.error) {
|
||||
err = response.error.message;
|
||||
}
|
||||
$("#top_msg").css('display', 'inline', 'important');
|
||||
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' + response.error.message + '</div>');
|
||||
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' + err + '</div>');
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -183,8 +195,12 @@
|
||||
window.location = html.result.url;
|
||||
}
|
||||
else {
|
||||
var err = html;
|
||||
if (html.error) {
|
||||
err = html.error.message;
|
||||
}
|
||||
$("#top_msg").css('display', 'inline', 'important');
|
||||
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' + html.error.message + '</div>');
|
||||
$("#top_msg").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' + err + '</div>');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -11,6 +11,7 @@ namespace Teknik.Areas.Vault.ViewModels
|
||||
{
|
||||
public bool isEdit { get; set; }
|
||||
public int vaultId { get; set; }
|
||||
public string CurrentSub { get; set; }
|
||||
public string title { get; set; }
|
||||
public string description { get; set; }
|
||||
public List<ModifyVaultItemViewModel> items { get; set; }
|
||||
@ -19,6 +20,7 @@ namespace Teknik.Areas.Vault.ViewModels
|
||||
{
|
||||
isEdit = false;
|
||||
vaultId = -1;
|
||||
CurrentSub = "vault";
|
||||
title = string.Empty;
|
||||
description = string.Empty;
|
||||
items = new List<ModifyVaultItemViewModel>();
|
||||
|
@ -12,6 +12,7 @@ namespace Teknik.Areas.Vault.ViewModels
|
||||
public string Url { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
public Users.Models.User User { get; set; }
|
||||
public string CurrentSub { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Description { get; set; }
|
||||
public DateTime DateCreated { get; set; }
|
||||
@ -20,6 +21,7 @@ namespace Teknik.Areas.Vault.ViewModels
|
||||
|
||||
public VaultViewModel()
|
||||
{
|
||||
CurrentSub = "vault";
|
||||
Title = string.Empty;
|
||||
Description = string.Empty;
|
||||
DateCreated = DateTime.Now;
|
||||
|
@ -12,8 +12,8 @@
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var validateItemURL = '@Url.SubRouteUrl("vault", "Vault.Action", new { action = "ValidateItem" })';
|
||||
var modifyVaultURL = '@Url.SubRouteUrl("vault", "Vault.Action", new { action = action })';
|
||||
var validateItemURL = '@Url.SubRouteUrl(Model.CurrentSub, "Vault.Action", new { action = "ValidateItem" })';
|
||||
var modifyVaultURL = '@Url.SubRouteUrl(Model.CurrentSub, "Vault.Action", new { action = action })';
|
||||
|
||||
var itemCount = @Model.items.Count();
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
@Styles.Render("~/Content/vault")
|
||||
|
||||
<script type="text/javascript">
|
||||
var deleteVaultURL = '@Url.SubRouteUrl("v", "Vault.DeleteVault")';
|
||||
var deleteVaultURL = '@Url.SubRouteUrl(Model.CurrentSub, "Vault.DeleteVault")';
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
|
Loading…
Reference in New Issue
Block a user