Skip to content

Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.

5.6 KB
Raw Blame
@model NewsItemModel
@inject IPageHeadBuilder pagebuilder
@{
    Layout = "_TwoColumns";

    //title
    pagebuilder.AddTitleParts(!string.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Title);
    pagebuilder.AddMetaDescriptionParts(Model.MetaDescription);
    pagebuilder.AddMetaKeywordParts(Model.MetaKeywords);
}
<div class="page news-item-page" vue-island="news">
    <div class="card mt-3">
        <div class="card-header">
            @if (!string.IsNullOrEmpty(Model.PictureModel.ImageUrl))
            {
                <img class="img-fluid mb-3" src="@Model.PictureModel.ImageUrl" alt="@Model.PictureModel.AlternateText" loading="lazy">
            }
            <h1 class="h5 mb-0">
                @Model.Title
            </h1>
            <span class="small text-muted">
                @Model.CreatedOn.ToString("D")
            </span>
        </div>
        @await Component.InvokeAsync("Widget", new { widgetZone = "newsitem_page_before_body", additionalData = Model.Id })
        <div class="card-body">
            @Html.Raw(Model.Full)
        </div>
    </div>
    @await Component.InvokeAsync("Widget", new { widgetZone = "newsitem_page_before_comments", additionalData = Model.Id })
    @if (Model.AllowComments)
    {
        <fieldset class="new-comment py-3 px-0" id="comments">
            <h5>
                <strong>@Loc["News.Comments.LeaveYourComment"]</strong>
            </h5>
            <validation-observer v-slot="{ handleSubmit }">
                <form id="addNewsComment" asp-action="NewsCommentAdd" asp-controller="News" method="post" v-on:submit.prevent="handleSubmit(news.submitComment)">
                    <input type="hidden" name="Id" value="@Model.Id"/>
                    <fieldset class="form-group">
                        <validation-provider tag="div" rules="required" name="CommentTitle" v-slot="{ errors, classes }">
                            <label for="CommentTitle" class="col-form-label">@Loc["News.Comments.CommentTitle"]:</label>
                            <span class="required">*</span>
                            <input name="CommentTitle" v-bind:class="[classes , 'form-control enter-comment-title']"
                                   data-val-required="@Loc["News.Comments.CommentTitle.Required"]"
                                   v-model="news.CommentTitle"/>
                            <span class="field-validation-error">{{ errors[0] }}</span>
                        </validation-provider>
                    </fieldset>
                    <fieldset class="form-group">
                        <validation-provider tag="div" rules="required" name="CommentText" v-slot="{ errors, classes }">
                            <label for="CommentText" class="col-form-label">@Loc["News.Comments.CommentText"]:</label>
                            <span class="required">*</span>
                            <textarea name="CommentText" v-model="news.CommentText" 
                                    data-val-required="@Loc["News.Comments.CommentText.Required"]"
                                    v-bind:class="[classes , 'form-control']" autofocus="autofocus" rows="4"></textarea>
                            <span class="field-validation-error">{{ errors[0] }}</span>
                        </validation-provider>
                    </fieldset>
                    @if (Model.AddNewComment.DisplayCaptcha)
                    {
                        <div class="captcha-box">
                            <captcha/>
                        </div>
                    }
                    <div class="buttons text-xs-center text-md-start generalMarginSupporter">
                        <input type="submit" name="add-comment" class="btn btn-info news-item-add-comment-button" value="@Loc["News.Comments.SubmitButton"]"/>
                    </div>
                </form>
            </validation-observer>
        </fieldset>
        <script type="application/json" data-grand-vm="comments">@Json.Serialize(new { name = "news", formId = "addNewsComment", comments = Model.Comments, fields = new[] { "CommentTitle", "CommentText" } })</script>
        <template v-if="news.Model.length > 0">
            <div class="comment-list">
                <h4 class="generalTitle generalMarginSupporter">
                    <strong>@Loc["News.Comments"]</strong>
                </h4>
                <div class="comments">
                    <template v-for="comment in news.Model">
                        <div class="card mb-3">
                            <div class="card-header">
                                <div class="d-inline-flex w-100">
                                    <h6 class="mb-0">{{comment.CustomerName}}</h6>
                                    <i class="b-icon bi bi-calendar2-check text-info mx-2" aria-hidden="true"></i>
                                    <small class="date text-muted">
                                        <span>@Loc["News.Comments.CreatedOn"]:</span>
                                        <span>{{new Date( comment.CreatedOn).toDateString()}}</span>
                                    </small>
                                </div>
                            </div>
                            <div class="card-body">
                                <h5>{{comment.CommentTitle}}</h5>
                                {{comment.CommentText}}
                            </div>
                        </div>
                    </template>
                </div>
            </div>
        </template>
    }
    @await Component.InvokeAsync("Widget", new { widgetZone = "newsitem_page_after_comments", additionalData = Model.Id })
</div>