Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aspect support for cm:content #100

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@
<tokenised>false</tokenised>
</index>
</property>
<property name="up:allowedProxyTypes">
<title>Allowed proxy types</title>
<type>d:text</type>
<mandatory>false</mandatory>
<multiple>true</multiple>
<index enabled="true">
<atomic>true</atomic>
<stored>false</stored>
<tokenised>false</tokenised>
</index>
</property>
</properties>
</aspect>
</aspects>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ while (destNode !== null && !destNode.hasAspect("up:UploadFolder")) {

if (destNode === null) {
model.types = null;
model.proxyTypes = null;
} else {
model.types = destNode.properties["up:allowedTypes"];
model.proxyTypes = destNode.properties["up:allowedProxyTypes"];
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,16 @@
<#else>
null
</#if>
,
"proxyTypes" :
<#if proxyTypes??>
[
<#list proxyTypes as proxyType>
"${proxyType}"<#if proxyType_has_next>,</#if>
</#list>
]
<#else>
null
</#if>
}
</#escape>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
"${allowedType}"<#if allowedType_has_next>,</#if>
</#list>
</#if>
],
"allowedProxyTypes": [
<#if node.properties["up:allowedProxyTypes"]??>
<#list node.properties["up:allowedProxyTypes"] as allowedProxyType>
"${allowedProxyType}"<#if allowedProxyType_has_next>,</#if>
</#list>
</#if>
]
}<#if node_has_next>,</#if>
</#list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if (node.hasAspect("up:UploadFolder")) {
} else {
var props = new Array(2);
props["up:allowedTypes"] = null;
props["up:allowedProxyTypes"] = null;
node.addAspect("up:UploadFolder", props);
node.save();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"node": {
"nodeRef": "${node.nodeRef}",
"path": "${node.displayPath}\/${node.properties.name}",
"allowedTypes": []
"allowedTypes": [],
"allowedProxyTypes": []
}
}
</#escape>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
title.path = Path
title.allowed.types = Allowed types
title.allowed.proxyTypes= Allowed proxy types
title.actions = Actions
loading.folders = Loading folders
no.folders.found = No folders found
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ div.yui-u.edit-metadata.flat-button {
display: none;
}

.form-container select.supported-types-select {
.form-container select.supported-types-select, .form-container select.supported-proxy-types-select {
width: 100%;
height: 20em;
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ YAHOO.extend(SoftwareLoop.UploaderPlusAdmin, Alfresco.component.Base, {
sortable: false,
formatter: SoftwareLoop.hitch(this, this.allowedTypesFormatter)
},
{
key: "allowedProxyTypes",
label: this.msg("title.allowed.proxyTypes"),
sortable: false,
formatter: SoftwareLoop.hitch(this, this.allowedTypesFormatter)
},
{
key: "actions",
label: this.msg("title.actions"),
Expand All @@ -116,7 +122,7 @@ YAHOO.extend(SoftwareLoop.UploaderPlusAdmin, Alfresco.component.Base, {
connXhrMode: "queueRequests",
responseSchema: {
resultsList: "results",
fields: ["path", "nodeRef", "allowedTypes"]
fields: ["path", "nodeRef", "allowedTypes", "allowedProxyTypes"]
}
});

Expand Down Expand Up @@ -299,10 +305,11 @@ YAHOO.extend(SoftwareLoop.UploaderPlusAdmin, Alfresco.component.Base, {
titleNode.innerHTML =
Alfresco.util.encodeHTML(this.prettyPath(data.path));
}
var selectNode = YAHOO.util.Dom.getElementsByClassName(
var supportedTypes = YAHOO.util.Dom.getElementsByClassName(
"supported-types-select", "select")[0];

this.populateAllowedTypesSelect(selectNode);
var supportedProxyTypes = YAHOO.util.Dom.getElementsByClassName(
"supported-proxy-types-select", "select")[0];
this.populateAllowedTypesSelect(supportedTypes, supportedProxyTypes);

return true;
},
Expand All @@ -313,6 +320,7 @@ YAHOO.extend(SoftwareLoop.UploaderPlusAdmin, Alfresco.component.Base, {
Alfresco.logger.debug("onSuccess callback", arguments);
var dataObj = response.config.dataObj;
data.allowedTypes = dataObj.prop_up_allowedTypes.split(",");
data.allowedProxyTypes = dataObj.prop_up_allowedProxyTypes.split(",");
this.widgets.dataTable.updateRow(record, data);
Alfresco.util.PopupManager.displayMessage({
text: this.msg("operation.completed.successfully")
Expand Down Expand Up @@ -369,12 +377,18 @@ YAHOO.extend(SoftwareLoop.UploaderPlusAdmin, Alfresco.component.Base, {
Alfresco.logger.debug("END deleteUploadFolderHandler");
},

populateAllowedTypesSelect: function (selectNode) {
populateAllowedTypesSelect: function (allowedTypes, allowedProxyTypes) {
Alfresco.logger.debug("populateAllowedTypesSelect", arguments);
var selectedValues = selectNode.getAttribute("data-selectedValues");
var selectedValuesArray = [];
if (selectedValues) {
selectedValuesArray = selectedValues.split(",");
var selectedAllowedTypeValues = allowedTypes.getAttribute("data-selectedValues");
var selectedAllowedTypeValuesArray = [];
if (allowedTypes) {
selectedAllowedTypeValuesArray = selectedAllowedTypeValues.split(",");
}

var selectedAllowedProxyTypeValues = allowedProxyTypes.getAttribute("data-selectedValues");
var selectedAllowedProxyTypeValuesArray = [];
if (allowedProxyTypes) {
selectedAllowedProxyTypeValuesArray = selectedAllowedProxyTypeValues.split(",");
}
Alfresco.util.Ajax.jsonGet({
url: this.listContentTypesUrl,
Expand All @@ -386,15 +400,31 @@ YAHOO.extend(SoftwareLoop.UploaderPlusAdmin, Alfresco.component.Base, {
for (var i = 0; i < types.length; i++) {
Alfresco.logger.debug("Type index", i);
var type = types[i];
var selected = selectedValuesArray.indexOf(type) > -1;
var selected = selectedAllowedTypeValuesArray.indexOf(type) > -1;

var typeName = this.msg("type." + type.replace(":", "_"));
if (typeName.lastIndexOf("type.", 0) === 0) {
typeName = type;
}

var option = new Option(typeName, type);
selectNode.add(option);
allowedTypes.add(option);
option.selected = selected;
}

var types = response.json.types;
for (var i = 0; i < types.length; i++) {
Alfresco.logger.debug("Type index", i);
var type = types[i];
var selected = selectedAllowedProxyTypeValuesArray.indexOf(type) > -1;

var typeName = this.msg("type." + type.replace(":", "_"));
if (typeName.lastIndexOf("type.", 0) === 0) {
typeName = type;
}

var option = new Option(typeName, type);
allowedProxyTypes.add(option);
option.selected = selected;
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"/uploader-plus/allowed-content-types",

types : null,
proxyTypes : null,

typesLoaded : false,

Expand Down Expand Up @@ -53,6 +54,7 @@
fn: function (response) {
Alfresco.logger.debug("loadTypes successCallback", arguments);
this.types = response.json.types;
this.proxyTypes = response.json.proxyTypes;
this.typesLoaded = true;

if (callback) {
Expand Down Expand Up @@ -271,7 +273,14 @@
var formRuntime = this.formUi.formsRuntime;
var form = Dom.get(formRuntime.formId);
var propertyData = formRuntime._buildAjaxForSubmit(form);
propertyData.contentType = contentType;

//Replace content type with cm:content for proxy types, to allow aspects to be added
if (this.proxyTypes && this.proxyTypes.indexOf(contentType)!==-1) {
propertyData.contentType = "cm:content";
} else {
propertyData.contentType = contentType;
}

this.fileStore[data.id].propertyData = propertyData;
Alfresco.logger.debug("END processMetadata", propertyData);
},
Expand Down
10 changes: 10 additions & 0 deletions surf/src/main/resources/META-INF/share-config-custom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
<form>
<field-visibility>
<show id="up:allowedTypes"/>
<show id="up:allowedProxyTypes"/>
</field-visibility>
</form>
<form id="upload-folder">
<field-visibility>
<show id="up:allowedTypes"/>
<show id="up:allowedProxyTypes"/>
</field-visibility>
<edit-form
template="../documentlibrary/forms/doclib-simple-metadata.ftl"/>
Expand All @@ -33,6 +35,14 @@
</control-param>
</control>
</field>
<field id="up:allowedProxyTypes">
<control
template="/com/softwareloop/uploader-plus/controls/selecttypes.ftl">
<control-param name="styleClass">
supported-proxy-types-select
</control-param>
</control>
</field>
</appearance>
</form>
</forms>
Expand Down