diff options
Diffstat (limited to 'Pages/ViewMedia.razor')
| -rw-r--r-- | Pages/ViewMedia.razor | 73 |
1 files changed, 49 insertions, 24 deletions
diff --git a/Pages/ViewMedia.razor b/Pages/ViewMedia.razor index e559460..68e6d70 100644 --- a/Pages/ViewMedia.razor +++ b/Pages/ViewMedia.razor @@ -1,6 +1,7 @@ @page "/ViewMedia" @inject IDbContextFactory<HBContext> dbFactory @inject ITagService tagService +@inject IMediaService mediaService @implements IDisposable <PageTitle>@title</PageTitle> @@ -11,20 +12,26 @@ <img src="/media/@(media.Guid)"/> <div id="metadata"> <div id="metadata-fileinfo"> - @if(true) { - <label> - Title: - <input type="text" style="width:100%;"/> - </label> - <p>Description:</p> - <textarea/> + @if(infoEditMode) { + <form @onsubmit=@(() => ApplyInfoEdit(true))> + <table id="edit-metadata"> + <tr> + <td>Title:</td> + <td><input type="text" @bind=shortDescription/></td> + </tr> + <tr> + <td>Description:</td> + <td><textarea rows="4" @bind=longDescription/></td> + </tr> + </table> + </form> } else { - <p>Title: <i>@(@media.ShortDescription ?? "None")</i></p> - <p>Description: <i>@(media.LongDescription ?? "None")</i></p> + <p>Title: <i>@(media.ShortDescription ?? "None")</i></p> + <p class="newlines">Description:<br/><i>@(media.LongDescription ?? "None")</i></p> } <p class="heading">Upload history</p> <hr/> - <table class="data-table"> + <table id="uploaded-files" class="data-table"> <tr> <th>Created On</th> <th>Last Write</th> @@ -42,22 +49,25 @@ </tr> } </table> - <div class="button-container"> - <button @onclick=@(() => deleteDialog.Show()) class="warning">Delete</button> - <button>Apply</button> - </div> </div> <div id="metadata-tags"> <p class="heading">Tags</p> <hr/> <MediaTagTable Media=media @ref=mediaTagTable/> <div class="button-container"> + <button @onclick=@(() => deleteDialog.Show()) class="warning">Delete</button> <button @onclick=@(() => tagDialog.Show()) class="secondary">Add Tag</button> @if(media.IsIngest) { <button @onclick=@(() => SetIngest(false))>Mark Tagging Complete</button> } else { <button class="secondary" @onclick=@(() => SetIngest(true))>Mark Tagging Incomplete</button> } + @if(infoEditMode) { + <button @onclick=@(() => ApplyInfoEdit(false)) class="secondary">Cancel</button> + <button @onclick=@(() => ApplyInfoEdit(true))>Apply</button> + } else { + <button @onclick=@(() => InfoEditMode = true) class="secondary">Edit Info</button> + } </div> </div> </div> @@ -84,7 +94,9 @@ private string title; - private bool infoEditMode = false; + private bool infoEditMode = false; + private string? shortDescription; + private string? longDescription; private Dialog deleteDialog; private TagSelectDialog tagDialog; @@ -109,17 +121,30 @@ } private void SetIngest(bool ingest) { - var ingestTag = db.TagDefinitions - .First(td => td.Guid == HBContext.IngestTag); + mediaService.SetIngest(media, ingest); + StateHasChanged(); + } - if(!ingest) - media.Tags.RemoveAll(t => t.TagDefinition.Guid == ingestTag.Guid); - else - if(!media.IsIngest) - media.Tags.Add(new(ingestTag)); + private bool InfoEditMode { + get => infoEditMode; + set { + shortDescription = media.ShortDescription; + longDescription = media.LongDescription; + infoEditMode = value; + StateHasChanged(); + } + } - db.SaveChanges(); - StateHasChanged(); + private void ApplyInfoEdit(bool apply) { + if(apply) { + if(string.IsNullOrEmpty(shortDescription)) shortDescription = null; + if(string.IsNullOrEmpty(longDescription)) longDescription = null; + media.ShortDescription = shortDescription; + media.LongDescription = longDescription; + mediaService.SetDescription(media, shortDescription, longDescription); + } + + infoEditMode = false; } public void Dispose() => db.Dispose(); |
