Skip to content

Commit

Permalink
Merge pull request #155 from csKyou/master
Browse files Browse the repository at this point in the history
Fixed an issue where profile.json's public setting is not working whe…
  • Loading branch information
Dixon Siu authored Feb 19, 2019
2 parents 5e9d24d + 3435b6d commit baeb1c1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 35 deletions.
57 changes: 50 additions & 7 deletions src/html/js/cellProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ cellProfile.prototype.retrieveCollectionAPIResponse = function (json, operationP
if (!baseUrl.endsWith("/")) {
baseUrl += "/";
}
var path = sessionStorage.selectedcellUrl+"__/";
var accessor = objCommon.initializeAccessor(getClientStore().baseURL, cellName,"","");
var objCellManager = new _pc.CellManager(accessor);
var path = objCellManager.getCellUrl(cellName)+"__/";
if (profileLng) {
path += "locales/" + profileLng;
}
Expand All @@ -193,7 +195,7 @@ cellProfile.prototype.retrieveCollectionAPIResponse = function (json, operationP
/**
* The purpose of this function is to update cell profile.
*/
cellProfile.prototype.updateCellProfile = function() {
cellProfile.prototype.updateCellProfile = function() {
var displayName = document.getElementById("editDisplayName").value;
var description = document.getElementById("editDescription").value;
var fileData = null;
Expand All @@ -205,6 +207,7 @@ cellProfile.prototype.updateCellProfile = function() {
var validDesciption = uCellProfile.validateDescription(description,"popupEditDescriptionErrorMsg");
if (validDesciption){
var prof = this.getCellProfileInfo();
var status = prof.getStatusCode();
prof = prof.bodyAsJson();
if (document.getElementById("editDisplayName").dataset.CellType == "App") {
// If cellType is App, update en of existing profile.json
Expand All @@ -222,11 +225,16 @@ cellProfile.prototype.updateCellProfile = function() {
"ProfileImageName" : profileBoxImageName
};
}
$.extend(
true,
prof,
latestProf
);
if (status == 200) {
$.extend(
true,
prof,
latestProf
);
} else {
prof = latestProf;
}

fileData = prof;
var selectedLng = $("#profileLngList").val();
response = uCellProfile.retrieveCollectionAPIResponse(fileData, "EDIT",sessionStorage.selectedcell, selectedLng);
Expand Down Expand Up @@ -948,9 +956,44 @@ cellProfile.prototype.createFirstCellProfile = function(displayName,descriptionD
var accessor = objCommon.initializeAccessor(getClientStore().baseURL, sessionStorage.selectedcell,"","");
var objCellManager = new _pc.CellManager(accessor);
sessionStorage.selectedcellUrl = objCellManager.getCellUrl(sessionStorage.selectedcell);
if (scopeSelection == "Public") {
this.appendAllReadACLToProfile();
}
}
};

cellProfile.prototype.appendAllReadACLToProfile = function() {
var baseUrl = getClientStore().baseURL;
if (!baseUrl.endsWith("/")) {
baseUrl += "/";
}
var cellName = sessionStorage.selectedcell;
var path = sessionStorage.selectedcellUrl + "__/profile.json";
var accessor = objCommon.initializeAccessor(baseUrl, cellName);
var objJDavCollection = new _pc.DavCollection(accessor, path);
var objXmlBaseUrlRole = new _pc.Role(accessor);
objXmlBaseUrlRole.setBoxName("[main]");
var resourceBaseUrl = objXmlBaseUrlRole.getResourceBaseUrl();
var boxName = null;
var roleName = "all (anyone)";
json = {
"Name" : roleName,
"_Box.Name" : boxName
};
var objJRole = new _pc.Role(accessor, json);
var objJAcl = new _pc.Acl();
objJAcl.setBase(resourceBaseUrl);
objAce = new _pc.Ace();
objAce.setRole(objJRole);
objAce.setPrincipal('all');
objAce.addPrivilege("D:read");
objJAcl.addAce(objAce);

var objJAclManager = new _pc.AclManager(accessor, objJDavCollection);
var response = objJAclManager.setAsAcl(objJAcl);
return response;
}

//Methods for Expand and collapse - More/Less Start.
/**
* The purpose of this method is to create more/less link functionality
Expand Down
8 changes: 4 additions & 4 deletions src/html/js/dataManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -3225,9 +3225,9 @@ dataManagement.prototype.validateFieldsPerType = function(edit) {
* @param propVal
* @returns {Array}
*/
dataManagement.prototype.getListData = function(propVal) {
dataManagement.prototype.getListData = function(propVal, propType) {
var arrayData = propVal.split(',');
if(propVal.indexOf('、') != -1){
if(propType != "Edm.String" && propVal.indexOf('、') != -1){
arrayData = propVal.split('、');
}
var noOfItems = arrayData.length;
Expand Down Expand Up @@ -3270,7 +3270,7 @@ dataManagement.prototype.createJsonData = function(edit) {
} else if (uDataManagement.propertyDetailsList[index][2] == "List") {
var propName = uDataManagement.propertyDetailsList[index][0];
var propVal = $(elem + index).val();
var propValData = uDataManagement.getListData(propVal);
var propValData = uDataManagement.getListData(propVal, uDataManagement.propertyDetailsList[index][1]);
json[propName] = propValData;
}
}
Expand All @@ -3288,7 +3288,7 @@ dataManagement.prototype.createJsonData = function(edit) {
if ($(elem + index).val() != "") {
var propName = uDataManagement.propertyDetailsList[index][0];
var propVal = $(elem + index).val();
var propValData = uDataManagement.getListData(propVal);
var propValData = uDataManagement.getListData(propVal, uDataManagement.propertyDetailsList[index][1]);
json[propName] = propValData;
}
}
Expand Down
23 changes: 0 additions & 23 deletions src/html/templates/en/cellListView.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,29 +161,6 @@
return false;
}

function createCell(accessor, objCell, objCellManager) {
var cell = objCellManager.create(undefined, objCell, null, null, null);
if ($('#chkAdmin').is(':checked')) {
var roleName = document.getElementById("txtRoleName").value;
createRoleFromCellWindow(accessor, roleName, cell.name);
}

//When Create Profile is checked.
if ($('#chkCreateProfile').is(':checked')) {
var displayName = $("#txtCellDisplayName").val();
var descriptionDetails = document.getElementById("txtCellDescription").value;
var scopeSelection = $("#btnPublic").val();
if ($('#btnPrivate').is(':checked')) {
scopeSelection = $("#btnPrivate").val();
}
uCellProfile.createFirstCellProfile(displayName,descriptionDetails,cell.name, scopeSelection);
}

reloadCellList(cell.name);
removeSpinner("modalSpinnerCellList");
return true;
}

/* The purpose of this function is to reload the cell list.
*/
function reloadCellList(createdCellName) {
Expand Down
2 changes: 1 addition & 1 deletion src/html/templates/en/schemaManagement.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
//enable display if properties are present
$('#PropertyViewBody').show();
var entityTypeNames = uEntityTypeOperations.fetchEntityTypes(sessionStorage.selectedCollectionURL);
uEntityTypeOperations.updatePropertyView(entityTypeNames[0]);
uEntityTypeOperations.updatePropertyView(entityTypeNames[sessionStorage.selectedEntityTypeCount]);
}else{
document.getElementById("PropertyViewEmptyBody").style.display = "block";
}
Expand Down

0 comments on commit baeb1c1

Please sign in to comment.