<div class="view-customize">
	{{ui/ui-button color=constants.Color.Green light=true icon=constants.Icon.People label=constants.Label.Add onClick=(action "onShowAddGroupModal")}}
	<div id="add-group-modal" class="modal" tabindex="-1" role="dialog">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">Add Group</div>
				<div class="modal-body">
					<form onsubmit= {{action "onAddGroup"}}>
						<div class="form-group">
							<label for="new-group-name">Name</label>
							{{focus-input id="new-group-name" type="text" class="form-control mousetrap" placeholder="Enter group name" value=newGroup.name}}
							<small class="form-text text-muted">e.g. Managers, Developers, Acme Team</small>
						</div>
						<div class="form-group">
							<label for="new-group-desc">Description (optional)</label>
							{{textarea id="new-group-desc" value=newGroup.purpose class="form-control" rows="3"}}
						</div>
					</form>
				</div>
				<div class="modal-footer">
					{{ui/ui-button color=constants.Color.Gray light=true label=constants.Label.Close dismiss=true}}
					{{ui/ui-button-gap}}
					{{ui/ui-button color=constants.Color.Red light=true label=constants.Label.Add onClick=(action "onAddGroup")}}
				</div>
			</div>
		</div>
	</div>

	{{ui/ui-spacer size=300}}

	<div class="groups-list">
		{{#each groups as |group|}}
			<div class="group">
				<div class="name">
					{{group.name}} ({{group.members}})
				</div>
				<div class="desc">{{group.purpose}}</div>
				{{ui/ui-spacer size=200}}
				{{#ui/ui-toolbar dark=false light=true raised=true large=false bordered=true}}
					{{ui/ui-toolbar-icon icon=constants.Icon.AddUser color=constants.Color.Gray tooltip="Add members" onClick=(action "onShowAddMemberModal" group.id)}}
					{{#if (gt group.members 0)}}
						{{ui/ui-toolbar-icon icon=constants.Icon.RemoveUser color=constants.Color.Gray tooltip="Remove members" onClick=(action "onShowRemoveMemberModal" group.id)}}
					{{/if}}
					{{ui/ui-toolbar-icon icon=constants.Icon.Edit color=constants.Color.Gray tooltip="Edit group" onClick=(action "onShowEditModal" group.id)}}
					{{ui/ui-toolbar-icon icon=constants.Icon.Delete color=constants.Color.Red tooltip="Delete group" onClick=(action "onShowDeleteModal" group.id)}}
				{{/ui/ui-toolbar}}
			</div>
		{{/each}}
	</div>

	<div id="delete-group-modal" class="modal" tabindex="-1" role="dialog">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">Delete Group</div>
				<div class="modal-body">
					<form onsubmit= {{action "onDeleteGroup"}}>
						<p>Are you sure you want to delete this group?</p>
						<div class="form-group">
							<label for="delete-group-name">Please type group name to confirm</label>
							{{input id="delete-group-name" type="text" class="form-control mousetrap" placeholder="Group name" value=deleteGroup.name}}
							<small class="form-text text-muted">This will remove group membership information and associated permissions!</small>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					{{ui/ui-button color=constants.Color.Gray light=true label=constants.Label.Close dismiss=true}}
					{{ui/ui-button-gap}}
					{{ui/ui-button color=constants.Color.Red light=true label=constants.Label.Delete onClick=(action "onDeleteGroup")}}
				</div>
			</div>
		</div>
	</div>

	<div id="edit-group-modal" class="modal" tabindex="-1" role="dialog">
		<div class="modal-dialog" role="document">
			<div class="modal-content">
				<div class="modal-header">Edit Group</div>
				<div class="modal-body">
					<form onsubmit= {{action "onEditGroup"}}>
						<div class="form-group">
							<label for="edit-group-name">Name</label>
							{{input id="edit-group-name" type="text" class="form-control mousetrap" placeholder="Enter group name" value=editGroup.name}}
							<small class="form-text text-muted">e.g. Managers, Developers, Acme Team</small>
						</div>
						<div class="form-group">
							<label for="edit-group-desc">Description (optional)</label>
							{{textarea id="edit-group-desc" value=editGroup.purpose class="form-control" rows="3"}}
						</div>
					</form>
				</div>
				<div class="modal-footer">
					{{ui/ui-button color=constants.Color.Gray light=true label=constants.Label.Close dismiss=true}}
					{{ui/ui-button-gap}}
					{{ui/ui-button color=constants.Color.Green light=true label=constants.Label.Save onClick=(action "onEditGroup")}}
				</div>
			</div>
		</div>
	</div>

	<div id="group-remove-member-modal" class="modal" tabindex="-1" role="dialog">
		<div class="modal-dialog modal-lg" role="document">
			<div class="modal-content">
				<div class="modal-header">Remove Member &mdash; {{membersGroup.name}} ({{members.length}})</div>
				<div class="modal-body">
					<div class="view-customize">
						<div class="group-users-members">
							{{#each members as |member|}}
								<div class="item">
									{{#ui/ui-toolbar dark=false light=true raised=true large=false bordered=true}}
										{{ui/ui-toolbar-icon icon=constants.Icon.RemoveUser color=constants.Color.Red tooltip="Remove member" onClick=(action "onLeaveGroup" member.userId)}}
										{{ui/ui-toolbar-label color=constants.Color.Gray label=member.fullname onClick=(action "onLeaveGroup" member.userId)}}
									{{/ui/ui-toolbar}}
								</div>
							{{/each}}
						</div>
					</div>
				</div>
				<div class="modal-footer">
					{{ui/ui-button color=constants.Color.Gray light=true label=constants.Label.Close dismiss=true}}
				</div>
			</div>
		</div>
	</div>

	<div id="group-add-member-modal" class="modal" tabindex="-1" role="dialog">
		<div class="modal-dialog modal-lg" role="document">
			<div class="modal-content">
				<div class="modal-header">Add Member &mdash; {{membersGroup.name}} ({{members.length}})</div>
				<div class="modal-body">
					<div class="form-group">
						<label for="group-members-search">Find users</label>
						{{input id="group-members-search" type="text" class="form-control mousetrap" placeholder="Search members and users..." value=searchText key-up=(action "onSearch")}}
						<small class="form-text text-muted">firstname, lastname, email</small>
					</div>
					<div class="view-customize">
						<div class="text-center">
							{{#ui/ui-toolbar dark=false light=false raised=false large=true bordered=false tooltip="Maximum users to display"}}
								{{ui/ui-toolbar-label color=constants.Color.Gray label="5" selected=(eq userLimit 5) onClick=(action "onLimit" 5)}}
								{{ui/ui-toolbar-label color=constants.Color.Gray label="10" selected=(eq userLimit 10) onClick=(action "onLimit" 10)}}
								{{ui/ui-toolbar-label color=constants.Color.Gray label="25" selected=(eq userLimit 25) onClick=(action "onLimit" 25)}}
								{{ui/ui-toolbar-label color=constants.Color.Gray label="50" selected=(eq userLimit 50) onClick=(action "onLimit" 50)}}
								{{ui/ui-toolbar-label color=constants.Color.Gray label="100" selected=(eq userLimit 100) onClick=(action "onLimit" 100)}}
								{{ui/ui-toolbar-label color=constants.Color.Gray label="250" selected=(eq userLimit 250) onClick=(action "onLimit" 250)}}
								{{ui/ui-toolbar-label color=constants.Color.Gray label="500" selected=(eq userLimit 500) onClick=(action "onLimit" 500)}}
								{{ui/ui-toolbar-label color=constants.Color.Gray label="1,000" selected=(eq userLimit 1000) onClick=(action "onLimit" 1000)}}
								{{ui/ui-toolbar-label color=constants.Color.Gray label="ALL" selected=(eq userLimit 99999) onClick=(action "onLimit" 99999)}}
							{{/ui/ui-toolbar}}
						</div>
						{{ui/ui-spacer size=300}}
						<div class="group-users-members">
							{{#each users as |user|}}
								<div class="item">
									{{#ui/ui-toolbar dark=false light=true raised=true large=false bordered=true}}
										{{#if user.isMember}}
											{{ui/ui-toolbar-icon icon=constants.Icon.RemoveUser color=constants.Color.Red tooltip="Remove member" onClick=(action "onLeaveGroup" user.id)}}
										{{else}}
											{{ui/ui-toolbar-icon icon=constants.Icon.AddUser color=constants.Color.Green tooltip="Add member" onClick=(action "onJoinGroup" user.id)}}
											{{ui/ui-toolbar-label color=constants.Color.Gray label=(concat user.firstname " " user.lastname) onClick=(action "onJoinGroup" user.id)}}
										{{/if}}
									{{/ui/ui-toolbar}}
								</div>
							{{/each}}
						</div>
					</div>
				</div>
				<div class="modal-footer">
					{{ui/ui-button color=constants.Color.Gray light=true label=constants.Label.Close dismiss=true}}
				</div>
			</div>
		</div>
	</div>
</div>