@using System
@using MrCMS.Entities.Documents.Web
@using MrCMS.Helpers
@using MrCMS.Web.Areas.Admin.Models
@model Webpage
@{
    ViewBag.Title = "Edit | " + Model.Name;
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

@using (Html.BeginForm("Edit", "Webpage", FormMethod.Post, new {id = "edit-document", data_are_you_sure = Resource(AdminMessages.AreYouSureDefaultMessage)}))
{
    <div class="row">
        <div class="col-lg-12">
            <div class="btn-group display-inline" id="edit-webpage-options">
                <button class="btn btn-primary">@Resource("Save")</button>
                <a href="/@Model.LiveUrlSegment" class="btn btn-default">View</a>

                @Html.ActionLink(Resource("Move"), "Set", "WebpageParent", new {Model.Id}, new {data_toggle = "fb-modal", @class = "btn btn-default"})
                @if (Model.CanAddChildren())
                {
                    @Html.ActionLink(Resource("Add a child page"), "Add", new {Model.Id}, new {@class = "btn btn-default"})
                }
                @if (Model.CanDelete())
                {
                    <a href="@Url.Action(Resource("Delete"), "Webpage", new {id = Model.Id})" class="btn btn-danger" data-toggle="fb-modal">Delete</a>
                }

                @(Model.PublishOn == null
                      ? Html.ActionLink(Resource("Publish Now"), "PublishNow", new {id = Model.Id}, new {@class = "btn btn-warning", id = "publish-status-change"})
                      : Html.ActionLink(Resource("Unpublish"), "Unpublish", new {id = Model.Id}, new {@class = "btn btn-success", id = "publish-status-change"}))

                @Html.EditorFor(x => x.PublishOn)
                @Html.ValidationMessageFor(x => x.PublishOn)

                <span class="@(Model.PublishStatus == Webpage.WebpagePublishStatus.Published ? "green" : "orange")">@Resource(Model.PublishStatus.ToString())</span>
            </div>
        </div>
    </div>
    @Html.ValidationSummary()

    Html.RenderPartial(Convert.ToString(ViewData["EditView"]));
}

