diff --git a/Start/Client/Components/Bookmark.razor b/Start/Client/Components/Bookmark.razor new file mode 100644 index 0000000..193daea --- /dev/null +++ b/Start/Client/Components/Bookmark.razor @@ -0,0 +1,20 @@ +
  • + @if (!String.IsNullOrEmpty(this.Model.Notes)) + { +
    + + @this.Model.Title + + @this.Model.Notes +
    + } + else + { + @this.Model.Title + } +
  • + +@code { + [Parameter] + public BookmarkDto Model { get; set; } = null!; +} diff --git a/Start/Client/Components/BookmarkContainer.razor b/Start/Client/Components/BookmarkContainer.razor index 35aafe4..1c8834f 100644 --- a/Start/Client/Components/BookmarkContainer.razor +++ b/Start/Client/Components/BookmarkContainer.razor @@ -1,5 +1,21 @@ -
    - @if (this.Container == null) +@using Start.Client.Store.State +@using Start.Client.Store.Features.CreateGroup +@using Fluxor + +@inherits Fluxor.Blazor.Web.Components.FluxorComponent + +@inject IDispatcher dispatch +@inject IState state + +
    + @if (this.state.Value.CurrentContainerState.ErrorMessage != null) + { + + @this.state.Value.CurrentContainerState.ErrorMessage + + } + + @if (this.state.Value.CurrentContainerState.IsLoadingCurrentContainer) {
    @@ -7,27 +23,60 @@

    Loading Bookmarks

    -

    Loading Bookmarks

    } - else if (!this.Container.BookmarkGroups?.Any() ?? true) + else if (this.state.Value.CurrentContainerState.Container == null) + { +
    +
    + +
    +

    Failed To Load Container

    +
    + } + else if (this.state.Value.CurrentContainerState.Container.BookmarkGroups == null + || (!(this.state.Value.CurrentContainerState.Container.BookmarkGroups?.Any()) ?? true)) {

    No Bookmark Groups

    +
    + +
    } else { - foreach (BookmarkGroupDto group in this.Container.BookmarkGroups!) - { - - } +
    + @* The compiler doesn't pick up that null has already been checked for, + so the ! is needed *@ + @foreach (BookmarkGroupDto group in this.state.Value.CurrentContainerState.Container.BookmarkGroups!) + { + + } + +
    + +
    +
    }
    @code { - [Parameter] - public BookmarkContainerDto? Container { get; set; } + public void ShowCreateGroupForm() + { + if (this.state.Value.CurrentContainerState.Container == null) + return; + + dispatch.Dispatch(new ShowCreateGroupFormAction( + this.state.Value.CurrentContainerState.Container.BookmarkContainerId, + this.state.Value.CurrentContainerState.Container.Title)); + } } diff --git a/Start/Client/Components/BookmarkGroup.razor b/Start/Client/Components/BookmarkGroup.razor index 64a7381..a644691 100644 --- a/Start/Client/Components/BookmarkGroup.razor +++ b/Start/Client/Components/BookmarkGroup.razor @@ -1,24 +1,47 @@ -

    - @this.Group.Title -

    - +
    +
    +

    @this.Group.Title

    + +
    +
    +
      + @if (this.Group.Bookmarks == null || !this.Group.Bookmarks.Any()) + { +
    • +
      +
      + +
      +

      No Bookmarks

      +
      + +
      +
      +
    • + } + else + { + foreach (BookmarkDto bookmark in this.Group.Bookmarks) + { + + } + } +
    +
    +
    @code { [Parameter] - public BookmarkGroupDto Group { get; set; } = null!; // [Required] is a .net 6 feature + public BookmarkGroupDto Group { get; set; } = null!; + + protected void OnCreateBookmarkClicked() + { + // Placeholder + } } diff --git a/Start/Client/Components/CreateContainer.razor b/Start/Client/Components/CreateContainer.razor index bf013f6..d9ac20b 100644 --- a/Start/Client/Components/CreateContainer.razor +++ b/Start/Client/Components/CreateContainer.razor @@ -14,6 +14,7 @@ @this.state.Value.CreateContainerErrorMessage } +
    diff --git a/Start/Client/Components/CreateGroup.razor b/Start/Client/Components/CreateGroup.razor new file mode 100644 index 0000000..85be69b --- /dev/null +++ b/Start/Client/Components/CreateGroup.razor @@ -0,0 +1,82 @@ +@using Start.Client.Store.Features.CreateGroup +@using Fluxor + +@inherits Fluxor.Blazor.Web.Components.FluxorComponent + +@inject IActionSubscriber actionSubscriber +@inject IDispatcher dispatch +@inject IState state + + + + + + @if (this.state.Value.CreateGroupErrorMessage != null) + { + + @this.state.Value.CreateGroupErrorMessage + + } + + + +
    +
    +
    +
    + + +
    +
    + + +
    +
    +
    +
    +
    +
    + @if (this.state.Value.IsLoadingCreateGroup) + { + + } + else + { + + } +
    +
    +
    +
    +
    +
    + +@code { + private BookmarkGroupDto Model { get; set; } = new("", "", 0); + + protected override void OnInitialized() + { + base.OnInitialized(); + + this.Model = new BookmarkGroupDto("", "", state.Value.ContainerId); + + // Keep the model's container ID up to date + actionSubscriber.SubscribeToAction(this, + (a) => this.Model.BookmarkContainerId = a.ContainerId); + } + + protected void OnSubmit() + { + dispatch.Dispatch(new SubmitCreateGroupAction(this.Model)); + } + + protected void OnDialogClose() + { + dispatch.Dispatch(new HideCreateGroupFormAction()); + } +} diff --git a/Start/Client/Components/Dialog.razor b/Start/Client/Components/Dialog.razor index 9ddd797..6b35968 100644 --- a/Start/Client/Components/Dialog.razor +++ b/Start/Client/Components/Dialog.razor @@ -1,4 +1,8 @@ -