<xf:js src="xf/sort.js, vendor/dragula/dragula.js"/>
<xf:css src="public:dragula.less"/>

<xf:formrow label="{{ phrase('allowed_thread_types') }}">
	<div data-xf-init="list-sorter" data-drag-handle=".dragHandle">
		<div class="is-undraggable js-blockDragbefore">
			<span class="dragHandle" aria-label="{{ phrase('drag_handle')|for_attr }}"></span>
			<xf:checkbox standalone="true">
				<xf:option selected="true" disabled="true">{{ phrase('thread_type_plural.discussion') }}</xf:option>
			</xf:checkbox>
		</div>

		<xf:foreach loop="$typeConfig.allowed_thread_types"
			value="$threadTypeId"
			if="{$possibleThreadTypes.{$threadTypeId}}"
		>
			<div class="u-inputSpacer">
				<span class="dragHandle" aria-label="{{ phrase('drag_handle')|for_attr }}"></span>
				<xf:checkbox standalone="true">
					<xf:option name="type_config[allowed_thread_types][]" value="{$threadTypeId}" selected="true"
						label="{$possibleThreadTypes.{$threadTypeId}}"
						data-xf-init="disabler"
						data-container="#js-{$threadTypeId}Config"
						data-optional="on"
						data-hide="on" />
				</xf:checkbox>
			</div>
		</xf:foreach>

		<xf:foreach loop="$possibleThreadTypes"
			key="$threadTypeId"
			value="$typeTitle"
			if="{{ !in_array($threadTypeId, $typeConfig.allowed_thread_types) }}"
		>
			<div class="u-inputSpacer">
				<span class="dragHandle" aria-label="{{ phrase('drag_handle')|for_attr }}"></span>
				<xf:checkbox standalone="true">
					<xf:option name="type_config[allowed_thread_types][]" value="{$threadTypeId}"
						label="{$typeTitle}"
						data-xf-init="disabler"
						data-container="#js-{$threadTypeId}Config"
						data-optional="on"
						data-hide="on" />
				</xf:checkbox>
			</div>
		</xf:foreach>
	</div>
</xf:formrow>

<xf:if is="$possibleThreadTypes.question">
	<xf:checkboxrow rowid="js-questionConfig">
		<xf:option name="type_config[allow_answer_voting]"
			selected="$typeConfig.allow_answer_voting"
			label="{{ phrase('allow_answer_voting_in_question_threads') }}"
			hint="{{ phrase('if_enabled_users_will_be_able_to_vote_on_answers_given_to_questions') }}">
			<xf:checkbox>
				<xf:option
					name="type_config[allow_answer_downvote]"
					selected="{{ !$typeConfig.allow_answer_voting OR $typeConfig.allow_answer_downvote }}"
					label="{{ phrase('allow_answers_given_to_votable_questions_to_be_downvoted') }}"
					hint="{{ phrase('if_disabled_users_may_only_choose_to_upvote_answers') }}" />
			</xf:checkbox>
		</xf:option>
	</xf:checkboxrow>
</xf:if>