Organize asset details and separate reference editing
This commit is contained in:
parent
9e176c3348
commit
4bae5d99cd
@ -77,11 +77,6 @@ public sealed class StoryAssetsController(IAssetService assets) : Controller
|
||||
{
|
||||
assetId = await assets.SaveAssetAsync(model);
|
||||
}
|
||||
catch (EntityImageUploadException ex)
|
||||
{
|
||||
TempData["ImageError"] = ex.Message;
|
||||
return RedirectToAction(nameof(Edit), new { id = ex.EntityId });
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
ModelState.AddModelError(string.Empty, ex.Message);
|
||||
@ -92,6 +87,27 @@ public sealed class StoryAssetsController(IAssetService assets) : Controller
|
||||
return RedirectToAction(nameof(Details), new { id = assetId });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
[RequestSizeLimit(11L * 1024 * 1024)]
|
||||
public async Task<IActionResult> SaveImage(int id, string operation, IFormFile? upload)
|
||||
{
|
||||
if (!ModelState.IsValid) return BadRequest();
|
||||
var result = await assets.SaveAssetImageAsync(id, operation, upload);
|
||||
if (result is null) return NotFound();
|
||||
|
||||
if (result.Succeeded)
|
||||
{
|
||||
TempData["AssetImageSaved"] = operation == "remove" ? "Asset image removed." : "Asset image saved.";
|
||||
}
|
||||
else
|
||||
{
|
||||
TempData["ImageError"] = result.ErrorMessage;
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Details), new { id, tab = "reference" });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> Archive(int id, int projectId)
|
||||
@ -106,7 +122,7 @@ public sealed class StoryAssetsController(IAssetService assets) : Controller
|
||||
public async Task<IActionResult> AddDependency(AssetDependencyEditViewModel model, int returnAssetId)
|
||||
{
|
||||
await assets.SaveDependencyAsync(model);
|
||||
return RedirectToAction(nameof(Details), new { id = returnAssetId });
|
||||
return RedirectToAction(nameof(Details), new { id = returnAssetId, tab = "dependencies" });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@ -126,7 +142,7 @@ public sealed class StoryAssetsController(IAssetService assets) : Controller
|
||||
public async Task<IActionResult> DeleteDependency(int id, int returnAssetId)
|
||||
{
|
||||
await assets.DeleteDependencyAsync(id);
|
||||
return RedirectToAction(nameof(Details), new { id = returnAssetId });
|
||||
return RedirectToAction(nameof(Details), new { id = returnAssetId, tab = "dependencies" });
|
||||
}
|
||||
|
||||
private async Task<StoryAssetEditViewModel?> RehydrateEditModel(StoryAssetEditViewModel posted)
|
||||
|
||||
@ -137,7 +137,7 @@ public sealed class StoryElementReferencesController(
|
||||
private IActionResult Return(StoryElementReferenceScope scope, string? error = null)
|
||||
{
|
||||
if (error is not null) TempData["ReferenceError"] = error;
|
||||
return RedirectToAction("Details", scope.DetailsController, new { id = scope.EntityID, tab = scope.EntityType is StoryElementType.Character or StoryElementType.Location ? "reference" : null },
|
||||
return RedirectToAction("Details", scope.DetailsController, new { id = scope.EntityID, tab = "reference" },
|
||||
scope.EntityType == StoryElementType.Character && Request.Form["operation"] == "caption"
|
||||
? "character-gallery" : "story-element-references");
|
||||
}
|
||||
|
||||
@ -183,7 +183,7 @@ public interface IAssetRepository
|
||||
Task<AssetLookupData> GetLookupsAsync(int? projectId = null);
|
||||
Task<IReadOnlyList<StoryAsset>> ListAssetsAsync(int projectId);
|
||||
Task<StoryAsset?> GetAssetAsync(int storyAssetId);
|
||||
Task<int> SaveAssetAsync(StoryAsset asset);
|
||||
Task<int> SaveAssetAsync(StoryAsset asset, bool preserveImage = false);
|
||||
Task<IReadOnlyList<AssetAlias>> ListAliasesAsync(int storyAssetId);
|
||||
Task<int> AddAliasAsync(int storyAssetId, string alias, int? sortOrder);
|
||||
Task UpdateAliasAsync(int assetAliasId, string alias, int? sortOrder);
|
||||
@ -3433,7 +3433,7 @@ public sealed class AssetRepository(ISqlConnectionFactory connectionFactory) : I
|
||||
return await connection.QuerySingleOrDefaultAsync<StoryAsset>("dbo.StoryAsset_Get", new { StoryAssetID = storyAssetId }, commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
public async Task<int> SaveAssetAsync(StoryAsset asset)
|
||||
public async Task<int> SaveAssetAsync(StoryAsset asset, bool preserveImage = false)
|
||||
{
|
||||
using var connection = connectionFactory.CreateConnection();
|
||||
return await connection.QuerySingleAsync<int>(
|
||||
@ -3451,7 +3451,8 @@ public sealed class AssetRepository(ISqlConnectionFactory connectionFactory) : I
|
||||
asset.IsResolved,
|
||||
asset.ShowInQuickAddBar,
|
||||
asset.ImagePath,
|
||||
asset.ThumbnailPath
|
||||
asset.ThumbnailPath,
|
||||
PreserveImage = preserveImage
|
||||
},
|
||||
commandType: CommandType.StoredProcedure);
|
||||
}
|
||||
|
||||
@ -199,6 +199,7 @@ public interface IAssetService
|
||||
Task<StoryAssetEditViewModel?> GetEditAssetAsync(int storyAssetId);
|
||||
Task<StoryAssetDetailViewModel?> GetAssetDetailAsync(int storyAssetId);
|
||||
Task<int> SaveAssetAsync(StoryAssetEditViewModel model);
|
||||
Task<VisualIdentityImageResult?> SaveAssetImageAsync(int storyAssetId, string operation, IFormFile? upload);
|
||||
Task ArchiveAssetAsync(int storyAssetId);
|
||||
Task<int> AddAssetEventAsync(AssetEventCreateViewModel model);
|
||||
Task DeleteAssetEventAsync(int assetEventId);
|
||||
@ -8058,6 +8059,7 @@ public sealed class AssetService(
|
||||
{
|
||||
Project = project,
|
||||
Asset = asset,
|
||||
Aliases = (await assets.ListAliasesAsync(storyAssetId)).Select(alias => alias.Alias).ToList(),
|
||||
ProjectAssets = projectAssets,
|
||||
Events = await assets.ListEventsByAssetAsync(storyAssetId),
|
||||
Dependencies = await assets.ListDependenciesByAssetAsync(storyAssetId),
|
||||
@ -8079,7 +8081,6 @@ public sealed class AssetService(
|
||||
public async Task<int> SaveAssetAsync(StoryAssetEditViewModel model)
|
||||
{
|
||||
var isNew = model.StoryAssetID == 0;
|
||||
var existing = isNew ? null : await assets.GetAssetAsync(model.StoryAssetID);
|
||||
var assetId = await assets.SaveAssetAsync(new StoryAsset
|
||||
{
|
||||
StoryAssetID = model.StoryAssetID,
|
||||
@ -8091,30 +8092,41 @@ public sealed class AssetService(
|
||||
CurrentStateID = model.CurrentStateID,
|
||||
CurrentLocationID = model.CurrentLocationID,
|
||||
IsResolved = model.IsResolved,
|
||||
ShowInQuickAddBar = model.ShowInQuickAddBar,
|
||||
ImagePath = model.ImagePath ?? existing?.ImagePath,
|
||||
ThumbnailPath = model.ThumbnailPath ?? existing?.ThumbnailPath
|
||||
});
|
||||
ShowInQuickAddBar = model.ShowInQuickAddBar
|
||||
}, preserveImage: true);
|
||||
await SyncAssetAliasesAsync(assetId, model.Aliases);
|
||||
var imageHost = existing ?? new StoryAsset { StoryAssetID = assetId, ProjectID = model.ProjectID };
|
||||
imageHost.StoryAssetID = assetId;
|
||||
imageHost.ProjectID = model.ProjectID;
|
||||
if (model.ImageUpload is { Length: > 0 } upload)
|
||||
{
|
||||
var result = await visualIdentityImages.UploadAssetImageAsync(imageHost, upload);
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
throw new EntityImageUploadException(result.ErrorMessage ?? "Asset image could not be uploaded.", assetId);
|
||||
}
|
||||
}
|
||||
else if (model.RemoveImage && existing is not null)
|
||||
{
|
||||
await visualIdentityImages.RemoveAssetImageAsync(existing);
|
||||
}
|
||||
await activity.RecordAsync(model.ProjectID, isNew ? "Created" : "Updated", "Asset", assetId, model.AssetName);
|
||||
return assetId;
|
||||
}
|
||||
|
||||
public async Task<VisualIdentityImageResult?> SaveAssetImageAsync(int storyAssetId, string operation, IFormFile? upload)
|
||||
{
|
||||
var asset = await assets.GetAssetAsync(storyAssetId);
|
||||
if (asset is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
switch (operation)
|
||||
{
|
||||
case "upload" when upload is not null:
|
||||
var result = await visualIdentityImages.UploadAssetImageAsync(asset, upload);
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
break;
|
||||
case "remove":
|
||||
await visualIdentityImages.RemoveAssetImageAsync(asset);
|
||||
break;
|
||||
default:
|
||||
return new(false, "Choose an image to upload.");
|
||||
}
|
||||
|
||||
await activity.RecordAsync(asset.ProjectID, "Updated", "Asset", asset.StoryAssetID, asset.AssetName);
|
||||
return new(true);
|
||||
}
|
||||
|
||||
public async Task ArchiveAssetAsync(int storyAssetId)
|
||||
{
|
||||
var asset = await assets.GetAssetAsync(storyAssetId);
|
||||
|
||||
37
PlotLine/Sql/351_StoryAssetPreserveImageOnBaseSave.sql
Normal file
37
PlotLine/Sql/351_StoryAssetPreserveImageOnBaseSave.sql
Normal file
@ -0,0 +1,37 @@
|
||||
CREATE OR ALTER PROCEDURE dbo.StoryAsset_Save
|
||||
@StoryAssetID int = NULL,
|
||||
@ProjectID int,
|
||||
@AssetName nvarchar(200),
|
||||
@AssetKindID int,
|
||||
@Description nvarchar(max) = NULL,
|
||||
@Importance int,
|
||||
@CurrentStateID int = NULL,
|
||||
@CurrentLocationID int = NULL,
|
||||
@IsResolved bit,
|
||||
@ShowInQuickAddBar bit = 0,
|
||||
@ImagePath nvarchar(500) = NULL,
|
||||
@ThumbnailPath nvarchar(500) = NULL,
|
||||
@PreserveImage bit = 0
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON;
|
||||
IF @StoryAssetID IS NULL OR @StoryAssetID = 0
|
||||
BEGIN
|
||||
INSERT dbo.StoryAssets (ProjectID, AssetName, AssetKindID, Description, Importance, CurrentStateID, CurrentLocationID, IsResolved, ShowInQuickAddBar, ImagePath, ThumbnailPath)
|
||||
VALUES (@ProjectID, @AssetName, @AssetKindID, @Description, @Importance, @CurrentStateID, @CurrentLocationID, @IsResolved, @ShowInQuickAddBar, @ImagePath, @ThumbnailPath);
|
||||
SET @StoryAssetID = CAST(SCOPE_IDENTITY() AS int);
|
||||
END
|
||||
ELSE
|
||||
BEGIN
|
||||
UPDATE dbo.StoryAssets
|
||||
SET AssetName = @AssetName, AssetKindID = @AssetKindID, Description = @Description, Importance = @Importance,
|
||||
CurrentStateID = @CurrentStateID, CurrentLocationID = @CurrentLocationID, IsResolved = @IsResolved,
|
||||
ShowInQuickAddBar = @ShowInQuickAddBar,
|
||||
ImagePath = CASE WHEN @PreserveImage = 1 THEN ImagePath ELSE @ImagePath END,
|
||||
ThumbnailPath = CASE WHEN @PreserveImage = 1 THEN ThumbnailPath ELSE @ThumbnailPath END,
|
||||
UpdatedDate = SYSUTCDATETIME()
|
||||
WHERE StoryAssetID = @StoryAssetID;
|
||||
END
|
||||
SELECT @StoryAssetID;
|
||||
END;
|
||||
GO
|
||||
@ -1822,12 +1822,6 @@ public sealed class StoryAssetEditViewModel
|
||||
public string? ImagePath { get; set; }
|
||||
public string? ThumbnailPath { get; set; }
|
||||
|
||||
[Display(Name = "Upload image")]
|
||||
public IFormFile? ImageUpload { get; set; }
|
||||
|
||||
[Display(Name = "Remove image")]
|
||||
public bool RemoveImage { get; set; }
|
||||
|
||||
public Project? Project { get; set; }
|
||||
public IReadOnlyList<SelectListItem> AssetKindOptions { get; set; } = [];
|
||||
public IReadOnlyList<SelectListItem> AssetStateOptions { get; set; } = [];
|
||||
@ -1838,6 +1832,7 @@ public sealed class StoryAssetDetailViewModel
|
||||
{
|
||||
public Project Project { get; set; } = new();
|
||||
public StoryAsset Asset { get; set; } = new();
|
||||
public IReadOnlyList<string> Aliases { get; set; } = [];
|
||||
public IReadOnlyList<StoryAsset> ProjectAssets { get; set; } = [];
|
||||
public IReadOnlyList<AssetEvent> Events { get; set; } = [];
|
||||
public IReadOnlyList<AssetDependency> Dependencies { get; set; } = [];
|
||||
|
||||
@ -3,9 +3,10 @@
|
||||
ViewData["DesktopLayout"] = "details";
|
||||
ViewData["Title"] = Model.Asset.AssetName;
|
||||
ViewData["ProjectSection"] = "Assets";
|
||||
var firstAssetEvent = Model.Events.FirstOrDefault();
|
||||
var firstCustodyEvent = Model.CustodyEvents.FirstOrDefault();
|
||||
var firstSceneId = firstAssetEvent?.SceneID ?? firstCustodyEvent?.SceneID;
|
||||
IReadOnlyList<(string Id, string Label)> tabs =
|
||||
[("overview", "Overview"), ("reference", "Reference"), ("dependencies", "Dependencies"), ("scene-history", "Scene history")];
|
||||
var requestedTab = Context.Request.Query["tab"].ToString();
|
||||
var activeTab = tabs.Any(tab => tab.Id == requestedTab) ? requestedTab : "overview";
|
||||
}
|
||||
|
||||
<nav data-pwa-identity class="breadcrumb-trail" aria-label="Breadcrumb">
|
||||
@ -17,14 +18,9 @@
|
||||
|
||||
<partial name="_ProjectSectionNav" model="Model.Project" />
|
||||
|
||||
<div data-pd-context="asset" data-pd-context-id="@Model.Asset.StoryAssetID" data-pd-context-label="@Model.Asset.AssetName" data-pwa-help class="page-heading">
|
||||
<partial name="_Avatar" model="@(new AvatarViewModel { DisplayName = Model.Asset.AssetName, ImagePath = Model.Asset.ImagePath, ThumbnailPath = Model.Asset.ThumbnailPath, Size = "xl", Lazy = false })" />
|
||||
<div>
|
||||
<p class="eyebrow">@Model.Asset.KindName</p>
|
||||
<h1>@Model.Asset.AssetName <help-icon key="storyAssets.details" /></h1>
|
||||
<p class="lead-text">@Model.Asset.Description</p>
|
||||
</div>
|
||||
<div data-pwa-context="Manage" class="button-row">
|
||||
<div data-pd-context="asset" data-pd-context-id="@Model.Asset.StoryAssetID" data-pd-context-label="@Model.Asset.AssetName" data-pwa-help class="page-heading flex-wrap justify-content-start">
|
||||
<partial name="_AssetIdentity" model="@((new AvatarViewModel { DisplayName = Model.Asset.AssetName, ImagePath = Model.Asset.ImagePath, ThumbnailPath = Model.Asset.ThumbnailPath, Size = "xl", Lazy = false }, Model.Project.ProjectName, Model.Asset.KindName, "storyAssets.details"))" />
|
||||
<div data-pwa-context="Manage" class="button-row ms-sm-auto">
|
||||
<a class="btn btn-outline-secondary" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID">Story assets</a>
|
||||
<div class="dropdown pw-actions">
|
||||
<button class="btn pw-actions__toggle dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">Tools</button>
|
||||
@ -47,124 +43,148 @@
|
||||
<div class="alert alert-info">@assetMessage</div>
|
||||
}
|
||||
|
||||
<section class="asset-detail-grid">
|
||||
<article class="plain-card">
|
||||
<h2>Current state <help-icon key="storyAssets.currentState" /></h2>
|
||||
<p><strong>Importance:</strong> @Model.Asset.Importance / 10</p>
|
||||
<p><strong>State:</strong> @(Model.Asset.CurrentStateName ?? "No state")</p>
|
||||
<p><strong>Location:</strong> @(Model.Asset.CurrentLocationPath ?? "No location")</p>
|
||||
<p><strong>Resolved:</strong> @(Model.Asset.IsResolved ? "Yes" : "No")</p>
|
||||
</article>
|
||||
|
||||
<article class="plain-card">
|
||||
<h2>Dependencies <help-icon key="storyAssets.dependencies" /></h2>
|
||||
@if (!Model.Dependencies.Any())
|
||||
{
|
||||
<p class="muted">No dependencies yet.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="asset-mini-list">
|
||||
@foreach (var dependency in Model.Dependencies)
|
||||
{
|
||||
<div class="asset-mini-item">
|
||||
<strong>@dependency.SourceAssetName @dependency.DependencyTypeName.ToLowerInvariant() @dependency.TargetAssetName</strong>
|
||||
<span>@dependency.SourceRequiredStateName before @dependency.TargetBlockedStateName</span>
|
||||
<form asp-action="DeleteDependency" method="post">
|
||||
<input type="hidden" name="id" value="@dependency.AssetDependencyID" />
|
||||
<input type="hidden" name="returnAssetId" value="@Model.Asset.StoryAssetID" />
|
||||
<button class="btn btn-outline-secondary btn-sm" type="submit">Remove</button>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<form asp-action="AddDependency" method="post" class="asset-create-form">
|
||||
<input type="hidden" name="ProjectID" value="@Model.Project.ProjectID" />
|
||||
<input type="hidden" name="returnAssetId" value="@Model.Asset.StoryAssetID" />
|
||||
<div class="row g-2">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Source asset <help-icon key="storyAssets.dependencies.sourceAsset" mode="inline" /></label>
|
||||
<select class="form-select form-select-sm" name="SourceAssetID" asp-items="Model.AssetOptions"></select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Target asset <help-icon key="storyAssets.dependencies.targetAsset" mode="inline" /></label>
|
||||
<select class="form-select form-select-sm" name="TargetAssetID" asp-items="Model.AssetOptions"></select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Dependency <help-icon key="storyAssets.dependencies.dependencyType" mode="inline" /></label>
|
||||
<select class="form-select form-select-sm" name="AssetDependencyTypeID" asp-items="Model.AssetDependencyTypeOptions"></select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Source required state <help-icon key="storyAssets.dependencies.sourceRequiredState" mode="inline" /></label>
|
||||
<select class="form-select form-select-sm" name="SourceRequiredStateID" asp-items="Model.AssetStateOptions">
|
||||
<option value="">Any</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Target blocked state <help-icon key="storyAssets.dependencies.targetBlockedState" mode="inline" /></label>
|
||||
<select class="form-select form-select-sm" name="TargetBlockedStateID" asp-items="Model.AssetStateOptions">
|
||||
<option value="">Any</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label">Description <help-icon key="storyAssets.dependencies.description" mode="inline" /></label>
|
||||
<textarea class="form-control form-control-sm" name="Description" rows="2"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-outline-primary btn-sm mt-2" type="submit">Add dependency</button>
|
||||
</form>
|
||||
</article>
|
||||
</section>
|
||||
|
||||
@await Component.InvokeAsync("StoryElementReferences", new { entityType = PlotLine.Data.StoryElementType.Asset, entityId = Model.Asset.StoryAssetID })
|
||||
<section class="list-section mt-3">
|
||||
<h2>Events across scenes <help-icon key="storyAssets.eventsAcrossScenes" /></h2>
|
||||
@if (!Model.Events.Any())
|
||||
{
|
||||
<p class="muted">No scene events yet.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="asset-mini-list">
|
||||
@foreach (var assetEvent in Model.Events)
|
||||
<partial name="_AssetTabs" model="@((tabs, activeTab))" />
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane @(activeTab == "overview" ? "active" : null)" id="asset-panel-overview" role="tabpanel"
|
||||
aria-labelledby="asset-tab-overview" tabindex="0">
|
||||
<article class="plain-card">
|
||||
<h2>Current state <help-icon key="storyAssets.currentState" /></h2>
|
||||
@if (!string.IsNullOrWhiteSpace(Model.Asset.Description))
|
||||
{
|
||||
<div class="asset-mini-item story-asset-event-item">
|
||||
<span class="asset-event-marker">@assetEvent.MarkerText</span>
|
||||
<div class="story-asset-event-details">
|
||||
<strong>@assetEvent.EventTitle</strong>
|
||||
<span>@assetEvent.BookDisplayTitle / Ch @assetEvent.ChapterNumber / Scene @assetEvent.SceneNumber: @assetEvent.SceneTitle</span>
|
||||
<span>@assetEvent.FromStateName -> @assetEvent.ToStateName</span>
|
||||
<a asp-controller="Timeline" asp-action="Index" asp-route-ProjectID="@Model.Project.ProjectID" asp-route-SelectedSceneID="@assetEvent.SceneID" asp-route-FocusType="asset" asp-route-FocusID="@Model.Asset.StoryAssetID" asp-route-navigateFocus="true">Open in timeline</a>
|
||||
</div>
|
||||
<p class="lead-text">@Model.Asset.Description</p>
|
||||
}
|
||||
@if (Model.Aliases.Count > 0)
|
||||
{
|
||||
<p><strong>Aliases:</strong> @string.Join(", ", Model.Aliases)</p>
|
||||
}
|
||||
<p><strong>Importance:</strong> @Model.Asset.Importance / 10</p>
|
||||
<p><strong>State:</strong> @(Model.Asset.CurrentStateName ?? "No state")</p>
|
||||
<p><strong>Location:</strong> @(Model.Asset.CurrentLocationPath ?? "No location")</p>
|
||||
<p><strong>Resolved:</strong> @(Model.Asset.IsResolved ? "Yes" : "No")</p>
|
||||
</article>
|
||||
</div>
|
||||
<div class="tab-pane @(activeTab == "reference" ? "active" : null)" id="asset-panel-reference" role="tabpanel"
|
||||
aria-labelledby="asset-tab-reference" tabindex="0">
|
||||
<partial name="_AssetPrimaryImage" model="@((Model.Asset.StoryAssetID, Model.Asset.AssetName, Model.Asset.ImagePath, Model.Asset.ThumbnailPath))" />
|
||||
@await Component.InvokeAsync("StoryElementReferences", new { entityType = PlotLine.Data.StoryElementType.Asset, entityId = Model.Asset.StoryAssetID })
|
||||
</div>
|
||||
<div class="tab-pane @(activeTab == "dependencies" ? "active" : null)" id="asset-panel-dependencies" role="tabpanel"
|
||||
aria-labelledby="asset-tab-dependencies" tabindex="0">
|
||||
<article class="plain-card">
|
||||
<h2>Dependencies <help-icon key="storyAssets.dependencies" /></h2>
|
||||
@if (!Model.Dependencies.Any())
|
||||
{
|
||||
<p class="muted">No dependencies yet.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="asset-mini-list">
|
||||
@foreach (var dependency in Model.Dependencies)
|
||||
{
|
||||
<div class="asset-mini-item">
|
||||
<strong>@dependency.SourceAssetName @dependency.DependencyTypeName.ToLowerInvariant() @dependency.TargetAssetName</strong>
|
||||
<span>@dependency.SourceRequiredStateName before @dependency.TargetBlockedStateName</span>
|
||||
@if (!string.IsNullOrWhiteSpace(dependency.Description))
|
||||
{
|
||||
<span>@dependency.Description</span>
|
||||
}
|
||||
<form asp-action="DeleteDependency" method="post">
|
||||
<input type="hidden" name="id" value="@dependency.AssetDependencyID" />
|
||||
<input type="hidden" name="returnAssetId" value="@Model.Asset.StoryAssetID" />
|
||||
<button class="btn btn-outline-secondary btn-sm" type="submit">Remove</button>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
|
||||
<section class="list-section mt-3">
|
||||
<h2>Custody <help-icon key="storyAssets.custody" /></h2>
|
||||
@if (!Model.CustodyEvents.Any())
|
||||
{
|
||||
<p class="muted">No custody events yet.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="asset-mini-list">
|
||||
@foreach (var custody in Model.CustodyEvents)
|
||||
<form asp-action="AddDependency" method="post" class="asset-create-form">
|
||||
<input type="hidden" name="ProjectID" value="@Model.Project.ProjectID" />
|
||||
<input type="hidden" name="returnAssetId" value="@Model.Asset.StoryAssetID" />
|
||||
<div class="row g-2">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Source asset <help-icon key="storyAssets.dependencies.sourceAsset" mode="inline" /></label>
|
||||
<select class="form-select form-select-sm" name="SourceAssetID" asp-items="Model.AssetOptions"></select>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Target asset <help-icon key="storyAssets.dependencies.targetAsset" mode="inline" /></label>
|
||||
<select class="form-select form-select-sm" name="TargetAssetID" asp-items="Model.AssetOptions"></select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Dependency <help-icon key="storyAssets.dependencies.dependencyType" mode="inline" /></label>
|
||||
<select class="form-select form-select-sm" name="AssetDependencyTypeID" asp-items="Model.AssetDependencyTypeOptions"></select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Source required state <help-icon key="storyAssets.dependencies.sourceRequiredState" mode="inline" /></label>
|
||||
<select class="form-select form-select-sm" name="SourceRequiredStateID" asp-items="Model.AssetStateOptions">
|
||||
<option value="">Any</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label">Target blocked state <help-icon key="storyAssets.dependencies.targetBlockedState" mode="inline" /></label>
|
||||
<select class="form-select form-select-sm" name="TargetBlockedStateID" asp-items="Model.AssetStateOptions">
|
||||
<option value="">Any</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<label class="form-label">Description <help-icon key="storyAssets.dependencies.description" mode="inline" /></label>
|
||||
<textarea class="form-control form-control-sm" name="Description" rows="2"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<button class="btn btn-outline-primary btn-sm mt-2" type="submit">Add dependency</button>
|
||||
</form>
|
||||
</article>
|
||||
</div>
|
||||
<div class="tab-pane @(activeTab == "scene-history" ? "active" : null)" id="asset-panel-scene-history" role="tabpanel"
|
||||
aria-labelledby="asset-tab-scene-history" tabindex="0">
|
||||
<section class="list-section mt-3">
|
||||
<h2>Events across scenes <help-icon key="storyAssets.eventsAcrossScenes" /></h2>
|
||||
@if (!Model.Events.Any())
|
||||
{
|
||||
<div class="asset-mini-item">
|
||||
<strong>@custody.CustodyEventTypeName</strong>
|
||||
<span>@custody.CustodianSummary</span>
|
||||
<span>@custody.BookDisplayTitle / Ch @custody.ChapterNumber / Scene @custody.SceneNumber: @custody.SceneTitle</span>
|
||||
<a asp-controller="Timeline" asp-action="Index" asp-route-ProjectID="@Model.Project.ProjectID" asp-route-SelectedSceneID="@custody.SceneID" asp-route-FocusType="asset" asp-route-FocusID="@Model.Asset.StoryAssetID" asp-route-navigateFocus="true">Open in timeline</a>
|
||||
<p class="muted">No scene events yet.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="asset-mini-list">
|
||||
@foreach (var assetEvent in Model.Events)
|
||||
{
|
||||
<div class="asset-mini-item story-asset-event-item">
|
||||
<span class="asset-event-marker">@assetEvent.MarkerText</span>
|
||||
<div class="story-asset-event-details">
|
||||
<strong>@assetEvent.EventTitle</strong>
|
||||
<span>@assetEvent.BookDisplayTitle / Ch @assetEvent.ChapterNumber / Scene @assetEvent.SceneNumber: @assetEvent.SceneTitle</span>
|
||||
<span>@assetEvent.FromStateName -> @assetEvent.ToStateName</span>
|
||||
<a asp-controller="Timeline" asp-action="Index" asp-route-ProjectID="@Model.Project.ProjectID" asp-route-SelectedSceneID="@assetEvent.SceneID" asp-route-FocusType="asset" asp-route-FocusID="@Model.Asset.StoryAssetID" asp-route-navigateFocus="true">Open in timeline</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section class="list-section mt-3">
|
||||
<h2>Custody <help-icon key="storyAssets.custody" /></h2>
|
||||
@if (!Model.CustodyEvents.Any())
|
||||
{
|
||||
<p class="muted">No custody events yet.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="asset-mini-list">
|
||||
@foreach (var custody in Model.CustodyEvents)
|
||||
{
|
||||
<div class="asset-mini-item">
|
||||
<strong>@custody.CustodyEventTypeName</strong>
|
||||
<span>@custody.CustodianSummary</span>
|
||||
<span>@custody.BookDisplayTitle / Ch @custody.ChapterNumber / Scene @custody.SceneNumber: @custody.SceneTitle</span>
|
||||
<a asp-controller="Timeline" asp-action="Index" asp-route-ProjectID="@Model.Project.ProjectID" asp-route-SelectedSceneID="@custody.SceneID" asp-route-FocusType="asset" asp-route-FocusID="@Model.Asset.StoryAssetID" asp-route-navigateFocus="true">Open in timeline</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script src="~/js/story-element-references.js" asp-append-version="true"></script>
|
||||
|
||||
@ -1,26 +1,37 @@
|
||||
@model StoryAssetEditViewModel
|
||||
@{
|
||||
ViewData["DesktopLayout"] = "wide";
|
||||
ViewData["ProjectSection"] = "Assets";
|
||||
ViewData["Title"] = Model.StoryAssetID == 0 ? "New Story Asset" : "Edit Story Asset";
|
||||
}
|
||||
|
||||
<div data-pwa-task class="page-heading compact">
|
||||
<div>
|
||||
<p class="eyebrow">Story asset</p>
|
||||
<h1>@ViewData["Title"] <help-icon key="storyAssets.edit" /></h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (TempData["ImageError"] is string imageError)
|
||||
@if (Model.Project is not null)
|
||||
{
|
||||
<div class="alert alert-warning">@imageError</div>
|
||||
<nav data-pwa-identity class="breadcrumb-trail" aria-label="Breadcrumb">
|
||||
<a asp-controller="Projects" asp-action="Index">Projects</a>
|
||||
<a asp-controller="Projects" asp-action="Details" asp-route-id="@Model.ProjectID">@Model.Project.ProjectName</a>
|
||||
<a asp-action="Index" asp-route-projectId="@Model.ProjectID">Story assets</a>
|
||||
<span>@ViewData["Title"]</span>
|
||||
</nav>
|
||||
|
||||
<partial name="_ProjectSectionNav" model="Model.Project" />
|
||||
}
|
||||
|
||||
<form asp-action="Save" method="post" class="edit-panel pd-record-form" enctype="multipart/form-data">
|
||||
<div data-pwa-task class="page-heading compact flex-wrap justify-content-start">
|
||||
<partial name="_AssetIdentity" model="@((new AvatarViewModel { DisplayName = Model.StoryAssetID == 0 ? "New Story Asset" : Model.AssetName, ImagePath = Model.ImagePath, ThumbnailPath = Model.ThumbnailPath, Size = "xl", Lazy = false }, Model.Project?.ProjectName, Model.AssetKindOptions.FirstOrDefault(kind => kind.Value == Model.AssetKindID.ToString())?.Text, "storyAssets.edit"))" />
|
||||
@if (Model.StoryAssetID > 0)
|
||||
{
|
||||
<div class="button-row">
|
||||
<a class="btn btn-outline-secondary" asp-action="Details" asp-route-id="@Model.StoryAssetID">View asset</a>
|
||||
<a class="btn btn-outline-secondary" asp-action="Details" asp-route-id="@Model.StoryAssetID" asp-route-tab="reference">Manage references</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<form asp-action="Save" method="post" class="edit-panel pd-record-form">
|
||||
<input asp-for="StoryAssetID" type="hidden" />
|
||||
<input asp-for="ProjectID" type="hidden" />
|
||||
<input asp-for="ImagePath" type="hidden" />
|
||||
<input asp-for="ThumbnailPath" type="hidden" />
|
||||
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
|
||||
|
||||
<div class="row g-3 pd-record-fields">
|
||||
<div class="pd-record-group-label" role="heading" aria-level="2">Names</div>
|
||||
@ -86,36 +97,23 @@
|
||||
<div class="form-text">Makes this item available as a draggable shortcut on the Timeline page.</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pd-record-group-label" role="heading" aria-level="2">Description and image</div>
|
||||
<div class="col-12 pd-record-span-8">
|
||||
<div class="pd-record-group-label" role="heading" aria-level="2">Description</div>
|
||||
<div class="col-12">
|
||||
<label asp-for="Description" class="form-label"></label>
|
||||
<textarea asp-for="Description" class="form-control" rows="5"></textarea>
|
||||
</div>
|
||||
<div class="col-12 pd-record-span-4">
|
||||
<div class="visual-image-editor">
|
||||
<div>
|
||||
<p class="eyebrow">Asset Image</p>
|
||||
<partial name="_Avatar" model="@(new AvatarViewModel { DisplayName = Model.AssetName, ImagePath = Model.ImagePath, ThumbnailPath = Model.ThumbnailPath, Size = "lg", Lazy = false })" />
|
||||
</div>
|
||||
<div class="visual-image-editor__controls">
|
||||
<label asp-for="ImageUpload" class="form-label"></label>
|
||||
<input asp-for="ImageUpload" class="form-control" type="file" accept=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp" />
|
||||
<div class="form-text">JPG, PNG or WebP. A 128 x 128 thumbnail is generated automatically.</div>
|
||||
@if (!string.IsNullOrWhiteSpace(Model.ImagePath) || !string.IsNullOrWhiteSpace(Model.ThumbnailPath))
|
||||
{
|
||||
<label class="form-check mt-2">
|
||||
<input asp-for="RemoveImage" class="form-check-input" />
|
||||
<span class="form-check-label">Remove image</span>
|
||||
</label>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-pwa-context="Record" data-pwa-priority="0" class="button-row mt-3">
|
||||
<button class="btn btn-primary" data-pwa-icon="save" type="submit">Save asset</button>
|
||||
<a class="btn btn-outline-secondary" data-pwa-icon="close" asp-action="Index" asp-route-projectId="@Model.ProjectID">Cancel</a>
|
||||
@if (Model.StoryAssetID > 0)
|
||||
{
|
||||
<a class="btn btn-outline-secondary" data-pwa-icon="close" asp-action="Details" asp-route-id="@Model.StoryAssetID">Cancel</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a class="btn btn-outline-secondary" data-pwa-icon="close" asp-action="Index" asp-route-projectId="@Model.ProjectID">Cancel</a>
|
||||
}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
11
PlotLine/Views/StoryAssets/_AssetIdentity.cshtml
Normal file
11
PlotLine/Views/StoryAssets/_AssetIdentity.cshtml
Normal file
@ -0,0 +1,11 @@
|
||||
@model (AvatarViewModel Avatar, string? ProjectName, string? Kind, string HelpKey)
|
||||
|
||||
<partial name="_Avatar" model="Model.Avatar" />
|
||||
<div>
|
||||
<p class="eyebrow">@(Model.ProjectName is string projectName ? $"{projectName} · Story asset" : "Story asset")</p>
|
||||
<h1>@Model.Avatar.DisplayName <help-icon key="@Model.HelpKey" /></h1>
|
||||
@if (!string.IsNullOrWhiteSpace(Model.Kind))
|
||||
{
|
||||
<p class="muted">@Model.Kind</p>
|
||||
}
|
||||
</div>
|
||||
30
PlotLine/Views/StoryAssets/_AssetPrimaryImage.cshtml
Normal file
30
PlotLine/Views/StoryAssets/_AssetPrimaryImage.cshtml
Normal file
@ -0,0 +1,30 @@
|
||||
@model (int Id, string Name, string? ImagePath, string? ThumbnailPath)
|
||||
|
||||
<section class="plain-card mb-3" aria-labelledby="asset-primary-image-heading">
|
||||
<h2 id="asset-primary-image-heading">Asset image</h2>
|
||||
@if (TempData["ImageError"] is string imageError)
|
||||
{
|
||||
<div class="alert alert-warning" role="alert">@imageError</div>
|
||||
}
|
||||
@if (TempData["AssetImageSaved"] is string imageSaved)
|
||||
{
|
||||
<span hidden data-toast-message="success">@imageSaved</span>
|
||||
}
|
||||
<div class="visual-image-editor flex-wrap">
|
||||
<partial name="_Avatar" model="@(new AvatarViewModel { DisplayName = Model.Name, ImagePath = Model.ImagePath, ThumbnailPath = Model.ThumbnailPath, Size = "lg", Lazy = false })" />
|
||||
<form asp-action="SaveImage" method="post" enctype="multipart/form-data" class="visual-image-editor__controls mw-100">
|
||||
<input type="hidden" name="id" value="@Model.Id" />
|
||||
<label for="asset-primary-image-upload" class="form-label">Upload image</label>
|
||||
<input id="asset-primary-image-upload" name="upload" class="form-control" type="file"
|
||||
accept=".jpg,.jpeg,.png,.webp,image/jpeg,image/png,image/webp" aria-describedby="asset-primary-image-format" />
|
||||
<div id="asset-primary-image-format" class="form-text">JPG, PNG or WebP. A 128 × 128 thumbnail is generated automatically.</div>
|
||||
<div class="button-row mt-2">
|
||||
<button class="btn btn-outline-primary" type="submit" name="operation" value="upload">Save image</button>
|
||||
@if (!string.IsNullOrWhiteSpace(Model.ImagePath) || !string.IsNullOrWhiteSpace(Model.ThumbnailPath))
|
||||
{
|
||||
<button class="btn btn-outline-secondary" type="submit" name="operation" value="remove">Remove image</button>
|
||||
}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
12
PlotLine/Views/StoryAssets/_AssetTabs.cshtml
Normal file
12
PlotLine/Views/StoryAssets/_AssetTabs.cshtml
Normal file
@ -0,0 +1,12 @@
|
||||
@model (IReadOnlyList<(string Id, string Label)> Tabs, string ActiveTab)
|
||||
|
||||
<nav class="nav nav-tabs mb-3" role="tablist" aria-label="Asset workspace">
|
||||
@foreach (var tab in Model.Tabs)
|
||||
{
|
||||
var active = tab.Id == Model.ActiveTab;
|
||||
<button class="nav-link @(active ? "active" : null)" id="asset-tab-@tab.Id"
|
||||
type="button" role="tab" data-bs-toggle="tab" data-bs-target="#asset-panel-@tab.Id"
|
||||
aria-controls="asset-panel-@tab.Id" aria-selected="@(active ? "true" : "false")"
|
||||
tabindex="@(active ? null : "-1")">@tab.Label</button>
|
||||
}
|
||||
</nav>
|
||||
Loading…
x
Reference in New Issue
Block a user