提交 d44d3345 编写于 作者: D dwebster

Fixes: ACT-21, ACT-22, ACT-144.

Extends Activiti.widget.DataTable with support for exposing bubbled events
Adds core i18n date/time formats
上级 66cf95f4
<#assign el=args.htmlid/>
<div id="processesContainer">
<table id="processesTable">
<thead>
<tr>
<th>${msg("processes.name")}</th>
<th>${msg("processes.key")}</th>
<th>${msg("processes.version")}</th>
<th>${msg("processes.actions")}</th>
</tr>
</thead>
<tbody>
<#list processDefinitions as processDefinition>
<tr>
<td>${processDefinition.name!processDefinition.id}</td>
<td>${processDefinition.key}</td>
<td>${processDefinition.version}</td>
<td>
<a href="#start?id=${processDefinition.id}" class="processAction startProcess">
<#if processDefinition.startFormResourceKey??>
${msg("processes.startForm")}
<#else>
${msg("processes.start")}
</#if>
</a>
</td>
</tr>
</#list>
</tbody>
</table>
<div class="processes">
<div id="${el}-paginator"></div>
<div id="${el}-datatable"></div>
</div>
<script type="text/javascript">//<![CDATA[
new Activiti.component.Processes("${el}").setMessages(${messages});
new Activiti.component.Processes("${el?js_string}").setMessages(${messages});
//]]></script>
\ No newline at end of file
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Activiti.component.Processes
*
* Controls the Process List
*
* @namespace Activiti
* @class Activiti.component.Processes
*/
(function()
{
/**
* Activiti.component.Processes
*
* Controls the Process List
*
* @namespace Activiti
* @class Activiti.component.Processes
*/
(function()
{
/**
* Shortcuts
*/
var Dom = YAHOO.util.Dom, Selector = YAHOO.util.Selector, Event = YAHOO.util.Event, $html = Activiti.util.decodeHTML;
/**
var Dom = YAHOO.util.Dom, Selector = YAHOO.util.Selector, Event = YAHOO.util.Event, $html = Activiti.util.decodeHTML;
/**
* Processes constructor.
*
* @param {String} htmlId The HTML id of the parent element
* @return {Activiti.component.Processes} The new component.Navigation instance
* @constructor
*/
Activiti.component.Processes = function Processes_constructor(htmlId)
{
Activiti.component.Processes = function Processes_constructor(htmlId)
{
Activiti.component.Processes.superclass.constructor.call(this, "Activiti.component.Processes", htmlId);
// Create new service instances and set this component to receive the callbacks
this.services.processService = new Activiti.service.ProcessService(this);
// Listen for events that interest this component
this.onEvent(Activiti.event.processActionClick, this.onProcessActionClick);
return this;
};
YAHOO.extend(Activiti.component.Processes, Activiti.component.Base,
{
/**
* Fired by YUI when parent element is available for scripting.
* Template initialisation, including instantiation of YUI widgets and event listener binding.
*
* @method onReady
*/
onReady: function Processes_onReady()
{
// YOU ARE HERE: DATATABLE Upgrade
/* New Code, not working yet
this.widgets.dataList = new Activiti.widget.DataList(this.id + "-task-list",
};
YAHOO.extend(Activiti.component.Processes, Activiti.component.Base,
{
/**
* Fired by YUI when parent element is available for scripting.
* Template initialisation, including instantiation of YUI widgets and event listener binding.
*
* @method onReady
*/
onReady: function Processes_onReady()
{
this.widgets.dataTable = new Activiti.widget.DataTable(
this.id + "-processes",
this,
[ { event: Activiti.event.selectTaskFilter, value: {} }],
[
{ event: Activiti.event.displayProcesses, value: {} },
{ event: "linkClickEvent", subscribe: true, trigger: Activiti.event.processActionClick}
],
this.id + "-datatable",
[ this.id + "-paginator" ],
[
{key:"Name",label:"Name",sortable:true},
{key:"Key",label:"Key",sortable:true},
{key:"Version",label:"Version",sortable:true},
{key:"Action",label:"Actions"}
];
{key:"id", sortable:true},
{key:"key",sortable:true},
{key:"version",sortable:true},
{key:"action"}
]
);
*/
var columnDefs = [
{key:"Name",label:"Name",sortable:true},
{key:"Key",label:"Key",sortable:true},
{key:"Version",label:"Version",sortable:true},
{key:"Action",label:"Actions"}
];
this.dataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get("processesTable"));
this.dataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE;
this.dataSource.responseSchema = {
fields: [{key:"Name"},
{key:"Key"},
{key:"Version"},
{key:"Action"}
]
};
this.myDataTable = new YAHOO.widget.DataTable("processesContainer", columnDefs, this.dataSource,
{sortedBy:{key:"Name",dir:"asc"}}
);
// Bind Ready Event
var linkElements = Dom.getElementsByClassName("startProcess", "a");
for (var i = 0; i < linkElements.length; i++)
{
YAHOO.util.Event.addListener(linkElements[i], "click", this.onStartProcessClick)
}
},
/**
* Called when a process has been selected from the process list.
* Will start new process based on the option.
*
* @method onStartProcessMenuClick
* @param eventType The name of the event
* @param eventArgs Event arguments
*/
onStartProcessClick: function Processes_onStartProcessClick(e)
// Needed to load data and set up other events
if (!Activiti.event.isInitEvent(Activiti.event.displayProcesses))
{
this.fireEvent(Activiti.event.displayProcesses, {}, null, true);
}   
// Display form if url
var processId = Activiti.util.getQueryStringParameter("id");
if (processId != null)
{
var id = this.href.split("?id=")[1]
if (id)
{
new Activiti.widget.StartProcessInstanceForm(this.id + "-startProcessInstanceForm", id);
YAHOO.util.Event.preventDefault(e)
}
this.startProcess(processId);
}
});
},
/**
* Activiti.widget.DataTable-callback to construct the url to use to load data into the data table.
*
* @method onDataTableCreateURL
* @param dataTable {Activiti.widget.DataTable} The data table that is invoking the callback
* @param eventName The name of the event to create a url from
* @param eventValue The event values to create a url from
* @return A url, based on the event, to use when loading data into the data table
*/
onDataTableCreateURL: function Processes_onDataTableCreateURL(dataTable, eventName, eventValue)
{
return this.services.processService.loadProcessDefinitionsURL(eventValue);
},
/**
*
* Activiti.widget.DataTable-callback that is called to render the content of each cell in the Actions row
*
* @method onDataTableRenderCellAction
* @param {Object} dataTable
* @param {Object} el
* @param {Object} oRecord
* @param {Object} oColumn
* @param {Object} oData
*/
onDataTableRenderCellAction: function Processes_onDataTableRenderCellAssignee(dataTable, el, oRecord, oColumn, oData) {
var actions = [],
linkOpen = '<a href="#start?id=' + oRecord.getData().id + '" rel="' + oRecord.getData().id + '" class="processAction startProcess">',
linkClose = "</a>";
if (oRecord.getData().startFormResourceKey != null) {
actions.push(linkOpen + this.msg("processes.startForm") + linkClose);
}
else {
actions.push(linkOpen + this.msg("processes.start") + linkClose);
}
// TODO: Add Other Actions (View XML, View Image, etc.)
//actions.push('<a href="#start?id=' + oRecord.getData().id + '" rel="' + oRecord.getData().id + '" class="processAction viewProcess">'+this.msg("processes.viewProcess")+'</a>');
el.innerHTML = actions.join(" ");
},
/**
* Called when a process start link has been clicked
* Will start new process based on the element
*
* @method startProcess
* @param eventType The name of the event
* @param eventArgs Event arguments
*/
startProcess: function Processes_onStartProcessClick(processId)
{
if (processId)
{
new Activiti.widget.StartProcessInstanceForm(this.id + "-startProcessInstanceForm", processId);
}
},
/**
*
* Triggered when an action link on a process is clicked
*
* @method
*/
onProcessActionClick: function Processes_onProcessActionClick(event, args, me)
{
var el = args[1].e.target,
commonClasses = "processAction ",
processId = el.rel;
switch (el.className.replace(commonClasses, ""))
{
case "startProcess":
me.startProcess(processId)
break;
case "viewProcess":
break;
case "viewXML":
break;
default:
}
},
/**
* Triggers every time the Processes table is reloaded
*
* @method onDisplayProcesses
* @param {Object} event
* @param {Object} args
*/
onDisplayProcesses: function Processes_onDisplayProcesses(event, args)
{
this.widgets.dataTable.reload();
}
});
})();
......@@ -15,7 +15,7 @@
* Activiti.component.TaskList
*
* Will display a list of tasks based on the filter from the Activiti.event.TASKS_FILTER_CLICKED event.
* Will also let user clain and complete taks in the list.
* Will also let user claim and complete tasks in the list.
*
* @namespace Activiti
* @class Activiti.component.TaskList
......
......@@ -33,15 +33,19 @@ h1 {
background-color:#CFE7CB;
}
.processAction {
#Activiti .processAction {
display:block;
padding-left:20px;
}
.startProcess {
#Activiti .startProcess {
background: url("../images/process-start-icon.png") no-repeat 0 3px;
}
.viewProcess,
.viewXML {
#Activiti .viewProcess,
#Activiti .viewXML {
background: url("../images/process-view-icon.png") no-repeat 0 3px;
}
\ No newline at end of file
}
#Activiti .activiti-datatable table {
width:auto;
}
......@@ -15,5 +15,13 @@
<dest-id>database</dest-id>
<assoc-type>child</assoc-type>
</page-association>
<page-association>
<dest-id>deployments</dest-id>
<assoc-type>child</assoc-type>
</page-association>
<page-association>
<dest-id>jobs</dest-id>
<assoc-type>child</assoc-type>
</page-association>
</associations>
</page>
\ No newline at end of file
......@@ -14,8 +14,7 @@
/**
* Activiti.component.DatabaseTable
*
* Will display a list of tasks based on the filter from the Activiti.event.TASKS_FILTER_CLICKED event.
* Will also let user clain and complete taks in the list.
* Displays the contents of the selected Database Table.
*
* @namespace Activiti
* @class Activiti.component.DatabaseTable
......
......@@ -13,4 +13,34 @@ h1 {
/* Override Core style for long DB table names */
.yui-gf div.yui-u.first {
min-width:18em;
}
#Activiti .deployments,
#Activiti .jobs {
padding-bottom:10px;
}
#Activiti .jobs .activiti-datatable table,
#Activiti .deployments .activiti-datatable table {
width:auto;
}
#Activiti .jobAction {
display:block;
padding-left:20px;
}
#Activiti .executeJob {
background: url("../images/process-start-icon.png") no-repeat 0 3px;
}
#Activiti .viewException{
background: url("../images/process-view-icon.png") no-repeat 0 3px;
}
#Activiti .viewException .exception{
display:none;
}
/* Bug fix for close button overlapping text */
.yui-skin-sam #prompt.yui-panel .bd {
padding-top:25px;
}
\ No newline at end of file
......@@ -32,3 +32,26 @@ Activiti.widget.DataTable.paginator.lastPageLinkLabel=>>
Activiti.service.TaskService.claimTaskSuccess=Task was successfully claimed.
Activiti.service.TaskService.completeTaskSuccess=Task was successfully completed.
Activiti.service.ProcessService.startProcessSuccess=Process was successfully started.
## Dates
days.initial=S,M,T,W,T,F,S
days.short=Su,Mo,Tu,We,Th,Fr,Sa
days.medium=Sun,Mon,Tue,Wed,Thu,Fri,Sat
days.long=Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
months.short=Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec
months.long=January,February,March,April,May,June,July,August,September,October,November,December
## Date Formats
Activiti.date-format.default=ddd d mmm yyyy HH:MM:ss
Activiti.date-format.defaultFTL=EEE d MMM yyyy HH:mm:ss
Activiti.date-format.defaultDateOnly=ddd d mmm yyyy
Activiti.date-format.shortDate=d/m/yy
Activiti.date-format.mediumDate=d mmm, yyyy
Activiti.date-format.mediumDateFTL=d MMM, yyyy
Activiti.date-format.longDate=dd mmmm, yyyy
Activiti.date-format.fullDate=dddd, d mmmm, yyyy
Activiti.date-format.shortTime=h:MM TT
Activiti.date-format.mediumTime=h:MM:ss TT
Activiti.date-format.longTime=h:MM:ss TT Z
Activiti.date-format.am=am
Activiti.date-format.pm=pm
\ No newline at end of file
......@@ -70,7 +70,6 @@
<@script type="text/javascript" src="${resource}/yui/bubbling.v2.1.js"></@script>
<script type="text/javascript" src="${url.context}/service/messages.js?locale=${locale}"></script>
<script type="text/javascript" src="${resource}/js/activiti-core.js"></script>
<script type="text/javascript" src="${resource}/js/activiti-form.js"></script>
<script type="text/javascript" src="${resource}/js/activiti-widget.js"></script>
<script type="text/javascript" src="${resource}/js/activiti-service.js"></script>
<script type="text/javascript">//<![CDATA[
......
......@@ -14,3 +14,21 @@ function getTables(connector)
}
return null;
}
/**
* Gets a list of the Deployments from the server
*
* @method getDeployments
* @param connector
* @return {Array} A list with deployment objects
*/
function getDeployments(connector)
{
var result = connector.get("/management/deployments");
if (result.status == 200)
{
return eval('(' + result + ')').data;
}
return null;
}
......@@ -1075,6 +1075,68 @@ Activiti.event = function() {
collapseTreeNode: "collapseTreeNode",
/**
* Fires when the Processes Table is ready
*
* @property displayProcesses
* @type string
*/
displayProcesses: "displayProcesses",
/**
* Fires when the Deployments Table is ready
*
* @property displayDeployments
* @type string
*/
displayDeployments: "displayDeployments",
/**
* Fires when the Jobs Table is ready
*
* @property displayJobs
* @type string
*/
displayJobs: "displayJobs",
/**
* Fires when a process Action in the Activiti Explorer is clicked on
*
* @property processActionClick
* @type string
*/
processActionClick: "processActionClick",
/**
* Fires when a deployment is deleted
*
* @property deleteDeployment
* @type string
*/
deleteDeployment: "deleteDeployment",
/**
* Fires when a job Action is triggered
*
* @property jobAction
* @type {String}
*/
jobAction: "jobAction",
/**
* Fires when a job is sent for executed
*
* @property executeJob
* @type {String}
*/
executeJob: "executeJob",
/**
* Called from the activiti initializer when the first body element is ready.
*
......
......@@ -923,6 +923,20 @@ Activiti.service.Ajax = function() {
*/
loadProcessInstanceFormURL: function ProcessService_loadProcessInstanceFormURL(processDefinitionId) {
return Activiti.service.REST_PROXY_URI_RELATIVE + "process-definition/" + encodeURIComponent(processDefinitionId) + "/form";
},
/**
* Returns the url to load the process definitions from the server
*
* @method loadProcessDefinitionsURL
* @param {Object} eventValue an object of URL parameters
* @return {string} the URL
*/
loadProcessDefinitionsURL: function ProcessService_loadProcessDefinitionsURL(eventValue)
{
var url = Activiti.service.REST_PROXY_URI_RELATIVE + "process-definitions",
params = Activiti.util.objectToArgumentString(eventValue);
return (params) ? url + "?" + params : url;
}
......@@ -1133,7 +1147,11 @@ Activiti.service.Ajax = function() {
{
event: {
loadTables: "loadTables",
loadTable: "loadTable"
loadTable: "loadTable",
deleteDeployments: "deleteDeployments",
loadJob: "loadJob",
executeJob: "executeJob",
jobAction: "jobAction"
}
});
......@@ -1215,6 +1233,129 @@ Activiti.service.Ajax = function() {
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "management/table/" + encodeURIComponent(table) + "/data?" +
Activiti.util.Pagination.args(filters);
},
/**
* Returns the url to load the deployments from the server
*
* @method loadDeploymentsURL
* @param {Object} eventValue an object of URL parameters
* @return {string} the URL
*/
loadDeploymentsURL: function ManagementService_loadDeploymentsURL(eventValue)
{
var url = Activiti.service.REST_PROXY_URI_RELATIVE + "deployments",
params = Activiti.util.objectToArgumentString(eventValue);
return (params) ? url + "?" + params : url;
},
/**
* Returns the url to delete the deployments from the server
*
* @method deleteDeploymentsURL
* @param {Array} deploymentIds
* @param {Boolean} cascade
* @return {String} the URL
*/
deleteDeploymentsURL: function ManagementService_deleteDeploymentsURL(cascade)
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "deployments/delete?cascade=" + cascade;
},
/**
* Calls the url to delete the deployments from the server
*
* @method deleteDeployments
* @param {Array} deploymentIds
* @param {Boolean} cascade
* @return {String} the URL
*/
deleteDeployments: function ManagementService_deleteDeployments(deploymentIds, cascade, obj)
{
deploymentsObj = {deploymentIds: deploymentIds};
this.jsonPost(this.deleteDeploymentsURL(cascade), deploymentsObj, obj, "deleteDeployment");
},
/**
* Returns the URL needed to get a list of jobs
*
* @method loadJobsURL
* @param {Object} eventValue - parameters needed for the URL
* @return {String} URL
*/
loadJobsURL: function ManagementService_loadJobsURL(eventValue)
{
var url = Activiti.service.REST_PROXY_URI_RELATIVE + "management/jobs",
params = Activiti.util.objectToArgumentString(eventValue);
return (params) ? url + "?" + params : url;
},
/**
* Returns URL for job details
*
* @method loadJobURL
* @param {String} jobId
* @return {String} URL
*/
loadJobURL: function ManagementService_loadJobURL(jobId)
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "management/job/" + jobId;
},
/**
* Returns URL to execute a job
*
* @method executeJobURL
* @param {String} jobId
* @return {String} URL
*/
executeJobURL: function ManagementService_executeJobURL(jobId)
{
return this.loadJobURL(jobId) + "/execute";
},
/**
* Returns URL to execute multiple jobs
*
* @method executeJobsURL
* @return {String} URL
*/
executeJobsURL: function ManagementService_executeJobsURL()
{
return Activiti.service.REST_PROXY_URI_RELATIVE + "management/jobs/execute"
},
/**
* Loads the JSON for a job details and triggers a callback function
*
* @method loadJob
* @param {String} jobId
* @param {Object} obj - helper object for callback function
* @return {String} URL
*/
loadJob: function ManagementService_loadJob(jobId, obj)
{
this.jsonGet(this.loadJobURL(jobId), obj, "loadJob");
},
/**
* Executes a job via the REST API and triggers a callback function
*
* @method executeJob
* @param {String} jobId
* @param {Object} obj - helper object for callback function
* @return {String} URL
*/
executeJob: function ManagementService_executeJob(jobId, obj)
{
this.jsonPut(this.executeJobURL(jobId),{}, obj, "executeJob");
},
executeJobs: function ManagementService_executeJobs(jobIds, obj)
{
jobsObj = {jobIds: jobIds};
this.jsonPost(this.executeJobsURL(), jobsObj, obj, "executeJob");
}
});
......
......@@ -671,10 +671,18 @@ Activiti.widget.PopupManager = function()
return true;
};
// Now that we are ready we may start to listen for events
for (var ei = 0, eil = events.length; ei < eil; ei++) {
this._eventPatterns[events[ei].event] = events[ei].value;
Activiti.event.on(events[ei].event, this.onEvent, this)
// Now that we are ready we may handle events
for (var ei = 0, eil = events.length; ei < eil; ei++)
{
//Subscribe to events bubbled up to the YAHOO.widget.dataTable object
if (events[ei].subscribe && events[ei].subscribe === true)
{
me._dataTable.subscribe(events[ei].event, me.trigger, {event: events[ei].trigger});
} else // Listen for the event
{
this._eventPatterns[events[ei].event] = events[ei].value;
Activiti.event.on(events[ei].event, this.onEvent, this)
}
}
},
......@@ -690,7 +698,7 @@ Activiti.widget.PopupManager = function()
* Called when table is paginated or sorted and will fire an event so it gets put in the browser history.
* Afterwards onEvent will be called so the actual data can be loaded.
*
* @method onEvent
* @method fireEvent
* @param start {int}
* @param sort {string}
* @param order {string}
......@@ -725,6 +733,19 @@ Activiti.widget.PopupManager = function()
}
},
/**
* Triggers a non Filter/Pagination event
*
* @param {Object} e Event Object
* @param {Object} args Object of arguments
* @param {String} args.event Name of event to trigger
*/
trigger: function(e, args)
{
args.e = e; // Ensure the event object is passed through to the listening function
YAHOO.Bubbling.fire(args.event, args);
},
/**
* Reloads the datatable with the current pagination settings
*/
......@@ -1270,4 +1291,4 @@ Activiti.widget.PopupManager = function()
});
})();
})();
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册