提交 b3f93b1c 编写于 作者: 蔡祥熠

Merge branch 'fix/widget' into 'develop'

Merge of fix/widget 部件、部件元素可以跨应用选择、页面保存部件可以保存到其他应用 to develop

See merge request o2oa/o2oa!437
......@@ -363,6 +363,18 @@ o2.widget.O2Application = new Class({
}
}
});
o2.widget.O2Portal = new Class({
Extends: o2.widget.O2Group,
getPersonData: function(){
if (!this.data.name){
this.action = new o2.xDesktop.Actions.RestActions("", "x_portal_assemble_surface", "");
this.action.actions = {"getPortal": {"uri": "/jaxrs/portal/{id}"}};
this.action.invoke({"name": "getPortal", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
this.data = json.data;
}.bind(this)});
}
}
});
o2.widget.O2CMSApplication = new Class({
Extends: o2.widget.O2Group,
getPersonData: function(){
......
......@@ -175,8 +175,11 @@ MWF.xApplication.portal.PageDesigner.Module.Div = MWF.PCDiv = new Class({
return;
}
var appname, appid = module.appSelect.options[module.appSelect.selectedIndex].value;
if(appid)appname = module.appSelect.options[module.appSelect.selectedIndex].text;
var flag = true;
o2.Actions.get("x_portal_assemble_designer").listWidget( module.page.designer.application.id, function( json ){
o2.Actions.get("x_portal_assemble_designer").listWidget( appid || module.page.designer.application.id, function( json ){
for( var i=0; i<json.data.length; i++ ){
if( json.data[i].name === widgetName ){
module.page.designer.notice(module.page.designer.lp.notice.widgetNameConflict, "error");
......@@ -186,7 +189,7 @@ MWF.xApplication.portal.PageDesigner.Module.Div = MWF.PCDiv = new Class({
}
}.bind(this), null, false);
if( flag ){
module._makeWidget( widgetName );
module._makeWidget( widgetName, appid, appname );
this.close();
}
}
......@@ -199,6 +202,17 @@ MWF.xApplication.portal.PageDesigner.Module.Div = MWF.PCDiv = new Class({
}
],
"onPostShow": function(){
o2.Actions.load("x_portal_assemble_designer").PortalAction.list(function (json) {
var td = dlg.node.getElementById("MWFPortalSelect");
var select = module.appSelect = new Element("select").inject(td);
var option = new Element("option", {"text": ""}).inject(select);
json.data.each(function(app){
var option = new Element("option", {
"text": app.name,
"value": app.id
}).inject(select);
}.bind(this));
});
this.widgetNameInput = dlg.node.getElementById("MWFNewWidgetName");
......@@ -208,7 +222,7 @@ MWF.xApplication.portal.PageDesigner.Module.Div = MWF.PCDiv = new Class({
dlg.show();
}.bind(this));
},
_makeWidget : function( name ){
_makeWidget : function( name, appid, appname ){
//var pcData, mobileData;
//if (this.pcPage){
// this.pcPage._getPageData();
......@@ -245,6 +259,17 @@ MWF.xApplication.portal.PageDesigner.Module.Div = MWF.PCDiv = new Class({
fieldList = this._getWidgetFieldList( pcData.json.moduleList );
}
if( appid ){
if(pcData && pcData.json){
pcData.json.application = appid;
pcData.json.applicationName = appname;
}
if(mobileData && mobileData.json){
mobileData.json.application = appid;
mobileData.json.applicationName = appname;
}
}
debugger;
......
<div style="font-size:12px">
<div style="height:18px; background-color:#EEE; border-bottom: 1px solid #333; maring-bottom:5px">创建部件</div><br/>
<table width="100%" border="0" cellspacing="0" cellpadding="3px">
<tr>
<td align="right">选择门户</td>
<td colspan="2" id="MWFPortalSelect"></td>
</tr>
<tr>
<td align="right">部件名称</td>
<td colspan="2"><input type="text" id="MWFNewWidgetName" value="" class="editTableInput"/></td>
......
......@@ -27,8 +27,14 @@
</tr>
</table>
<div id="text{$.pid}selectWidget" style="display: text{($.widgetType!='script')?'block':'none'}">
<div id="text{$.pid}selectWidget" class="MWFWidgetSelectContainer" style="display: text{($.widgetType!='script')?'block':'none'}">
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
<tr>
<td class="editTableTitle">{{$.lp.application}}:</td>
<td class="editTableValue">
<div class="MWFWidgetAppSelect" name="widgetAppSelected"></div>
</td>
</tr>
<tr>
<td class="editTableTitle">{{$.lp.widget}}:</td>
<td class="editTableValue">
......@@ -44,6 +50,10 @@
</table>
</div>
<div id="text{$.pid}scriptWidget" style="display: text{($.widgetType=='script')?'block':'none'}">
<div style="padding: 5px;">{{$.lp.crossApplication}}:<br/>return { <br/>
&nbsp;&nbsp;"application" : "applicationName", //{{$.lp.computeSubmitAnnotation1}} <br/>
&nbsp;&nbsp;"widget" : "widgetName" //{{$.lp.computeWidgetAnnotation2}}<br/>
}; <br/> {{$.lp.thisApplication}}:<br/>return "widgetName"; </div>
<div class="MWFScriptArea" name="widgetScript" title="{{$.lp.widgetScript}} (S)"></div>
</div>
......
......@@ -79,24 +79,44 @@ MWF.xApplication.portal.PageDesigner.Module.Widgetmodules = MWF.PCWidgetmodules
}
],
"onPostShow": function(){
var td = dlg.node.getElementById("MWFWidgetSelectTd");
this.form.designer.actions.listWidget(this.form.designer.application.id, function(json){
var select = this.widgetSelect = new Element("select").inject(td);
var option = new Element("option", {"text": "none"}).inject(select);
json.data.each(function(widget){
o2.Actions.load("x_portal_assemble_designer").PortalAction.list(function (json) {
var td = dlg.node.getElementById("MWFPortalSelectTd");
var select = module.appSelect = new Element("select").inject(td);
var option = new Element("option", {"text": ""}).inject(select);
json.data.each(function(app){
var option = new Element("option", {
"text": widget.name,
"value": widget.id
"text": app.name,
"value": app.id
}).inject(select);
}.bind(this));
}.bind(this));
select.addEvent("change", function(){
var appid = module.appSelect.options[module.appSelect.selectedIndex].value;
module.setWidgetSelectOptions( appid );
})
});
var td = dlg.node.getElementById("MWFWidgetSelectTd");
module.widgetSelect = new Element("select").inject(td);
module.setWidgetSelectOptions();
}.bind(this)
});
dlg.show();
}.bind(this));
},
setWidgetSelectOptions: function( aplication ){
var select = this.widgetSelect;
select.empty();
this.form.designer.actions.listWidget( aplication || this.form.designer.application.id, function(json){
var option = new Element("option", {"text": "none"}).inject(select);
json.data.each(function(widget){
var option = new Element("option", {
"text": widget.name,
"value": widget.id
}).inject(select);
}.bind(this));
}.bind(this));
},
_dragComplete: function(relativeNode, position){
if (!this.node){
this._createNode(relativeNode, position );
......
<div style="font-size:12px">
<div style="height:18px; background-color:#EEE; border-bottom: 1px solid #333; maring-bottom:5px">{{$.lp.insertWidget}}</div><br/>
<table width="100%" border="0" cellspacing="0" cellpadding="3px">
<tr>
<td align="right">{{$.lp.selectPortal}}</td>
<td colspan="2" id="MWFPortalSelectTd"></td>
</tr>
<tr>
<td align="right">{{$.lp.selectWidget}}</td>
<td colspan="2" id="MWFWidgetSelectTd"></td>
......
......@@ -44,6 +44,7 @@ MWF.APPPOD.LP = {
//"confiltNoPix" : "请填写前缀或后缀",
"selectPage" : "请选择页面",
"selectPortal" : "请选择门户",
"selectWidget" : "请选择部件",
//"moduleConflitError" : "组件标识重复",
//"moduleConflitErrorOnPix" : "添加了前缀或后缀后组件标识仍然重复"
......
......@@ -507,10 +507,8 @@ MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
}.bind(this))
},
_loadSubformSelect : function( node, formNodeName, appNodeName ){
var select;
var select = new Element("select").inject(node);
this.getSubFormList(function(){
select = new Element("select").inject(node);
select.addEvent("change", function(e){
var value = select.options[select.selectedIndex].value;
this.setValue(formNodeName, value, select);
......@@ -601,27 +599,62 @@ MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
},
loadWidgetSelect: function(){
var widgetNodes = this.propertyContent.getElements(".MWFWidgetSelect");
if (widgetNodes.length){
this.getWidgetList(function(){
widgetNodes.each(function(node){
var select = new Element("select").inject(node);
select.addEvent("change", function(e){
var value = e.target.options[e.target.selectedIndex].value;
this.setValue(e.target.getParent("div").get("name"), value, select);
}.bind(this));
this.setWidgetSelectOptions(node, select);
var wdigetContainers = this.propertyContent.getElements(".MWFWidgetSelectContainer");
if (wdigetContainers.length){
wdigetContainers.each( function( container ){
var appSelectNode = container.getElement(".MWFWidgetAppSelect");
var widgetSelectNode = container.getElement(".MWFWidgetSelect");
var widgetSelect;
var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
refreshNode.addEvent("click", function(e){
var appNodeName = appSelectNode.get("name");
var widgetNodeName = widgetSelectNode.get("name");
this.loadPortalApplictionSelect( appSelectNode, appNodeName, function( apps ){
var oldValue = this.data[appNodeName] || "";
this.data[appNodeName] = !apps.length ? "" : apps[0].data.id;
if( oldValue !== this.data[appNodeName] ){
this.getWidgetList(function(){
this.setWidgetSelectOptions(node, select);
}.bind(this), true);
}.bind(this));
this.setWidgetSelectOptions(widgetSelectNode, widgetSelect);
widgetSelect.fireEvent("change");
}.bind(this), true, appNodeName);
}
}.bind(this));
widgetSelect = this._loadWidgetSelect( widgetSelectNode, widgetNodeName, appNodeName ) ;
}.bind(this));
}
},
loadPortalApplictionSelect : function( node, appNodeName, callback ){
var application = appNodeName ? this.data[appNodeName] : "";
MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
"title" : this.form.designer.lp.selectApplication,
"type": "portal",
"count" : 1,
"names": application ? [ {id : application} ] : [],
"onChange": function (apps) {
callback(apps)
}.bind(this)
});
}.bind(this))
},
_loadWidgetSelect : function( node, widgetNodeName, appNodeName ){
var select = new Element("select").inject(node);
this.getWidgetList(function(){
select.addEvent("change", function(e){
var value = select.options[select.selectedIndex].value;
this.setValue(widgetNodeName, value, select);
}.bind(this));
this.setWidgetSelectOptions(node, select);
var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
refreshNode.addEvent("click", function(e){
this.getWidgetList(function(){
this.setWidgetSelectOptions(node, select);
}.bind(this), true, appNodeName);
}.bind(this));
}.bind(this), false, appNodeName );
return select;
},
setWidgetSelectOptions: function(node, select){
var name = node.get("name");
select.empty();
......@@ -636,9 +669,10 @@ MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
}
}.bind(this));
},
getWidgetList: function(callback, refresh){
getWidgetList: function(callback, refresh, appNodeName){
var application = appNodeName ? this.data[appNodeName] : "";
if (!this.widgets || refresh){
this.form.designer.actions.listWidget(this.form.designer.application.id, function(json){
this.form.designer.actions.listWidget(application || this.form.designer.application.id, function(json){
this.widgets = json.data;
if (callback) callback();
}.bind(this));
......
......@@ -406,6 +406,7 @@ MWF.xApplication.process.FormDesigner.LP = {
"crossApplication": "CrossApplication",
"computeSubmitAnnotation1": "application name, alias or id",
"computeSubmitAnnotation2": "form name or id",
"computeWidgetAnnotation2": "widget name or id",
"thisApplication": "Current Application",
"submitFormScript": "Submit Form Script",
"flowActionScript": "Submit Action Script",
......@@ -1033,6 +1034,7 @@ MWF.xApplication.process.FormDesigner.LP = {
"parameterScript": "Parameter Script (Return JSON Object)",
"insertWidget": "Tnsert Widget",
"selectWidget": "Select Widget",
"selectPortal": "Select Portal",
"inDiv": "Wrapped in a div",
"outerSideModuleId": "external related component ID",
......
......@@ -405,6 +405,7 @@ MWF.xApplication.process.FormDesigner.LP = {
"crossApplication": "跨应用",
"computeSubmitAnnotation1": "应用名称、别名、id",
"computeSubmitAnnotation2": "表单名称、id",
"computeWidgetAnnotation2": "部件名称、id",
"thisApplication": "本应用",
"submitFormScript": "提交表单脚本",
"flowActionScript": "提交(继续流转)操作脚本",
......@@ -1038,6 +1039,7 @@ MWF.xApplication.process.FormDesigner.LP = {
"parameterScript": "参数脚本 (返回对象)",
"insertWidget": "插入部件元素",
"selectWidget": "选择部件",
"selectPortal": "选择门户",
"inDiv": "是否包裹div",
"outerSideModuleId": "外部相关组件标识",
......
......@@ -104,6 +104,7 @@ MWF.xApplication.process.ProcessDesigner.widget.PersonSelector = new Class({
if (type==="dutyname") this.identitys.push(new MWF.widget.O2Duty(data, this.node));
if (type==="cmsapplication") this.identitys.push(new MWF.widget.O2CMSApplication(data, this.node));
if (type==="cmscategory") this.identitys.push(new MWF.widget.O2CMSCategory(data, this.node));
if (type==="portal") this.identitys.push(new MWF.widget.O2Portal(data, this.node));
if (type==="portalfile") this.identitys.push(new MWF.widget.O2File(data, this.node));
if (type==="processfile") this.identitys.push(new MWF.widget.O2File(data, this.node));
......@@ -212,6 +213,7 @@ MWF.xApplication.process.ProcessDesigner.widget.PersonSelector = new Class({
if (type==="process") this.identitys.push(new MWF.widget.O2Process(item.data, this.node));
if (type==="cmsapplication") this.identitys.push(new MWF.widget.O2CMSApplication(item.data, this.node));
if (type==="cmscategory") this.identitys.push(new MWF.widget.O2CMSCategory(item.data, this.node));
if (type==="portal") this.identitys.push(new MWF.widget.O2Portal(item.data, this.node));
if (type==="formfield") this.identitys.push(new MWF.widget.O2FormField(item.data, this.node));
if (type==="cmsformfield") this.identitys.push(new MWF.widget.O2FormField(item.data, this.node));
......
......@@ -185,13 +185,24 @@ MWF.xApplication.process.Xform.Widget = MWF.APPWidget = new Class(
var method = (this.form.options.mode !== "Mobile" && !layout.mobile) ? "getWidgetByName" : "getWidgetByNameMobile";
if (this.json.widgetType==="script"){
if (this.json.widgetScript && this.json.widgetScript.code){
var formNome = this.form.Macro.exec(this.json.widgetScript.code, this);
if (formNome){
var app = this.form.businessData.pageInfor.portal;
o2.Actions.get("x_portal_assemble_surface")[method](formNome, app, function(json){
this.getWidgetData(json.data);
var data = this.form.Macro.exec(this.json.widgetScript.code, this);
if (data){
var widgetName, app;
if (typeOf(data) === "string") {
widgetName = data;
} else {
if (data.application) app = data.application;
if (data.widget) widgetName = data.widget;
}
if (widgetName) {
if (!app) app = this.form.businessData.pageInfor.portal;
o2.Actions.get("x_portal_assemble_surface")[method](widgetName, app, function(json){
this.getWidgetData(json.data);
if (callback) callback();
}.bind(this));
}else{
if (callback) callback();
}.bind(this));
}
}else{
if (callback) callback();
}
......@@ -205,7 +216,12 @@ MWF.xApplication.process.Xform.Widget = MWF.APPWidget = new Class(
if (callback) callback();
}else{
var app = this.form.businessData.pageInfor.portal;
var app;
if (this.json.widgetAppSelected) {
app = this.json.widgetAppSelected;
} else {
app = this.form.businessData.pageInfor.portal;
}
o2.Actions.get("x_portal_assemble_surface")[method](this.json.widgetSelected, app, function(json){
this.getWidgetData(json.data);
if (callback) callback();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册