提交 7b67fa66 编写于 作者: 蔡祥熠

Merge branch 'cherry-pick-b817e412' into 'develop'

Merge branch 'fix/Process.include_dictionarty' into 'wrdp'

See merge request o2oa/o2oa!1569
......@@ -1642,7 +1642,195 @@ MWF.xScript.JSONData = function(data, callback, key, parent, _form){
// this.destory = this["delete"];
// }
//};
var dictLoaded = {};
// var dictLoaded = {};
MWF.xScript.dictLoaded = {};
MWF.xScript.addDictToCache = function ( options, path, json ) {
debugger;
// if( !key ){
// var name = options.name || options.id || options.alias;
// var type = options.appType || "process";
// var application = options.appName || options.appId || options.application || options.appAlias;
// var enableAnonymous = options.enableAnonymous || false;
// key = name+type+application+enableAnonymous;
// }
if( !path )path = "root";
if( path.indexOf("root") !== 0 )path = "root." + path ;
// if( MWF.xScript.dictLoaded[key] ){
// var dicts = MWF.xScript.dictLoaded[key];
// var arr = path.split(/\./g);
// var p;
// for( var i=0 ; i<arr.length; i++ ){
// p = i === 0 ? arr[0] : ( p + "." + arr[i] );
// if( dicts[ p ] )return; //如果上级路径存在,则返回
// }
// }
// if( MWF.xScript.dictLoaded[key] && MWF.xScript.dictLoaded[key][path]){
// MWF.xScript.dictLoaded[key][path] = json;
// return;
// }
var type = options.appType || "process";
var enableAnonymous = options.enableAnonymous || false;
var appFlagList = [];
if( options.application )appFlagList.push( options.application );
if( options.appId )appFlagList.push( options.appId );
if( options.appName )appFlagList.push( options.appName );
if( options.appAlias )appFlagList.push( options.appAlias );
var dictFlagList = [];
if( options.id )dictFlagList.push( options.id );
if( options.name )dictFlagList.push( options.name );
if( options.alias )dictFlagList.push( options.alias );
var cache = {};
cache[path] = json;
for( var i=0; i<appFlagList.length; i++ ){
for( var j=0; j<dictFlagList.length; j++ ){
var k = dictFlagList[j] + type + appFlagList[i] + enableAnonymous;
if( !MWF.xScript.dictLoaded[k] ){
MWF.xScript.dictLoaded[k] = cache; //指向同一个对象
// MWF.xScript.dictLoaded[k][path] = json; //指向不同的对象
}else if( i===0 && j===0 ){
MWF.xScript.setDictToCache( k, path ,json );
var arr = path.split(/\./g);
var p;
var cache = MWF.xScript.dictLoaded[k];
for( var l=0 ; l<arr.length; l++ ){
p = l === 0 ? arr[0] : ( p + "." + arr[l] );
if( cache[ p ] )break;
}
if( p ){
var mathP = p+".";
Object.keys( cache ).each( function( path, idx){
if( path.indexOf( mathP ) === 0 )delete cache[path];
})
}
}
}
}
};
MWF.xScript.getMatchedDict = function(key, path){
debugger;
if( !path )path = "root";
if( path.indexOf("root") !== 0 )path = "root." + path ;
var arr = path.split(/\./g);
if( MWF.xScript.dictLoaded[key] ){
var dicts = MWF.xScript.dictLoaded[key];
var list = Array.clone(arr);
var p;
var dict;
for( var i=0 ; i<arr.length; i++ ){
p = i === 0 ? arr[0] : ( p + "." + arr[i] );
list.shift();
if( dicts[ p ] ){
dict = dicts[ p ];
break;
}
}
return {
dict : dict,
unmatchedPathList : list
}
}
return {
dict : null,
unmatchedPathList : list
}
};
MWF.xScript.insertDictToCache = function(key, path, json){
if( MWF.xScript.dictLoaded[key] ){
var matchedDict = MWF.xScript.getMatchedDict( key, path );
var dict = matchedDict.dict;
var list = matchedDict.unmatchedPathList;
if( !dict ){
MWF.xScript.dictLoaded[key][path] = json;
}else{
for( var j=0; j<list.length-1; j++ ){
if( !dict[ list[j] ] ){
dict[ list[j] ] = {};
}
dict = dict[ list[j] ];
}
var lastPath = list[list.length-1];
if( !dict[lastPath] ){
dict[lastPath] = json;
}else if( typeOf( dict[lastPath] ) === "array" ){
dict[lastPath].push( json );
}
}
}else{
MWF.xScript.dictLoaded[key] = {};
MWF.xScript.dictLoaded[key][path] = json;
}
};
MWF.xScript.setDictToCache = function(key, path, json){
if( MWF.xScript.dictLoaded[key] ){
var matchedDict = MWF.xScript.getMatchedDict( key, path );
var dict = matchedDict.dict;
var list = matchedDict.unmatchedPathList;
if( !dict ){
MWF.xScript.dictLoaded[key][path] = json;
}else{
for( var j=0; j<list.length-1; j++ ){
if( !dict[ list[j] ] ){
dict[ list[j] ] = {};
}
dict = dict[ list[j] ];
}
dict[list[list.length-1]] = json;
}
}else{
MWF.xScript.dictLoaded[key] = {};
MWF.xScript.dictLoaded[key][path] = json;
}
};
MWF.xScript.getDictFromCache = function( key, path ){
debugger;
var matchedDict = MWF.xScript.getMatchedDict( key, path );
var dict = matchedDict.dict;
var list = matchedDict.unmatchedPathList;
if( dict ){
for( var j=0; j<list.length; j++ ){
dict = dict[ list[j] ];
if( !dict )return null;
}
return dict;
}
return null;
};
MWF.xScript.deleteDictToCache = function(key, path){
debugger;
var matchedDict = MWF.xScript.getMatchedDict( key, path );
var dict = matchedDict.dict;
var list = matchedDict.unmatchedPathList;
if( dict){
for( var j=0; j<list.length-1; j++ ){
dict = dict[ list[j] ];
if( !dict )return;
}
delete dict[list[list.length-1]];
}
};
MWF.xScript.createDict = function(application){
//optionsOrName : {
// type : "", //默认为process, 可以为 process cms
......@@ -1661,9 +1849,16 @@ MWF.xScript.createDict = function(application){
var applicationId = options.application || application;
var enableAnonymous = options.enableAnonymous || false;
var key = name+type+applicationId+enableAnonymous
if (!dictLoaded[key]) dictLoaded[key] = {};
this.dictData = dictLoaded[key];
var opt = {
"appType" : type,
"name" : name,
"appId" : applicationId,
"enableAnonymous" : enableAnonymous
};
var key = name+type+applicationId+enableAnonymous;
// if (!dictLoaded[key]) dictLoaded[key] = {};
// this.dictData = dictLoaded[key];
//MWF.require("MWF.xScript.Actions.DictActions", null, false);
if( type == "cms" ){
......@@ -1682,29 +1877,31 @@ MWF.xScript.createDict = function(application){
this.get = function(path, success, failure, async, refresh){
var value = null;
if (path){
if (!refresh && this.dictData[path]){
if (success) success(this.dictData[path]);
return this.dictData[path];
if (!refresh ){
var data = MWF.xScript.getDictFromCache( key, path );
if( data ){
if (success) success( data );
return data;
}
}
if (path){
var p = encodePath( path );
//var p = path.replace(/\./g, "/");
action[ ( (enableAnonymous && type == "cms") ? "getDictDataAnonymous" : "getDictData" ) ](encodeURIComponent(this.name), applicationId, p, function(json){
value = json.data;
this.dictData[path] = value;
// this.dictData[path] = value;
MWF.xScript.addDictToCache(opt, path, value);
if (success) success(json.data);
}.bind(this), function(xhr, text, error){
if (failure) failure(xhr, text, error);
}, !!async, false);
}else{
if (this.dictData["root"]){
if (success) success(this.dictData["root"]);
return this.dictData["root"];
}
action[ ( (enableAnonymous && type == "cms") ? "getDictRootAnonymous" : "getDictRoot" ) ](this.name, applicationId, function(json){
value = json.data;
this.dictData["root"] = value;
// this.dictData["root"] = value;
MWF.xScript.addDictToCache(opt, path, value);
if (success) success(json.data);
}.bind(this), function(xhr, text, error){
if (failure) failure(xhr, text, error);
......@@ -1718,6 +1915,7 @@ MWF.xScript.createDict = function(application){
var p = encodePath( path );
//var p = path.replace(/\./g, "/");
action.setDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
MWF.xScript.setDictToCache(key, path, value);
if (success) success(json.data);
}, function(xhr, text, error){
if (failure) failure(xhr, text, error);
......@@ -1727,6 +1925,7 @@ MWF.xScript.createDict = function(application){
var p = encodePath( path );
//var p = path.replace(/\./g, "/");
action.addDictData(encodeURIComponent(this.name), applicationId, p, value, function(json){
MWF.xScript.insertDictToCache(key, path, value);
if (success) success(json.data);
}, function(xhr, text, error){
if (failure) failure(xhr, text, error);
......@@ -1736,6 +1935,7 @@ MWF.xScript.createDict = function(application){
var p = encodePath( path );
//var p = path.replace(/\./g, "/");
action.deleteDictData(encodeURIComponent(this.name), applicationId, p, function(json){
MWF.xScript.deleteDictToCache(key, path);
if (success) success(json.data);
}, function(xhr, text, error){
if (failure) failure(xhr, text, error);
......
......@@ -587,7 +587,7 @@ MWF.xApplication.Meeting.Main = new Class({
//) )
return {
action : this.currentTopMenuNode ? this.currentTopMenuNode.retrieve("action") : "toMyMeeting",
options : this.currentView.recordStatus ? this.currentView.recordStatus() : null
options : (this.currentView && this.currentView.recordStatus) ? this.currentView.recordStatus() : null
};
},
reload: function( ){
......
......@@ -30,7 +30,7 @@ MWF.xApplication.Meeting.MeetingView = new Class({
this.userName = layout.desktop.session.user.distinguishedName;
this.userId = layout.desktop.session.user.id;
this.userIdentity = [];
layout.desktop.session.user.identityList.each( function( i ){
( layout.desktop.session.user.identityList || [] ).each( function( i ){
this.userIdentity.push( i.distinguishedName )
}.bind(this));
......
......@@ -30,11 +30,13 @@ MWF.xApplication.Selector.Dictionary = new Class({
dictionaryJson.data.each(function (dictionary) {
var appName = dictionary.appName || dictionary.applicationName;
var appId = dictionary.appId || dictionary.application;
var appAlias = dictionary.appAlias || dictionary.applicationAlias;
if (!json[appId]) {
json[appId] = {
name: appName,
applicationName: appName,
appName: appName,
appAlias: appAlias,
application: appId,
appId: appId
};
......@@ -42,6 +44,7 @@ MWF.xApplication.Selector.Dictionary = new Class({
}
dictionary.appName = appName;
dictionary.appId = appId;
dictionary.appAlias = appAlias;
dictionary.appType = type;
dictionary.type = "dictionary";
json[appId].dictionaryList.push(dictionary)
......
......@@ -85,6 +85,9 @@
</table>
<!-- <div class="MWFScriptIncluder" name="scripts"></div>-->
<div style="height:24px; text-align: center; line-height: 24px; background-color: #EEE; border-top: 1px solid #999;font-weight:bold;">预加载数据字典</div>
<div class="MWFDictionaryIncluder" name="includeDictionaries"></div>
<!--<div class="MWFArraylist" name="cssLinks" title="CSS引用"></div>-->
<!--<div class="MWFArraylist" name="scriptSrc" title="JS引用"></div>-->
......
......@@ -86,6 +86,7 @@ MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
this.loadViewFilter();
this.loadDocumentTempleteSelect();
this.loadScriptIncluder();
this.loadDictionaryIncluder();
//this.testRestful();
// this.loadScriptInput();
//MWF.process.widget.EventsEditor
......@@ -1407,7 +1408,6 @@ debugger;
}.bind(this));
dictionaryNodes.each(function(node){
debugger;
var data = this.data[node.get("name")];
new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
"type": "Dictionary",
......@@ -1419,6 +1419,7 @@ debugger;
if( ids.length > 0 ){
// var d = ids[0].data;
ids.each( function (id) {
debugger;
var d = id.data;
data.push({
"type" : "dictionary",
......@@ -1426,6 +1427,7 @@ debugger;
"alias": d.alias,
"id": d.id,
"appName" : d.appName || d.applicationName,
"appAlias" : d.appAlias || d.applicationAlias,
"appId": d.appId,
"application": d.application,
"appType" : d.appType
......@@ -1482,6 +1484,24 @@ debugger;
}.bind(this));
},
loadDictionaryIncluder : function(){
var nodes = this.propertyContent.getElements(".MWFDictionaryIncluder");
if (nodes.length){
nodes.each(function(node){
var name = node.get("name");
MWF.xDesktop.requireApp("process.FormDesigner", "widget.DictionaryIncluder", function(){
var dictionaryIncluder = new MWF.xApplication.process.FormDesigner.widget.DictionaryIncluder(node, this.designer, {
"onChange": function(){
var data = dictionaryIncluder.getData();
this.data[name] = data;
}.bind(this)
});
dictionaryIncluder.load(this.data[name])
}.bind(this));
}.bind(this));
}
},
loadScriptIncluder : function(){
var nodes = this.propertyContent.getElements(".MWFScriptIncluder");
if (nodes.length){
......
......@@ -102,6 +102,17 @@ MWF.xApplication.process.FormDesigner.LP = {
"delete_title": "取消加载脚本确认",
"delete_text": "您确定要取消加载选择的脚本?"
},
"dictionaryIncluder" : {
"selectDictionary" : "选择:",
"repeatAddDictionaryNotice" : "请不要重复添加数据字典",
"rootDictionaryExistNotice" : "已经添加了该数据字典的根路径,无需再添加",
"parentDictionaryExistNotice" : "已经添加了该数据字典的父路径,无需再添加",
"subDictionaryExistNotice" : "已经存在该数据字典的子路径,请先删除再添加",
"selectDictionaryNotice" : "请先选择数据字典",
"path" : "路径:",
"delete_title": "取消加载数据字典确认",
"delete_text": "您确定要取消加载选择的数据字典?"
},
"validation": {
"validation": "校验",
"anytime": "任何时候",
......
{
"titleNode": {
"height": "24px",
"background-color": "#eeeeee",
"line-height": "24px",
"text-align": "center",
"border-top": "1px solid #999"
},
"editorNode": {
"border-top": "0px",
"overflow": "hidden"
},
"actionNode":{
"height": "30px",
"text-align": "center"
},
"listNode": {
"border-top": "1px solid #bbb",
"min-height": "60px",
"padding-top": "2px",
"overflow": "hidden"
},
"editTableTdValue": {
"height": "24px",
"line-height": "24px",
"border-bottom": "1px dashed #CCC"
},
"decisionNameInput": {
"color": "#666",
"width": "90%",
"border-top": "1px solid #AAA",
"border-left": "1px solid #AAA",
"border-bottom": "1px solid #CCC",
"border-right": "1px solid #CCC"
},
"valueInput":{
"color": "#666",
"width": "90%",
"border-top": "1px solid #AAA",
"border-left": "1px solid #AAA",
"border-bottom": "1px solid #CCC",
"border-right": "1px solid #CCC"
},
"promptInput": {
"color": "#666",
"width": "90%",
"border-top": "1px solid #AAA",
"border-left": "1px solid #AAA",
"border-bottom": "1px solid #CCC",
"border-right": "1px solid #CCC"
},
"valueSelect": {
"color": "#666",
"width": "auto",
"border-top": "1px solid #AAA",
"border-left": "1px solid #AAA",
"border-bottom": "1px solid #CCC",
"border-right": "1px solid #CCC"
},
"titleTd": {
"width": "60px",
"font-weight": "bold",
"font-size": "12px",
"height": "24px",
"line-height": "24px"
},
"actionAreaNode": {
"width": "110px",
"height": "22px",
"margin": "auto",
"margin-top": "4px"
},
"addAction": {
"width": "50px",
"height": "20px",
"line-height": "20px",
"float": "left",
"cursor": "pointer",
"border-radius": "3px",
"border": "1px solid #999",
"background-color": "#798795",
"color": "#FFF"
},
"modifyAction": {
"width": "50px",
"height": "20px",
"line-height": "20px",
"float": "right",
"cursor": "pointer",
"border-radius": "3px",
"border": "1px solid #999",
"background-color": "#798795",
"color": "#FFF"
},
"modifyAction_disabled": {
"width": "50px",
"height": "20px",
"line-height": "20px",
"float": "right",
"cursor": "pointer",
"border-radius": "3px",
"border": "1px solid #999",
"background-color": "#d1dee9",
"color": "#999"
},
"errorNode": {
"height": "24px",
"background-color": "#fbe8e8",
"color": "#FF0000"
},
"errorTextNode": {
"height": "24px",
"line-height": "24px",
"background": "url("+"../x_component_process_FormDesigner/widget/$ValidationEditor/default/icon/error.png) no-repeat 5px center",
"padding-left": "30px"
},
"dictionaryNode" : {
"padding-left" : "5px",
"padding-top" : "5px"
},
"itemNode": {
"cursor": "pointer",
"height": "auto",
"margin": "2px 4px",
"background-color": "#fff",
"border": "1px solid #ddd"
},
"itemNode_current": {
"cursor": "pointer",
"height": "auto",
"margin": "2px 4px",
"background-color": "#eee",
"border": "1px solid #bbb"
},
"itemDeleteNode": {
"width": "20px",
"height": "24px",
"float": "right",
"background": "url("+"../x_component_process_FormDesigner/widget/$ValidationEditor/default/icon/delete1.png) no-repeat center center",
"cursor": "pointer"
},
"itemContentNode": {
"padding": "5px",
"margin-right": "20px",
"height": "auto",
"overflow": "hidden",
"text-overflow": "ellipsis",
"white-space": "nowrap"
}
}
\ No newline at end of file
MWF.xApplication.process.FormDesigner.widget = MWF.xApplication.process.FormDesigner.widget || {};
MWF.require("MWF.widget.UUID", null, false);
MWF.require("MWF.widget.O2Identity", null, false);
MWF.xApplication.process.FormDesigner.widget.DictionaryIncluder = new Class({
Implements: [Options, Events],
Extends: MWF.widget.Common,
options: {
"style": "default",
"maxObj": document.body
},
initialize: function(node, designer, options){
this.setOptions(options);
this.node = $(node);
this.designer = designer;
this.path = "../x_component_process_FormDesigner/widget/$DictionaryIncluder/";
this.cssPath = "../x_component_process_FormDesigner/widget/$DictionaryIncluder/"+this.options.style+"/css.wcss";
this._loadCss();
this.lp = this.designer.lp.dictionaryIncluder;
this.items = [];
},
load: function(data){
this.editorNode = new Element("div", {"styles": this.css.editorNode}).inject(this.node);
this.actionNode = new Element("div", {"styles": this.css.actionNode}).inject(this.node);
this.listNode = new Element("div", {"styles": this.css.listNode}).inject(this.node);
this.loadEditorNode();
this.loadActionNode();
this.loadListNode(data);
},
loadEditorNode: function(){
debugger;
var html = "<table width='100%' border='0' cellpadding='5' cellspacing='0' class='editTable'>" +
"<tr><td>"+this.lp.selectDictionary+"</td><td><div class='dictionarySelectorArea'></div></td></tr>" +
"<tr><td>"+this.lp.path+"</td><td><input type='text' style='width:90%'/></td></tr>"+
"</table>";
this.editorNode.set("html", html);
var tds = this.editorNode.getElements("td").setStyles(this.css.editTableTdValue);
this.dictionarySelectorArea = this.editorNode.getElement(".dictionarySelectorArea");
this.pathField = this.editorNode.getElement("input[type='text']");
this.loadDictionarySelector();
},
loadDictionarySelector: function( data ){
MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
var _self = this;
if( !data )data = [];
this.dictionarySelector = new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(this.dictionarySelectorArea, this.designer, {
"type": "Dictionary",
"count": 1,
"names": data,
"onChange": function(ids){
var json;
if( ids.length ){
var d = ids[0].data;
json = {
"type" : "dictionary",
"name": d.name,
"alias": d.alias,
"id": d.id,
"appName" : d.appName || d.applicationName,
"appId": d.appId || d.application,
"appAilas": d.appAilas || d.applicationAilas,
"appType" : d.appType
};
}
this.currentSelectDictionary = json;
}.bind(this)
});
}.bind(this));
},
loadActionNode: function(){
this.actionAreaNode = new Element("div", {"styles": this.css.actionAreaNode}).inject(this.actionNode);
this.addAction = new Element("div", {"styles": this.css.addAction, "text": this.designer.lp.validation.add}).inject(this.actionAreaNode);
this.modifyAction = new Element("div", {"styles": this.css.modifyAction_disabled, "text": this.designer.lp.validation.modify}).inject(this.actionAreaNode);
this.addAction.addEvent("click", function(){
this.add();
}.bind(this));
this.modifyAction.addEvent("click", function(){
this.modify();
}.bind(this));
},
getCurrentData: function(){
return {
"path": this.pathField.get("value"),
"dictionary": this.currentSelectDictionary || null
};
},
add: function(){
debugger;
this.hideErrorNode();
var data = this.getCurrentData();
if ( !data.dictionary ){
this.showErrorNode(this.lp.selectDictionaryNotice);
return false;
}
for( var i=0; i<this.items.length; i++ ){
var d = this.items[i].data;
if( d.dictionary.id === data.dictionary.id ){
if( d.path === data.path ){
this.showErrorNode(this.lp.repeatAddDictionaryNotice);
return false;
}else if( !d.path || d.path === "root" ){
this.showErrorNode(this.lp.rootDictionaryExistNotice);
return false;
}else if( !data.path || data.path === "root" ){
this.showErrorNode(this.lp.subDictionaryExistNotice);
return false;
}else if( d.path.indexOf( data.path + "." ) === 0 ){
this.showErrorNode(this.lp.subDictionaryExistNotice);
return false;
}else if( data.path.indexOf( d.path + "." ) === 0 ){
this.showErrorNode(this.lp.parentDictionaryExistNotice);
return false;
}
}
}
var item = new MWF.xApplication.process.FormDesigner.widget.DictionaryIncluder.Item(data, this);
this.items.push(item);
item.selected();
this.empty();
this.fireEvent("change");
},
empty: function(){
this.pathField.set("value","");
if(this.dictionarySelector)this.dictionarySelector.setData( [] );
this.currentSelectDictionary = null;
},
showErrorNode: function(text){
this.errorNode = new Element("div", {"styles": this.css.errorNode}).inject(this.actionNode, "before");
this.errorTextNode = new Element("div", {"styles": this.css.errorTextNode}).inject(this.errorNode);
this.errorTextNode.set("text", text);
this.errorNode.addEvent("click", function(){this.hideErrorNode();}.bind(this));
},
hideErrorNode: function(){
if (this.errorNode) this.errorNode.destroy();
},
modify: function(){
debugger;
if (this.currentItem){
this.hideErrorNode();
var data = this.getCurrentData();
if ( !data.dictionary ){
this.showErrorNode(this.lp.selectDictionaryNotice);
return false;
}
for( var i=0; i<this.items.length; i++ ){
if( this.items[i] === this.currentItem )continue;
var d = this.items[i].data;
if( d.dictionary.id === data.dictionary.id ){
if( d.path === data.path ){
this.showErrorNode(this.lp.repeatAddDictionaryNotice);
return false;
}else if( !d.path || d.path === "root" ){
this.showErrorNode(this.lp.rootDictionaryExistNotice);
return false;
}else if( !data.path || data.path === "root" ){
this.showErrorNode(this.lp.subDictionaryExistNotice);
return false;
}else if( d.path.indexOf( data.path + "." ) === 0 ){
this.showErrorNode(this.lp.subDictionaryExistNotice);
return false;
}else if( data.path.indexOf( d.path + "." ) === 0 ){
this.showErrorNode(this.lp.parentDictionaryExistNotice);
return false;
}
}
}
this.currentItem.reload(data);
this.currentItem.unSelected();
this.disabledModify();
this.empty();
this.fireEvent("change");
}
},
loadListNode: function(data){
if (data){
if (data.length){
data.each(function(itemData){
var item = new MWF.xApplication.process.FormDesigner.widget.DictionaryIncluder.Item(itemData, this);
this.items.push(item);
}.bind(this));
}
}
},
enabledModify: function(){
this.modifyAction.setStyles(this.css.modifyAction);
},
disabledModify: function(){
this.modifyAction.setStyles(this.css.modifyAction_disabled);
},
setData: function(data){
this.pathField.set( "value", data.path || "");
if( !this.dictionarySelector ){
this.loadDictionarySelector( data.dictionary ? [data.dictionary] : [] );
}else{
this.dictionarySelector.setData( data.dictionary ? [data.dictionary] : [] );
}
this.currentSelectDictionary = data.dictionary;
},
deleteItem: function(item){
if (this.currentItem == item) item.unSelected();
this.items.erase(item);
item.node.destroy();
MWF.release(item);
this.fireEvent("change");
},
getData: function(){
var data = [];
this.items.each(function(item){
data.push(item.data);
});
return data;
}
});
MWF.xApplication.process.FormDesigner.widget.DictionaryIncluder.Item = new Class({
initialize: function(data, editor){
this.data = data;
this.editor = editor;
this.container = this.editor.listNode;
this.css = this.editor.css;
this.lp = this.editor.designer.lp;
this.load();
},
load: function(){
debugger;
this.node = new Element("div", {"styles": this.css.itemNode}).inject(this.container);
this.deleteNode = new Element("div", {"styles": this.css.itemDeleteNode}).inject(this.node);
this.contentNode = new Element("div", {"styles": this.css.itemContentNode}).inject(this.node);
this.dictionaryNode = new Element("div", {
styles : this.css.dictionaryNode
}).inject(this.contentNode);
new MWF.widget.O2Dictionary(this.data.dictionary, this.dictionaryNode);
this.pathNode = new Element("div", {"styles": {"padding-left": "5px","padding-top": "5px"}}).inject(this.contentNode);
this.pathNode.set({
"text": this.lp.dictionaryIncluder.path + (this.data.path || "root")
});
this.contentNode.addEvent("click", function(){
this.selected();
}.bind(this));
this.deleteNode.addEvent("click", function(e){
this.deleteItem(e);
}.bind(this));
},
reload: function(data){
this.data = data;
this.pathNode.set({
"text": this.lp.dictionaryIncluder.path + (this.data.path || "root")
});
this.dictionaryNode.empty();
new MWF.widget.O2Dictionary(data.dictionary, this.dictionaryNode)
},
selected: function(){
if (this.editor.currentItem) this.editor.currentItem.unSelected();
this.node.setStyles(this.css.itemNode_current);
this.editor.currentItem = this;
this.editor.setData(this.data);
this.editor.enabledModify();
},
unSelected: function(){
this.node.setStyles(this.css.itemNode);
this.editor.currentItem = null;
//this.editor.modifyValidation();
this.editor.disabledModify();
},
deleteItem: function(e){
var _self = this;
this.editor.designer.confirm("warn", e, this.lp.dictionaryIncluder.delete_title, this.lp.dictionaryIncluder.delete_text, 300, 120, function(){
_self.destroy();
this.close();
}, function(){
this.close();
});
},
destroy: function(){
this.editor.deleteItem(this);
}
});
\ No newline at end of file
......@@ -217,6 +217,7 @@ MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class({
this.loadRelatedScript();
//this.loadResource( function () {
this.loadDictionaryList( function () {
this.fireEvent("queryLoad");
if (this.event_resolve){
this.event_resolve(function(){
......@@ -225,6 +226,8 @@ MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class({
}else{
this.loadForm(callback);
}
}.bind(this));
//}.bind(this));
}.bind(this));
......@@ -258,72 +261,87 @@ MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class({
loadDictionaryList: function( callback ){
this.dictionaryLoaded = false;
var loadedCount = 0;
if( this.json.dictionaries && this.json.dictionaries.length ){
this.json.dictionaries.map(function (d) {
d.type = d.appType;
d.application = d.application || d.appId || d.appName;
new this.Macro.environment.Dict( d ).get( "", function(){
loadedCount++;
if (this.json.dictionaries.length <= loadedCount){
this.dictionaryLoaded = true;
if(callback)callback();
}
}.bind(this), null, true);
if( this.json.includeDictionaries && this.json.includeDictionaries.length ){
var fun = function () {
loadedCount++;
if (this.json.includeDictionaries.length <= loadedCount){
this.dictionaryLoaded = true;
if(callback)callback();
}
}.bind(this);
this.json.includeDictionaries.map(function (d) {
var action = MWF.Actions.get( d.dictionary.appType === "cms" ? "x_cms_assemble_control" : "x_processplatform_assemble_surface");
if ( d.path && d.path !== "root" ){
action[ "getDictData" ]( d.dictionary.id, d.dictionary.appId, d.path, function(json){
MWF.xScript.addDictToCache(d.dictionary, d.path, json.data);
fun();
}.bind(this), function(){
fun();
}.bind(this), true );
}else{
action[ "getDictRoot" ](d.dictionary.id, d.dictionary.appId, function(json){
MWF.xScript.addDictToCache(d.dictionary, d.path, json.data);
fun();
}.bind(this), function(){
fun();
}.bind(this), true );
}
}.bind(this));
}else{
this.dictionaryLoaded = true;
if(callback)callback();
}
},
loadScriptList : function( callback ){
var asyncList = [];
var syncList = [];
this.syncScriptLoaded = false;
this.asyncScriptLoaded = false;
if( this.json.scripts && this.json.scripts.length ){
for( var i=0; i<this.json.scripts.length; i++ ){
var script = this.json.scripts[i];
script.scriptList.map( function ( s ) {
s.type = s.appType;
s.application = s.application || s.appId || s.appName;
});
if( script.async ){
asyncList = asyncList.concat( script.scriptList );
}else{
syncList = syncList.concat( script.scriptList );
}
}
}
var loadSyncList = function () {
if( syncList.length === 0 ){
this.syncScriptLoaded = true;
if(callback)callback();
}else{
this.Macro.environment.include(syncList, function(){
this.syncScriptLoaded = true;
if(callback)callback();
}.bind(this), false);
}
}.bind(this);
var loadAsyncList = function () {
if( asyncList.length === 0 ){
this.asyncScriptLoaded = true;
if(callback)callback();
}else{
this.Macro.environment.include(asyncList, function(){
this.asyncScriptLoaded = true;
if(callback)callback();
}.bind(this), true);
}
}.bind(this);
loadAsyncList();
loadSyncList();
},
// loadScriptList : function( callback ){
// var asyncList = [];
// var syncList = [];
//
// this.syncScriptLoaded = false;
// this.asyncScriptLoaded = false;
//
// if( this.json.scripts && this.json.scripts.length ){
// for( var i=0; i<this.json.scripts.length; i++ ){
// var script = this.json.scripts[i];
// script.scriptList.map( function ( s ) {
// s.type = s.appType;
// s.application = s.application || s.appId || s.appName;
// });
// if( script.async ){
// asyncList = asyncList.concat( script.scriptList );
// }else{
// syncList = syncList.concat( script.scriptList );
// }
// }
// }
//
// var loadSyncList = function () {
// if( syncList.length === 0 ){
// this.syncScriptLoaded = true;
// if(callback)callback();
// }else{
// this.Macro.environment.include(syncList, function(){
// this.syncScriptLoaded = true;
// if(callback)callback();
// }.bind(this), false);
// }
// }.bind(this);
//
// var loadAsyncList = function () {
// if( asyncList.length === 0 ){
// this.asyncScriptLoaded = true;
// if(callback)callback();
// }else{
// this.Macro.environment.include(asyncList, function(){
// this.asyncScriptLoaded = true;
// if(callback)callback();
// }.bind(this), true);
// }
// }.bind(this);
//
// loadAsyncList();
// loadSyncList();
// },
loadForm: function(callback){
if (this.lockDataPerson){
var text = MWF.xApplication.process.Xform.LP.keyLockInfor;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册