include ./_current_plan_mixins

.row
	.col-xs-12(ng-cloak)
		form.project-search.form-horizontal(role="form")
			.form-group.has-feedback.has-feedback-left.col-md-7.col-xs-12
				input.form-control.col-md-7.col-xs-12(
					placeholder=translate('search_projects')+"…",
					aria-label=translate('search_projects')+"…",
					autofocus='autofocus',
					ng-model="searchText.value",
					focus-on='search:clear',
					ng-keyup="searchProjects()"
				)
				i.fa.fa-search.form-control-feedback-left(aria-hidden="true")
				i.fa.fa-times.form-control-feedback(
					ng-click="clearSearchText()",
					style="cursor: pointer;",
					ng-show="searchText.value.length > 0"
					aria-hidden="true"
				)
				button.sr-only(
					type="button"
					ng-click="clearSearchText()"
					ng-show="searchText.value.length > 0"
				) #{translate('clear_search')}

		.project-tools(ng-cloak)
			.project-list-upgrade-prompt(ng-cloak ng-hide="selectedProjects.length > 0")
				+current_plan()
			.btn-toolbar
				.btn-group(ng-hide="selectedProjects.length < 1")
					a.btn.btn-secondary(
						href,
						aria-label=translate('download'),
						tooltip=translate('download'),
						tooltip-placement="bottom",
						tooltip-append-to-body="true",
						ng-click="downloadSelectedProjects()"
					)
						i.fa.fa-cloud-download(aria-hidden="true")
					a.btn.btn-secondary(
						href,
						ng-if="filter !== 'archived'"
						aria-label=translate("archive"),
						tooltip=translate("archive"),
						tooltip-placement="bottom",
						tooltip-append-to-body="true",
						ng-click="openArchiveProjectsModal()"
					)
						i.fa.fa-inbox(aria-hidden="true")
					a.btn.btn-secondary(
						href,
						ng-if="filter !== 'trashed'"
						aria-label=translate("trash"),
						tooltip=translate("trash"),
						tooltip-placement="bottom",
						tooltip-append-to-body="true",
						ng-click="openTrashProjectsModal()"
					)
						i.fa.fa-trash(aria-hidden="true")
				.btn-group.dropdown(
					ng-hide="selectedProjects.length < 1 || filter === 'archived' || filter === 'trashed'", 
					dropdown
				)
					a.btn.btn-secondary.dropdown-toggle(
						href,
						data-toggle="dropdown",
						dropdown-toggle,
						tooltip=translate('add_to_folders'),
						tooltip-append-to-body="true",
						tooltip-placement="bottom"
					)
						i.fa.fa-folder-open
						|  
						span.caret
						span.sr-only #{translate('add_to_folders')}
					ul.dropdown-menu.dropdown-menu-right.js-tags-dropdown-menu.tags-dropdown-menu(
						role="menu"
						ng-controller="TagListController"
					)
						li.dropdown-header #{translate("add_to_folder")}
						li(
							ng-repeat="tag in tags | orderBy:'name'",
							ng-controller="TagDropdownItemController"
						)
							a(href="#", ng-click="addOrRemoveProjectsFromTag()", stop-propagation="click")
								i.fa(
									ng-class="{\
										'fa-check-square-o': areSelectedProjectsInTag == true,\
										'fa-square-o': areSelectedProjectsInTag == false,\
										'fa-minus-square-o': areSelectedProjectsInTag == 'partial'\
									}"
								)
								span.sr-only Add or remove project from tag
								|  {{tag.name}}
						li.divider
						li
							a(href, ng-click="openNewTagModal()", stop-propagation="click") #{translate("create_new_folder")}

				.btn-group.dropdown(
					ng-hide="selectedProjects.length != 1  || filter === 'archived' || filter === 'trashed'", 
					dropdown
				)
					a.btn.btn-secondary.dropdown-toggle(
						href,
						data-toggle="dropdown",
						dropdown-toggle
					) #{translate("more")} 
						span.caret
					ul.dropdown-menu.dropdown-menu-right(role="menu")
						li(ng-show="getFirstSelectedProject().accessLevel == 'owner'")
							a(
								href,
								ng-click="openRenameProjectModal()"
							) #{translate("rename")}
						li
							a(
								href,
								ng-click="openCloneProjectModal(getFirstSelectedProject())"
							) #{translate("make_copy")}

				.btn-group(ng-show="filter === 'archived' && selectedProjects.length > 0")
					a.btn.btn-secondary(
						href,
						data-original-title=translate("unarchive"),
						data-toggle="tooltip",
						data-placement="bottom",
						ng-click="unarchiveProjects(selectedProjects)"
					) #{translate("unarchive")}

				.btn-group(ng-show="filter === 'trashed' && selectedProjects.length > 0")
					a.btn.btn-secondary(
						href,
						data-original-title=translate("untrash"),
						data-toggle="tooltip",
						data-placement="bottom",
						ng-click="untrashProjects(selectedProjects)"
					) #{translate("untrash")}

				.btn-group(ng-show="filter === 'trashed' && selectedProjects.length > 0")
					a.btn.btn-danger(
						href,
						ng-if="hasLeavableProjectsSelected() && !hasDeletableProjectsSelected()",
						data-original-title=translate('leave'),
						data-toggle="tooltip",
						data-placement="bottom",
						ng-click="openLeaveProjectsModal()"
					) #{translate("leave")}

					a.btn.btn-danger(
						href,
						ng-if="hasDeletableProjectsSelected() && !hasLeavableProjectsSelected()",
						data-original-title=translate('delete'),
						data-toggle="tooltip",
						data-placement="bottom",
						ng-click="openDeleteProjectsModal()"
					) #{translate("delete")}

					a.btn.btn-danger(
						href,
						ng-if="hasDeletableProjectsSelected() && hasLeavableProjectsSelected()",
						data-original-title=translate('delete_and_leave'),
						data-toggle="tooltip",
						data-placement="bottom",
						ng-click="openLeaveOrDeleteProjectsModal()"
					) #{translate("delete_and_leave")}

.row.row-spaced
	.col-xs-12
		.card.card-thin.project-list-card
			ul.list-unstyled.project-list.structured-list(
				select-all-list,
				ng-if="projects.length > 0",
				max-height="projectListHeight - 25",
				ng-cloak
			)
				table.project-list-table
					tr.project-list-table-header-row
						th.project-list-table-name-cell
							.project-list-table-name-container
								input.project-list-table-select-item(
									select-all,
									type="checkbox"
									aria-label=translate('select_all_projects')
								)
								span.header.clickable.project-list-table-name(ng-click="changePredicate('name')") #{translate("title")}
									i.tablesort.fa(ng-class="getSortIconClass('name')" aria-hidden="true")
								button.sr-only(ng-click="changePredicate('name')") Sort by #{translate("title")}
						th.project-list-table-owner-cell
							span.header.clickable(ng-click="changePredicate('ownerName')") #{translate("owner")}
								i.tablesort.fa(ng-class="getSortIconClass('ownerName')" aria-hidden="true")
							button.sr-only(ng-click="changePredicate('ownerName')") Sort by #{translate("owner")}
						th.project-list-table-lastupdated-cell
							span.header.clickable(ng-click="changePredicate('lastUpdated')") #{translate("last_modified")}
								i.tablesort.fa(ng-class="getSortIconClass('lastUpdated')" aria-hidden="true")
							button.sr-only(ng-click="changePredicate('lastUpdated')") Sort by #{translate("last_modified")}
						th.project-list-table-actions-cell
							span.header #{translate("actions")}
					tr.project-list-table-row(
						ng-repeat="project in visibleProjects | orderBy:getValueForCurrentPredicate:reverse:comparator",
						ng-controller="ProjectListItemController"
						select-row
					)
						include ./item
					tr(
						ng-if="visibleProjects.length == 0",
						ng-cloak
					)
						td(colspan="4").project-list-table-no-projects-cell
								span.small #{translate("no_projects")}

			div.welcome.text-centered(ng-if="projects.length == 0", ng-cloak)
				h2 #{translate("welcome_to_sl")}
				p #{translate("new_to_latex_look_at")} 
					a(href="/templates") #{translate("templates").toLowerCase()}
					|   #{translate("or")}
					a(href="/learn")  #{translate("latex_help_guide")}
					| ,
					br 
					|  #{translate("or_create_project_left")}

							
