Skip to content

Commit

Permalink
Merge pull request #194 from aegif/topic_2.3.10
Browse files Browse the repository at this point in the history
Topic 2.3.10
  • Loading branch information
sixpetals committed Mar 2, 2016
2 parents 012c051 + c2d2462 commit 6ba234b
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 162 deletions.
2 changes: 1 addition & 1 deletion ui/app/views/group/blank.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h3><i class="fa fa-user">@group.name</i>@Messages("view.group.create.caption")<
<!-- scripts -->
<script type="text/javascript">
//binding: create button
$(document).on('click','#group-create', function(){
$('#group-create').on('click', function(){
var users = [];
var groups = [];
$('#ps-selected-table :checkbox').each(function(i,chkbx){
Expand Down
4 changes: 2 additions & 2 deletions ui/app/views/menubar.scala.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@(repositoryId:String)
@(repositoryId:String, term:String = "")

@import constant.Token
@import util.Util
Expand Down Expand Up @@ -51,7 +51,7 @@
<li>
<form class="navbar-form" role="search" action="@routes.Node.search(repositoryId)" method="GET">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="term" id="srch-term">
<input type="text" class="form-control" placeholder="Search" name="term" id="srch-term" value="@term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
</div>
Expand Down
311 changes: 156 additions & 155 deletions ui/app/views/node/permission.scala.html
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>
8 changes: 4 additions & 4 deletions ui/app/views/node/search.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
<html>
@header()
<body>
@menubar(repositoryId)
@menubar(repositoryId, term)
<div class="container">
<div class="row">
<div class="col-md-11">
@Messages("view.node.search.term"): @term

<br/><br/>
</div>

<div class="col-md-11">
<div id="list">
@list(repositoryId)(objects)
@list(repositoryId)(objects)
</div>
</div>
</div>
Expand Down

0 comments on commit 6ba234b

Please sign in to comment.