<ol class="breadcrumb">
	<li><a href="#/">Dashboard</a></li>
	<li>Settings</li>
	<li><a href="#/message-templates">Message Templates</a></li>
	<li class="active">{{vm.action}} Message Template</li>
</ol>

<ng-include src="'views/modals/uploadImageCKEditorModal.html'"></ng-include>

<div class="container-fluid">
	<div class="row">
		<div class="col-md-12">
			<form name="form" class="form-horizontal" ng-submit="vm._save(vm.message_template)" novalidate>
				<input type="hidden" ng-if="vm.action == 'Edit'" name="id" id="id" ng-model="vm.message_template.id">
				<div class="panel panel-midnightblue">
					<div class="panel-heading">
						<h2>{{vm.action}} Message Template</h2>
					</div>
					<div class="panel-body">
						<p>Fields with <span style="color: #cc0000;">*</span> are required.</p>
						<div class="form-group">
							<label for="category" class="col-sm-2 control-label">Category <span style="color: #cc0000;">*</span></label>
							<div class="col-sm-8">
								<select class="form-control" name="category" id="category" ng-model="vm.message_template.category" ng-required="true">
									<option value="">-- Select --</option>
									<option value="GENERAL">General</option>
									<option value="WELCOME_CUSTOMER">Welcome Customer</option>
								</select>
								<p class="help-block" ng-show="form.name.$touched && form.name.$error.required">Value is required.</p>
							</div>
						</div>
						<div class="form-group">
							<label for="name" class="col-sm-2 control-label">Name <span style="color: #cc0000;">*</span></label>
							<div class="col-sm-8">
								<input type="text" class="form-control" name="name" id="name" ng-model="vm.message_template.name" ng-required="true" ng-minlength="3">
								<p class="help-block" ng-show="form.name.$touched && form.name.$error.required">Value is required.</p>
								<p class="help-block" ng-show="form.name.$touched && form.name.$error.minlength">Value is too short.</p>
							</div>
						</div>
						<div class="form-group">
							<label for="subject" class="col-sm-2 control-label">Subject <span style="color: #cc0000;">*</span></label>
							<div class="col-sm-8">
								<input type="text" class="form-control" name="subject" id="subject" ng-model="vm.message_template.subject" ng-required="true" ng-minlength="3">
								<p class="help-block" ng-show="form.subject.$touched && form.subject.$error.required">Value is required.</p>
								<p class="help-block" ng-show="form.subject.$touched && form.subject.$error.minlength">Value is too short.</p>
							</div>
						</div>
						<div class="form-group">
							<label for="description" class="col-sm-2 control-label">Description <span style="color: #cc0000;">*</span></label>
							<div class="col-sm-8">
								<textarea ck-editor-routely-directive name="description" id="description" ng-model="vm.message_template.description"></textarea>
								<p class="help-block" ng-show="form.description.$touched && form.description.$error.required">Value is required.</p>
							</div>
						</div>
						<div class="form-group">
							<label for="attachments" class="col-sm-2 control-label"></label>
							<div class="col-sm-8">
								<a class="btn btn-sm btn-info" title="New Attachment" ngf-multiple="false" ngf-select="vm._uploadFile($file)" ngf-max-size="10MB" ngf-pattern="'image/*,.pdf,.doc,.docx,.xls,.xlsx'" ngf-accept="'image/*,.pdf,.doc,.docx,.xls,.xlsx'" ngf-model-invalid="invalidFiles">+ New Attachment</a>
								<p ng-if="invalidFiles" style="color: #cc0000">Invalid File. Only Files (Images, .PDF, .DOC, .DOCX, .XLS, .XLSX) up to 10MB.</p>
							</div>
						</div>
						<div class="form-group" ng-if="vm._attachments.length">
							<label for="attachments" class="col-sm-2 control-label">Attachments</label>
							<div class="col-sm-8">
								<table class="table table-bordered">
									<tbody>
										<tr ng-repeat="attachment in vm._attachments">
											<td><a href="{{attachment.url}}" target="_blank">{{attachment.name}}</a></td>
											<td class="text-center"><a class="btn btn-sm btn-danger" ng-click="vm._removeFile(attachment.name)" title="Remove">Remove</a></td>
										</tr>
									</tbody>
								</table>
							</div>
						</div>
					</div>
					<div class="panel-footer">
						<div class="row">
							<div class="col-sm-8 col-sm-offset-2">
								<button type="submit" ng-disabled="!form.$valid" class="btn-primary btn">Save</button>
								<a href="#/message-templates" class="btn-default btn">Cancel</a>
							</div>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>
</div>
