{template "common/header"}
<div class="we7-step">
	<ul>
		<li ><span class="content">1 安装应用</span></li>
		<li class="active"><span class="content">2 分配应用权限</span> </li>
		<li><span class="content">3 安装成功</span> </li>
	</ul>
</div>

<div id="js-module-group" class="module-group-page clearfix" ng-controller="moduleGroup" ng-cloak>
	<img src="{php echo tomedia($module['logo'])}" class="module-img" alt="">{if !empty($module['title'])}{$module['title']}{else}模板{/if}
	<div class="we7-header">
		分配应用权限组(这里来定义哪些应用权限组可使用{if !empty($module['title'])}{$module['title']} 功能{else}该模板{/if})
	</div>
	<div class="alert we7-page-alert we7-margin-top hidden">
		如果不选择可用权限组,则默认加入所有权限组
	</div>
	<form class="form we7-form we7-margin-top" action="" method="post" id="form1">
		<div class="form-group">
			<label class="col-sm-1 control-label">应用权限组</label>
			<div class="col-sm-11 form-controls">
				<div class="we7-group-show " ng-repeat="extend in moduleGroupList.groups" ng-if="extend.checked == 1">
					<input type="checkbox" name="group[]" checked value="{{extend.id}}">
					<div class="name">
						{{extend.name}}
					</div>
					<div class="group-app-list">
						<div class="group-app-item" ng-repeat="module in extend.modules_all">
							<img src="{{module.logo}}" class="module-img" alt="">
							<div class="info">
								<div class="title text-over">
									{{module.title}}
								</div>
								<div class="type-list">
									<i ng-class="itme.icon" ng-repeat="itme in module.group_support | moduleInfo" ></i>
								</div>
							</div>
						</div>
						<div class="group-app-item" ng-repeat="module in extend.templates">
							<img src="{{module.logo}}" class="template-img" alt="">
							<div class="info">
								<div class="title">
									{{module.title}}
								</div>
								<div class="type-list">
									<i class="wi wi-template"></i>
								</div>
							</div>
						</div>
					</div>
					<a class="action"></a>
					<a href="" class="remove" ng-click="extend.checked = 0"><i class="wi wi-error"></i></a>
				</div>
				<we7-modal-app module-list="moduleGroupList" multiple="true" on-confirm="groupConfirm()">
					<div class="add-new-block" >
						<i class="wi wi-plus"></i> 添加应用权限组
					</div>
				</we7-modal-app>
			</div>
		</div>
		<input type="hidden" name="flag" value="1">
		<input type="hidden" name="upgrade_flag" value="1">
		<input type="hidden" name="tid" value="{$tid}">
		<input type="hidden" name="support" value="{$module_support_name}">
		<div class="form-group col-sm-offset-1">
			<input type="submit" class="btn btn-primary" name="submit" value="确定继续安装{$module['title']}">
		</div>
	</form>

	<div class="distribution-steps">
		<div class="we7-margin-bottom-sm font-lg">分配应用权限的流程说明</div>
		<div class="steps-container">
			<div>
				<div class="num">1</div>
				<div class="title">
					<span class="wi wi-appjurisdiction"></span>添加应用权限组
				</div>
				<div class="content">
					设置应用权限组名称，选择需要添加的公众号应用、小程序应用、微站模板，保存提交。
					<div><a href="{php echo url('module/group/post')}" class="color-default">去添加应用组 ></a></div>
				</div>
			</div>
			<div>
				<div class="num">2</div>
				<div class="title">
					<span class="wi wi-distribution"></span>分配应用到应用权限组
				</div>
				<div class="content">
					选择上方相应的应用权限组，把应用添加到组中。或者到应用权限中编辑应用权限组。
					<div><a href="{php echo url('module/group')}" class="color-default">选择/去编辑应用组 ></a></div>
				</div>
			</div>
		</div>
	</div>
	<script>
		angular.module('moduleApp').value('config', {
			module_group: {php echo !empty($module_group) ? json_encode($module_group) : 'null'}
		});
		angular.module('moduleApp').controller('moduleGroup', ['$scope', 'config', function ($scope, config) {
			$scope.moduleGroupList = {
				groups: config.module_group
			}
			$scope.loadChange = function() {
				$('.we7-group-show').each(function() {
					$(this).removeClass('low');
					$(this).removeClass('closed');
					if($(this).find('.group-app-list').outerHeight() > 70) {
						$(this).removeClass('low');
						$(this).addClass('closed');
						$(this).find('.action').on('click', function() {
							$(this).parent().toggleClass('closed')
						})
					} else {
						$(this).addClass('low');
						$(this).removeClass('closed');
					}
				})
			}

			// 添加应用权限组
			$scope.groupConfirm = function() {
				setTimeout(function(){
					$scope.loadChange()
				}, 20)
			}
		}]);
		angular.bootstrap($('#js-module-group'), ['moduleApp']);
	</script>
</div>
{template 'common/footer'}
