<section>
	<div class='form' ng-controller="aclCtrl as formCtrl">
		<form novalidate="" class="css-form ng-pristine" name="">
			<div class="header"><h3 class="">{{translation.modifyProductPackage[LANG]}}: {{product.name}}</h3></div>
			
			<div class="body">
				<div ng-if="msg.type">
					<alert type="{{msg.type}}">{{msg.msg}}</alert>
					<br>
				</div>
				<div ng-if="environments_codes.length===0">
					<alert type="warning">No environments found.
						Add your environment before you can edit the ACL.
					</alert>
				</div>
				<div ng-if="oldACL===true">
					<alert type="warning">Your product ACL is still at the package Level and was done with the previous
						version of SOAJS. The new version of SOAJS allows you to create ACL at the product level and
						then package it. Either contact Soajs for support or click here to delete the old ACL and create
						a new one..
					</alert>
				</div>
				<tabset ng-if="oldACL!==true">
					<tab ng-repeat="oneEnv in environments_codes" heading="{{oneEnv.code}}"><br>
						<input type="text" class="form-control acl-search" ng-model="searchKeyword" placeholder="Search ..."/>
						<div id="generate-ApiList-{{oneEnv.code}}" class="entryServiceBoxes">
							<div id="s_{{oneEnv.code}}_{{group}}" ng-repeat="(group, services) in allServiceApis">
								<div ng-if="group === 'SOAJS Core Services'">
									<fieldset class="width100">
										<legend>{{group}}</legend>
										<div ng-repeat="service in services| reposSearchFilter:searchKeyword" class="clearfix service-container" ng-if="service.name !== 'controller'">
											<div class="clearfix serviceNameHead">
												<div ng-include="'modules/dashboard/productization/directives/service-name.tmpl'"></div>
											</div>
											<div ng-include="'modules/dashboard/productization/directives/api-permission.tmpl'"></div>
										</div>
									</fieldset>
								</div>
								<div ng-if="group !== 'SOAJS Core Services'">
									<fieldset class="width100">
										<legend>{{group}}</legend>
										<div ng-repeat="service in services.slice(((paginations[group].currentPage-1)*itemsPerPage), ((paginations[group].currentPage)*itemsPerPage))| reposSearchFilter:searchKeyword" class="clearfix service-container" ng-if="service.name !== 'controller'">
											<div class="clearfix serviceNameHead">
												<div ng-include="'modules/dashboard/productization/directives/service-name.tmpl'"></div>
											</div>
											<div ng-include="'modules/dashboard/productization/directives/api-permission.tmpl'"></div>
										</div>
										<table border="0" ng-if="group!== 'SOAJS Core Services'" cellspacing="0" cellpadding="0" width="100%" class="navigation">
											<tr>
												<td align="right">
													<pagination total-items="paginations[group].totalItems" ng-model="paginations[group].currentPage" max-size="maxSize" class="pagination-sm" boundary-links="true" rotate="false" num-pages="numPages" items-per-page="itemsPerPage"></pagination>
												</td>
											</tr>
										</table>
									</fieldset>
								</div>
							</div>
						</div>
					</tab>
				</tabset>
			</div>
			<div ng-if="oldACL!==true" class="footer" ng-if="environments_codes.length"><br/>
				<input type="submit" class="btn btn-sm btn-primary" ng-click="saveACL()" value="Save ACL"/>
			</div>
			<div ng-if="oldACL===true" class="footer"><br/>
				<input type="submit" class="btn btn-sm btn-danger" ng-click="purgeACL()" value="Purge ACL"/>
			</div>
		</form>
	</div>
</section>