mirror of https://github.com/abpframework/eventhub
23 changed files with 128 additions and 522 deletions
@ -1,35 +0,0 @@ |
|||||
@using EventHub.Web.Pages.Events.Components.CreateEventArea |
|
||||
@using Microsoft.AspNetCore.Http |
|
||||
@model EventHub.Web.Pages.Events.Components.CreateEventArea.CreateEventAreaViewComponent.NewEventViewModel |
|
||||
|
|
||||
@{ |
|
||||
if (Model is null) |
|
||||
{ |
|
||||
throw new BadHttpRequestException(""); |
|
||||
} |
|
||||
|
|
||||
var eventId = ViewData["EventId"] as Guid?; |
|
||||
var eventUrlCode = ViewData["EventUrlCode"]?.ToString(); |
|
||||
|
|
||||
var result = Enum.TryParse(ViewData["StepType"]!.ToString(), out CreateEventAreaViewComponent.ProgressStepType stepType); |
|
||||
if (!result) |
|
||||
{ |
|
||||
throw new BadHttpRequestException(""); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
<div id="CreateEventContainer" style="@(stepType != CreateEventAreaViewComponent.ProgressStepType.NewEvent ? "display: none" : "")"> |
|
||||
<partial name="_newEventSection.cshtml" model="@Model"/> |
|
||||
</div> |
|
||||
<div id="CreateTrackContainer" style="@(stepType != CreateEventAreaViewComponent.ProgressStepType.NewTrack ? "display: none" : "")"> |
|
||||
<partial name="_addTrackSection.cshtml" model="@Model.Tracks"/> |
|
||||
</div> |
|
||||
<div id="CreateSessionContainer" style="@(stepType != CreateEventAreaViewComponent.ProgressStepType.NewSession ? "display: none" : "")"> |
|
||||
<partial name="_addSessionSection.cshtml" model="@Model.Tracks"/> |
|
||||
</div> |
|
||||
<div id="PreviewContainer" style="@(stepType != CreateEventAreaViewComponent.ProgressStepType.Preview ? "display: none" : "")"> |
|
||||
<partial name="_previewSection.cshtml" model="@Model"/> |
|
||||
</div> |
|
||||
|
|
||||
<input type="hidden" id="EventId" value="@eventId"/> |
|
||||
<input type="hidden" id="EventUrlCode" value="@eventUrlCode"/> |
|
||||
@ -1,15 +0,0 @@ |
|||||
@using EventHub.Web.Pages.Events.Components.CreateEventArea |
|
||||
@model EventHub.Web.Pages.Events.Components.CreateEventArea.CreateEventAreaViewComponent.ProgressStepType |
|
||||
|
|
||||
<div class="px-4 py-1"> |
|
||||
<div class="progresses py-4"> |
|
||||
<ul class="d-flex align-items-center justify-content-between"> |
|
||||
<li id="step-1" class="create-steps @(Model == CreateEventAreaViewComponent.ProgressStepType.NewEvent ? "blue" : "")">1<span>New Event</span></li> |
|
||||
<li id="step-2" class="create-steps @(Model == CreateEventAreaViewComponent.ProgressStepType.NewTrack ? "blue" : "")">2<span>Add Track</span></li> |
|
||||
<li id="step-3" class="create-steps @(Model == CreateEventAreaViewComponent.ProgressStepType.NewSession ? "blue" : "")">3<span>Add Session</span></li> |
|
||||
</ul> |
|
||||
<div class="progress"> |
|
||||
<div class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
@ -0,0 +1,35 @@ |
|||||
|
@using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea |
||||
|
@using Microsoft.AspNetCore.Http |
||||
|
@model EventHub.Web.Pages.Events.Components.CreateOrEditEventArea.CreateOrEditEventAreaViewComponent.NewEventViewModel |
||||
|
|
||||
|
@{ |
||||
|
if (Model is null) |
||||
|
{ |
||||
|
throw new BadHttpRequestException(""); |
||||
|
} |
||||
|
|
||||
|
var eventId = ViewData["EventId"] as Guid?; |
||||
|
var eventUrlCode = ViewData["EventUrlCode"]?.ToString(); |
||||
|
|
||||
|
var result = Enum.TryParse(ViewData["StepType"]!.ToString(), out CreateOrEditEventAreaViewComponent.ProgressStepType stepType); |
||||
|
if (!result) |
||||
|
{ |
||||
|
throw new BadHttpRequestException(""); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
<div id="CreateEventContainer" style="@(stepType != CreateOrEditEventAreaViewComponent.ProgressStepType.Event ? "display: none" : "")"> |
||||
|
<partial name="_newEventSection.cshtml" model="@Model"/> |
||||
|
</div> |
||||
|
<div id="CreateTrackContainer" style="@(stepType != CreateOrEditEventAreaViewComponent.ProgressStepType.Track ? "display: none" : "")"> |
||||
|
<partial name="_addTrackSection.cshtml" model="@Model.Tracks"/> |
||||
|
</div> |
||||
|
<div id="CreateSessionContainer" style="@(stepType != CreateOrEditEventAreaViewComponent.ProgressStepType.Session ? "display: none" : "")"> |
||||
|
<partial name="_addSessionSection.cshtml" model="@Model.Tracks"/> |
||||
|
</div> |
||||
|
<div id="PreviewContainer" style="@(stepType != CreateOrEditEventAreaViewComponent.ProgressStepType.Preview ? "display: none" : "")"> |
||||
|
<partial name="_previewSection.cshtml" model="@Model"/> |
||||
|
</div> |
||||
|
|
||||
|
<input type="hidden" id="EventId" value="@eventId"/> |
||||
|
<input type="hidden" id="EventUrlCode" value="@eventUrlCode"/> |
||||
@ -0,0 +1,20 @@ |
|||||
|
@using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea |
||||
|
@model EventHub.Web.Pages.Events.Components.CreateOrEditEventArea.CreateOrEditEventAreaViewComponent.ProgressStepType |
||||
|
|
||||
|
@{ |
||||
|
var eventId = ViewData["EventId"] as Guid?; |
||||
|
var prefixOfStep = eventId.HasValue ? "Edit" : "New"; |
||||
|
} |
||||
|
|
||||
|
<div class="px-4 py-1"> |
||||
|
<div class="progresses py-4"> |
||||
|
<ul class="d-flex align-items-center justify-content-between"> |
||||
|
<li id="step-1" class="create-steps @(Model == CreateOrEditEventAreaViewComponent.ProgressStepType.Event ? "blue" : "")">1<span>@prefixOfStep Event</span></li> |
||||
|
<li id="step-2" class="create-steps @(Model == CreateOrEditEventAreaViewComponent.ProgressStepType.Track ? "blue" : "")">2<span>@prefixOfStep Track</span></li> |
||||
|
<li id="step-3" class="create-steps @(Model == CreateOrEditEventAreaViewComponent.ProgressStepType.Session ? "blue" : "")">3<span>@prefixOfStep Session</span></li> |
||||
|
</ul> |
||||
|
<div class="progress"> |
||||
|
<div class="progress-bar" role="progressbar" style="width: 0%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
@ -1,135 +1,19 @@ |
|||||
@page "/event/edit/{url}" |
@page "/event/edit/{url}" |
||||
@inject IHtmlLocalizer<EventHubResource> L |
@using EventHub.Web.Pages.Events.Components.CreateOrEditEventArea |
||||
@using EventHub.Localization |
|
||||
@using EventHub.Web |
|
||||
@using Microsoft.AspNetCore.Mvc.Localization |
|
||||
@using Microsoft.Extensions.Options |
|
||||
@model EventHub.Web.Pages.Events.EditPageModel |
@model EventHub.Web.Pages.Events.EditPageModel |
||||
@inject IOptions<EventHubUrlOptions> UrlOptions |
|
||||
|
|
||||
@section scripts { |
@section scripts { |
||||
<abp-script src="/Pages/Events/Edit.js"/> |
<abp-script src="/libs/awesomplete/awesomplete.min.js" /> |
||||
} |
} |
||||
|
|
||||
<form method="post" enctype="multipart/form-data"> |
@section styles { |
||||
<div class="container pt-4"> |
<abp-style src="/libs/awesomplete/awesomplete.css" /> |
||||
<div class="row py-4"> |
} |
||||
<div class="col-md-9 mx-auto profile-content"> |
|
||||
|
|
||||
<div class="card"> |
|
||||
<div class="card-body" style="min-height: 496px"> |
|
||||
<h3 class="mb-4">Edit Event</h3> |
|
||||
<div class="form"> |
|
||||
<div class="row"> |
|
||||
<input type="hidden" value="@Model.Url" id="event-detail-url"/> |
|
||||
<abp-input asp-for="Event.Id"/> |
|
||||
<div class="col-md-6"> |
|
||||
<div class="form-label-group"> |
|
||||
<select asp-for="Event.OrganizationId" asp-items="Model.Organizations" class="form-select"> |
|
||||
<option selected value="">Organization</option> |
|
||||
</select> |
|
||||
<span asp-validation-for="Event.OrganizationId" class="text-danger"></span> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div class="col-md-6"> |
|
||||
<div class="form-label-group"> |
|
||||
<input type="text" id="inputTitle" asp-for="Event.Title" class="form-control" placeholder="Title"> |
|
||||
<label for="inputTitle">Title</label> |
|
||||
<span asp-validation-for="Event.Title" class="text-danger"></span> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div class="col-md-6"> |
|
||||
<div class="form-label-group"> |
|
||||
<input id="inputStartdate" asp-for="Event.StartTime" class="form-control" placeholder="Start Date"> |
|
||||
<label for="inputStartdate">Start Date</label> |
|
||||
<span asp-validation-for="Event.StartTime" class="text-danger"></span> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div class="col-md-6"> |
|
||||
<div class="form-label-group"> |
|
||||
<input id="inputEnddate" asp-for="Event.EndTime" class="form-control" placeholder="End Date"> |
|
||||
<label for="inputEnddate">End Date</label> |
|
||||
<span asp-validation-for="Event.EndTime" class="text-danger"></span> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div class="col-md-12"> |
|
||||
<div class="form-label-group form-floating"> |
|
||||
<textarea rows="5" type="text" id="inputDescription" asp-for="Event.Description" class="form-control" placeholder="Description"></textarea> |
|
||||
<span asp-validation-for="Event.Description" class="text-danger"></span> |
|
||||
</div> |
|
||||
</div> |
|
||||
|
|
||||
<div class="col-md-12"> |
|
||||
<h4 class="mb-4">Cover Image</h4> |
|
||||
<div class="row"> |
|
||||
<div class="col-5"> |
|
||||
<div class="image-area"> |
|
||||
<img id="imageResult" src="@(UrlOptions.Value.Api.EnsureEndsWith('/') + $"api/eventhub/event/cover-image/{Model.Event.Id}")" alt="" class="img-fluid rounded shadow-sm mx-auto d-block"> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div class="col-7"> |
|
||||
<div> |
|
||||
<p class="mb-3">For horizontal format 600x300 sized upload images.</p> |
|
||||
<input type="file" id="Event_CoverImageFile" asp-for="Event.CoverImageFile" class="form-control border-0" hidden> |
|
||||
<label id="upload-label" for="Event_CoverImageFile" class="btn btn-primary btn-lg text-white">Choose file</label> |
|
||||
<span asp-validation-for="Event.CoverImageFile" class="text-danger"></span> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div class="col-md-6"> |
|
||||
<select class="form-select" asp-for="Event.IsOnline"> |
|
||||
<option selected="selected" value="">Event Type</option> |
|
||||
<option value="@Boolean.TrueString">Online</option> |
|
||||
<option value="@Boolean.FalseString">In Person</option> |
|
||||
</select> |
|
||||
<span asp-validation-for="Event.IsOnline" class="text-danger"></span> |
|
||||
</div> |
|
||||
<div class="col-md-6 event-link-group" style="display: none"> |
|
||||
<div class="form-label-group"> |
|
||||
<input type="text" id="inputOnlineLink" asp-for="Event.OnlineLink" class="form-control" placeholder="Online Link"> |
|
||||
<label for="inputOnlineLink">Online Link</label> |
|
||||
<span asp-validation-for="Event.OnlineLink" class="text-danger"></span> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div class="col-md-6"> |
|
||||
<div class="form-label-group"> |
|
||||
<input type="number" id="inputCapacity" asp-for="Event.Capacity" class="form-control" placeholder="Capacity"> |
|
||||
<label for="inputCapacity">Capacity</label> |
|
||||
<span asp-validation-for="Event.Capacity" class="text-danger"></span> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div class="col-md-6 event-location-group"> |
|
||||
<select asp-for="Event.CountryId" asp-items="Model.Countries" class="form-select"> |
|
||||
<option selected="" value="">Country</option> |
|
||||
</select> |
|
||||
<span asp-validation-for="Event.CountryId" class="text-danger"></span> |
|
||||
</div> |
|
||||
<div class="col-md-6 event-location-group"> |
|
||||
<div class="form-label-group"> |
|
||||
<input type="text" id="inputCity" asp-for="Event.City" class="form-control" placeholder="City"> |
|
||||
<label for="inputCity">City</label> |
|
||||
<span asp-validation-for="Event.City" class="text-danger"></span> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div class="col-md-6"> |
|
||||
<select asp-for="Event.Language" asp-items="Model.Languages" aria-label="en" class="form-select"> |
|
||||
<option selected value="">Language</option> |
|
||||
</select> |
|
||||
<span asp-validation-for="Event.Language" class="text-danger"></span> |
|
||||
</div> |
|
||||
|
|
||||
|
|
||||
<div class="col-md-12 text-end"> |
<div class="container mt-5"> |
||||
<button type="submit" class="btn btn-primary btn-lg"> |
@await Component.InvokeAsync(typeof(CreateOrEditEventAreaViewComponent), new |
||||
@L["Submit"] |
{ |
||||
</button> |
eventUrlCode = Model.UrlCode, |
||||
</div> |
stepType = CreateOrEditEventAreaViewComponent.ProgressStepType.Event |
||||
</div> |
}) |
||||
</div> |
</div> |
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
</form> |
|
||||
|
|||||
@ -1,202 +1,19 @@ |
|||||
using System; |
|
||||
using System.Collections.Generic; |
|
||||
using System.ComponentModel; |
|
||||
using System.ComponentModel.DataAnnotations; |
|
||||
using System.Globalization; |
|
||||
using System.IO; |
|
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using EventHub.Events; |
using EventHub.Events; |
||||
using EventHub.Organizations; |
|
||||
using EventHub.Web.Helpers; |
|
||||
using JetBrains.Annotations; |
|
||||
using Microsoft.AspNetCore.Http; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Microsoft.AspNetCore.Mvc.Rendering; |
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form; |
|
||||
using Volo.Abp.Content; |
|
||||
using Volo.Abp.Users; |
|
||||
|
|
||||
namespace EventHub.Web.Pages.Events |
namespace EventHub.Web.Pages.Events |
||||
{ |
{ |
||||
public class EditPageModel : EventHubPageModel |
public class EditPageModel : EventHubPageModel |
||||
{ |
{ |
||||
[BindProperty(SupportsGet = true)] |
public string UrlCode { get; set; } |
||||
public new string Url { get; set; } |
|
||||
|
|
||||
[BindProperty] |
public EditPageModel() |
||||
public EditEventViewModel Event { get; set; } |
|
||||
|
|
||||
public List<SelectListItem> Organizations { get; private set; } |
|
||||
public List<SelectListItem> Countries { get; private set; } |
|
||||
public List<SelectListItem> Languages { get; private set; } |
|
||||
|
|
||||
private readonly IEventAppService _eventAppService; |
|
||||
private readonly IOrganizationAppService _organizationAppService; |
|
||||
|
|
||||
public EditPageModel( |
|
||||
IEventAppService eventAppService, |
|
||||
IOrganizationAppService organizationAppService) |
|
||||
{ |
|
||||
_eventAppService = eventAppService; |
|
||||
_organizationAppService = organizationAppService; |
|
||||
} |
|
||||
|
|
||||
public async Task OnGetAsync() |
|
||||
{ |
{ |
||||
var urlCode = EventUrlCodeHelper.GetCodeFromUrl(Url); |
|
||||
var eventDetailDto = await _eventAppService.GetByUrlCodeAsync(urlCode); |
|
||||
|
|
||||
Event = ObjectMapper.Map<EventDetailDto, EditEventViewModel>(eventDetailDto); |
|
||||
|
|
||||
await FillOrganizationsAsync(); |
|
||||
await FillCountriesAsync(); |
|
||||
FillLanguages(); |
|
||||
} |
} |
||||
|
|
||||
public async Task<IActionResult> OnPostAsync() |
public void OnGet(string url) |
||||
{ |
{ |
||||
try |
UrlCode = EventUrlCodeHelper.GetCodeFromUrl(url); |
||||
{ |
|
||||
ValidateModel(); |
|
||||
|
|
||||
var updateEventDto = ObjectMapper.Map<EditEventViewModel, UpdateEventDto>(Event); |
|
||||
|
|
||||
await using var memoryStream = new MemoryStream(); |
|
||||
if (Event.CoverImageFile != null && Event.CoverImageFile.Length > 0) |
|
||||
{ |
|
||||
await Event.CoverImageFile.CopyToAsync(memoryStream); |
|
||||
memoryStream.Position = 0; |
|
||||
|
|
||||
updateEventDto.CoverImageStreamContent = new RemoteStreamContent(memoryStream, fileName: Event.CoverImageFile.FileName, contentType: Event.CoverImageFile.ContentType); |
|
||||
} |
|
||||
|
|
||||
await _eventAppService.UpdateAsync(Event.Id, updateEventDto); |
|
||||
await memoryStream.DisposeAsync(); |
|
||||
|
|
||||
return RedirectToPage("./Detail", new { url = Url }); |
|
||||
} |
|
||||
catch (Exception exception) |
|
||||
{ |
|
||||
ShowAlert(exception); |
|
||||
await FillOrganizationsAsync(); |
|
||||
await FillCountriesAsync(); |
|
||||
FillLanguages(); |
|
||||
return Page(); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
private async Task FillOrganizationsAsync() |
|
||||
{ |
|
||||
var result = await _organizationAppService.GetOrganizationsByUserIdAsync(CurrentUser.GetId()); |
|
||||
Organizations = result.Items.Select( |
|
||||
organization => new SelectListItem |
|
||||
{ |
|
||||
Value = organization.Id.ToString(), |
|
||||
Text = organization.DisplayName |
|
||||
} |
|
||||
).ToList(); |
|
||||
|
|
||||
if (Event.OrganizationId != Guid.Empty) |
|
||||
{ |
|
||||
Organizations.Single(x => x.Value == Event.OrganizationId.ToString()).Selected = true; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
private async Task FillCountriesAsync() |
|
||||
{ |
|
||||
var result = await _eventAppService.GetCountriesLookupAsync(); |
|
||||
|
|
||||
Countries = result.Select( |
|
||||
country => new SelectListItem |
|
||||
{ |
|
||||
Value = country.Id.ToString(), |
|
||||
Text = country.Name |
|
||||
} |
|
||||
).ToList(); |
|
||||
|
|
||||
if (Event.CountryId.HasValue) |
|
||||
{ |
|
||||
Countries.Single(x => x.Value == Event.CountryId.ToString()).Selected = true; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
private void FillLanguages() |
|
||||
{ |
|
||||
var result = CultureInfo.GetCultures(CultureTypes.NeutralCultures) |
|
||||
.DistinctBy(x => x.EnglishName) |
|
||||
.OrderBy(x => x.EnglishName) |
|
||||
.ToList(); |
|
||||
result.Remove(result.Single(x => x.TwoLetterISOLanguageName == "iv")); // Invariant Language
|
|
||||
|
|
||||
Languages = result.Select( |
|
||||
cultureInfo => new SelectListItem |
|
||||
{ |
|
||||
Value = cultureInfo.TwoLetterISOLanguageName, |
|
||||
Text = cultureInfo.EnglishName |
|
||||
} |
|
||||
).ToList(); |
|
||||
|
|
||||
if (!string.IsNullOrWhiteSpace(Event.Language)) |
|
||||
{ |
|
||||
Languages.Single(x => x.Value == Event.Language).Selected = true; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public class EditEventViewModel |
|
||||
{ |
|
||||
[HiddenInput] |
|
||||
public Guid Id { get; set; } |
|
||||
|
|
||||
[SelectItems(nameof(Organizations))] |
|
||||
[DisplayName("Organization")] |
|
||||
public Guid OrganizationId { get; set; } |
|
||||
|
|
||||
[Required] |
|
||||
[StringLength(EventConsts.MaxTitleLength, MinimumLength = EventConsts.MinTitleLength)] |
|
||||
public string Title { get; set; } |
|
||||
|
|
||||
[Required] |
|
||||
[DataType(DataType.DateTime)] |
|
||||
public DateTime StartTime { get; set; } = DateTime.Now; |
|
||||
|
|
||||
[Required] |
|
||||
[DataType(DataType.DateTime)] |
|
||||
public DateTime EndTime { get; set; } = DateTime.Now; |
|
||||
|
|
||||
[Required] |
|
||||
[StringLength(EventConsts.MaxDescriptionLength, MinimumLength = EventConsts.MinDescriptionLength)] |
|
||||
[TextArea] |
|
||||
public string Description { get; set; } |
|
||||
|
|
||||
[CanBeNull] |
|
||||
[Display(Name = "Cover Image")] |
|
||||
[DataType(DataType.Upload)] |
|
||||
[MaxFileSize(EventConsts.MaxCoverImageFileSize)] |
|
||||
[AllowedExtensions(new string[] { ".jpg", ".png", ".jpeg" })] |
|
||||
public IFormFile CoverImageFile { get; set; } |
|
||||
|
|
||||
[Required] |
|
||||
public bool IsOnline { get; set; } |
|
||||
|
|
||||
[CanBeNull] |
|
||||
[StringLength(EventConsts.MaxOnlineLinkLength, MinimumLength = EventConsts.MinOnlineLinkLength)] |
|
||||
public string OnlineLink { get; set; } |
|
||||
|
|
||||
[SelectItems(nameof(Countries))] |
|
||||
[DisplayName("Country")] |
|
||||
public Guid? CountryId { get; set; } |
|
||||
|
|
||||
[CanBeNull] |
|
||||
[StringLength(EventConsts.MaxCityLength, MinimumLength = EventConsts.MinCityLength)] |
|
||||
public string City { get; set; } |
|
||||
|
|
||||
[SelectItems(nameof(Languages))] |
|
||||
[DisplayName("Language")] |
|
||||
public string Language { get; set; } |
|
||||
|
|
||||
[Range(1, int.MaxValue)] |
|
||||
public int? Capacity { get; set; } |
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,94 +0,0 @@ |
|||||
$(function () { |
|
||||
var l = abp.localization.getResource('EventHub'); |
|
||||
|
|
||||
var isOnline = $("#Event_IsOnline option:selected").val() |
|
||||
if (isOnline === "True") { |
|
||||
$(".event-link-group").show(); |
|
||||
$(".event-location-group").hide(); |
|
||||
} else { |
|
||||
$(".event-link-group").hide(); |
|
||||
$(".event-location-group").show(); |
|
||||
} |
|
||||
|
|
||||
$('#Event_IsOnline').on('change', '', function () { |
|
||||
var isOnline = $("#Event_IsOnline option:selected").val() |
|
||||
if (isOnline === "True") { |
|
||||
$("#Event_CountryId").attr("required", false); |
|
||||
$("#inputCity").attr("required", false); |
|
||||
$(".event-link-group").show(); |
|
||||
$(".event-location-group").hide(); |
|
||||
} else { |
|
||||
$("#Event_CountryId").attr("required", true); |
|
||||
$("#inputCity").attr("required", true); |
|
||||
$(".event-link-group").hide(); |
|
||||
$(".event-location-group").show(); |
|
||||
} |
|
||||
}); |
|
||||
|
|
||||
var infoArea = document.getElementById('upload-label'); |
|
||||
var fileInput = document.getElementById('Event_CoverImageFile'); |
|
||||
var file; |
|
||||
|
|
||||
if (fileInput !== null) { |
|
||||
fileInput.addEventListener('change', function () { |
|
||||
var showFile = true; |
|
||||
|
|
||||
file = fileInput.files[0]; |
|
||||
|
|
||||
if (file === undefined) { |
|
||||
$('#Event_CoverImageFile').val(''); |
|
||||
$('#imageResult').attr('src', '#'); |
|
||||
infoArea.textContent = 'Choose file' |
|
||||
return; |
|
||||
} |
|
||||
|
|
||||
var permittedExtensions = ["jpg", "jpeg", "png"] |
|
||||
var fileExtension = $(this).val().split('.').pop(); |
|
||||
if (permittedExtensions.indexOf(fileExtension) === -1) { |
|
||||
showFile = false; |
|
||||
abp.message.error(l('EventCoverImageExtensionNotAllowed')) |
|
||||
.then(() => { |
|
||||
$('#Event_CoverImageFile').val(''); |
|
||||
file = null; |
|
||||
}); |
|
||||
} else if (file.size > 1024 * 1024) { |
|
||||
showFile = false; |
|
||||
abp.message.error(l('EventCoverImageSizeExceedMessage')) |
|
||||
.then(() => { |
|
||||
$('#Event_CoverImageFile').val(''); |
|
||||
file = null; |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
var img = new Image(); |
|
||||
img.onload = function () { |
|
||||
var imageError = true; |
|
||||
var sizes = { |
|
||||
width: this.width, |
|
||||
height: this.height |
|
||||
}; |
|
||||
URL.revokeObjectURL(this.src); |
|
||||
|
|
||||
if (showFile && imageError) { |
|
||||
readURL(file); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
var objectURL = URL.createObjectURL(file); |
|
||||
img.src = objectURL; |
|
||||
}); |
|
||||
|
|
||||
function readURL(input) { |
|
||||
if (input) { |
|
||||
var reader = new FileReader(); |
|
||||
|
|
||||
reader.onload = function (e) { |
|
||||
$('#imageResult').attr('src', e.target.result); |
|
||||
infoArea.textContent = 'File name: ' + input.name; |
|
||||
} |
|
||||
|
|
||||
reader.readAsDataURL(input); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
Loading…
Reference in new issue