{% include 'ucp_header.html' %}

<div class="tab-pane active">
	<form id="postform" method="post" action="{{ S_UCP_ACTION }}"{{ S_FORM_ENCTYPE }} class="iz-form">

		<section class="iz-card iz-card--ucp">
			<header class="iz-card__header">
				<h2 class="iz-card__title">{{ L_TITLE }}</h2>
			</header>

			<div class="iz-card__body">
				<p class="iz-prose">{{ L_DRAFTS_EXPLAIN }}</p>

				{% if S_EDIT_DRAFT %}

					<div class="iz-space iz-space--sm"></div>

					{% include 'posting_editor.html' %}

					<div class="iz-space iz-space--md"></div>

					<div class="iz-actions">
						{{ S_HIDDEN_FIELDS }}
						<button type="submit" name="submit" value="{{ L_SAVE }}" class="iz-btn iz-btn--primary">
							{{ L_SAVE }}
						</button>
						{{ S_FORM_TOKEN }}
					</div>

				{% else %}

					{% if draftrow %}
						<section class="iz-card iz-card--nested">
							<header class="iz-card__header">
								<h3 class="iz-card__title">{{ L_DRAFTS }}</h3>
							</header>

							<div class="iz-card__body">
								<div class="iz-tablewrap" role="region" aria-label="{{ L_DRAFTS }}">
									<table class="iz-table iz-table--drafts">
										<thead>
											<tr>
												<th scope="col">{{ L_DRAFT_TITLE }}</th>
												<th scope="col" class="iz-only-desktop">{{ L_SAVE_DATE }}</th>
												<th scope="col" class="iz-table__check">{{ L_MARK }}</th>
											</tr>
										</thead>
										<tbody>
											{% for draftrow in draftrow %}
												<tr>
													<td>
														<a class="iz-link" href="{{ draftrow.U_VIEW_EDIT }}">{{ draftrow.DRAFT_SUBJECT }}</a>

														<div class="iz-meta iz-meta--small">
															{% if draftrow.S_LINK_TOPIC %}
																{{ L_TOPIC }}{{ L_COLON }}&nbsp;<a class="iz-link" href="{{ draftrow.U_VIEW }}">{{ draftrow.TITLE }}</a>
															{% elseif draftrow.S_LINK_FORUM %}
																{{ L_FORUM }}{{ L_COLON }}&nbsp;<a class="iz-link" href="{{ draftrow.U_VIEW }}">{{ draftrow.TITLE }}</a>
															{% elseif S_PRIVMSGS %}
															{% else %}
																{{ L_NO_TOPIC_FORUM }}
															{% endif %}
														</div>
													</td>

													<td class="iz-only-desktop">
														<div class="iz-meta iz-meta--small">{{ draftrow.DATE }}</div>
														<div class="iz-actions iz-actions--compact">
															{% if draftrow.U_INSERT %}
																<a class="iz-link" href="{{ draftrow.U_INSERT }}">{{ L_LOAD_DRAFT }}</a>
																<span class="iz-sep">•</span>
															{% endif %}
															<a class="iz-link" href="{{ draftrow.U_VIEW_EDIT }}">{{ L_VIEW_EDIT }}</a>
														</div>
													</td>

													<td class="iz-table__check">
														<div class="iz-choice iz-choice--check">
															<input type="checkbox" name="d[{{ draftrow.DRAFT_ID }}]" id="d{{ draftrow.DRAFT_ID }}">
															<label for="d{{ draftrow.DRAFT_ID }}">
																<span class="iz-visually-hidden">{{ L_MARK }}</span>
															</label>
														</div>
													</td>
												</tr>
											{% endfor %}
										</tbody>
									</table>
								</div>
							</div>
						</section>

						<div class="iz-space iz-space--sm"></div>

						<div class="iz-toolbar iz-toolbar--ucp-actions" aria-label="{{ L_OPTIONS }}">
							<div class="iz-toolbar__left">
								<div class="iz-actions">
									<button type="button" class="iz-btn iz-btn--ghost iz-btn--sm" onclick="marklist('postform', '', true); return false;">
										{{ L_MARK_ALL }}
									</button>
									<button type="button" class="iz-btn iz-btn--ghost iz-btn--sm" onclick="marklist('postform', '', false); return false;">
										{{ L_UNMARK_ALL }}
									</button>
									<button class="iz-btn iz-btn--danger iz-btn--sm" type="submit" name="delete" title="{{ L_DELETE_MARKED }}">
										{{ L_DELETE_MARKED }}
									</button>
								</div>

								{{ S_FORM_TOKEN }}
							</div>
						</div>

					{% else %}
						<div class="iz-alert iz-alert--info" role="status">
							<strong>{{ L_INFO_BOX }}</strong>&nbsp;{{ L_NO_SAVED_DRAFTS }}
						</div>
					{% endif %}

				{% endif %}

			</div>
		</section>

	</form>
</div>

{% include 'ucp_footer.html' %}
