Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
alfresco-inboxes-how-to-customise-the-results-view
define([
"dojo/_base/declare",
"dojo/_base/lang",
"dojo/date/locale",
"./Item",
"softwareloop/cmis/cmis"
], function (declare, lang, locale, Item, cmis) {
return declare([Item], {
composeLines: function () {
var dossierPicture = this.entry.getAttributeValue("owd:dossierPicture");
this.previewUrl = lang.replace(
"{proxyUri}api/node/workspace/SpacesStore/{entryId}/content/thumbnails/doclib?c=queue&ph=true&lastModified=1",
{
proxyUri: Alfresco.constants.PROXY_URI,
entryId: dossierPicture.substring(24)
}
);
this.escapedLine1 = this.encodeHTML(
this.entry.getAttributeValue("cmis:name"));
var dossierPersonnelNumber =
this.entry.getAttributeValue("owd:dossierPersonnelNumber");
this.escapedLine2 = this.encodeHTML(
"Personnel number: " + dossierPersonnelNumber);
var line3 = this.message(
"modified.on.by",
{
date: locale.format(this.entry.getAttributeValue("cmis:lastModificationDate"), {
formatLength: "medium",
locale: Alfresco.constants.JS_LOCALE.substring(0, 2)
}),
user: this.entry.getAttributeValue("cmis:lastModifiedBy")
}
);
this.escapedLine3 = this.encodeHTML(line3);
var line4 = "Knowledge: " +
this.entry.getAttributeValues("owd:knowledge").join(", ");
this.escapedLine4 = this.encodeHTML(line4);
this.escapedTag = this.encodeHTML(
this.entry.getAttributeValue("owd:dossierStatus"));
this.approveLabel = "Mark active";
this.rejectLabel = "Mark retired";
var filter = "path|" +
encodeURIComponent(this.entry.getAttributeValue("cmis:path"));
this.downloadUrl = lang.replace(
"{pageContext}repository#filter={filter}&page=1",
{
pageContext: Alfresco.constants.URL_PAGECONTEXT,
filter: encodeURIComponent(filter)
}
);
this.downloadLabel = "View in repository";
},
approveAction: function () {
this.updateStatus("Active");
},
rejectAction: function () {
this.updateStatus("Retired");
},
updateStatus: function (status) {
var url = lang.replace(
"{proxyUri}cmis/s/workspace:SpacesStore/i/{entryId}",
{
proxyUri: Alfresco.constants.PROXY_URI,
entryId: this.entry.id
}
);
var dossierStatus = this.entry.attributes["owd:dossierStatus"];
dossierStatus.values[0] = status;
var updateAttributes = {};
updateAttributes["owd:dossierStatus"] = dossierStatus;
cmis.updateEntry(url, updateAttributes, function() {
location.reload(false);
});
}
});
});
<inbox id="Dossiers"
iconClass="foundicon-paper-clip"
itemClass="softwareloop/inboxes/Dossier">
<query><![CDATA[
SELECT *
FROM owd:dossier AS d
]]></query>
</inbox>
<inboxes>
<group id="my-documents">
<inbox id="Dossiers" iconClass="foundicon-paper-clip" itemClass="softwareloop/inboxes/Dossier">
<query><![CDATA[
SELECT *
FROM owd:dossier
]]></query>
</inbox>
<inbox id="for-my-approval" iconClass="foundicon-inbox">
<query><![CDATA[
SELECT d.*, t.*
FROM cmis:document AS d
JOIN cm:titled AS t on d.cmis:objectId = t.cmis:objectId
WHERE contains(d, 'PATH:"/app:company_home/st:sites/cm:swsdp/cm:documentLibrary/cm:Budget_x0020_Files/cm:Invoices/*"')
]]></query>
</inbox>
<inbox id="overdue" iconClass="foundicon-clock">
<query><![CDATA[
SELECT d.*, t.*
FROM cmis:document AS d
JOIN cm:titled AS t on d.cmis:objectId = t.cmis:objectId
WHERE contains(d, 'PATH:"/app:company_home/st:sites/cm:swsdp/cm:documentLibrary/cm:Agency_x0020_Files/cm:Contracts/*"')
]]></query>
</inbox>
<inbox id="high-priority" iconClass="foundicon-flag">
<query><![CDATA[
SELECT d.*, t.*
FROM cmis:document AS d
JOIN cm:titled AS t on d.cmis:objectId = t.cmis:objectId
WHERE contains(d, 'PATH:"/app:company_home/st:sites/cm:swsdp/cm:documentLibrary/cm:Agency_x0020_Files/cm:Mock-Ups/*"')
]]></query>
</inbox>
</group>
<group id="archive">
<inbox id="invoices" iconClass="foundicon-page">
<query><![CDATA[
SELECT d.*, t.*
FROM cmis:document AS d
JOIN cm:titled AS t on d.cmis:objectId = t.cmis:objectId
WHERE d.cmis:objectTypeId='cmis:document'
AND d.cmis:createdBy = 'mjackson'
]]></query>
</inbox>
<inbox id="purchase-orders" iconClass="foundicon-left-arrow">
<query><![CDATA[
SELECT d.*, t.*
FROM cmis:document AS d
JOIN cm:titled AS t on d.cmis:objectId = t.cmis:objectId
WHERE d.cmis:objectTypeId='cmis:document'
AND d.cmis:createdBy = 'abeecher'
]]></query>
</inbox>
<inbox id="quotations" iconClass="foundicon-right-arrow">
<query><![CDATA[
SELECT d.*, t.*
FROM cmis:document AS d
JOIN cm:titled AS t on d.cmis:objectId = t.cmis:objectId
WHERE contains(d, 'PATH:"/app:company_home/st:sites/cm:swsdp/cm:documentLibrary/cm:Presentations/*"')
]]></query>
</inbox>
<inbox id="marketing-documents" iconClass="foundicon-globe">
<query><![CDATA[
SELECT d.*, t.*
FROM cmis:document AS d
JOIN cm:titled AS t on d.cmis:objectId = t.cmis:objectId
WHERE contains(d, 'PATH:"/app:company_home/st:sites/cm:swsdp/cm:documentLibrary/cm:Agency_x0020_Files/cm:Images/*"')
]]></query>
</inbox>
</group>
</inboxes>
<div class="inboxes-item">
<div class="inbox-item-icon"><img src="${previewUrl}"></div>
<div class="inbox-item-description">
<div class="inboxes-item-line1">
<div class="inboxes-item-float-right inboxes-item-show-on-hover">
<button class="inboxes-item-button inboxes-item-button-approve"
data-dojo-attach-event="click:approveAction">${approveLabel}
</button>
<button class="inboxes-item-button inboxes-item-button-reject"
data-dojo-attach-event="click:rejectAction">${rejectLabel}
</button>
</div>
<h2>
${escapedLine1}
<span class="inboxes-item-tag">${escapedTag}</span>
</h2>
</div>
<div class="inboxes-item-line2">
<h3>${escapedLine2}</h3>
</div>
<div class="inboxes-item-line3">
<div class="inboxes-item-float-right inboxes-item-show-on-hover">
<a class="download-link" href="${downloadUrl}">${downloadLabel}</a>
</div>
${escapedLine3}
</div>
<div class="inboxes-item-line4">
${escapedLine4}
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment