* submit quote is a little bit sexier (still needs some work)
* added the loading gif when you vote on a quote
This commit is contained in:
parent
5cb296c978
commit
d159a91208
@ -11,9 +11,9 @@
|
|||||||
<property name="Modified" column="modified" not-null="false" type="DateTime" />
|
<property name="Modified" column="modified" not-null="false" type="DateTime" />
|
||||||
|
|
||||||
<many-to-one name="Creator" column="creator" not-null="true" foreign-key="fk_quote_user"/>
|
<many-to-one name="Creator" column="creator" not-null="true" foreign-key="fk_quote_user"/>
|
||||||
<many-to-one name="Game" column="game_id" not-null="true" foreign-key="fk_quote_game" cascade="save-update" />
|
<many-to-one name="Game" column="game_id" not-null="true" foreign-key="fk_quote_game" />
|
||||||
|
|
||||||
<set access="nosetter.camelcase" name="Categories" table="quote_category_map" cascade="save-update">
|
<set access="nosetter.camelcase" name="Categories" table="quote_category_map">
|
||||||
<key column="quote_id" />
|
<key column="quote_id" />
|
||||||
<many-to-many class="VideoGameQuotes.Api.Category" column="category_id" />
|
<many-to-many class="VideoGameQuotes.Api.Category" column="category_id" />
|
||||||
</set>
|
</set>
|
||||||
|
40
Src/VideoGameQuotes.Web/Controllers/GameController.cs
Normal file
40
Src/VideoGameQuotes.Web/Controllers/GameController.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using System.Web.Mvc;
|
||||||
|
using Portoa.Util;
|
||||||
|
using Portoa.Web;
|
||||||
|
using Portoa.Web.Controllers;
|
||||||
|
using VideoGameQuotes.Api;
|
||||||
|
using VideoGameQuotes.Web.Models;
|
||||||
|
using VideoGameQuotes.Web.Security;
|
||||||
|
using VideoGameQuotes.Web.Services;
|
||||||
|
|
||||||
|
namespace VideoGameQuotes.Web.Controllers {
|
||||||
|
public class GameController : Controller {
|
||||||
|
private readonly IGameService gameService;
|
||||||
|
private readonly ICurrentUserProvider<User> userProvider;
|
||||||
|
|
||||||
|
public GameController(IGameService gameService, ICurrentUserProvider<User> userProvider) {
|
||||||
|
this.gameService = gameService;
|
||||||
|
this.userProvider = userProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, VerifyUser]
|
||||||
|
public ActionResult Create(CreateGameModel model) {
|
||||||
|
if (!ModelState.IsValid) {
|
||||||
|
return Json(this.CreateJsonErrorResponse("Some errors occurred."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gameService.FindByNameAndSystems(model.GameName, model.SystemIds) != null) {
|
||||||
|
return Json(this.CreateJsonResponse("A game with that name for one of those systems already exists."));
|
||||||
|
}
|
||||||
|
|
||||||
|
var game = new Game { Name = model.GameName, Website = model.GameWebsite, Region = model.GameRegions, Creator = userProvider.CurrentUser };
|
||||||
|
model.SystemIds.Walk(id => game.AddSystem(new GamingSystem { Id = id }));
|
||||||
|
if (model.PublisherIds != null) {
|
||||||
|
model.PublisherIds.Walk(id => game.AddPublisher(new Publisher {Id = id}));
|
||||||
|
}
|
||||||
|
|
||||||
|
game = gameService.Save(game);
|
||||||
|
return Json(this.CreateJsonResponse(data: game.ToDto()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
30
Src/VideoGameQuotes.Web/Controllers/PublisherController.cs
Normal file
30
Src/VideoGameQuotes.Web/Controllers/PublisherController.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System.Web.Mvc;
|
||||||
|
using Portoa.Web.Controllers;
|
||||||
|
using VideoGameQuotes.Api;
|
||||||
|
using VideoGameQuotes.Web.Models;
|
||||||
|
using VideoGameQuotes.Web.Security;
|
||||||
|
using VideoGameQuotes.Web.Services;
|
||||||
|
|
||||||
|
namespace VideoGameQuotes.Web.Controllers {
|
||||||
|
public class PublisherController : Controller {
|
||||||
|
private readonly IPublisherService publisherService;
|
||||||
|
|
||||||
|
public PublisherController(IPublisherService publisherService) {
|
||||||
|
this.publisherService = publisherService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost, VerifyUser]
|
||||||
|
public ActionResult Create(CreatePublisherModel model) {
|
||||||
|
if (!ModelState.IsValid) {
|
||||||
|
return Json(this.CreateJsonErrorResponse("Some errors occurred."));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (publisherService.FindByName(model.PublisherName) != null) {
|
||||||
|
return Json(this.CreateJsonResponse("A publisher with that name already exists."));
|
||||||
|
}
|
||||||
|
|
||||||
|
var publisher = publisherService.Save(new Publisher { Name = model.PublisherName, Website = model.PublisherWebsite });
|
||||||
|
return Json(this.CreateJsonResponse(data: publisher.ToDto()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using Portoa.Util;
|
|
||||||
using Portoa.Web;
|
|
||||||
using Portoa.Web.Controllers;
|
using Portoa.Web.Controllers;
|
||||||
using VideoGameQuotes.Api;
|
using VideoGameQuotes.Api;
|
||||||
using VideoGameQuotes.Web.Models;
|
using VideoGameQuotes.Web.Models;
|
||||||
@ -10,59 +8,6 @@ using VideoGameQuotes.Web.Security;
|
|||||||
using VideoGameQuotes.Web.Services;
|
using VideoGameQuotes.Web.Services;
|
||||||
|
|
||||||
namespace VideoGameQuotes.Web.Controllers {
|
namespace VideoGameQuotes.Web.Controllers {
|
||||||
|
|
||||||
public class GameController : Controller {
|
|
||||||
private readonly IGameService gameService;
|
|
||||||
private readonly ICurrentUserProvider<User> userProvider;
|
|
||||||
|
|
||||||
public GameController(IGameService gameService, ICurrentUserProvider<User> userProvider) {
|
|
||||||
this.gameService = gameService;
|
|
||||||
this.userProvider = userProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost, VerifyUser]
|
|
||||||
public ActionResult Create(CreateGameModel model) {
|
|
||||||
if (!ModelState.IsValid) {
|
|
||||||
return Json(this.CreateJsonErrorResponse("Invalid request"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gameService.FindByNameAndSystems(model.Name, model.SystemIds) != null) {
|
|
||||||
return Json(this.CreateJsonResponse("A game with that name for one of those systems already exists"));
|
|
||||||
}
|
|
||||||
|
|
||||||
var game = new Game { Name = model.Name, Website = model.Website, Region = model.Region, Creator = userProvider.CurrentUser };
|
|
||||||
model.SystemIds.Walk(id => game.AddSystem(new GamingSystem { Id = id }));
|
|
||||||
if (model.PublisherIds != null) {
|
|
||||||
model.PublisherIds.Walk(id => game.AddPublisher(new Publisher {Id = id}));
|
|
||||||
}
|
|
||||||
|
|
||||||
game = gameService.Save(game);
|
|
||||||
return Json(this.CreateJsonResponse(data: game.ToDto()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PublisherController : Controller {
|
|
||||||
private readonly IPublisherService publisherService;
|
|
||||||
|
|
||||||
public PublisherController(IPublisherService publisherService) {
|
|
||||||
this.publisherService = publisherService;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost, VerifyUser]
|
|
||||||
public ActionResult Create(CreatePublisherModel model) {
|
|
||||||
if (!ModelState.IsValid) {
|
|
||||||
return Json(this.CreateJsonErrorResponse("Invalid request"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (publisherService.FindByName(model.Name) != null) {
|
|
||||||
return Json(this.CreateJsonResponse("A publisher with that name already exists"));
|
|
||||||
}
|
|
||||||
|
|
||||||
var publisher = publisherService.Save(new Publisher { Name = model.Name, Website = model.Website });
|
|
||||||
return Json(this.CreateJsonResponse(data: publisher.ToDto()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class SystemController : Controller {
|
public class SystemController : Controller {
|
||||||
private readonly ISystemService systemService;
|
private readonly ISystemService systemService;
|
||||||
|
|
||||||
@ -73,14 +18,14 @@ namespace VideoGameQuotes.Web.Controllers {
|
|||||||
[HttpPost, VerifyUser]
|
[HttpPost, VerifyUser]
|
||||||
public ActionResult Create(CreateSystemModel model) {
|
public ActionResult Create(CreateSystemModel model) {
|
||||||
if (!ModelState.IsValid) {
|
if (!ModelState.IsValid) {
|
||||||
return Json(this.CreateJsonErrorResponse("Invalid request"));
|
return Json(this.CreateJsonErrorResponse("Some errors occurred"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (systemService.FindByNameOrAbbreviation(model.Name, model.Abbreviation).Any()) {
|
if (systemService.FindByNameOrAbbreviation(model.SystemName, model.SystemAbbreviation).Any()) {
|
||||||
return Json(this.CreateJsonResponse("A system with that name or abbreviation already exists"));
|
return Json(this.CreateJsonResponse("A system with that name or abbreviation already exists."));
|
||||||
}
|
}
|
||||||
|
|
||||||
var system = systemService.Save(new GamingSystem { Abbreviation = model.Abbreviation, Name = model.Name, ReleaseDate = model.ReleaseDate });
|
var system = systemService.Save(new GamingSystem { Abbreviation = model.SystemAbbreviation, Name = model.SystemName, ReleaseDate = model.SystemReleaseDate });
|
||||||
return Json(this.CreateJsonResponse(data: system.ToDto()));
|
return Json(this.CreateJsonResponse(data: system.ToDto()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ namespace VideoGameQuotes.Web {
|
|||||||
|
|
||||||
protected override void ConfigureModelBinders(ModelBinderDictionary binders) {
|
protected override void ConfigureModelBinders(ModelBinderDictionary binders) {
|
||||||
binders
|
binders
|
||||||
.Add<Region, FlagEnumModelBinder>()
|
.Add<Region, FlagEnumModelBinder<Region>>()
|
||||||
.Add<BrowseModel, BrowseModelBinder>()
|
.Add<BrowseModel, BrowseModelBinder>()
|
||||||
.Add<ApiModel, ApiModelBinder>();
|
.Add<ApiModel, ApiModelBinder>();
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,16 @@ using VideoGameQuotes.Api;
|
|||||||
|
|
||||||
namespace VideoGameQuotes.Web.Models {
|
namespace VideoGameQuotes.Web.Models {
|
||||||
public class CreateGameModel {
|
public class CreateGameModel {
|
||||||
[Required]
|
public CreateGameModel() {
|
||||||
public string Name { get; set; }
|
GameRegions = Region.Unknown;
|
||||||
public string Website { get; set; }
|
}
|
||||||
public Region Region { get; set; }
|
|
||||||
[Required]
|
[Required(ErrorMessage = "The game must have a name, idiot")]
|
||||||
|
public string GameName { get; set; }
|
||||||
|
public string GameWebsite { get; set; }
|
||||||
|
public Region GameRegions { get; set; }
|
||||||
public List<int> PublisherIds { get; set; }
|
public List<int> PublisherIds { get; set; }
|
||||||
|
[Required(ErrorMessage = "At least one system must be specified, uglyface")]
|
||||||
public List<int> SystemIds { get; set; }
|
public List<int> SystemIds { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,9 @@
|
|||||||
namespace VideoGameQuotes.Web.Models {
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace VideoGameQuotes.Web.Models {
|
||||||
public class CreatePublisherModel {
|
public class CreatePublisherModel {
|
||||||
public string Name { get; set; }
|
[Required(ErrorMessage = "Publishers must have a name, douchebag")]
|
||||||
public string Website { get; set; }
|
public string PublisherName { get; set; }
|
||||||
|
public string PublisherWebsite { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,11 +3,11 @@ using System.ComponentModel.DataAnnotations;
|
|||||||
|
|
||||||
namespace VideoGameQuotes.Web.Models {
|
namespace VideoGameQuotes.Web.Models {
|
||||||
public class CreateSystemModel {
|
public class CreateSystemModel {
|
||||||
[Required]
|
[Required(ErrorMessage = "Systems must have a name, fatty")]
|
||||||
public string Name { get; set; }
|
public string SystemName { get; set; }
|
||||||
[Required, StringLength(12)]
|
[Required(ErrorMessage = "Abbreviation is required, ugly"), StringLength(12, ErrorMessage = "Abbreviations cannot be longer than 12 characters, flabcakes")]
|
||||||
public string Abbreviation { get; set; }
|
public string SystemAbbreviation { get; set; }
|
||||||
[Required]
|
[Required(ErrorMessage = "How about giving an accurate release date (try Wikipedia), nardlover?")]
|
||||||
public DateTime ReleaseDate { get; set; }
|
public DateTime SystemReleaseDate { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,10 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
using Portoa.Validation.DataAnnotations;
|
||||||
using VideoGameQuotes.Api;
|
using VideoGameQuotes.Api;
|
||||||
using VideoGameQuotes.Web.Validation;
|
|
||||||
|
|
||||||
namespace VideoGameQuotes.Web.Models {
|
namespace VideoGameQuotes.Web.Models {
|
||||||
|
|
||||||
@ -29,11 +30,14 @@ namespace VideoGameQuotes.Web.Models {
|
|||||||
public int QuoteId { get; set; }
|
public int QuoteId { get; set; }
|
||||||
public List<QuoteFlag> Flags { get; set; }
|
public List<QuoteFlag> Flags { get; set; }
|
||||||
|
|
||||||
[NonEmptyText(ErrorMessage = "Quote text must be non-empty"), DisplayName("Quote")]
|
[Required(ErrorMessage = "Quote text must be non-empty, saddlebags")]
|
||||||
|
[StringLength(1024, ErrorMessage = "Quote can't be longer than 1024 characters, slut")]
|
||||||
|
[DisplayName("Quote")]
|
||||||
public string QuoteText { get; set; }
|
public string QuoteText { get; set; }
|
||||||
[DisplayName("Categories")]
|
[DisplayName("Categories")]
|
||||||
public IList<int> CategoryIds { get; set; }
|
public IList<int> CategoryIds { get; set; }
|
||||||
|
|
||||||
|
[GreaterThanZero(ErrorMessage = "Quit screwing with the form, faggle"), DisplayName("Game")]
|
||||||
public int GameId { get; set; }
|
public int GameId { get; set; }
|
||||||
|
|
||||||
public IEnumerable<Game> AllGames { get; set; }
|
public IEnumerable<Game> AllGames { get; set; }
|
||||||
@ -106,7 +110,7 @@ namespace VideoGameQuotes.Web.Models {
|
|||||||
return MakeTable(
|
return MakeTable(
|
||||||
"region-checkbox-table",
|
"region-checkbox-table",
|
||||||
cellsPerRow,
|
cellsPerRow,
|
||||||
(IEnumerable<Region>)Enum.GetValues(typeof(Region)),
|
Enum.GetValues(typeof(Region)).Cast<Region>().Where(region => region != Region.Unknown),
|
||||||
region => CreateCheckbox("GameRegions", region, "region_" + (int)region, region.ToString())
|
region => CreateCheckbox("GameRegions", region, "region_" + (int)region, region.ToString())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Controllers\AdminController.cs" />
|
<Compile Include="Controllers\AdminController.cs" />
|
||||||
<Compile Include="Controllers\ApiController.cs" />
|
<Compile Include="Controllers\ApiController.cs" />
|
||||||
|
<Compile Include="Controllers\GameController.cs" />
|
||||||
<Compile Include="Controllers\HomeController.cs" />
|
<Compile Include="Controllers\HomeController.cs" />
|
||||||
|
<Compile Include="Controllers\PublisherController.cs" />
|
||||||
<Compile Include="Controllers\SystemController.cs" />
|
<Compile Include="Controllers\SystemController.cs" />
|
||||||
<Compile Include="Models\CreateGameModel.cs" />
|
<Compile Include="Models\CreateGameModel.cs" />
|
||||||
<Compile Include="Models\CreatePublisherModel.cs" />
|
<Compile Include="Models\CreatePublisherModel.cs" />
|
||||||
@ -138,7 +140,9 @@
|
|||||||
<Content Include="media\css\global.css" />
|
<Content Include="media\css\global.css" />
|
||||||
<Content Include="media\css\quote.css" />
|
<Content Include="media\css\quote.css" />
|
||||||
<Content Include="media\css\reset.css" />
|
<Content Include="media\css\reset.css" />
|
||||||
|
<Content Include="media\images\add.png" />
|
||||||
<Content Include="media\images\favicon.png" />
|
<Content Include="media\images\favicon.png" />
|
||||||
|
<Content Include="media\images\loading.gif" />
|
||||||
<Content Include="media\images\search.png" />
|
<Content Include="media\images\search.png" />
|
||||||
<Content Include="media\js\jquery.cookie.js" />
|
<Content Include="media\js\jquery.cookie.js" />
|
||||||
<Content Include="media\js\vgquotes.js" />
|
<Content Include="media\js\vgquotes.js" />
|
||||||
|
@ -6,60 +6,63 @@
|
|||||||
<%= Html.HiddenFor(model => model.QuoteId, new { id = "quote-id" })%>
|
<%= Html.HiddenFor(model => model.QuoteId, new { id = "quote-id" })%>
|
||||||
|
|
||||||
<p id="game-select">
|
<p id="game-select">
|
||||||
<%= Html.Label("Game", "GameId") %>
|
<%= Html.LabelFor(model => model.GameId, new { @class = "label" })%>
|
||||||
<br />
|
<br />
|
||||||
<%= Html.DropDownListFor(model => model.GameId, Model.GetGameList()) %>
|
<%= Html.DropDownListFor(model => model.GameId, Model.GetGameList()) %>
|
||||||
|
|
||||||
<a href="#" id="create-game-link">Create new game</a>
|
<a href="#" id="create-game-link" class="create-new-link">Create new game</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div id="create-game-form">
|
<div id="create-game-form">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Create new game</legend>
|
<legend>Create new game</legend>
|
||||||
|
<p class="error-message"></p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= Html.Label("Name", "GameName") %>
|
<%= Html.Label("Name", "GameName", new { @class = "label" })%>
|
||||||
<br />
|
<br />
|
||||||
<%= Html.TextBox("GameName") %>
|
<%= Html.TextBox("GameName") %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= Html.Label("Website", "GameWebsite") %> <small>(link to Wikipedia page or something)</small>
|
<%= Html.Label("Website", "GameWebsite", new { @class = "label" })%> <small>(link to Wikipedia page or something)</small>
|
||||||
<br />
|
<br />
|
||||||
<%= Html.TextBox("GameWebsite") %>
|
<%= Html.TextBox("GameWebsite") %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Regions
|
<span id="GameRegions" class="label">Regions</span>
|
||||||
<br />
|
<br />
|
||||||
<%= Model.MakeRegionTable() %>
|
<%= Model.MakeRegionTable() %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div id="system-select">
|
<div id="system-select">
|
||||||
Systems
|
<span id="SystemIds" class="label">Systems</span>
|
||||||
<br />
|
<br />
|
||||||
<%= Model.MakeSystemTable(Html) %>
|
<%= Model.MakeSystemTable(Html) %>
|
||||||
<a href="#" id="create-system-link">Create new system</a>
|
<a href="#" id="create-system-link" class="create-new-link">Create new system…</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="create-system-form">
|
<div id="create-system-form">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Create new system</legend>
|
<legend>Create new system</legend>
|
||||||
|
|
||||||
|
<p class="error-message"></p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= Html.Label("Name", "SystemName") %>
|
<%= Html.Label("Name", "SystemName", new { @class = "label" })%>
|
||||||
<br />
|
<br />
|
||||||
<%= Html.TextBox("SystemName") %>
|
<%= Html.TextBox("SystemName") %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= Html.Label("Abbreviation", "SystemAbbreviation") %>
|
<%= Html.Label("Abbreviation", "SystemAbbreviation", new { @class = "label" })%>
|
||||||
<br />
|
<br />
|
||||||
<%= Html.TextBox("SystemAbbreviation")%>
|
<%= Html.TextBox("SystemAbbreviation")%>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= Html.Label("Release Date", "SystemReleaseDate") %>
|
<%= Html.Label("Release Date", "SystemReleaseDate", new { @class = "label" })%>
|
||||||
<br />
|
<br />
|
||||||
<%= Html.TextBox("SystemReleaseDate", null) %>
|
<%= Html.TextBox("SystemReleaseDate", null) %>
|
||||||
</p>
|
</p>
|
||||||
@ -70,24 +73,26 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="publisher-select">
|
<div id="publisher-select">
|
||||||
Publishers
|
<span class="label">Publishers</span>
|
||||||
<br />
|
<br />
|
||||||
<%= Model.MakePublisherTable(Html) %>
|
<%= Model.MakePublisherTable(Html) %>
|
||||||
<a href="#" id="create-publisher-link">Create new publisher</a>
|
<a href="#" id="create-publisher-link" class="create-new-link">Create new publisher</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="create-publisher-form">
|
<div id="create-publisher-form">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Create new publisher</legend>
|
<legend>Create new publisher</legend>
|
||||||
|
|
||||||
|
<p class="error-message"></p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= Html.Label("Name", "PublisherName") %>
|
<%= Html.Label("Name", "PublisherName", new { @class = "label" })%>
|
||||||
<br />
|
<br />
|
||||||
<%= Html.TextBox("PublisherName") %>
|
<%= Html.TextBox("PublisherName") %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= Html.Label("Website", "PublisherWebsite") %>
|
<%= Html.Label("Website", "PublisherWebsite", new { @class = "label" }) %>
|
||||||
<br />
|
<br />
|
||||||
<%= Html.TextBox("PublisherWebsite") %>
|
<%= Html.TextBox("PublisherWebsite") %>
|
||||||
</p>
|
</p>
|
||||||
@ -103,18 +108,18 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= Html.LabelFor(model => model.QuoteText) %>
|
<%= Html.LabelFor(model => model.QuoteText, new { @class = "label" })%>
|
||||||
<br />
|
<br />
|
||||||
<%= Html.TextAreaFor(model => model.QuoteText) %>
|
<%= Html.TextAreaFor(model => model.QuoteText) %>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>
|
<p>
|
||||||
<%= Html.LabelFor(model => model.CategoryIds) %>
|
<span class="label">Categories</span>
|
||||||
</p>
|
</p>
|
||||||
<%= Model.MakeCategoryTable(Html) %>
|
<%= Model.MakeCategoryTable(Html) %>
|
||||||
|
|
||||||
<a href="#" id="create-category-link">Create new category</a>
|
<a href="#" id="create-category-link" class="create-new-link">Create new category</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if (Model.QuoteId > 0) { %>
|
<% if (Model.QuoteId > 0) { %>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<%@ Import Namespace="VideoGameQuotes.Api" %>
|
<%@ Import Namespace="VideoGameQuotes.Api" %>
|
||||||
|
|
||||||
<li><%= Html.ActionLink("Recent", "recent", "Quote", null, new { title = "View most recently submitted quotes" })%></li>
|
<li><%= Html.ActionLink("Recent", "recent", "Quote", null, new { title = "View most recently submitted quotes" })%></li>
|
||||||
<li><%= Html.RouteLink("Best", "quote", new { action = "best" }, new { title = "View the top rated quotes" })%></li>
|
<li><%= Html.ActionLink("Best", "best", "quote", null, new { title = "View the top rated quotes" })%></li>
|
||||||
<li><%= Html.ActionLink("Browse", "browse", "Quote", new { qualifiers = "" }, new { title = "Browse the quote database" })%></li>
|
<li><%= Html.ActionLink("Browse", "browse", "Quote", new { qualifiers = "" }, new { title = "Browse the quote database" })%></li>
|
||||||
<li><%= Html.ActionLink("Random", "random", "Quote", null, new { title = "View a random quote" })%></li>
|
<li><%= Html.ActionLink("Random", "random", "Quote", null, new { title = "View a random quote" })%></li>
|
||||||
<li><%= Html.ActionLink("Submit", "submit", "Quote", null, new { title = "Submit a new quote" }) %></li>
|
<li><%= Html.ActionLink("Submit", "submit", "Quote", null, new { title = "Submit a new quote" }) %></li>
|
||||||
|
@ -112,6 +112,14 @@ ul.menu {
|
|||||||
width: 600px;
|
width: 600px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.error-message {
|
||||||
|
display: none;
|
||||||
|
color: #990000;
|
||||||
|
}
|
||||||
|
.field-validation-error {
|
||||||
|
color: #990000;
|
||||||
|
}
|
||||||
|
|
||||||
.paging-menu p {
|
.paging-menu p {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
font-size: 80%;
|
font-size: 80%;
|
||||||
@ -130,6 +138,25 @@ ul.menu {
|
|||||||
border: none !important;
|
border: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
#edit-quote-form input[type="text"] {
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
#edit-quote-form td {
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
#edit-quote-form textarea {
|
||||||
|
width: 500px;
|
||||||
|
height: 120px;
|
||||||
|
}
|
||||||
|
.create-new-link {
|
||||||
|
padding-left: 20px;
|
||||||
|
background: transparent url(/media/images/add.png) left center no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
#browse-default-menu li {
|
#browse-default-menu li {
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
|
BIN
Src/VideoGameQuotes.Web/media/images/add.png
Normal file
BIN
Src/VideoGameQuotes.Web/media/images/add.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 733 B |
BIN
Src/VideoGameQuotes.Web/media/images/loading.gif
Normal file
BIN
Src/VideoGameQuotes.Web/media/images/loading.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.6 KiB |
@ -1,13 +1,58 @@
|
|||||||
(function($, window, undefined){
|
(function($, window, undefined){
|
||||||
|
|
||||||
$.fn.center = function () {
|
$.fn.center = function() {
|
||||||
this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
|
this.css("top", ($(window).height() - this.height()) / 2 + $(window).scrollTop() + "px");
|
||||||
this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
|
this.css("left", ($(window).width() - this.width()) / 2 + $(window).scrollLeft() + "px");
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$.fn.applyModelErrors = function(errorMessage, errorData) {
|
||||||
|
var $this = this;
|
||||||
|
|
||||||
|
if (errorMessage !== null) {
|
||||||
|
$this.find(".error-message").first().text(errorMessage).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
$.each(errorData, function(inputFieldName, value) {
|
||||||
|
var $input = $this.find("input[name='" + inputFieldName + "']");
|
||||||
|
if ($input.length > 1) {
|
||||||
|
$input = $("#" + inputFieldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($input.length) {
|
||||||
|
$input.addClass("input-validation-error");
|
||||||
|
$("<span/>")
|
||||||
|
.addClass("field-validation-error")
|
||||||
|
.text(value)
|
||||||
|
.insertAfter($input);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.clearModelErrors = function() {
|
||||||
|
this
|
||||||
|
.find(".field-validation-error")
|
||||||
|
.remove()
|
||||||
|
.end()
|
||||||
|
.find(".input-validation-error")
|
||||||
|
.removeClass("input-validation-error")
|
||||||
|
.end()
|
||||||
|
.find(".error-message")
|
||||||
|
.empty()
|
||||||
|
.hide();
|
||||||
|
};
|
||||||
|
|
||||||
$.vgquotes = {
|
$.vgquotes = {
|
||||||
refresh: function() { }
|
refresh: function() { },
|
||||||
|
ajaxErrorHandler: function(xhr) {
|
||||||
|
alert("An error occurred (" + xhr.statusCode + ")");
|
||||||
|
},
|
||||||
|
preload: function(images) {
|
||||||
|
//MM_preloadImages(lulz)
|
||||||
|
$.each(images, function() {
|
||||||
|
$('<img/>')[0].src = this;
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
(function(){
|
(function(){
|
||||||
@ -61,6 +106,10 @@
|
|||||||
|
|
||||||
var setupVoting = function() {
|
var setupVoting = function() {
|
||||||
var voting = false;
|
var voting = false;
|
||||||
|
|
||||||
|
var loadingGif = "/media/images/loading.gif";
|
||||||
|
$.vgquotes.preload([loadingGif]);
|
||||||
|
|
||||||
$(".vote-for, .vote-against").live("click", function() {
|
$(".vote-for, .vote-against").live("click", function() {
|
||||||
if (voting) {
|
if (voting) {
|
||||||
alert("Please wait for the current vote to process before voting again");
|
alert("Please wait for the current vote to process before voting again");
|
||||||
@ -72,23 +121,23 @@
|
|||||||
var $container = $votingLink.parents(".quote-container");
|
var $container = $votingLink.parents(".quote-container");
|
||||||
var direction = $votingLink.hasClass("vote-for") ? 1 : 0;
|
var direction = $votingLink.hasClass("vote-for") ? 1 : 0;
|
||||||
var quoteId = $container.find("input.quote-id").val();
|
var quoteId = $container.find("input.quote-id").val();
|
||||||
|
var $score = $container.find(".quote-score");
|
||||||
|
var score = $score.text();
|
||||||
|
|
||||||
$.ajax("/vote", {
|
$.ajax("/vote", {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: { QuoteId: quoteId, Direction: direction },
|
||||||
QuoteId: quoteId,
|
beforeSend: function() {
|
||||||
Direction: direction
|
$score.empty().append($("<img/>").attr({ src: loadingGif, title: "submitting your vote" + String.fromCharCode(0x2026) }));
|
||||||
},
|
},
|
||||||
|
|
||||||
success: function(data, status, $xhr) {
|
success: function(data, status, $xhr) {
|
||||||
if (data.Error !== null) {
|
if (data.Error !== null) {
|
||||||
alert(data.Error);
|
window.alert(data.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$container
|
score = data.Data.netVotes;
|
||||||
.find(".quote-score")
|
$score.attr("title", "+" + data.Data.upVotes + ", -" + data.Data.downVotes);
|
||||||
.attr("title", "+" + data.Data.upVotes + ", -" + data.Data.downVotes)
|
|
||||||
.text(data.Data.netVotes);
|
|
||||||
|
|
||||||
//remove the voting arrow, and add the other one if needed
|
//remove the voting arrow, and add the other one if needed
|
||||||
$votingLink.remove();
|
$votingLink.remove();
|
||||||
@ -111,7 +160,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
complete: function() { voting = false; }
|
complete: function() {
|
||||||
|
voting = false;
|
||||||
|
var $img = $score.find("img");
|
||||||
|
if ($img.length) {
|
||||||
|
$img.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
$score.text(score);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -257,12 +314,14 @@
|
|||||||
$("#create-publisher-link, #create-publisher-cancel").click(toggleFormAndLink("publisher"));
|
$("#create-publisher-link, #create-publisher-cancel").click(toggleFormAndLink("publisher"));
|
||||||
|
|
||||||
$("#create-system-submit").click(function() {
|
$("#create-system-submit").click(function() {
|
||||||
|
var $container = $("#create-system-form");
|
||||||
$.ajax("/system/create", {
|
$.ajax("/system/create", {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: { Name: $("#SystemName").val(), Abbreviation: $("#SystemAbbreviation").val(), ReleaseDate: $("#SystemReleaseDate").val() },
|
data: { SystemName: $("#SystemName").val(), SystemAbbreviation: $("#SystemAbbreviation").val(), SystemReleaseDate: $("#SystemReleaseDate").val() },
|
||||||
|
beforeSend: function() { $container.clearModelErrors(); },
|
||||||
success: function(data, statux, $xhr) {
|
success: function(data, statux, $xhr) {
|
||||||
if (data.Error !== null) {
|
if (data.Error !== null) {
|
||||||
alert(data.Error);
|
$container.applyModelErrors(data.Error, data.Data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -276,12 +335,14 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#create-publisher-submit").click(function() {
|
$("#create-publisher-submit").click(function() {
|
||||||
|
var $container = $("#create-publisher-form");
|
||||||
$.ajax("/publisher/create", {
|
$.ajax("/publisher/create", {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: { Name: $("#PublisherName").val(), Website: $("#PublisherWebsite").val() },
|
data: { PublisherName: $("#PublisherName").val(), PublisherWebsite: $("#PublisherWebsite").val() },
|
||||||
|
beforeSend: function() { $container.clearModelErrors(); },
|
||||||
success: function(data, statux, $xhr) {
|
success: function(data, statux, $xhr) {
|
||||||
if (data.Error !== null) {
|
if (data.Error !== null) {
|
||||||
alert(data.Error);
|
$container.applyModelErrors(data.Error, data.Data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,24 +355,20 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$("#create-game-submit").click(function() {
|
$("#create-game-submit").click(function() {
|
||||||
var regions = [], publishers = [], systems = [];
|
var regions = [], publishers = [], systems = [], data = { GameName: $("#GameName").val(), GameWebsite: $("#GameWebsite").val() };
|
||||||
$("input:checked[name='GameRegions']").each(function(index, input) { regions.push(input.value); });
|
$("input:checked[name='GameRegions']").each(function(index, input) { if (typeof(data.GameRegions) === "undefined") { data.GameRegions = []; } data.GameRegions.push(input.value); });
|
||||||
$("input:checked[name='SystemIds']").each(function(index, input) { systems.push(input.value); });
|
$("input:checked[name='SystemIds']").each(function(index, input) { if (typeof(data.SystemIds) === "undefined") { data.SystemIds = []; } data.SystemIds.push(input.value); });
|
||||||
$("input:checked[name='PublisherIds']").each(function(index, input) { publishers.push(input.value); });
|
$("input:checked[name='PublisherIds']").each(function(index, input) { if (typeof(data.PublisherIds) === "undefined") { data.PublisherIds = []; } data.PublisherIds.push(input.value); });
|
||||||
|
var $container = $("#create-game-form");
|
||||||
|
|
||||||
$.ajax("/game/create", {
|
$.ajax("/game/create", {
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: data,
|
||||||
Name: $("#GameName").val(),
|
|
||||||
Website: $("#GameWebsite").val(),
|
|
||||||
Region: regions,
|
|
||||||
SystemIds: systems,
|
|
||||||
PublisherIds: publishers
|
|
||||||
},
|
|
||||||
traditional: true,
|
traditional: true,
|
||||||
|
beforeSend: function() { $container.clearModelErrors(); },
|
||||||
success: function(data, statux, $xhr) {
|
success: function(data, statux, $xhr) {
|
||||||
if (data.Error !== null) {
|
if (data.Error !== null) {
|
||||||
alert(data.Error);
|
$container.applyModelErrors(data.Error, data.Data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,6 +482,10 @@
|
|||||||
if ($("#edit-quote-form").length > 0) {
|
if ($("#edit-quote-form").length > 0) {
|
||||||
setupQuoteForm();
|
setupQuoteForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$("body").ajaxError(function(e, xhr, options, error){
|
||||||
|
$.vgquotes.ajaxErrorHandler.call(this, xhr);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user