Creating my own document type in Share (3.4)

I want to create my own type of document in the share environment.

Let start with adding it to the contentmodel.xml
……………..
<type name=”mjb:tnsDocument”>
<title>TNS Document</title>
<parent>cm:content</parent>
<mandatory-aspects>
<aspect>mjb:documentProperties</aspect>
<aspect>mjb:regionable</aspect>
<aspect>mjb:collectionable</aspect>
<aspect>cm:versionable</aspect>
</mandatory-aspects>
</type>
…………………….

Next, add it to the web-client-config-custom.xml
…………………….
<config evaluator=”string-compare” condition=”Content Wizards”>
<content-types>
<type name=”mjb:tnsDocument” display-label=”TNS Document” />
</content-types>
</config>
…..++…………………….
<config evaluator=”string-compare” condition=”Action Wizards”>
<aspects>
</aspects>
<subtypes>
<type name=”mjb:tnsDocument” />
<!– // Shown in is-subtype condition –>
</subtypes>
<specialise-types>
<type name=”mjb:tnsDocument” />
</specialise-types>
……….+++……………………….
<config evaluator=”node-type” condition=”mjb:tnsDocument”>
<property-sheet>
<separator name=”tnsDocument” display-label=”TNS Document” component-generator=”HeaderSeparatorGenerator” />
</property-sheet>
</config>
…………………………………

 

 

Advertenties

Custom Action in Share

I`ll extract the information from here; http://ecmarchitect.com/images/articles/alfresco-actions/actions-article-2ed.pdf  and here: http://wiki.alfresco.com/wiki/Custom_Actions
This post = just to be able to quickly grab the files I need to change to add more buttons.

In the Share project (part of the my personal Eclipse setup)

/web/share/components/documentlibrary/recalculate-workflow-action.css

CONTENT:
.doclist .onActionXopus a {    background-image: url(plaatje-16.gif) !important; }

/web/share/components/documentlibrary/recalculate-workflow-action.js

CONTENT:

/** DocumentList “Recalculate Workflow ” action **/
(function() {
Alfresco.doclib.Actions.prototype.onActionRecalculateWorkflow = function DL_onActionRecalculateWorkflow(asset)  {
nodeRef = new Alfresco.util.NodeRef(asset.nodeRef);
alert(“comment MJB=” + file.nodeRef);
}
} )  ( ) ;

/config/web-extensions/site-webscripts/org/alfresco/components/documentlibrary/actions-common.get.head.ftl

…..add this line …..
<#– WF Action –>
<@link rel=”stylesheet” type=”text/css” href=”${page.url.context}/res/components/documentlibrary/recalculate-workflow-action.css” />
<script type=”text/javascript” src=”${page.url.context}/res/components/documentlibrary/recalculate-workflow-action.js”></script>
……………………………..

/config/web-extensions/site-webscripts/org/alfresco/components/documentlibrary/documentlist.get.config.xml

…..add this line …..
<action type=”action-link” id=”onActionRecalculateWorkflow” permission=”edit” label=”actions.document.recalculateWorkflow” />
…………………………

 

… there is still something missing here….

..  i’ll figure that out soon….

Making a Dashlet work in Alfresco Share

Go to this folder : (this is where my tomcat/alfresco3.4.4 is installed)

C:\alfresco-enterprise-tomcat-3.4.4\tomcat\shared\classes\alfresco\web-extension\site-webscripts\org\alfresco\components\dashlets\

Add three files :

mjb.get.desc.xml

<webscript>
   <shortname>MJB</shortname>
   <description>MJB's test Dashlet</description>
   <family>user-dashlet</family>
   <url>/components/dashlets/mjb</url>
</webscript>

mjb.get.html.ftl

<div class="dashlet">
   <div class="title">${title}</div>
   <div class="body">
	<div> cmisQuery       = ${cmisQuery!""} </div>
	<div> Aantal entries  = ${no_entries!""} </div>
   	<div> props[icon]     = ${props["icon"]!""} </div>
      	<div> props[propName] = ${props["propName"]!""} </div>
	<div> doc             = ${doc!""} </div>
	<div> object          = ${object!""} </div>
	<div> properties      = ${properties!""} </div>
	<div> Qname           = ${Qname!""} </div>
	<div> propName        = ${text!""} </div>
	<div> name	      = ${name!""} </div>
   </div>
</div>

mjb.get.js

// Needs to come from cmis:document because cmis:file returns nothing
var selectString =  "SELECT d.*, t.*, a.* FROM cmis:document AS d " +
		    "JOIN cm:titled AS t ON d.cmis:objectId = t.cmis:objectId " +
		    "JOIN cm:author AS a ON d.cmis:objectId = a.cmis:objectId " +
		    "WHERE IN_FOLDER(d, 'workspace://SpacesStore/560b8dd6-6503-4ad5-8066-5946c1456ec1') " +
		    "ORDER BY d.cmis:name"

var cmisQuery = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><cmis:query xmlns:cmis=\"http://docs.oasis-open.org/ns/cmis/core/200908/\"><cmis:statement>" + selectString + "</cmis:statement></cmis:query>";

// get the documents for the currently active site
var conn = remote.connect("alfresco");

var result = conn.post(stringUtils.urlEncodeComponent("/cmis/queries"), cmisQuery, "application/cmisquery+xml");

	if (result != null) {model.title = "ik krijg iets terug van de query";} else { model.title = "ik krijg niets terug van de query"; }
	model.title = "resultset from query";	// Titel voor de dashlet
	model.result = result;					// keihard de XML -als ruw block data- overgooien.
	model.cmisQuery = cmisQuery;			// Query weergeven

// Lets make a proof of the pudding model.
model.nodes=createModel(atom.toFeed(result));

function getElementByTagName(list, elTagName) {
   var el;
   for (var i = 0, l = list.size(); i < l; i++) {
      el = list.get(i);
      if (el.QName.localPart == elTagName) {
	 model.Qname = el;
         return el;
      }
   }
   return null;
}

function createModel(feed) {
  var list = new Array();
  var entries = feed.getEntries();
  model.entries = entries;
  model.no_entries = entries.size();

  for (var i=0; i < entries.size(); i++) {
    var doc = entries.get(i);
        model.doc = doc;
    var object =  doc.getExtension(atom.createQName("http://docs.oasis-open.org/ns/cmis/restatom/200908/","object"));
    model.object = object;
	properties = getElementByTagName(object.getElements(), "properties");
	model.properties = properties;
    propertiesList = properties.getElements();
	var props = new Array();
	props["icon"] = doc.getExtension(atom.createQName("http://www.alfresco.org","icon")).getText();

	model.text = "";
	var mjb = true;

    for (var j = 0; j < propertiesList.size(); j++) {
      property = propertiesList.get(j);
      if (property != null && property.firstChild != null) {
		 model.text += property.getAttributeValue("propertyDefinitionId");

		 if ((property.getAttributeValue("propertyDefinitionId") == "cmis:name") && (mjb = true)) {
			mjb = false;
			//found cmis:name
			model.name = property.firstChild.text;
		 }
		 var propName = localPart(property.getAttributeValue("propertyDefinitionId"));
		 props[propName] = property.firstChild.text;
		 model.propName = propName;
      }
    }
	model.props = props;
	list[i] = props;
  }
  return list;
}

function localPart(qName){
  return qName.substring(qName.lastIndexOf(":") + 1, qName.length());
}

Note that the workspace ID works for me – but will not work for you. You will need to replace this : workspace://SpacesStore/560b8dd6-6503-4ad5-8066-5946c1456ec1
with a noderef to a directory with a files in it.

Get your own noderef by going into Alfresco – find  a nice looking directory – go to “View Details” – find the Alfresco Node Reference link – right-click and “Copy link adress” which has a similar format (workspace://SpacesStore/some-numbers-and-letters-with-dashes) Paste this is the javascript file (mjb.get.js)

Once the files are in place, your need to update the Alfresco Share webscripts library:
http://localhost:8080/share/page/index
Press the refresh button – you should see 1 more webscript available.
Then login to share
http://localhost:8080/share
Click ‘dashboard wijzigen’ and drag your new dashlet (called MJB) into it.

Yes I know it is very dirty code. It’s even throwing horrible looking output.
But it’s just a small proof of the pudding that shows it’s working.