1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533 |
- MWF.xApplication = MWF.xApplication || {};
- MWF.xApplication.query = MWF.xApplication.query || {};
- MWF.xApplication.query.ViewDesigner = MWF.xApplication.query.ViewDesigner || {};
- MWF.APPDVD = MWF.xApplication.query.ViewDesigner;
- MWF.require("MWF.widget.Common", null, false);
- MWF.require("MWF.xScript.Macro", null, false);
- MWF.xDesktop.requireApp("query.ViewDesigner", "lp."+MWF.language, null, false);
- MWF.xDesktop.requireApp("query.ViewDesigner", "Property", null, false);
- MWF.xApplication.query.ViewDesigner.View = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "isView": false,
- "showTab": true,
- "propertyPath": "../x_component_query_ViewDesigner/$View/view.html"
- },
- initialize: function(designer, data, options){
- this.setOptions(options);
- this.path = "../x_component_query_ViewDesigner/$View/";
- this.cssPath = "../x_component_query_ViewDesigner/$View/"+this.options.style+"/css.wcss";
- this._loadCss();
- this.designer = designer;
- this.data = data;
- if (!this.data.data) this.data.data = {};
- this.parseData();
- this.node = this.designer.designNode;
- //this.tab = this.designer.tab;
- this.areaNode = new Element("div", {"styles": {"height": "100%", "overflow": "auto"}});
- //MWF.require("MWF.widget.ScrollBar", function(){
- // new MWF.widget.ScrollBar(this.areaNode, {"distance": 100});
- //}.bind(this));
- this.propertyListNode = this.designer.propertyDomArea;
- //this.propertyNode = this.designer.propertyContentArea;
- if(this.designer.application) this.data.applicationName = this.designer.application.name;
- if(this.designer.application) this.data.application = this.designer.application.id;
- this.isNewView = (this.data.name) ? false : true;
- this.items = [];
- this.view = this;
- this.autoSave();
- this.designer.addEvent("queryClose", function(){
- if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
- }.bind(this));
- },
- autoSave: function(){
- this.autoSaveTimerID = window.setInterval(function(){
- if (!this.autoSaveCheckNode) this.autoSaveCheckNode = this.designer.contentToolbarNode.getElement("#MWFDictionaryAutoSaveCheck");
- if (this.autoSaveCheckNode){
- if (this.autoSaveCheckNode.get("checked")){
- this.save();
- }
- }
- }.bind(this), 60000);
- },
- parseData: function(){
- this.json = this.data;
- if( !this.json.data.events ){
- var url = "../x_component_query_ViewDesigner/$View/view.json";
- MWF.getJSON(url, {
- "onSuccess": function(obj){
- this.json.data.events = obj.data.events;
- }.bind(this),
- "onerror": function(text){
- this.notice(text, "error");
- }.bind(this),
- "onRequestFailure": function(xhr){
- this.notice(xhr.responseText, "error");
- }.bind(this)
- },false);
- }
- },
- showProperty: function(){
- if (!this.property){
- this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.designer.propertyContentArea, this.designer, {
- "path": this.options.propertyPath,
- "onPostLoad": function(){
- this.property.show();
- }.bind(this)
- });
- this.property.load();
- }else{
- this.property.show();
- }
- },
- hideProperty: function(){
- if (this.property) this.property.hide();
- },
- load : function(){
- this.setAreaNodeSize();
- this.designer.addEvent("resize", this.setAreaNodeSize.bind(this));
- this.areaNode.inject(this.node);
- this.designer.viewListAreaNode.getChildren().each(function(node){
- var view = node.retrieve("view");
- if (view.id==this.data.id){
- if (this.designer.currentListViewItem){
- this.designer.currentListViewItem.setStyles(this.designer.css.listViewItem);
- }
- node.setStyles(this.designer.css.listViewItem_current);
- this.designer.currentListViewItem = node;
- this.lisNode = node;
- }
- }.bind(this));
- this.domListNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.designer.propertyDomArea);
- this.loadTemplateStyle( function () {
- this.loadActionbar();
- this.loadView();
- this.loadPaging();
- this.selected();
- this.setEvent();
- //if (this.options.showTab) this.page.showTabIm();
- this.setViewWidth();
- this.designer.addEvent("resize", this.setViewWidth.bind(this));
- this.fireEvent("postLoad");
- }.bind(this))
- },
- setEvent: function(){
- this.areaNode.addEvent("click", this.selected.bind(this));
- this.refreshNode.addEvent("click", function(e){
- this.loadViewData();
- e.stopPropagation();
- }.bind(this));
- this.addColumnNode.addEvent("click", function(e){
- this.addColumn();
- e.stopPropagation();
- }.bind(this));
- },
- loadViewData: function(){
- if (this.data.id){
- this.saveSilence(function(){
- this.viewContentBodyNode.empty();
- this.viewContentTableNode = new Element("table", {
- "styles": this.css.viewContentTableNode,
- "border": "0px",
- "cellPadding": "0",
- "cellSpacing": "0"
- }).inject(this.viewContentBodyNode);
- this.designer.actions.loadView(this.data.id, null,function(json){
- var entries = {};
- json.data.selectList.each(function(entry){entries[entry.column] = entry;}.bind(this));
- if (this.json.data.group.column){
- if (json.data.groupGrid.length){
- var groupColumn = null;
- for (var c = 0; c<json.data.selectList.length; c++){
- if (json.data.selectList[c].column === json.data.group.column){
- groupColumn = json.data.selectList[c];
- break;
- }
- }
- json.data.groupGrid.each(function(line, idx){
- var groupTr = new Element("tr", {
- "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTr"] : this.css.viewContentTrNode,
- "data-is-group" : "yes"
- }).inject(this.viewContentTableNode);
- var colSpan = this.items.length ;
- var td = new Element("td", {
- "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentGroupTd"] : this.css.viewContentGroupTdNode,
- "colSpan": colSpan
- }).inject(groupTr);
- var groupAreaNode;
- if( this.json.data.viewStyles ){
- groupAreaNode = new Element("div", {"styles": this.json.data.viewStyles["groupCollapseNode"]}).inject(td);
- groupAreaNode.set("text", line.group);
- }else{
- groupAreaNode = new Element("div", {"styles": this.css.viewContentTdGroupNode}).inject(td);
- var groupIconNode = new Element("div", {"styles": this.css.viewContentTdGroupIconNode}).inject(groupAreaNode);
- var groupTextNode = new Element("div", {"styles": this.css.viewContentTdGroupTextNode}).inject(groupAreaNode);
- if (groupColumn){
- //groupTextNode.set("text", (groupColumn.code) ? MWF.Macro.exec(groupColumn.code, {"value": line.group, "gridData": json.data.groupGrid, "data": json.data, "entry": line}) : line.group);
- groupTextNode.set("text", line.group);
- }else{
- groupTextNode.set("text", line.group);
- }
- }
- var subtrs = [];
- line.list.each(function(entry){
- var tr = new Element("tr", {
- "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTr"] : this.css.viewContentTrNode
- }).inject(this.viewContentTableNode);
- tr.setStyle("display", "none");
- //this.createViewCheckboxTd( tr );
- var td = new Element("td", {
- "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTd"] : this.css.viewContentTdNode
- }).inject(tr);
- Object.each(entries, function(c, k){
- var d = entry.data[k];
- if (d!=undefined){
- if (k!=this.json.data.group.column){
- var td = new Element("td", {
- "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTd"] : this.css.viewContentTdNode
- }).inject(tr);
- //td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.groupGrid, "data": json.data, "entry": entry}) : d);
- if (c.isHtml){
- td.set("html", d);
- }else{
- td.set("text", d);
- }
- }
- }
- }.bind(this));
- // Object.each(entry.data, function(d, k){
- // if (k!=this.json.data.group.column){
- // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
- // td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.groupGrid, "data": json.data, "entry": entry}) : d);
- // }
- // }.bind(this));
- subtrs.push(tr)
- }.bind(this));
- groupAreaNode.store("subtrs", subtrs);
- var _self = this;
- groupAreaNode.addEvent("click", function(){
- var subtrs = this.retrieve("subtrs");
- var iconNode = groupAreaNode.getFirst("div");
- if (subtrs[0]){
- if (subtrs[0].getStyle("display")=="none"){
- subtrs.each(function(subtr){ subtr.setStyle("display", "table-row"); });
- if( iconNode ) {
- iconNode.setStyle("background", "url(" + "../x_component_query_ViewDesigner/$View/default/icon/down.png) center center no-repeat");
- }else{
- this.setStyles( _self.json.data.viewStyles["groupExpandNode"] )
- }
- }else{
- subtrs.each(function(subtr){ subtr.setStyle("display", "none"); });
- if( iconNode ) {
- iconNode.setStyle("background", "url(" + "../x_component_query_ViewDesigner/$View/default/icon/right.png) center center no-repeat");
- }else{
- this.setStyles( _self.json.data.viewStyles["groupCollapseNode"] )
- }
- }
- }
- _self.setContentHeight();
- });
- }.bind(this));
- this.setContentColumnWidth();
- this.setContentHeight();
- }else if(this.json.data.noDataText){
- var noDataTextNodeStyle = this.css.noDataTextNode;
- if( this.json.data.viewStyles ){
- if( this.json.data.viewStyles["noDataTextNode"] ){
- noDataTextNodeStyle = this.json.data.viewStyles["noDataTextNode"]
- }else{
- this.json.data.viewStyles["noDataTextNode"] = this.css.noDataTextNode
- }
- }
- this.noDataTextNode = new Element( "div", {
- "styles": noDataTextNodeStyle,
- "text" : this.json.data.noDataText
- }).inject( this.viewContentBodyNode );
- }
- }else{
- if (json.data.grid.length){
- json.data.grid.each(function(line, idx){
- var tr = new Element("tr", {
- "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTr"] : this.css.viewContentTrNode
- }).inject(this.viewContentTableNode);
- //this.createViewCheckboxTd( tr );
- Object.each(entries, function(c, k){
- var d = line.data[k];
- if (d!=undefined){
- var td = new Element("td", {
- "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTd"] : this.css.viewContentTdNode
- }).inject(tr);
- //td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.grid, "data": json.data, "entry": line}) : d);
- if (c.isHtml){
- td.set("html", d);
- }else{
- td.set("text", d);
- }
- //td.set("text", d);
- }
- }.bind(this));
- // Object.each(line.data, function(d, k){
- // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
- // td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.grid, "data": json.data, "entry": line}) : d);
- // }.bind(this));
- }.bind(this));
- this.setContentColumnWidth();
- this.setContentHeight();
- }else if(this.json.data.noDataText){
- var noDataTextNodeStyle = this.css.noDataTextNode;
- if( this.json.data.viewStyles ){
- if( this.json.data.viewStyles["noDataTextNode"] ){
- noDataTextNodeStyle = this.json.data.viewStyles["noDataTextNode"]
- }else{
- this.json.data.viewStyles["noDataTextNode"] = this.css.noDataTextNode
- }
- }
- this.noDataTextNode = new Element( "div", {
- "styles": noDataTextNodeStyle,
- "text" : this.json.data.noDataText
- }).inject( this.viewContentBodyNode );
- }
- }
- }.bind(this));
- //this.getLookupAction(function(){
- // this.lookupAction.invoke({"name": "lookup","async": true, "parameter": {"id": this.data.id},"success": function(json){
- // if (json.data.length){
- // json.data.each(function(line, idx){
- // var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
- // line.each(function(cell, i){
- // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
- // td.set("text", cell);
- // }.bind(this));
- // }.bind(this));
- // this.setContentColumnWidth();
- // this.setContentHeight();
- // }
- // }.bind(this)});
- //}.bind(this));
- }.bind(this));
- }
- },
- setContentColumnWidth: function(){
- var titleTds = this.viewTitleTrNode.getElements("td");
- var widthList = [];
- titleTds.each(function(td){widthList.push(td.getSize().x);});
- var flag = false;
- if (this.viewContentTableNode){
- trs = this.viewContentTableNode.getElements("tr");
- for (var i=0; i<trs.length; i++){
- var tr = trs[i];
- var tds = tr.getElements("td");
- tds.each(function(contentTd, i){
- if (contentTd.get("colSpan")==1){
- contentTd.setStyle("width", ""+widthList[i]+"px");
- flag = true;
- }
- });
- if (flag) break;
- }
- //var tr = this.viewContentTableNode.getFirst("tr");
- //if (tr){
- // var tds = tr.getElements("td");
- // tds.each(function(contentTd, i){
- // if (!contentTd.get("colSpan")){
- // contentTd.setStyle("width", ""+widthList[i]+"px");
- // }
- // });
- //}
- }
- },
- //getLookupAction: function(callback){
- // if (!this.lookupAction){
- // MWF.require("MWF.xDesktop.Actions.RestActions", function(){
- // this.lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface_lookup", "");
- // this.lookupAction.getActions = function(actionCallback){
- //
- // this.actions = {"lookup": {"uri": "/jaxrs/view/{id}"}};
- // if (actionCallback) actionCallback();
- // }
- // if (callback) callback();
- // }.bind(this));
- // }else{
- // if (callback) callback();
- // }
- //},
- addColumn: function(){
- debugger;
- MWF.require("MWF.widget.UUID", function(){
- var id = (new MWF.widget.UUID).id;
- var json = {
- "id": id,
- "column": id,
- "displayName": this.designer.lp.unnamed,
- "orderType": "original"
- };
- if (!this.json.data.selectList) this.json.data.selectList = [];
- this.json.data.selectList.push(json);
- var column = new MWF.xApplication.query.ViewDesigner.View.Column(json, this);
- this.items.push(column);
- column.selected();
- if (this.viewContentTableNode){
- var trs = this.viewContentTableNode.getElements("tr");
- trs.each(function(tr){
- new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr)
- }.bind(this));
- //this.setContentColumnWidth();
- }
- this.setViewWidth();
- this.addColumnNode.scrollIntoView(false);
- }.bind(this));
- //new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 0}).toRight();
- },
- selected: function(){
- if (this.currentSelectedModule){
- if (this.currentSelectedModule==this){
- return true;
- }else{
- this.currentSelectedModule.unSelected();
- }
- }
- this.currentSelectedModule = this;
- this.showProperty();
- },
- unSelected: function(){
- this.currentSelectedModule = null;
- this.hideProperty();
- },
- loadViewNodes: function(){
- this.viewAreaNode = new Element("div#viewAreaNode", {"styles": this.css.viewAreaNode}).inject(this.areaNode);
- this.viewTitleNode = new Element("div#viewTitleNode", {"styles": this.css.viewTitleNode}).inject(this.viewAreaNode);
- this.refreshNode = new Element("div", {"styles": this.css.refreshNode}).inject(this.viewTitleNode);
- this.addColumnNode = new Element("div", {"styles": this.css.addColumnNode}).inject(this.viewTitleNode);
- this.viewTitleContentNode = new Element("div", {"styles": this.css.viewTitleContentNode}).inject(this.viewTitleNode);
- this.viewTitleTableNode = new Element("table", {
- "styles": this.css.viewTitleTableNode,
- "border": "0px",
- "cellPadding": "0",
- "cellSpacing": "0"
- }).inject(this.viewTitleContentNode);
- this.viewTitleTrNode = new Element("tr", {"styles": this.css.viewTitleTrNode}).inject(this.viewTitleTableNode);
- this.viewContentScrollNode = new Element("div", {"styles": this.css.viewContentScrollNode}).inject(this.viewAreaNode);
- this.viewContentNode = new Element("div", {"styles": this.css.viewContentNode}).inject(this.viewContentScrollNode);
- MWF.require("MWF.widget.ScrollBar", function(){
- new MWF.widget.ScrollBar(this.viewContentScrollNode, {"style": "view", "distance": 100, "indent": false});
- }.bind(this));
- this.contentLeftNode = new Element("div", {"styles": this.css.contentLeftNode}).inject(this.viewContentNode);
- this.contentRightNode = new Element("div", {"styles": this.css.contentRightNode}).inject(this.viewContentNode);
- this.viewContentBodyNode = new Element("div", {"styles": this.css.viewContentBodyNode}).inject(this.viewContentNode);
- this.viewContentTableNode = new Element("table", {
- "styles": this.css.viewContentTableNode,
- "border": "0px",
- "cellPadding": "0",
- "cellSpacing": "0"
- }).inject(this.viewContentBodyNode);
- },
- setContentHeight: function(){
- var size = this.areaNode.getSize();
- var titleSize = this.viewTitleNode.getSize();
- var actionbarSize = this.actionbarNode ? this.actionbarNode.getSize() : {x:0, y:0};
- var pagingSize = this.pagingNode ? this.pagingNode.getSize() : {x:0, y:0};
- var height = size.y-titleSize.y-actionbarSize.y-pagingSize.y-2;
- this.viewContentScrollNode.setStyle("height", height);
- var contentSize = this.viewContentBodyNode.getSize();
- if (height<contentSize.y) height = contentSize.y+10;
- this.viewContentNode.setStyle("height", height);
- this.contentLeftNode.setStyle("height", height);
- this.contentRightNode.setStyle("height", height);
- //this.viewContentBodyNode.setStyle("min-height", height);
- },
- loadViewColumns: function(){
- // for (var i=0; i<10; i++){
- if (this.json.data.selectList) {
- this.json.data.selectList.each(function (json) {
- this.items.push(new MWF.xApplication.query.ViewDesigner.View.Column(json, this));
- }.bind(this));
- }
- // }
- },
- loadViewSelectAllNode : function(){
- var _self = this;
- var td = new Element("td.viewTitleCheckboxTd",{ "styles": this.css.viewTitleColumnAreaNode }).inject( this.viewTitleTrNode );
- td.setStyles({
- "width":"30px", "text-align" : "center",
- "display" : this.json.data.selectAllEnable ? "table-cell" : "none"
- });
- new Element("input",{
- "type" : "checkbox",
- "events" : {
- "change" : function(){
- _self.viewContentTableNode.getElements(".viewContentCheckbox").set("checked", this.checked )
- }
- }
- }).inject(td);
- },
- createViewCheckboxTd : function( tr ){
- var td = new Element("td.viewContentCheckboxTd", {"styles": this.css.viewContentTdNode}).inject(tr, "top");
- td.setStyles({
- "width":"30px", "text-align" : "center",
- "display" : this.json.data.selectAllEnable ? "table-cell" : "none"
- });
- new Element("input.viewContentCheckbox",{
- "type" : "checkbox"
- }).inject(td);
- },
- loadView: function(){
- this.loadViewNodes();
- //this.loadViewSelectAllNode();
- this.loadViewColumns();
- // this.addTopItemNode.addEvent("click", this.addTopItem.bind(this));
- },
- loadActionbar: function(){
- this.actionbarNode = new Element("div#actionbarNode", {"styles": this.css.actionbarNode}).inject(this.areaNode);
- this.actionbarList = [];
- if( !this.json.data.actionbarHidden ){
- this.showActionbar( true );
- }
- },
- hideActionbar : function(){
- this.actionbarNode.hide();
- this.setContentHeight();
- },
- showActionbar : function( noSetHeight ){
- this.actionbarNode.show();
- if( !this.json.data.actionbarList )this.json.data.actionbarList = [];
- if( !this.actionbarList || this.actionbarList.length == 0 ){
- if( this.json.data.actionbarList.length ){
- this.json.data.actionbarList.each( function(json){
- this.actionbarList.push( new MWF.xApplication.query.ViewDesigner.View.Actionbar( json, this.json.data.actionbarList, this) )
- }.bind(this));
- }else{
- this.actionbarList.push( new MWF.xApplication.query.ViewDesigner.View.Actionbar( null, this.json.data.actionbarList, this) )
- }
- }
- if( !noSetHeight )this.setContentHeight();
- },
- loadPaging: function(){
- this.pagingNode = new Element("div#pagingNode", {"styles": this.css.pagingNode}).inject(this.areaNode);
- this.pagingList = [];
- if( !this.json.data.pagingbarHidden ){
- this.showPagingbar( true );
- }
- },
- hidePagingbar : function(){
- this.pagingNode.hide();
- this.setContentHeight();
- },
- showPagingbar : function( noSetHeight ){
- this.pagingNode.show();
- if( !this.json.data.pagingList )this.json.data.pagingList = [];
- if( !this.pagingList || this.pagingList.length == 0 ){
- if( this.json.data.pagingList.length ){
- this.json.data.pagingList.each( function(json){
- this.pagingList.push( new MWF.xApplication.query.ViewDesigner.View.Paging( json, this.json.data.pagingList, this) )
- }.bind(this));
- }else{
- this.pagingList.push( new MWF.xApplication.query.ViewDesigner.View.Paging( null, this.json.data.pagingList, this) )
- }
- }
- if( !noSetHeight )this.setContentHeight();
- },
- setViewWidth: function(){
- if( !this.viewAreaNode )return;
- this.viewAreaNode.setStyle("width", "auto");
- this.viewTitleNode.setStyle("width", "auto");
- var s1 = this.viewTitleTableNode.getSize();
- var s2 = this.refreshNode.getSize();
- var s3 = this.addColumnNode.getSize();
- var width = s1.x+s2.x+s2.x;
- var size = this.areaNode.getSize();
- if (width>size.x){
- this.viewTitleNode.setStyle("width", ""+width+"px");
- this.viewAreaNode.setStyle("width", ""+width+"px");
- }else{
- this.viewTitleNode.setStyle("width", ""+size.x+"px");
- this.viewAreaNode.setStyle("width", ""+size.x+"px");
- }
- this.setContentColumnWidth();
- this.setContentHeight();
- },
- //setPropertyContent: function(){
- // this.designer.propertyIdNode.set("text", this.data.id);
- // this.designer.propertyNameNode.set("value", this.data.name);
- // this.designer.propertyAliasNode.set("value", this.data.alias);
- // this.designer.propertyDescriptionNode.set("value", this.data.description);
- //
- // this.designer.jsonDomNode.empty();
- // MWF.require("MWF.widget.JsonParse", function(){
- // this.jsonParse = new MWF.widget.JsonParse(this.data.data, this.designer.jsonDomNode, this.designer.jsonTextAreaNode);
- // window.setTimeout(function(){
- // this.jsonParse.load();
- // }.bind(this), 1);
- // }.bind(this));
- //},
- setAreaNodeSize: function(){
- //var size = this.node.getSize();
- ////var tabSize = this.tab.tabNodeContainer.getSize();
- //var tabSize = this.node.getSize();
- //var y = size.y - tabSize.y;
- //this.areaNode.setStyle("height", ""+y+"px");
- //if (this.editor) if (this.editor.editor) this.editor.editor.resize();
- },
- // createRootItem: function() {
- // this.items.push(new MWF.xApplication.process.DictionaryDesigner.Dictionary.item("ROOT", this.data.data, null, 0, this, true));
- // },
- preview: function(){
- if( this.isNewView ){
- this.designer.notice( this.designer.lp.saveViewNotice, "error" );
- return;
- }
- this.saveSilence( function () {
- var url = "../x_desktop/app.html?app=query.Query&status=";
- url += JSON.stringify({
- id : this.data.application,
- viewId : this.data.id
- });
- window.open(o2.filterUrl(url),"_blank");
- }.bind(this));
- },
- saveSilence: function(callback){
- if (!this.data.name){
- this.designer.notice(this.designer.lp.notice.inputName, "error");
- return false;
- }
- if( !this.data.data && !this.data.data.where ){
- if( this.data.type === "cms" ){
- this.designer.notice(this.designer.lp.notice.selectCMS, "error");
- return false;
- }else{
- this.designer.notice(this.designer.lp.notice.selectProcess, "error");
- return false;
- }
- }else{
- var where = this.data.data.where;
- if( this.data.type === "cms" ){
- var appInfoList = where.appInfoList;
- var categoryInfoList = where.categoryInfoList;
- if( (!appInfoList || !appInfoList.length) && (!categoryInfoList || !categoryInfoList.length) ){
- this.designer.notice(this.designer.lp.notice.selectCMS, "error");
- return false;
- }
- }else{
- var applicationList = where.applicationList;
- var processList = where.processList;
- if( (!applicationList || !applicationList.length) && (!processList || !processList.length) ){
- this.designer.notice(this.designer.lp.notice.selectProcess, "error");
- return false;
- }
- }
- if( where.dateRange && where.dateRange.dateRangeType === "range" ){
- if( !where.dateRange.start || !where.dateRange.completed ){
- this.designer.notice(this.designer.lp.notice.selectDateRange, "error");
- return false;
- }
- }
- }
- // var list;
- // if( this.data.data && this.data.data.where ){
- // if( this.data.data.where.creatorIdentityList ){
- // list = this.data.data.where.creatorIdentityList;
- // for( var i=0; i< list.length ; i++){
- // if( typeOf( list[i] ) === "object" )list[i] = list[i].name || "";
- // }
- // }
- // if( this.data.data.where.creatorPersonList ){
- // list = this.data.data.where.creatorPersonList;
- // for( var i=0; i< list.length ; i++){
- // if( typeOf( list[i] ) === "object" )list[i] = list[i].name || "";
- // }
- // }
- // if( this.data.data.where.creatorUnitList ){
- // list = this.data.data.where.creatorIdentityList;
- // for( var i=0; i< list.length ; i++){
- // if( typeOf( list[i] ) === "object" )list[i] = list[i].name || "";
- // }
- // }
- // }
- this.designer.actions.saveView(this.data, function(json){
- this.data.id = json.data.id;
- this.isNewView = false;
- //this.page.textNode.set("text", this.data.name);
- if (this.lisNode) {
- this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
- }
- if (callback) callback();
- }.bind(this));
- },
- save: function(callback){
- //if (this.designer.tab.showPage==this.page){
- if (!this.data.name){
- this.designer.notice(this.designer.lp.notice.inputName, "error");
- return false;
- }
- //}
- if( !this.data.data && !this.data.data.where ){
- if( this.data.type === "cms" ){
- this.designer.notice(this.designer.lp.notice.selectCMS, "error");
- return false;
- }else{
- this.designer.notice(this.designer.lp.notice.selectProcess, "error");
- return false;
- }
- }else{
- var where = this.data.data.where;
- if( this.data.type === "cms" ){
- var appInfoList = where.appInfoList;
- var categoryInfoList = where.categoryInfoList;
- if( (!appInfoList || !appInfoList.length) && (!categoryInfoList || !categoryInfoList.length) ){
- this.designer.notice(this.designer.lp.notice.selectCMS, "error");
- return false;
- }
- }else{
- var applicationList = where.applicationList;
- var processList = where.processList;
- if( (!applicationList || !applicationList.length) && (!processList || !processList.length) ){
- this.designer.notice(this.designer.lp.notice.selectProcess, "error");
- return false;
- }
- }
- if( where.dateRange && where.dateRange.dateRangeType === "range" ){
- if( !where.dateRange.start || !where.dateRange.completed ){
- this.designer.notice(this.designer.lp.notice.selectDateRange, "error");
- return false;
- }
- }
- }
- debugger;
- // var list;
- // if( this.data.data && this.data.data.where ){
- // if( this.data.data.where.creatorIdentityList ){
- // list = this.data.data.where.creatorIdentityList;
- // for( var i=0; i< list.length ; i++){
- // if( typeOf( list[i] ) === "object" )list[i] = list[i].name || "";
- // }
- // }
- // if( this.data.data.where.creatorPersonList ){
- // list = this.data.data.where.creatorPersonList;
- // for( var i=0; i< list.length ; i++){
- // if( typeOf( list[i] ) === "object" )list[i] = list[i].name || "";
- // }
- // }
- // if( this.data.data.where.creatorUnitList ){
- // list = this.data.data.where.creatorUnitList;
- // for( var i=0; i< list.length ; i++){
- // if( typeOf( list[i] ) === "object" )list[i] = list[i].name || "";
- // }
- // }
- // }
- this.designer.actions.saveView(this.data, function(json){
- this.designer.notice(this.designer.lp.notice.save_success, "success", this.node, {"x": "left", "y": "bottom"});
- this.isNewView = false;
- this.data.id = json.data.id;
- //this.page.textNode.set("text", this.data.name);
- if (this.lisNode) {
- this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
- }
- if (callback) callback();
- }.bind(this));
- },
- explode: function(){},
- implode: function(){},
- _setEditStyle: function(name, input, oldValue){
- if (name=="type"){
- this.items.each(function(item){
- if (item.property){
- var processDiv = item.property.propertyContent.getElements("#"+item.json.id+"dataPathSelectedProcessArea");
- var cmsDiv = item.property.propertyContent.getElements("#"+item.json.id+"dataPathSelectedCMSArea");
- if (this.json[name]=="cms"){
- cmsDiv.setStyle("display", "block");
- processDiv.setStyle("display", "none");
- }else{
- cmsDiv.setStyle("display", "none");
- processDiv.setStyle("display", "block");
- }
- }
- }.bind(this));
- }
- if( name=="data.actionbarHidden" ){
- if( this.json.data.actionbarHidden ){
- this.hideActionbar()
- }else{
- this.showActionbar()
- }
- }
- if (name == "data.pagingbarHidden") {
- if (this.json.data.pagingbarHidden) {
- this.hidePagingbar()
- } else {
- this.showPagingbar()
- }
- }
- if( name=="data.selectAllEnable" ){
- if( this.json.data.selectAllEnable ){
- this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display","table-cell");
- this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display","table-cell");
- }else{
- this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display","none");
- this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display","none");
- }
- }
- if (name=="data.viewStyleType"){
- var loadOldTemplateStyle = function () {
- if( typeOf(oldValue) === "object" && oldValue.type === "script" ){ //如果原来是自定义表单样式
- this.loadCustomTemplateStyles( oldValue , function (oldTemplateStyles) {
- this.switchTemplateStyles( oldTemplateStyles );
- }.bind(this))
- }else{
- var oldFile, oldExtendFile;
- if( typeOf(oldValue) === "object" )oldValue === oldValue.id;
- if( oldValue && this.stylesList[oldValue] ){
- oldFile = this.stylesList[oldValue].file;
- oldExtendFile = this.stylesList[oldValue].extendFile;
- }
- this.loadTemplateStyles( oldFile, oldExtendFile, function( oldTemplateStyles ){
- this.switchTemplateStyles( oldTemplateStyles );
- }.bind(this))
- }
- }.bind(this);
- var viewStyleType = this.json.data.viewStyleType;
- if( typeOf(viewStyleType) === "object" && viewStyleType.type === "script" ){
- this.loadCustomTemplateStyles( viewStyleType , function (templateStyles) {
- this.templateStyles = templateStyles;
- loadOldTemplateStyle();
- this.json.data.styleConfig = viewStyleType;
- }.bind(this))
- }else{
- if( typeOf(viewStyleType) === "object" )viewStyleType = viewStyleType.id;
- var file = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].file : null;
- var extendFile = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].extendFile : null;
- this.loadTemplateStyles( file, extendFile, function( templateStyles ){
- this.templateStyles = templateStyles;
- loadOldTemplateStyle();
- this.json.data.styleConfig = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType] : null;
- //var oldFile, oldExtendFile;
- //if( oldValue && this.stylesList[oldValue] ){
- // oldFile = this.stylesList[oldValue].file;
- // oldExtendFile = this.stylesList[oldValue].extendFile;
- //}
- //this.loadTemplateStyles( oldFile, oldExtendFile, function( oldTemplateStyles ){
- //this.switchTemplateStyles( oldTemplateStyles );
- // this.json.data.styleConfig = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType] : null;
- //}.bind(this))
- }.bind(this))
- }
- }
- if (name=="data.viewStyles"){
- this.setCustomStyles();
- }
- },
- setAllStyles: function(){
- // this.setPropertiesOrStyles("styles");
- // this.setPropertiesOrStyles("properties");
- this.setCustomStyles();
- this.reloadMaplist();
- },
- reloadMaplist: function(){
- if (this.property) Object.each(this.property.maplists, function(map, name){ map.reload(this.json[name]);}.bind(this));
- },
- // setPropertiesOrStyles: function(name){
- // if (name=="styles"){
- // this.setCustomStyles();
- // }
- // if (name=="properties"){
- // this.node.setProperties(this.json.properties);
- // }
- // },
- setCustomStyles: function(){
- this.items.each( function( item ){
- item.setCustomStyles()
- }.bind(this));
- // var border = this.node.getStyle("border");
- // this.node.clearStyles();
- // this.node.setStyles((this.options.mode==="Mobile") ? this.css.formMobileNode : this.css.formNode);
- // var y = this.container.getStyle("height");
- // y = (y) ? y.toInt()-2 : this.container.getSize().y-2;
- // this.node.setStyle("min-height", ""+y+"px");
- //
- // if (this.initialStyles) this.node.setStyles(this.initialStyles);
- // this.node.setStyle("border", border);
- //
- // Object.each(this.json.styles, function(value, key){
- // var reg = /^border\w*/ig;
- // if (!key.test(reg)){
- // this.node.setStyle(key, value);
- // }
- // }.bind(this));
- },
- loadTemplateStyle : function( callback ){
- var setStyles = function ( templateStyles ){
- this.templateStyles = templateStyles;
- if( !this.json.data.viewStyleType )this.json.data.viewStyleType = "default";
- if ( this.templateStyles && this.templateStyles["view"]){
- if(!this.json.data.viewStyles){
- this.json.data.viewStyles = Object.clone(this.templateStyles["view"]);
- }else{
- this.setTemplateStyles(this.templateStyles["view"]);
- }
- }
- this.setCustomStyles();
- if(callback)callback();
- }.bind(this)
- this.loadStylesList(function(){
- var oldStyleValue = "";
- if (!this.json.data.viewStyleType) this.json.data.viewStyleType="default";
- var viewStyleType = this.json.data.viewStyleType;
- if( typeOf( viewStyleType ) === "object" && viewStyleType.type === "script" ){ //如果是自定义表单样式
- this.loadCustomTemplateStyles( viewStyleType, function ( templateStyles ) {
- setStyles( templateStyles )
- }.bind(this))
- }else {
- this.loadTemplateStyles( this.stylesList[viewStyleType].file, this.stylesList[viewStyleType].extendFile,
- function( templateStyles ){
- setStyles( templateStyles )
- }.bind(this)
- );
- }
- }.bind(this));
- },
- isForceClearCustomStyle: function (){
- return this.json.forceClearCustomStyle &&
- this.json.forceClearCustomStyle.length &&
- this.json.forceClearCustomStyle[0] === "yes"
- },
- removeStyles: function(from, to){
- if( this.isForceClearCustomStyle() ){
- this.json.data.viewStyles[to] = {};
- }else {
- if (this.json.data.viewStyles[to]) {
- Object.each(from, function (style, key) {
- if (this.json.data.viewStyles[to][key] && this.json.data.viewStyles[to][key] == style) {
- delete this.json.data.viewStyles[to][key];
- }
- }.bind(this));
- }
- }
- },
- copyStyles: function(from, to){
- if( this.isForceClearCustomStyle() ){
- this.json.data.viewStyles[to] = {};
- Object.each(from, function (style, key) {
- this.json.data.viewStyles[to][key] = style;
- }.bind(this));
- }else{
- if (!this.json.data.viewStyles[to]) this.json.data.viewStyles[to] = {};
- Object.each(from, function(style, key){
- if (!this.json.data.viewStyles[to][key]) this.json.data.viewStyles[to][key] = style;
- }.bind(this));
- }
- },
- // clearTemplateStyles: function(styles){
- // if (styles){
- // if (styles.styles) this.removeStyles(styles.styles, "styles");
- // if (styles.properties) this.removeStyles(styles.properties, "properties");
- // }
- // },
- // setTemplateStyles: function(styles){
- // if (styles.styles) this.copyStyles(styles.styles, "styles");
- // if (styles.properties) this.copyStyles(styles.properties, "properties");
- // },
- clearTemplateStyles: function(styles){
- if (styles){
- if (styles.container) this.removeStyles(styles.container, "container");
- if (styles.table) this.removeStyles(styles.table, "table");
- if (styles.titleTr) this.removeStyles(styles.titleTr, "titleTr");
- if (styles.titleTd) this.removeStyles(styles.titleTd, "titleTd");
- if (styles.contentTr) this.removeStyles(styles.contentTr, "contentTr");
- if (styles.contentSelectedTr) this.removeStyles(styles.contentSelectedTr, "contentSelectedTr");
- if (styles.contentTd) this.removeStyles(styles.contentTd, "contentTd");
- if (styles.zebraContentTd) this.removeStyles(styles.zebraContentTd, "zebraContentTd");
- if (styles.contentGroupTd) this.removeStyles(styles.contentGroupTd, "contentGroupTd");
- if (styles.groupCollapseNode) this.removeStyles(styles.groupCollapseNode, "groupCollapseNode");
- if (styles.groupExpandNode) this.removeStyles(styles.groupExpandNode, "groupExpandNode");
- if (styles.checkboxNode) this.removeStyles(styles.checkboxNode, "checkboxNode");
- if (styles.checkedCheckboxNode) this.removeStyles(styles.checkedCheckboxNode, "checkedCheckboxNode");
- if (styles.radioNode) this.removeStyles(styles.radioNode, "radioNode");
- if (styles.checkedRadioNode) this.removeStyles(styles.checkedRadioNode, "checkedRadioNode");
- if (styles.tableProperties) this.removeStyles(styles.tableProperties, "tableProperties");
- }
- },
- setTemplateStyles: function(styles){
- if (styles.container) this.copyStyles(styles.container, "container");
- if (styles.table) this.copyStyles(styles.table, "table");
- if (styles.titleTr) this.copyStyles(styles.titleTr, "titleTr");
- if (styles.titleTd) this.copyStyles(styles.titleTd, "titleTd");
- if (styles.contentTr) this.copyStyles(styles.contentTr, "contentTr");
- if (styles.contentSelectedTr) this.copyStyles(styles.contentSelectedTr, "contentSelectedTr");
- if (styles.contentTd) this.copyStyles(styles.contentTd, "contentTd");
- if (styles.zebraContentTd) this.copyStyles(styles.zebraContentTd, "zebraContentTd");
- if (styles.contentGroupTd) this.copyStyles(styles.contentGroupTd, "contentGroupTd");
- if (styles.groupCollapseNode) this.copyStyles(styles.groupCollapseNode, "groupCollapseNode");
- if (styles.groupExpandNode) this.copyStyles(styles.groupExpandNode, "groupExpandNode");
- if (styles.checkboxNode) this.copyStyles(styles.checkboxNode, "checkboxNode");
- if (styles.checkedCheckboxNode) this.copyStyles(styles.checkedCheckboxNode, "checkedCheckboxNode");
- if (styles.radioNode) this.copyStyles(styles.radioNode, "radioNode");
- if (styles.checkedRadioNode) this.copyStyles(styles.checkedRadioNode, "checkedRadioNode");
- if (styles.tableProperties) this.copyStyles(styles.tableProperties, "tableProperties");
- },
- switchTemplateStyles : function( oldTemplateStyles ){
- if (oldTemplateStyles["view"]) this.clearTemplateStyles(oldTemplateStyles["view"]);
- if (this.templateStyles["view"]) this.setTemplateStyles(this.templateStyles["view"]);
- this.setAllStyles();
- this.actionbarList.each( function (module) {
- if (oldTemplateStyles["actionbar"]){
- module.clearTemplateStyles(oldTemplateStyles["actionbar"]);
- }
- module.setStyleTemplate();
- module.setAllStyles();
- })
- this.pagingList.each( function (module) {
- if (oldTemplateStyles["paging"]){
- module.clearTemplateStyles(oldTemplateStyles["paging"]);
- }
- module.setStyleTemplate();
- module.setAllStyles();
- });
- },
- loadCustomTemplateStyles : function( scriptObject, callback ){
- // {
- // "type" : "script",
- // "name": script.name,
- // "alias": script.alias,
- // "id": script.id,
- // "appName" : script.appName || script.applicationName,
- // "appId": script.appId,
- // "application": script.application
- // }
- var promise = o2.Actions.load('x_program_center').ScriptAction.flag( scriptObject.alias || scriptObject.name, {});
- promise.then( function( json ) {
- try{
- var f = eval("(function(){\n return "+json.data.text+"\n})");
- var j = f();
- if( typeOf(j) !== "object" ){
- this.designer.notice( MWF.APPFD.LP.notValidJson, "error" );
- }else{
- if(callback)callback(j);
- }
- }catch (e) {
- this.designer.notice( e.message, "error" )
- }
- }.bind(this), function( responseJSON ){
- this.designer.notice( JSON.parse(responseJSON.responseText).message, "error" );
- if(callback)callback({});
- }.bind(this))
- },
- loadTemplateStyles : function( file, extendFile, callback ){
- if( !file ){
- if (callback) callback({});
- return;
- }
- this.templateStylesList = this.templateStylesList || {};
- if( this.templateStylesList[file] ){
- if (callback) callback(this.templateStylesList[file]);
- return;
- }
- this.loadTemplateStyleFile( file, function( json_file ){
- this.loadTemplateExtendStyleFile( extendFile, function( json_extend ){
- this.templateStylesList[file] = Object.merge( json_file, json_extend );
- if (callback) callback(this.templateStylesList[file]);
- }.bind(this))
- }.bind(this))
- },
- loadTemplateStyleFile : function(file, callback ){
- if( !file ){
- if (callback) callback({});
- return;
- }
- var stylesUrl = "../x_component_query_ViewDesigner/$View/skin/"+file;
- MWF.getJSON(stylesUrl,{
- "onSuccess": function(responseJSON){
- //this.templateStylesList[file] = responseJSON;
- if (callback) callback(responseJSON);
- }.bind(this),
- "onRequestFailure": function(){
- if (callback) callback({});
- }.bind(this),
- "onError": function(){
- if (callback) callback({});
- }.bind(this)
- }
- );
- },
- loadTemplateExtendStyleFile : function(extendFile, callback ){
- if( !extendFile ){
- if (callback) callback({});
- return;
- }
- var stylesUrl = "../x_component_query_ViewDesigner/$View/skin/"+extendFile;
- MWF.getJSON(stylesUrl,{
- "onSuccess": function(responseJSON){
- //this.templateStylesList[file] = responseJSON;
- if (callback) callback(responseJSON);
- }.bind(this),
- "onRequestFailure": function(){
- if (callback) callback({});
- }.bind(this),
- "onError": function(){
- if (callback) callback({});
- }.bind(this)
- }
- );
- },
- loadStylesList: function(callback){
- if( this.stylesList ){
- callback( this.stylesList )
- }else{
- var configUrl = "../x_component_query_ViewDesigner/$View/skin/config.json";
- MWF.getJSON(configUrl,{
- "onSuccess": function(responseJSON){
- this.stylesList = responseJSON;
- if (callback) callback(this.stylesList);
- }.bind(this),
- "onRequestFailure": function(){
- this.stylesList = {};
- if (callback) callback(this.stylesList);
- }.bind(this),
- "onError": function(){
- this.stylesList = {};
- if (callback) callback(this.stylesList);
- }.bind(this)
- }
- );
- }
- },
- saveAs: function(){
- var form = new MWF.xApplication.query.ViewDesigner.View.NewNameForm(this, {
- name : this.data.name + "_" + MWF.xApplication.query.ViewDesigner.LP.copy,
- query : this.data.query || this.data.application,
- queryName : this.data.queryName || this.data.applicationName
- }, {
- onSave : function( data, callback ){
- this._saveAs( data, callback );
- }.bind(this)
- }, {
- app: this.designer
- });
- form.edit()
- },
- cloneObject : function( obj ){
- if (null == obj || "object" != typeof obj) return obj;
- if ( typeof obj.length==='number'){ //数组
- //print( "array" );
- var copy = [];
- for (var i = 0, len = obj.length; i < len; ++i) {
- copy[i] = this.cloneObject(obj[i]);
- }
- return copy;
- }else{
- var copy = {};
- for (var attr in obj) {
- copy[attr] = this.cloneObject(obj[attr]);
- }
- return copy;
- }
- },
- _saveAs : function( data , callback){
- var _self = this;
- var d = this.cloneObject( this.data );
- d.isNewView = true;
- d.id = this.designer.actions.getUUID();
- d.name = data.name;
- d.alias = "";
- d.query = data.query;
- d.queryName = data.queryName;
- d.application = data.query;
- d.applicationName = data.queryName;
- d.pid = d.id + d.id;
- delete d[this.data.id+"viewFilterType"];
- d[d.id+"viewFilterType"]="custom";
- d.data.selectList.each( function( entry ){
- entry.id = (new MWF.widget.UUID).id;
- }.bind(this));
- this.designer.actions.saveView(d, function(json){
- this.designer.notice(this.designer.lp.notice.saveAs_success, "success", this.node, {"x": "left", "y": "bottom"});
- if (callback) callback();
- }.bind(this));
- }
- });
- MWF.xApplication.query.ViewDesigner.View.$Module = MWF.QV$Module = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- copyStyles: function(from, to){
- if (!this.json[to]) this.json[to] = {};
- Object.each(from, function(style, key){
- //if (!this.json[to][key])
- this.json[to][key] = style;
- }.bind(this));
- },
- removeStyles: function(from, to){
- if (this.json[to]){
- Object.each(from, function(style, key){
- if (this.json[to][key] && this.json[to][key]==style){
- delete this.json[to][key];
- }
- //if (this.json[from][key]){
- // delete this.json[to][key];
- //}
- }.bind(this));
- }
- },
- setTemplateStyles: function(styles){
- if (styles.styles) this.copyStyles(styles.styles, "styles");
- if (styles.properties) this.copyStyles(styles.properties, "properties");
- },
- clearTemplateStyles: function(styles){
- if (styles){
- if (styles.styles) this.removeStyles(styles.styles, "styles");
- if (styles.properties) this.removeStyles(styles.properties, "properties");
- }
- },
- setStyleTemplate: function(){
- if( this.view.templateStyles && this.view.templateStyles[this.moduleName] ){
- this.setTemplateStyles(this.view.templateStyles[this.moduleName]);
- }
- },
- setAllStyles: function(){
- this.setPropertiesOrStyles("styles");
- this.setPropertiesOrStyles("inputStyles");
- this.setPropertiesOrStyles("properties");
- this.reloadMaplist();
- },
- showProperty: function(){
- if (!this.property){
- this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
- "path": this.propertyPath,
- "onPostLoad": function(){
- this.property.show();
- }.bind(this)
- });
- this.property.load();
- }else{
- this.property.show();
- }
- },
- hideProperty: function(){
- if (this.property) this.property.hide();
- },
- deletePropertiesOrStyles: function(name, key){
- if (name=="properties"){
- try{
- this.node.removeProperty(key);
- }catch(e){}
- }
- },
- setPropertiesOrStyles: function(name){
- if (name=="styles"){
- try{
- this.setCustomStyles();
- }catch(e){}
- }
- if (name=="properties"){
- try{
- this.node.setProperties(this.json.properties);
- }catch(e){}
- }
- },
- setCustomNodeStyles: function(node, styles){
- var border = node.getStyle("border");
- node.clearStyles();
- //node.setStyles(styles);
- node.setStyle("border", border);
- Object.each(styles, function(value, key){
- var reg = /^border\w*/ig;
- if (!key.test(reg)){
- node.setStyle(key, value);
- }
- }.bind(this));
- },
- setCustomStyles: function(){
- var border = this.node.getStyle("border");
- this.node.clearStyles();
- this.node.setStyles(this.css.moduleNode);
- if (this.initialStyles) this.node.setStyles(this.initialStyles);
- this.node.setStyle("border", border);
- if (this.json.styles) Object.each(this.json.styles, function(value, key){
- if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
- var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
- var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
- if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
- value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
- }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
- value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
- }
- if (value.indexOf("/x_portal_assemble_surface")!==-1){
- value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
- }else if (value.indexOf("x_portal_assemble_surface")!==-1){
- value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
- }
- value = o2.filterUrl(value);
- }
- var reg = /^border\w*/ig;
- if (!key.test(reg)){
- if (key){
- if (key.toString().toLowerCase()==="display"){
- if (value.toString().toLowerCase()==="none"){
- this.node.setStyle("opacity", 0.3);
- }else{
- this.node.setStyle("opacity", 1);
- this.node.setStyle(key, value);
- }
- }else{
- this.node.setStyle(key, value);
- }
- }
- }
- //this.node.setStyle(key, value);
- }.bind(this));
- },
- _setEditStyle: function(name, obj, oldValue){
- var title = "";
- var text = "";
- if (name==="name"){
- title = this.json.name || this.json.id;
- text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
- this.treeNode.setText("<"+text+"> "+title);
- }
- if (name==="id"){
- title = this.json.name || this.json.id;
- if (!this.json.name){
- text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
- this.treeNode.setText("<"+text+"> "+this.json.id);
- }
- this.treeNode.setTitle(this.json.id);
- this.node.set("id", this.json.id);
- }
- this._setEditStyle_custom(name, obj, oldValue);
- },
- reloadMaplist: function(){
- if (this.property) Object.each(this.property.maplists, function(map, name){ map.reload(this.json[name]);}.bind(this));
- },
- getHtml: function(){
- var copy = this.node.clone(true, true);
- copy.clearStyles(true);
- var html = copy.outerHTML;
- copy.destroy();
- return html;
- },
- getJson: function(){
- var json = Object.clone(this.json);
- var o = {};
- o[json.id] = json;
- return o;
- }
- });
- MWF.xApplication.query.ViewDesigner.View.Column = new Class({
- Extends: MWF.QV$Module,
- initialize: function(json, view, next){
- this.propertyPath = "../x_component_query_ViewDesigner/$View/column.html";
- this.view = view;
- this.json = json;
- this.next = next;
- this.css = this.view.css;
- this.content = this.view.viewTitleTrNode;
- this.domListNode = this.view.domListNode;
- this.load();
- },
- load: function(){
- if( !this.json.events ){
- this.loadDefaultJson(function () {
- this._load()
- }.bind(this))
- }else{
- this._load();
- }
- },
- _load: function(){
- this.areaNode = new Element("td", {"styles": this.css.viewTitleColumnAreaNode});
- this.areaNode.store("column", this);
- if (this.next){
- this.areaNode.inject(this.next.areaNode, "before");
- }else{
- this.areaNode.inject(this.content);
- }
- this.node = new Element("div", {
- "styles": this.css.viewTitleColumnNode
- }).inject(this.areaNode);
- this.textNode = new Element("div", {
- "styles": this.css.viewTitleColumnTextNode,
- "text": this.json.displayName
- }).inject(this.node);
- this.createDomListItem();
- this._createIconAction();
- //if (!this.json.export) this.hideMode();
- this.setEvent();
- this.setCustomStyles();
- },
- loadDefaultJson: function(callback){
- if( this.view.defaultColumnJson ){
- this.json = Object.merge( this.json, Object.clone(this.view.defaultColumnJson) );
- if (callback) callback(this.json);
- return;
- }
- var url = this.view.path+"column.json";
- MWF.getJSON(url, {
- "onSuccess": function(obj){
- this.view.defaultColumnJson = Object.clone(obj);
- this.json = Object.merge( this.json, Object.clone(obj) );
- if (callback) callback(this.json);
- }.bind(this),
- "onerror": function(text){
- this.view.designer.notice(text, "error");
- }.bind(this),
- "onRequestFailure": function(xhr){
- this.view.designer.notice(xhr.responseText, "error");
- }.bind(this)
- }, false);
- },
- setCustomStyles : function(){
- var viewStyles = this.view.json.data.viewStyles;
- var border = this.areaNode.getStyle("border");
- this.areaNode.clearStyles();
- this.areaNode.setStyles(this.css.viewTitleColumnAreaNode);
- // var y = this.container.getStyle("height");
- // y = (y) ? y.toInt()-2 : this.container.getSize().y-2;
- // this.node.setStyle("min-height", ""+y+"px");
- // if (this.initialStyles) this.node.setStyles(this.initialStyles);
- this.node.setStyle("border", border);
- Object.each(viewStyles.titleTd, function(value, key){
- var reg = /^border\w*/ig;
- if (!key.test(reg)){
- this.node.setStyle(key, value);
- }
- }.bind(this));
- },
- createDomListItem: function(){
- this.listNode = new Element("div", {"styles": this.css.cloumnListNode});
- if (this.next){
- this.listNode.inject(this.next.listNode, "before");
- }else{
- this.listNode.inject(this.domListNode);
- }
- var listIconNode = new Element("div", {"styles": this.css.cloumnListIconNode}).inject(this.listNode);
- var listTextNode = new Element("div", {"styles": this.css.cloumnListTextNode}).inject(this.listNode);
- this.resetTextNode();
- },
- setEvent: function(){
- this.node.addEvents({
- "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
- "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.viewTitleColumnNode_over)}.bind(this),
- "mouseout": function(){if (!this.isSelected) if (this.isError){
- this.node.setStyles(this.css.viewTitleColumnNode_error)
- }else{
- this.node.setStyles(this.css.viewTitleColumnNode)
- }}.bind(this)
- });
- this.listNode.addEvents({
- "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
- "mouseover": function(){debugger; if (!this.isSelected) this.listNode.setStyles(this.css.cloumnListNode_over)}.bind(this),
- "mouseout": function(){if (!this.isSelected) this.listNode.setStyles(this.css.cloumnListNode)}.bind(this)
- });
- },
- _createIconAction: function(){
- if (!this.actionArea){
- this.actionArea = new Element("div", {"styles": this.css.actionAreaNode}).inject(this.view.areaNode, "after");
- this._createAction({
- "name": "move",
- "icon": "move1.png",
- "event": "mousedown",
- "action": "move",
- "title": MWF.APPDVD.LP.action.move
- });
- this._createAction({
- "name": "add",
- "icon": "add.png",
- "event": "click",
- "action": "addColumn",
- "title": MWF.APPDVD.LP.action.add
- });
- this._createAction({
- "name": "delete",
- "icon": "delete1.png",
- "event": "click",
- "action": "delete",
- "title": MWF.APPDVD.LP.action["delete"]
- });
- }
- },
- _createAction: function(action){
- var actionNode = new Element("div", {
- "styles": this.css.actionNodeStyles,
- "title": action.title
- }).inject(this.actionArea);
- actionNode.setStyle("background", "url("+this.view.path+this.view.options.style+"/action/"+action.icon+") no-repeat left center");
- actionNode.addEvent(action.event, function(e){
- this[action.action](e);
- }.bind(this));
- actionNode.addEvents({
- "mouseover": function(e){
- e.target.setStyle("border", "1px solid #999");
- }.bind(this),
- "mouseout": function(e){
- e.target.setStyle("border", "1px solid #F1F1F1");
- }.bind(this)
- });
- },
- _setActionAreaPosition: function(){
- var p = this.node.getPosition(this.view.areaNode.getOffsetParent());
- var y = p.y-25;
- var x = p.x;
- this.actionArea.setPosition({"x": x, "y": y});
- },
- _showActions: function(){
- if (this.actionArea){
- this._setActionAreaPosition();
- this.actionArea.setStyle("display", "block");
- }
- },
- _hideActions: function(){
- if (this.actionArea) this.actionArea.setStyle("display", "none");
- },
- selected: function(){
- if (this.view.currentSelectedModule){
- if (this.view.currentSelectedModule==this){
- return true;
- }else{
- this.view.currentSelectedModule.unSelected();
- }
- }
- this.node.setStyles(this.css.viewTitleColumnNode_selected);
- this.listNode.setStyles(this.css.cloumnListNode_selected);
- // new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
- // new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
- try{
- this.node.scrollIntoView(false);
- this.listNode.scrollIntoView(false);
- }catch (e) {
- }
- this.view.currentSelectedModule = this;
- this.isSelected = true;
- this._showActions();
- this.showProperty();
- },
- unSelected: function(){
- this.view.currentSelectedModule = null;
- //this.node.setStyles(this.css.viewTitleColumnNode);
- if (this.isError){
- this.node.setStyles(this.css.viewTitleColumnNode_error)
- }else{
- this.node.setStyles(this.css.viewTitleColumnNode)
- }
- this.listNode.setStyles(this.css.cloumnListNode);
- this.isSelected = false;
- this._hideActions();
- this.hideProperty();
- },
- showProperty: function(){
- if (!this.property){
- this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
- "path": this.propertyPath,
- "onPostLoad": function(){
- this.property.show();
- var processDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedProcessArea");
- var cmsDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedCMSArea");
- if (this.view.json.type=="cms"){
- processDiv.setStyle("display", "none");
- cmsDiv.setStyle("display", "block");
- }else{
- processDiv.setStyle("display", "block");
- cmsDiv.setStyle("display", "none");
- }
- }.bind(this)
- });
- this.property.load();
- }else{
- this.property.show();
- }
- },
- hideProperty: function(){
- if (this.property) this.property.hide();
- },
- _setEditStyle: function(name, input, oldValue){
- if (name=="displayName") this.resetTextNode();
- if (name=="selectType") this.resetTextNode();
- if (name=="attribute") this.resetTextNode();
- if (name=="path") this.resetTextNode();
- if( name==="isSwitchOrder" || name==="orderType" )this.resetTextNode();
- if (name=="column"){
- this.view.json.data.orderList.each(function(order){
- if (order.column==oldValue) order.column = this.json.column
- }.bind(this));
- if (this.view.json.data.group.column == oldValue) this.view.json.data.group.column = this.json.column;
- }
- },
- resetTextNode: function(){
- var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
- if (!listText) listText = "unnamed";
- this.textNode.set("text", this.json.displayName);
- if( this.json.isSwitchOrder || this.isSortedType(this.json.orderType) ){
- this.textNode.setStyles({
- "display": "flex",
- "align-items": "center",
- "cursor": "pointer"
- })
- this.sortNode = new Element("div", {
- styles: { "padding-left": "10px", 'font-size': "12px" }
- }).inject(this.textNode);
- new Element("div.o2-up.ooicon-icon_arrow_up").inject(this.sortNode);
- new Element("div.o2-down.ooicon-drop_down").inject(this.sortNode);
- if( !this.json.isSwitchOrder ){
- this.sortNode.setStyle("cursor", "not-allowed");
- }
- this.setOrderStyle();
- }else{
- if(this.sortNode){
- this.sortNode.destroy();
- this.sortNode = null;
- }
- }
- this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
- },
- setOrderStyle: function (){
- var upNode = this.sortNode.getElement('.o2-up');
- var downNode = this.sortNode.getElement('.o2-down');
- var orderType = this.json.orderType;
- if( !this.json.isSwitchOrder ){
- switch (orderType){
- case 'asc':
- downNode.hide(); break;
- case 'desc':
- upNode.hide(); break;
- default:
- upNode.hide();
- downNode.hide();
- break;
- }
- }
- switch (orderType){
- case 'asc':
- upNode.addClass('mainColor_color');
- downNode.removeClass('mainColor_color');
- break;
- case 'desc':
- upNode.removeClass('mainColor_color');
- downNode.addClass('mainColor_color');
- break;
- default:
- upNode.removeClass('mainColor_color');
- downNode.removeClass('mainColor_color');
- break;
- }
- },
- isSortedType: function(value){
- return ['asc', 'desc'].contains(value);
- },
- "delete": function(e){
- var _self = this;
- if (!e) e = this.node;
- this.view.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteColumnTitle, MWF.APPDVD.LP.notice.deleteColumn, 300, 120, function(){
- _self.destroy();
- this.close();
- }, function(){
- this.close();
- }, null);
- },
- isOrderColumn : function(){
- var sortList = this.view.json.data.orderList || [];
- var flag = false;
- sortList.each(function(order){
- if (order.column==this.json.column)flag = true;
- }.bind(this));
- return flag;
- },
- isGroupColumn : function() {
- if (!this.view.json || !this.view.json.data || !this.view.json.data.group) return false;
- return this.view.json.data.group.column === this.json.column;
- },
- destroy: function(){
- if (this.view.currentSelectedModule==this) this.view.currentSelectedModule = null;
- if (this.actionArea) this.actionArea.destroy();
- if (this.listNode) this.listNode.destroy();
- if (this.property) this.property.propertyContent.destroy();
- var idx = this.view.items.indexOf(this);
- if (this.view.viewContentTableNode){
- var trs = this.view.viewContentTableNode.getElements("tr");
- var isGroup = this.isGroupColumn();
- trs.each(function(tr){
- if( isGroup ){
- if( tr.get("data-is-group") === "yes" ){
- tr.destroy()
- }
- }else{
- if( tr.get("data-is-group") !== "yes" ){
- tr.deleteCell(idx);
- }
- }
- }.bind(this));
- }
- if (this.view.json.data.group.column === this.json.column){
- this.view.json.data.group.column = null;
- }
- var sortList = this.view.json.data.orderList || [];
- var deleteItem = null;
- sortList.each(function(order){
- if (order.column==this.json.column){
- deleteItem = order;
- }
- }.bind(this));
- if (deleteItem) sortList.erase(deleteItem);
- if (this.view.json.data.selectList) this.view.json.data.selectList.erase(this.json);
- if (this.view.json.data.calculate) if (this.view.json.data.calculate.calculateList) this.view.json.data.calculate.calculateList.erase(this.json);
- this.view.items.erase(this);
- if (this.view.property) this.view.property.loadStatColumnSelect();
- this.areaNode.destroy();
- this.view.selected();
- this.view.setViewWidth();
- this._destroy();
- MWF.release(this);
- delete this;
- },
- _destroy: function(){},
- addColumn: function(e, data){
- MWF.require("MWF.widget.UUID", function(){
- var json;
- if (data){
- json = Object.clone(data);
- json.id = (new MWF.widget.UUID).id;
- json.column = (new MWF.widget.UUID).id;
- }else{
- var id = (new MWF.widget.UUID).id;
- json = {
- "id": id,
- "column": id,
- "displayName": this.view.designer.lp.unnamed,
- "orderType": "original"
- };
- }
- var idx = this.view.json.data.selectList.indexOf(this.json);
- this.view.json.data.selectList.splice(idx, 0, json);
- var column = new MWF.xApplication.query.ViewDesigner.View.Column(json, this.view, this);
- this.view.items.splice(idx, 0, column);
- column.selected();
- if (this.view.viewContentTableNode){
- var trs = this.view.viewContentTableNode.getElements("tr");
- trs.each(function(tr){
- var td = tr.insertCell(idx);
- td.setStyles(this.css.viewContentTdNode);
- }.bind(this));
- }
- this.view.setViewWidth();
- }.bind(this));
- },
- move: function(e){
- var columnNodes = [];
- this.view.items.each(function(item){
- if (item!=this){
- columnNodes.push(item.areaNode);
- }
- }.bind(this));
- this._createMoveNode();
- this._setNodeMove(columnNodes, e);
- },
- _createMoveNode: function(){
- this.moveNode = new Element("div", {"text": this.node.get("text")});
- this.moveNode.inject(this.view.designer.content);
- this.moveNode.setStyles({
- "border": "2px dashed #ffa200",
- "opacity": 0.7,
- "height": "30px",
- "line-height": "30px",
- "padding": "0px 10px",
- "position": "absolute"
- });
- },
- _setMoveNodePosition: function(e){
- var x = e.page.x+2;
- var y = e.page.y+2;
- this.moveNode.positionTo(x, y);
- },
- createMoveFlagNode: function(){
- this.moveFlagNode = new Element("td", {"styles": this.css.moveFlagNode});
- },
- _setNodeMove: function(droppables, e){
- this._setMoveNodePosition(e);
- var movePosition = this.moveNode.getPosition();
- var moveSize = this.moveNode.getSize();
- var contentPosition = this.content.getPosition();
- var contentSize = this.content.getSize();
- var nodeDrag = new Drag.Move(this.moveNode, {
- "droppables": droppables,
- "limit": {
- "x": [contentPosition.x, contentPosition.x+contentSize.x],
- "y": [movePosition.y, movePosition.y+moveSize.y]
- },
- "onEnter": function(dragging, inObj){
- if (!this.moveFlagNode) this.createMoveFlagNode();
- this.moveFlagNode.inject(inObj, "before");
- }.bind(this),
- "onLeave": function(dragging, inObj){
- if (this.moveFlagNode){
- this.moveFlagNode.dispose();
- }
- }.bind(this),
- "onDrop": function(dragging, inObj){
- if (inObj){
- this.areaNode.inject(inObj, "before");
- var column = inObj.retrieve("column");
- this.listNode.inject(column.listNode, "before");
- // var idx = this.view.json.data.selectList.indexOf(column.json);
- this.view.json.data.selectList.erase(this.json);
- this.view.items.erase(this);
- var idx = this.view.json.data.selectList.indexOf(column.json);
- this.view.json.data.selectList.splice(idx, 0, this.json);
- this.view.items.splice(idx, 0, this);
- if (this.moveNode) this.moveNode.destroy();
- if (this.moveFlagNode) this.moveFlagNode.destroy();
- this._setActionAreaPosition();
- }else{
- if (this.moveNode) this.moveNode.destroy();
- if (this.moveFlagNode) this.moveFlagNode.destroy();
- }
- }.bind(this),
- "onCancel": function(dragging){
- if (this.moveNode) this.moveNode.destroy();
- if (this.moveFlagNode) this.moveFlagNode.destroy();
- }.bind(this)
- });
- nodeDrag.start(e);
- }
- //hideMode: function(){
- // if (!this.columnHideFlagNode){
- // this.columnHideFlagNode = new Element("div", {"styles": this.view.css.columnHideFlagNode}).inject(this.node);
- // }
- //},
- //showMode: function(){
- // if (this.columnHideFlagNode) this.columnHideFlagNode.destroy();
- // this.columnHideFlagNode = null;
- //}
- });
- MWF.require("MWF.widget.Toolbar", null, false);
- MWF.xApplication.query.ViewDesigner.View.Actionbar = new Class({
- Extends: MWF.xApplication.query.ViewDesigner.View.$Module,
- options : {
- "style" : "default",
- "customImageStyle" : "default"
- },
- initialize: function(json, jsonList, view, options){
- this.setOptions( options );
- this.propertyPath = "../x_component_query_ViewDesigner/$View/actionbar.html";
- this.path = "../x_component_query_ViewDesigner/$View/";
- this.imagePath_default = "../x_component_query_ViewDesigner/$View/";
- this.imagePath_custom = "../x_component_process_FormDesigner/Module/Actionbar/";
- this.cssPath = "../x_component_query_ViewDesigner/$View/"+this.options.style+"/actionbar.wcss";
- this.view = view;
- this.json = json;
- this.jsonList = jsonList;
- this.css = this.view.css;
- this.container = this.view.actionbarNode;
- this.moduleName = "actionbar";
- this.load();
- },
- load: function(){
- this.systemTools = [];
- this.customTools = [];
- if( !this.json ){
- this.loadDefaultJson(function(){
- this._load()
- }.bind(this));
- }else{
- this._load()
- }
- },
- _load : function(){
- this.json.moduleName = this.moduleName;
- this._createNode();
- //this._createIconAction();
- //if (!this.json.export) this.hideMode();
- this.setEvent();
- },
- loadDefaultJson: function(callback){
- var url = this.path+"actionbar.json";
- MWF.getJSON(url, {
- "onSuccess": function(obj){
- this.view.designer.actions.getUUID(function(id){
- obj.id=id;
- //obj.isNewView = true;
- //obj.application = this.view.designer.application.id;
- this.json = obj;
- this.jsonList.push( this.json );
- if (callback) callback(obj);
- }.bind(this));
- }.bind(this),
- "onerror": function(text){
- this.view.designer.notice(text, "error");
- }.bind(this),
- "onRequestFailure": function(xhr){
- this.view.designer.notice(xhr.responseText, "error");
- }.bind(this)
- });
- },
- setTemplateStyles: function(styles){
- this.json.style = styles.style;
- this.json.iconStyle = styles.iconStyle || "";
- this.json.iconOverStyle = styles.iconOverStyle || "";
- this.json.customIconStyle = styles.customIconStyle;
- this.json.customIconOverStyle = styles.customIconOverStyle || "";
- this.json.forceStyles = styles.forceStyles || "";
- },
- clearTemplateStyles: function(styles){
- this.json.style = "form";
- this.json.iconStyle = "";
- this.json.iconOverStyle = "";
- this.json.customIconStyle = "";
- this.json.customIconOverStyle = "";
- this.json.forceStyles = "";
- },
- setAllStyles: function(){
- this._resetActionbar();
- },
- setEvent: function(){
- this.node.addEvents({
- "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
- "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode_over)}.bind(this),
- "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode) }.bind(this)
- });
- },
- selected: function(){
- if (this.view.currentSelectedModule){
- if (this.view.currentSelectedModule==this){
- return true;
- }else{
- this.view.currentSelectedModule.unSelected();
- }
- }
- this.node.setStyles(this.css.toolbarWarpNode_selected);
- // new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
- try {
- this.node.scrollIntoView(false);
- }catch (e) {
- }
- this.view.currentSelectedModule = this;
- this.isSelected = true;
- //this._showActions();
- this.showProperty();
- },
- unSelected: function(){
- this.view.currentSelectedModule = null;
- this.node.setStyles(this.css.toolbarWarpNode)
- //this.listNode.setStyles(this.css.cloumnListNode);
- this.isSelected = false;
- //this._hideActions();
- this.hideProperty();
- },
- resetTextNode: function(){
- var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
- if (!listText) listText = "unnamed";
- this.textNode.set("text", this.json.displayName);
- this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
- },
- getJsonPath : function(){
- return this.path+"toolbars.json";
- },
- _createNode: function(callback){
- this.node = new Element("div", {
- "id": this.json.id,
- "MWFType": "actionbar",
- "styles": this.css.toolbarWarpNode,
- "events": {
- "selectstart": function(e){
- e.preventDefault();
- }
- }
- }).inject(this.container );
- this.toolbarNode = new Element("div").inject(this.node);
- this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
- if (!this.json.actionStyles){
- this.json.actionStyles = Object.clone(this.toolbarWidget.css);
- }else{
- this.toolbarWidget.css = Object.clone(this.json.actionStyles);
- }
- this.loadMultiToolbar();
- // if (this.json.defaultTools){
- // var json = Array.clone(this.json.defaultTools);
- // this.setToolbars(json, this.toolbarNode);
- // if (this.json.tools){
- // this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
- // }
- // this.toolbarWidget.load();
- // this._setEditStyle_custom("hideSystemTools");
- // }else{
- // MWF.getJSON( this.getJsonPath(), function(json){
- // this.json.defaultTools = json;
- // var json = Array.clone(this.json.defaultTools);
- // this.setToolbars(json, this.toolbarNode);
- // if (this.json.tools){
- // this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
- // }
- // this.toolbarWidget.load();
- // this._setEditStyle_custom("hideSystemTools");
- // }.bind(this), false);
- // }
- },
- _refreshActionbar: function(){
- //if (this.form.options.mode == "Mobile"){
- // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
- // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
- //}else{
- this.toolbarNode = this.node.getFirst("div");
- this.toolbarNode.empty();
- this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
- if (!this.json.actionStyles) this.json.actionStyles = Object.clone(this.toolbarWidget.css);
- this.toolbarWidget.css = this.json.actionStyles;
- this.loadMultiToolbar();
- // if (this.json.defaultTools){
- // var json = Array.clone(this.json.defaultTools);
- // this.setToolbars(json, this.toolbarNode);
- // if (this.json.tools){
- // this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
- // }
- // this.toolbarWidget.load();
- // }else{
- // MWF.getJSON( this.getJsonPath(), function(json){
- // this.json.defaultTools = json;
- // var json = Array.clone(this.json.defaultTools);
- // this.setToolbars(json, this.toolbarNode);
- // if (this.json.tools){
- // this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
- // }
- // this.toolbarWidget.load();
- // }.bind(this), false);
- // }
- //}
- },
- _resetActionbar: function(){
- //if (this.form.options.mode == "Mobile"){
- // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
- // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
- //}else{
- this.toolbarNode = this.node.getFirst("div");
- this.toolbarNode.empty();
- this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
- if (!this.json.actionStyles){
- this.json.actionStyles = Object.merge( Object.clone( this.toolbarWidget.css ), this.json.forceStyles || {} );
- }else{
- this.toolbarWidget.css = Object.merge( Object.clone( this.json.actionStyles ), this.toolbarWidget.css, this.json.forceStyles || {} );
- this.json.actionStyles = Object.clone(this.toolbarWidget.css);
- }
- this.loadMultiToolbar();
- // if (this.json.defaultTools){
- // var json = Array.clone(this.json.defaultTools);
- // this.setToolbars(json, this.toolbarNode);
- // if (this.json.tools){
- // this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
- // }
- // this.toolbarWidget.load();
- // }else{
- // MWF.getJSON(this.path+"toolbars.json", function(json){
- // this.json.defaultTools = json;
- // var json = Array.clone(this.json.defaultTools);
- // this.setToolbars(json, this.toolbarNode);
- // if (this.json.tools){
- // this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
- // }
- // this.toolbarWidget.load();
- // }.bind(this), false);
- // }
- //}
- },
- loadMultiToolbar : function(){
- if( this.json.multiTools ){
- if (MWF.xApplication.query.ViewDesigner.LP.actionBar){
- var jsonStr = JSON.stringify(this.json.multiTools);
- jsonStr = o2.bindJson(jsonStr, {"lp": MWF.xApplication.query.ViewDesigner.LP.actionBar});
- this.multiToolsJson = JSON.parse(jsonStr); //.map( function (d) { d.system = true; return d; });
- }else{
- this.multiToolsJson = this.json.multiTools;
- }
- var json = Array.clone(this.multiToolsJson);
- this.setMultiToolbars(json, this.toolbarNode);
- this.toolbarWidget.load();
- this._setEditStyle_custom("hideSystemTools");
- }else if( this.json.defaultTools ){
- this.json.multiTools = this.json.defaultTools.map( function (d) { d.system = true; return d; });
- if (this.json.tools){
- this.json.multiTools = this.json.multiTools.concat( this.json.tools )
- }
- this.setMultiToolbars( Array.clone(this.json.multiTools), this.toolbarNode);
- this.toolbarWidget.load();
- this._setEditStyle_custom("hideSystemTools");
- }else{
- o2.xhr_get(this.getJsonPath(), function(xhr){
- var jsonStr = xhr.responseText;
- this.json.multiTools = JSON.parse(jsonStr).map( function (d) { d.system = true; return d; });
- if (this.json.tools){
- this.json.multiTools = this.json.multiTools.concat( this.json.tools )
- }
- if (MWF.xApplication.query.ViewDesigner.LP.actionBar){
- jsonStr = o2.bindJson(jsonStr, {"lp": MWF.xApplication.query.ViewDesigner.LP.actionBar});
- this.multiToolsJson = JSON.parse(jsonStr).map( function (d) { d.system = true; return d; });
- }else{
- this.multiToolsJson = this.json.multiTools;
- }
- this.setMultiToolbars(Array.clone(this.multiToolsJson), this.toolbarNode);
- this.toolbarWidget.load();
- this._setEditStyle_custom("hideSystemTools");
- }.bind(this), null,null, false);
- }
- },
- setMultiToolbars: function(tools, node){
- tools.each(function(tool){
- if( tool.system ){
- this.setToolbars( [tool], node );
- }else{
- this.setCustomToolbars( [tool], node );
- }
- }.bind(this));
- },
- setToolbars: function(tools, node){
- tools.each(function(tool){
- var actionNode = new Element("div", {
- "MWFnodetype": tool.type,
- "MWFButtonImage": this.imagePath_default+""+this.options.style+"/actionbar/"+( this.json.iconStyle || "default" )+"/"+tool.img,
- "title": tool.title,
- "MWFButtonAction": tool.action,
- "MWFButtonText": tool.text
- }).inject(node);
- if( this.json.iconOverStyle ){
- actionNode.set("MWFButtonImageOver" , this.imagePath_default+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
- }
- this.systemTools.push(actionNode);
- if (tool.sub){
- var subNode = node.getLast();
- this.setToolbars(tool.sub, subNode);
- }
- }.bind(this));
- },
- setCustomToolbars: function(tools, node){
- //var style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
- var path = "";
- if( this.json.customIconStyle ){
- path = this.json.customIconStyle+ "/";
- }
- tools.each(function(tool){
- var actionNode = new Element("div", {
- "MWFnodetype": tool.type,
- "MWFButtonImage": this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+path+tool.img,
- "title": tool.title,
- "MWFButtonAction": tool.action,
- "MWFButtonText": tool.text
- }).inject(node);
- if( this.json.customIconOverStyle ){
- actionNode.set("MWFButtonImageOver" , this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
- }
- this.customTools.push(actionNode);
- if (tool.sub){
- var subNode = node.getLast();
- this.setToolbars(tool.sub, subNode);
- }
- }.bind(this));
- },
- _setEditStyle_custom: function(name){
- if (name=="hideSystemTools"){
- if (this.json.hideSystemTools){
- this.systemTools.each(function(tool){
- tool.setStyle("display", "none");
- });
- }else{
- this.systemTools.each(function(tool){
- tool.setStyle("display", "block");
- });
- }
- }
- if (name=="defaultTools" || name=="tools" || name=="multiTools" || name==="actionStyles"){
- this._refreshActionbar();
- }
- }
- });
- MWF.require("MWF.widget.Paging", null, false);
- MWF.xApplication.query.ViewDesigner.View.Paging = new Class({
- Extends: MWF.xApplication.query.ViewDesigner.View.$Module,
- options : {
- "style" : "default"
- },
- initialize: function(json, jsonList, view, options){
- this.setOptions( options );
- this.propertyPath = "../x_component_query_ViewDesigner/$View/paging.html";
- this.view = view;
- this.json = json;
- this.jsonList = jsonList;
- this.css = this.view.css;
- this.container = this.view.pagingNode;
- this.moduleName = "paging";
- this.load();
- },
- load: function(){
- this.systemTools = [];
- this.customTools = [];
- if( !this.json ){
- this.loadDefaultJson(function(){
- this._load();
- }.bind(this));
- }else{
- this._load();
- }
- },
- _load : function(){
- this.json.moduleName = this.moduleName;
- this._createNode();
- this.setEvent();
- },
- loadDefaultJson: function(callback){
- var url = this.view.path+"paging.json";
- MWF.getJSON(url, {
- "onSuccess": function(obj){
- this.view.designer.actions.getUUID(function(id){
- obj.id=id;
- this.json = obj;
- this.jsonList.push( this.json );
- if (callback) callback(obj);
- }.bind(this));
- }.bind(this),
- "onerror": function(text){
- this.view.designer.notice(text, "error");
- }.bind(this),
- "onRequestFailure": function(xhr){
- this.view.designer.notice(xhr.responseText, "error");
- }.bind(this)
- });
- },
- setTemplateStyles: function(styles){
- if( this.json.buttonStyle === "rect" ){
- this.json.style = styles.style_rect;
- }else if( this.json.buttonStyle === "round" ){
- this.json.style = styles.style_round;
- }else{
- this.json.style = styles.style;
- }
- this.json.forceStyles = styles.forceStyles || "";
- },
- clearTemplateStyles: function(styles){
- this.json.style = "blue_round";
- this.json.forceStyles = "";
- },
- setAllStyles: function(){
- this._resetPaging();
- },
- setEvent: function(){
- this.node.addEvents({
- "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
- "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.pagingWarpNode_over)}.bind(this),
- "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.pagingWarpNode) }.bind(this)
- });
- },
- selected: function(){
- if (this.view.currentSelectedModule){
- if (this.view.currentSelectedModule==this){
- return true;
- }else{
- this.view.currentSelectedModule.unSelected();
- }
- }
- this.node.setStyles(this.css.pagingWarpNode_selected);
- // new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
- try {
- this.node.scrollIntoView(false);
- }catch (e) {
- }
- this.view.currentSelectedModule = this;
- this.isSelected = true;
- this.showProperty();
- },
- unSelected: function(){
- this.view.currentSelectedModule = null;
- this.node.setStyles(this.css.pagingWarpNode);
- this.isSelected = false;
- this.hideProperty();
- },
- resetTextNode: function(){
- var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
- if (!listText) listText = "unnamed";
- this.textNode.set("text", this.json.displayName);
- this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
- },
- _createNode: function(callback){
- this.node = new Element("div", {
- "id": this.json.id,
- "MWFType": "paging",
- "styles": this.css.pagingWarpNode,
- "events": {
- "selectstart": function(e){
- e.preventDefault();
- }
- }
- }).inject(this.container );
- this.pagingNode = new Element("div").inject(this.node);
- this.loadWidget();
- // this.pagingWidget = new MWF.widget.Paging(this.pagingNode, {"style": this.json.style}, this);
- // if (!this.json.pagingStyles){
- // this.json.pagingStyles = Object.clone(this.pagingWidget.css);
- // }
- // this.pagingWidget.load();
- },
- loadWidget : function( isReset ){
- debugger;
- var visiblePages = this.json.visiblePages ? this.json.visiblePages.toInt() : 9;
- this.pagingWidget = new o2.widget.Paging(this.pagingNode, {
- style : this.json.style || "default",
- countPerPage: 20, //this.json.pageSize || this.options.perPageCount,
- visiblePages: visiblePages,
- currentPage: 1,
- itemSize: visiblePages * 20 * 3,
- // pageSize: this.pages,
- hasNextPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
- hasPrevPage: typeOf( this.json.hasPreNextPage ) === "boolean" ? this.json.hasPreNextPage : true,
- hasTruningBar: typeOf( this.json.hasTruningBar ) === "boolean" ? this.json.hasTruningBar : true,
- hasBatchTuring: typeOf( this.json.hasBatchTuring ) === "boolean" ? this.json.hasBatchTuring : true,
- hasFirstPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : true,
- hasLastPage: typeOf( this.json.hasFirstLastPage ) === "boolean" ? this.json.hasFirstLastPage : true,
- hasJumper: typeOf( this.json.hasPageJumper ) === "boolean" ? this.json.hasPageJumper : true,
- hiddenWithDisable: false,
- // hiddenWithNoItem: true,
- text: {
- prePage: this.json.prePageText,
- nextPage: this.json.nextPageText,
- firstPage: this.json.firstPageText,
- lastPage: this.json.lastPageText
- },
- hasInfor: this.json.showPagingInfor,
- inforPosition: this.json.pagingPosition,
- inforTextStyle: this.json.textStyle,
- onJumpingPage : function( pageNum, itemNum ){
- }.bind(this),
- onPostLoad : function () {
- this.view.setContentHeight()
- // if(this.setContentHeightFun)this.setContentHeightFun();
- }.bind(this)
- }, isReset ? {} : (this.json.pagingStyles || {}));
- if( isReset ){
- if (!this.json.pagingStyles){
- this.json.pagingStyles = Object.merge( Object.clone( this.pagingWidget.css ), this.json.forceStyles || {} );
- }else{
- this.pagingWidget.css = Object.merge( Object.clone( this.json.pagingStyles ), this.pagingWidget.css, this.json.forceStyles || {} );
- this.json.pagingStyles = Object.clone(this.pagingWidget.css);
- }
- }else{
- if (!this.json.pagingStyles){
- this.json.pagingStyles = Object.clone(this.pagingWidget.css);
- }
- }
- this.pagingWidget.load();
- },
- _resetPaging : function(){
- this.pagingNode.empty();
- this.loadWidget( true );
- },
- _refreshPaging: function(){
- this.pagingNode.empty();
- this.loadWidget();
- },
- _setEditStyle_custom: function(name, obj, oldValue){
- if ( ["hasTruningBar","visiblePages","hasBatchTuring",
- "hasFirstLastPage","hasPreNextPage","hasPageJumper",
- "firstPageText","lastPageText","prePageText","nextPageText",
- "pagingStyles","showPagingInfor","pagingPosition","textStyle"].contains(name)){
- this._refreshPaging();
- }else if( name === "buttonStyle" ){
- if( this.json.buttonStyle === "rect" ){
- this.json.style = this.view.templateStyles.paging.style_rect;
- }else{
- this.json.style = this.view.templateStyles.paging.style_round;
- }
- this._resetPaging();
- }
- }
- });
|