-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix : Adding authority lightbox Javascript
- Loading branch information
git -v
committed
Feb 23, 2016
1 parent
3829c6c
commit c2d2462
Showing
2 changed files
with
157 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,156 +1,157 @@ | ||
@import component._ | ||
@import principal._ | ||
|
||
@import util._ | ||
@import org.apache.commons.collections.CollectionUtils | ||
@import org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition | ||
@import org.apache.chemistry.opencmis.commons.data.Ace | ||
|
||
@(repositoryId:String)(obj:org.apache.chemistry.opencmis.client.api.CmisObject)(members:List[model.Principal])(permissionDefinitions:List[PermissionDefinition] = null) | ||
|
||
@script(repositoryId)(permissionDefinitions)() | ||
|
||
<div class="container tab-pane"> | ||
<div class="row" style="margin-bottom:15px"> | ||
<div class="col-sm-6 col-md-6"> | ||
@if(Util.isFreezeCopy(obj, session)){ | ||
@lockedNotice(obj) | ||
}else{ | ||
@saveButton("permission-update") | ||
} | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-sm-6 col-md-6"> | ||
@searchBox("追加可能なメンバを検索") | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-sm-6 col-md-6"> | ||
@searchTable(Messages("view.node.permission.search.caption"))(members) | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-sm-12 col-md-12"> | ||
@selectedTable(Messages("view.node.permission.table.caption"))(members)(Util.zipWithId(obj.getAcl))(permissionDefinitions) | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
//binding:update | ||
$(document).on('click', "#permission-update", function(){ | ||
//build data | ||
|
||
var acl = []; | ||
$('#ps-selected-table tbody tr').each(function(i, row){ | ||
var json = {}; | ||
//principalId | ||
var id = $(row).children('.ps-id').text(); | ||
json['principalId'] = id; | ||
|
||
//Permission | ||
var permissionDefs = []; | ||
@if(CollectionUtils.isNotEmpty(permissionDefinitions)){ | ||
@for(pdf <- permissionDefinitions){ | ||
permissionDefs.push("@pdf.getId"); | ||
} | ||
} | ||
var permissionValue = []; | ||
for(var i=0; i<permissionDefs.length; i++){ | ||
var checked = $($(row).find('.permission-' + escape(permissionDefs[i]) + ' > input')[0]).prop('checked'); | ||
if(checked){ | ||
permissionValue.push(permissionDefs[i]); | ||
} | ||
} | ||
json['permission'] = permissionValue; | ||
|
||
//Inheritance | ||
var inheritance = $($(row).find('.inheritance > input')).prop('checked'); | ||
json['inheritance'] = inheritance; | ||
|
||
acl.push(json); | ||
}); | ||
|
||
var data = { | ||
acl :JSON.stringify(acl) | ||
}; | ||
|
||
$.ajax({ | ||
url : "@routes.Node.updatePermission(repositoryId, obj.getId)", | ||
type : 'POST', | ||
data : data, | ||
success : function(data){ | ||
alert("成功しました"); | ||
window.location.reload(); | ||
}, | ||
error : function(XMLHttpRequest, textStatus, errorThrown) { | ||
alert("XMLHttpRequest : " + XMLHttpRequest.status); | ||
alert("textStatus : " + textStatus); | ||
alert("errorThrown : " + errorThrown.message); | ||
} | ||
}); | ||
}); | ||
|
||
//binding: remove checkbox | ||
$('td.ps-remove > :checkbox').off().on('click', function(event){ | ||
var row = $(this).parent().parent(); | ||
var inheritance = $(row.find('td.inheritance > :checkbox')).prop('checked') | ||
//validation | ||
if(inheritance){ | ||
event.preventDefault(); | ||
alert("継承されている権限は操作できません。変更するには継承を解除してください") | ||
return; | ||
} | ||
}); | ||
|
||
//binding: permission checkbox | ||
$('td.permission > :checkbox').off().on('click', function(event){ | ||
var row = $(this).parent().parent(); | ||
var inheritance = $(row.find('td.inheritance > :checkbox')).prop('checked') | ||
//validation | ||
if(inheritance){ | ||
event.preventDefault(); | ||
alert("継承されている権限は操作できません。変更するには継承を解除してください") | ||
return; | ||
} | ||
}); | ||
|
||
//binding: ace's ineheritance | ||
$('td.inheritance > :checkbox').off().on('click', function(event){ | ||
var row = $(this).parent().parent(); | ||
|
||
//validation | ||
if(!row.hasClass("ace-inherited")){ | ||
event.preventDefault(); | ||
return; | ||
} | ||
|
||
//processing | ||
var principal = $(row.find('.ps-id')).html(); | ||
var originalPermissions = []; | ||
|
||
$.ajax(jsRoutes.controllers.Node.jsGetAce("@repositoryId", "@obj.getId", principal) | ||
).done(function(data){ | ||
originalPermissions = data["permissions"]; | ||
@if(CollectionUtils.isNotEmpty(permissionDefinitions)){ | ||
@for(pdf <- permissionDefinitions){ | ||
var checked = ($.inArray("@pdf.getId", originalPermissions) >= 0) ; | ||
$(row.find('.permission-' + escape("@pdf.getId") + ' > input')[0]).prop('checked', | ||
checked); | ||
} | ||
} | ||
}).fail(function(XMLHttpRequest, textStatus, errorThrown){ | ||
//TODO | ||
}).always(function(){ | ||
//TODO | ||
}); | ||
}); | ||
|
||
function escape(selector){ | ||
return selector.replace(':',"\\:"); | ||
} | ||
@import component._ | ||
@import principal._ | ||
|
||
@import util._ | ||
@import org.apache.commons.collections.CollectionUtils | ||
@import org.apache.chemistry.opencmis.commons.definitions.PermissionDefinition | ||
@import org.apache.chemistry.opencmis.commons.data.Ace | ||
|
||
@(repositoryId:String)(obj:org.apache.chemistry.opencmis.client.api.CmisObject)(members:List[model.Principal])(permissionDefinitions:List[PermissionDefinition] = null) | ||
|
||
@script(repositoryId)(permissionDefinitions)() | ||
|
||
<div class="container tab-pane"> | ||
<div class="row" style="margin-bottom:15px"> | ||
<div class="col-sm-6 col-md-6"> | ||
@if(Util.isFreezeCopy(obj, session)){ | ||
@lockedNotice(obj) | ||
}else{ | ||
@saveButton("permission-update") | ||
} | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-sm-6 col-md-6"> | ||
@searchBox("追加可能なメンバを検索") | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-sm-6 col-md-6"> | ||
@searchTable(Messages("view.node.permission.search.caption"))(members) | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col-sm-12 col-md-12"> | ||
@selectedTable(Messages("view.node.permission.table.caption"))(members)(Util.zipWithId(obj.getAcl))(permissionDefinitions) | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
//binding:update | ||
|
||
$('#permission-update').on('click', function(){ | ||
//build data | ||
|
||
var acl = []; | ||
$('#ps-selected-table tbody tr').each(function(i, row){ | ||
var json = {}; | ||
//principalId | ||
var id = $(row).children('.ps-id').text(); | ||
json['principalId'] = id; | ||
|
||
//Permission | ||
var permissionDefs = []; | ||
@if(CollectionUtils.isNotEmpty(permissionDefinitions)){ | ||
@for(pdf <- permissionDefinitions){ | ||
permissionDefs.push("@pdf.getId"); | ||
} | ||
} | ||
var permissionValue = []; | ||
for(var i=0; i<permissionDefs.length; i++){ | ||
var checked = $($(row).find('.permission-' + escape(permissionDefs[i]) + ' > input')[0]).prop('checked'); | ||
if(checked){ | ||
permissionValue.push(permissionDefs[i]); | ||
} | ||
} | ||
json['permission'] = permissionValue; | ||
|
||
//Inheritance | ||
var inheritance = $($(row).find('.inheritance > input')).prop('checked'); | ||
json['inheritance'] = inheritance; | ||
|
||
acl.push(json); | ||
}); | ||
|
||
var data = { | ||
acl :JSON.stringify(acl) | ||
}; | ||
|
||
$.ajax({ | ||
url : "@routes.Node.updatePermission(repositoryId, obj.getId)", | ||
type : 'POST', | ||
data : data, | ||
success : function(data){ | ||
alert("成功しました"); | ||
window.location.reload(); | ||
}, | ||
error : function(XMLHttpRequest, textStatus, errorThrown) { | ||
alert("XMLHttpRequest : " + XMLHttpRequest.status); | ||
alert("textStatus : " + textStatus); | ||
alert("errorThrown : " + errorThrown.message); | ||
} | ||
}); | ||
}); | ||
|
||
//binding: remove checkbox | ||
$('td.ps-remove > :checkbox').off().on('click', function(event){ | ||
var row = $(this).parent().parent(); | ||
var inheritance = $(row.find('td.inheritance > :checkbox')).prop('checked') | ||
//validation | ||
if(inheritance){ | ||
event.preventDefault(); | ||
alert("継承されている権限は操作できません。変更するには継承を解除してください") | ||
return; | ||
} | ||
}); | ||
|
||
//binding: permission checkbox | ||
$('td.permission > :checkbox').off().on('click', function(event){ | ||
var row = $(this).parent().parent(); | ||
var inheritance = $(row.find('td.inheritance > :checkbox')).prop('checked') | ||
//validation | ||
if(inheritance){ | ||
event.preventDefault(); | ||
alert("継承されている権限は操作できません。変更するには継承を解除してください") | ||
return; | ||
} | ||
}); | ||
|
||
//binding: ace's ineheritance | ||
$('td.inheritance > :checkbox').off().on('click', function(event){ | ||
var row = $(this).parent().parent(); | ||
|
||
//validation | ||
if(!row.hasClass("ace-inherited")){ | ||
event.preventDefault(); | ||
return; | ||
} | ||
|
||
//processing | ||
var principal = $(row.find('.ps-id')).html(); | ||
var originalPermissions = []; | ||
|
||
$.ajax(jsRoutes.controllers.Node.jsGetAce("@repositoryId", "@obj.getId", principal) | ||
).done(function(data){ | ||
originalPermissions = data["permissions"]; | ||
@if(CollectionUtils.isNotEmpty(permissionDefinitions)){ | ||
@for(pdf <- permissionDefinitions){ | ||
var checked = ($.inArray("@pdf.getId", originalPermissions) >= 0) ; | ||
$(row.find('.permission-' + escape("@pdf.getId") + ' > input')[0]).prop('checked', | ||
checked); | ||
} | ||
} | ||
}).fail(function(XMLHttpRequest, textStatus, errorThrown){ | ||
//TODO | ||
}).always(function(){ | ||
//TODO | ||
}); | ||
}); | ||
|
||
function escape(selector){ | ||
return selector.replace(':',"\\:"); | ||
} | ||
</script> |