From f4e41bdbf58c068f56ef304e3c37463416613c97 Mon Sep 17 00:00:00 2001 From: nilspreusker Date: Fri, 22 Oct 2010 16:00:45 +0000 Subject: [PATCH] added view of artifact links and first shot at event handling for artifact links --- .../webapp/components/artifact/artifact.js | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/modules/activiti-webapp-cycle/src/main/webapp/components/artifact/artifact.js b/modules/activiti-webapp-cycle/src/main/webapp/components/artifact/artifact.js index 207f52600e..2db5d04906 100644 --- a/modules/activiti-webapp-cycle/src/main/webapp/components/artifact/artifact.js +++ b/modules/activiti-webapp-cycle/src/main/webapp/components/artifact/artifact.js @@ -130,6 +130,23 @@ this._tabView.addTab(tab); } + // ------------------------------ Links Tab -- + + // Add artifact links tab + var linksTab = new YAHOO.widget.Tab({ + label: "Links", + dataSrc: Activiti.service.REST_PROXY_URI_RELATIVE + "artifact-links?connectorId=" + encodeURIComponent(artifactJson.connectorId) + "&artifactId=" + encodeURIComponent(artifactJson.artifactId), + cacheData: true + }); + + linksTab.loadHandler.success = function(response) { + me.onLodLinksSuccess(this /* the tab */, response); + }; + + this._tabView.addTab(linksTab); + + // -------------------------- End Links Tab -- + this._tabView.appendTo('artifact-div'); // replace the tabViews onActiveTabCHange evnet handler with our own one @@ -234,6 +251,41 @@ } }, + onLodLinksSuccess: function Artifact_onLodLinksSuccess(tab, response) { + try{ + var responseJson = YAHOO.lang.JSON.parse(response.responseText); + + tab.set('content', '
'); + + var linksColumnDefs = [ + {key:"Name", sortable:true}, + {key:"Revision", sortable:true}, + {key:"Type"} + ]; + + var rows = []; + for(var i=0; i' + responseJson[i].label + '', Revision: responseJson[i].targetArtifactRevision, Type: responseJson[i].targetContentType }; + rows.push(row); + } + var linksDataSource = new YAHOO.util.LocalDataSource(rows); + + linksDataSource.responseSchema = { + fields: ["Name","Revision","Type"] + }; + + var linksDataTable = new YAHOO.widget.DataTable("linksTab", linksColumnDefs, linksDataSource, {scrollable:true}); + + var linkElements = Dom.getElementsByClassName("openArtifactLink", "a"); + for (var i = 0; i < linkElements.length; i++) { + YAHOO.util.Event.addListener(linkElements[i], "click", this.onArtifactLinkClick, this, true); + } + } + catch (e) { + alert("Invalid response for tab data"); + } + }, + onExecuteActionClick: function Artifact_onExecuteActionClick(e) { var connectorId = this.value.split("#TOKEN#")[0]; @@ -260,6 +312,18 @@ YAHOO.util.Event.preventDefault(event); }, + onArtifactLinkClick: function Artifact_onArtifactLinkClick(event) + { + + var params = event.target.href.split("?")[1].split("&"); + + var connectorId = params[0].split("=")[1]; + var artifactId = params[1].split("=")[1]; + var artifactName = params[2].split("=")[1]; + + this.fireEvent(Activiti.event.updateArtifactView, {"connectorId": connectorId, "repositoryNodeId": artifactId, "isRepositoryArtifact": true, "name": artifactName, "activeTabIndex": 0}, null, true); + }, + onClickFormEventButton: function Artifact_onClickFormEventButton(event, args) { return new Activiti.component.FileChooserDialog(this.id, args[1].value.callback); -- GitLab