Creating a new multiple action for a specific datalist

In the current project I’m working on there is a requirement that for one type of datalist the user should be able to select some of the items and based upon those items a pdf will be constructed and placed in a predefined folder in the document library.

One challenge in the implementation was to make the menu alternative only show up for one datalist type.

The server side javascript file responsible for displaying the drop-down menu is called data-list/toolbar.get.js, when putting this in the correct path mapped by your extension module to “site-webscripts/org/alfresco/components/data-lists/” our extended file will be processed after the alfresco original toolbar.get.js

First we need to make sure we add the menu alternative for the correct list. We will look at the query string to find out the name of the clicked list.

   var queryString = url.queryString;
   var listName = getQueryVariable('list', queryString);

   function getQueryVariable(variable, queryString) {
	var vars = queryString.split("&");
	for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
	return (false);
   }

Then we make a remote call to the Alfresco repository and ask for all datalists in the current site, looping them through and when we find the correct type of list and the name of the list matches we will push the new menu alternative onto the actionSet array.

   var site = page.url.templateArgs.site,
      theUrl = "/slingshot/datalists/lists/site/" + site + "/dataLists",
      result = remote.call(theUrl),
      canCreate = false,
      lists = [];
   
   if (result.status == 200)
   {
      response = JSON.parse(result.response);
      lists = response.datalists;
      
      var arrayLength = lists.length;
      for (var i = 0; i < arrayLength; i++) {
          if(lists[i].itemType=='somecodl:issueList' && lists[i].name==listName){
    		// add action for our list type
			model.actionSet.push({
				id : 'onActionCreateMeetingMinutes',
				type : 'action-link',
				permission : 'create',
				asset : '',
				href : '',
				label : 'menu.selected-items.meetingMinutes'
			});
          }
      }
   }

The final code will then look like this:


function extended_main(url){
	
   var queryString = url.queryString;
   var listName = getQueryVariable('list', queryString);

   var site = page.url.templateArgs.site,
      theUrl = "/slingshot/datalists/lists/site/" + site + "/dataLists",
      result = remote.call(theUrl),
      canCreate = false,
      lists = [];
   
   if (result.status == 200)
   {
      response = JSON.parse(result.response);
      lists = response.datalists;
      
      var arrayLength = lists.length;
      for (var i = 0; i < arrayLength; i++) {
          if(lists[i].itemType=='somecodl:issueList' && lists[i].name==listName){
    		// add action for Action List
			model.actionSet.push({
				id : 'onActionCreateMeetingMinutes',
				type : 'action-link',
				permission : 'create',
				asset : '',
				href : '',
				label : 'menu.selected-items.meetingMinutes'
			});
          }
      }
   }
	
   // Widget instantiation metadata...
   var toolbar = {
      id : "DataListToolbar",
      name : "Alfresco.component.DataListToolbar",
      options : {
         siteId : (page.url.templateArgs.site != null) ? page.url.templateArgs.site : ""
      }
   };
   
   model.widgets = [toolbar];
}

function getQueryVariable(variable, queryString) {
	var vars = queryString.split("&");
	for (var i = 0; i < vars.length; i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
	return (false);
}

extended_main(url);

When the new menu alternative is selected we will present a metadataform, and upon submission create a pdf in the documentLibrary, but thats another (yet to come) blogpost.

This entry was posted in Alfresco, datalists, Javascript. Bookmark the permalink.

34 Responses to Creating a new multiple action for a specific datalist

  1. I am genuinely pleased to read this blog
    posts which consists of plenty of helpful facts, thanks for providing these information.

  2. Verlene says:

    Hi there, I want to subscribe for this web site to
    take newest updates, so where can i do it please help out.

    • Trisha says:

      Emre,tat duyunuz konusuna üzüldüm, biz de yerine getirmek için çalışıyoruz ÅžiÅŸ House için ne yazık ki size katılmıyorum, çok titiz bir iÅnentml,ürüeleriŸin kalitesi çok yüksek.Selamlar

    • The “told you so” was referring to my allegation that the Spurs were the better team, which I think is quite clear. And I stand by Timmy. Best power forward EVER.

    • I just don’t know about this episode .I know what the facts they found were . I understand their conclusions , yet something about it does not ring true .Anyone else feeling a bit skeptical about this one ?

    • hehe und das erste unverschlüsselte Bild deiner Frau im Blog… wenn sie das rausfindet ;-) Habe heute noch meinSiemens C55 mit einem blauen Display. Sollte mir vielleicht mal ein neues kaufen heheBin Ende September bis Oktober wieder in Taiwan. Man könnte sich ja mal treffen von deguo-ren zu deguo-ren falls Zeit hast. Der Selbsthildeverein Taiwan geschädigter lao-wai Ehemänner wartet auf seine Gründung ;-) Komme auch nach Tapei..

    • ejemplo, pero ahora en el lado contrario. Si hablábamos hace unos días de aprender a gestionar la publicidad de una marca en determinadas webs, por la mala relación que se podía establecer entre el contenido donde iba insertada tu

    • I can't afford a Hermes birkin but I sure as hell wouldn't pose as somebody else to get one..This is so wrong on so many levels, that email to you is so rude. x

    • Tweet Florence on You are adorable and super awesome. Your blog is amazing,i’ve only watched you on Youtube but feel like i personally know you. Keep blogging…

    • http://www./ says:

      Bonjour,J’aimerais être informée des activités qui se dérouleront aux diverses places publiques soutenues par le Quartier des spectacles.Merci,Andrée Blais, Muséologue

    • This is an appalling situation. The London Metropolitan Police behaved not just in a shameful manner — they behaved in a real, totalitarian Police State manner. These are dangerous times. If peaceful protest against a serious and growing threat is removed from the people, then the people will eventually protest violently. — Paul WestonYep.And as I pointed out to some unreceptive Leftwingers recently, law and order is already breaking down all across Europe….in Muslim No Go Shariah Zones. Balkanization of much of Europe, will lead to predictable outcomes.EV

    • http://www./ says:

      What a great way to sneak in vegetables to a family favorite (and a great use for left over adobo sauce). It also seems like this recipe would be pretty flexible for changing out ingredients. Thank you for the inspiration.

    • http://www./ says:

      I love both sizzling rice and shrimp! Plus I keep on finding recipes with shrimp in them…I think it's a sign to stop being lazy and go buy some :)

    • http://www./ says:

      “Women are routinely sold into arranged marriages by their fathers who receive a dowry for the “sale”; the dowry sometimes issued in the form of goats or other forms of livestock.”Slavery.

    • http://www./ says:

      Die Idee ist so genial und so simpel, das musste ja einfach ein Knaller werden!Ich bin sowieso ein großer Fan dieser Fotoprojekte, aber das hier ist schon richtig, richtig weit vorne mit dabei!Nicht zuletzt, weil die Jungs einfach wirklich Freunde sind….

    • paradoxalement, je trouve un formidable espoir dans cette photo. certes, la violence est forte, mais en même temps, la confrontation est celle qu’on peut voir un peu partout dans le monde. « espoir » est peut-être excessif, mais il me semble qu’il y a là, dans ce corps-à-cors quelque chose de presque rassurant.

    • - It¡¦s really a nice and helpful piece of info. I¡¦m glad that you simply shared this useful information with us. Please keep us up to date like this. Thanks for sharing.

    • max can you stop others from sharing your cover photo ? it seems whenever i upload something cool, some one from my friends lists steals it by “sharing”

    • You are right Benny, everyday is a gift! I always try to improve and learn something new to help me get closer to my goals. More often than not it is a good idea to sit back and reflect upon all that surrounds us and as you’ve stated; focusing on the positives rather than the negatives will bring that what is desired.

    • I love that you share so much! Especially for someone like me who is just starting out in Boudoir. I pre-ordered your book a few weeks ago…can not wait for it to arrive! I’m sure you cover this in your book, but I am having trouble getting women to even want to pose for free photos (for portfolio building). How did you get the ball rolling? Any tips would be apreciated!

  3. I do not even know how I finished up here, however I
    believed this submit was once great. I don’t know who you are but
    certainly you’re going to a famous blogger in the event you are not
    already. Cheers!

  4. Freddy says:

    Thanks for the marvelous posting! I certainly enjoyed reading it, you will
    be a great author. I will make certain to bookmark your
    blog and may come back in the foreseeable future.
    I want to encourage one to continue your great work, have a nice evening!

  5. I’m glad that it turned out so effectively and I hope it will continue inside the future because it’s so interesting and meaningful towards the community.

  6. Very intriguing subject , thanks for putting up.

  7. This article will help the internet people for creating new blog or even a weblog from
    start to end.

  8. Sammie Garcias says:

    I discovered your site site on the internet and check some of your early posts. Continue to keep up the top notch operate. I recently additional increase your Feed to my MSN News Reader. Seeking forward to reading much more from you finding out later on!…

    http://tinyurl.com/ppupqu8

  9. I was more than happy to discover this website. I need to to thank you for ones time just for this fantastic read!! I definitely loved every bit of it and i also have you book-marked to see new stuff on your website.|

  10. webpage says:

    Hi, always i used to check webpage posts here in the early hours in the dawn, as i enjoy to find out more and more.|

  11. It’s all ahout Ray Ban Sunglasses click to view
    From : Ray Ban Justin vs Wayfarer

  12. Nancy DOR says:

    Hi,
    I am trying to had a new multiple action on Share too, your post helped me. However, I see my new action but it doesn’t work. I noticed that perharps we haven’t worked with the same Alfresco version. I am using Alfresco 4.2.f
    Could you help me to find what is wrong?

    I added in the toolbar.get.config.xml the line in the actionset :

    In C:\Alfresco\tomcat\webapps\share\components\data-lists\sample-action.js I added
    (I copied the onActionDuplicate in actions.js)
    (function()
    {
    Alfresco.service.DataListActions.prototype.onActionSample1 = function DL_onActionSample1(p_items)
    {
    var me = this,
    items = YAHOO.lang.isArray(p_items) ? p_items : [p_items],
    destinationNodeRef = new Alfresco.util.NodeRef(this.modules.dataGrid.datalistMeta.nodeRef),
    nodeRefs = [];

    for (var i = 0, ii = items.length; i < ii; i++)
    {
    nodeRefs.push(items[i].nodeRef);
    }

    this.modules.actions.genericAction(
    {
    success:
    {
    event:
    {
    name: "dataItemsDuplicated",
    obj:
    {
    items: items
    }
    },
    message: this.msg("message.duplicate.success", items.length)
    },
    failure:
    {
    message: this.msg("message.duplicate.failure")
    },
    webscript:
    {
    method: Alfresco.util.Ajax.POST,
    name: "duplicate/node/" + destinationNodeRef.uri
    },
    config:
    {
    requestContentType: Alfresco.util.Ajax.JSON,
    dataObj:
    {
    nodeRefs: nodeRefs
    }
    }
    });
    };
    })();

    In sample-action.css (next to sample-action.js) I added
    .toolbar .onActionSample
    {
    background-image: url(file-16.png) !important;
    }

    I added in the actions-common.get.head.ftl :

  13. spam scammer says:

    If you are going for most excellent contents like me, just go to see this web page daily because it offers quality contents, thanks|

  14. What’s up mates, how is the whole thing, and what you wish
    for to say about this piece of writing, in my view its actually
    awesome for me.

  15. It’s not it’s volume of Which I realize corresponds rather strongly to mass, but it’s not mass per se, but disruption of a magnetic

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>