@using InventoryTraker.Web.Helpers
@model InventoryTraker.Web.Models.ProfileForm

@{
	ViewBag.Title = "Your Profile";
}

<h1 class="page-header">Update Your Profile</h1>
<form novalidate
	  name="vm.form"
	  ng-controller="EditProfileController as vm"
      ng-submit="vm.form.$valid && vm.save()"
	  style="max-width: 500px;">
	<fieldset ng-disabled="vm.saving">

		<div class="alert alert-info" ng-show="vm.errorMessage == null && !vm.saving && !vm.success">
			Make changes below.
		</div>
		<div class="alert alert-info" ng-show="vm.saving">
			Saving changes...
		</div>
		<div class="alert alert-success" ng-show="vm.success">
			<span class="fa fa-check"></span>
			Changes saved!
		</div>
	    <div class="alert alert-danger" ng-show="vm.errorMessage != null">
	        {{vm.errorMessage}}
	    </div>

        @Html.Angular().FormForModel("vm.profile")

		<div class="form-group">
			<button class="btn btn-success">Save Changes</button>
			<a class="btn btn-warning" href="/">Cancel</a>
		</div>

	</fieldset>
</form>
@section Scripts
{
	<script>
		var url = '@(Html.BuildUrlFromExpression<ProfileController>(c => c.Update(null)))';

		window.app.constant('editProfileConfig', {
			saveUrl: url
		});

		window.app.constant('model', @Html.JsonFor(Model));
	</script>
}