<?php
	/** @var FreshRSS_View $this */
	$this->partial('aside_subscription');
?>

<main class="post">
	<div class="link-back-wrapper">
		<a class="link-back" href="<?= _url('index', 'index') ?>"><?= _t('gen.action.back_to_rss_feeds') ?></a>
	</div>

	<h1><?= _t('sub.menu.label_management') ?></h1>

	<h2><?= _t('sub.title.add_label') ?></h2>
	<form id="add_tag" method="post" action="<?= _url('tag', 'add') ?>" autocomplete="off">
		<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
		<div class="form-group">
			<label class="group-name" for="new_label_name"><?= _t('sub.tag.name') ?></label>
			<div class="group-controls">
				<input id="new_label_name" name="name" type="text" autocomplete="off" required="required" />
			</div>
		</div>

		<div class="form-group form-actions">
			<div class="group-controls">
				<button type="submit" class="btn btn-important"><?= _t('gen.action.add') ?></button>
			</div>
		</div>
	</form>

	<h2><?= _t('sub.title.rename_label') ?></h2>
	<?php
	$disabled = '';
	if (count($this->tags) < 1) {
		$disabled = ' disabled="disabled"';
	} ?>
	<form id="rename_tag" method="post" action="<?= _url('tag', 'rename') ?>" autocomplete="off">
		<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
		<div class="form-group">
			<label class="group-name" for="id_tag"><?= _t('sub.tag.old_name') ?></label>
			<div class="group-controls">
				<select name="id_tag" id="id_tag"<?= $disabled?>>
					<?php foreach ($this->tags as $tag): ?>
						<option value="<?= $tag->id() ?>"><?= $tag->name() ?></option>
					<?php endforeach; ?>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="group-name" for="rename_new_name"><?= _t('sub.tag.new_name') ?></label>
			<div class="group-controls">
				<input id="rename_new_name" name="name" type="text" autocomplete="off"<?= $disabled?>/>
			</div>
		</div>

		<div class="form-group form-actions">
			<div class="group-controls">
				<?php if (!$disabled) { ?>
				<button type="submit" class="btn btn-attention confirm"><?= _t('gen.action.rename') ?></button>
				<?php } ?>
			</div>
		</div>
	</form>

	<h2><?= _t('sub.title.delete_label') ?></h2>
	<form id="delete_tag" method="post" action="<?= _url('tag', 'delete') ?>" autocomplete="off">
		<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
		<div class="form-group">
			<label class="group-name" for="id_tag_delete"><?= _t('sub.tag.name') ?></label>
			<div class="group-controls">
				<select name="id_tag" id="id_tag_delete"<?= $disabled?>>
					<?php foreach ($this->tags as $tag): ?>
						<option value="<?= $tag->id() ?>"><?= $tag->name() ?></option>
					<?php endforeach; ?>
				</select>
			</div>
		</div>

		<div class="form-group form-actions">
			<div class="group-controls">
				<?php if (!$disabled) { ?>
				<button type="submit" class="btn btn-attention confirm"><?= _t('gen.action.remove') ?></button>
				<?php } ?>
			</div>
		</div>
	</form>
</main>
