| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- o2.widget = o2.widget || {};
- o2.require("o2.widget.Common", null, false);
- o2.require("o2.xDesktop.Actions.RestActions", null, false);
- o2.widget.O2Identity = new Class({
- Implements: [Options, Events],
- Extends: o2.widget.Common,
- options: {
- "style": "default",
- "canRemove": false,
- "lazy": false
- },
- initialize: function(data, container, options){
- this.setOptions(options);
- this.loadedInfor = false;
- this.path = o2.session.path+"/widget/$O2Identity/";
- this.cssPath = o2.session.path+"/widget/$O2Identity/"+this.options.style+"/css.wcss";
- this._loadCss();
- this.container = $(container);
- this.data = data;
- this.style = this.css;
- this.action = new o2.xDesktop.Actions.RestActions("", "x_organization_assemble_control", "x_component_Org");
- // this.explorer = explorer;
- // this.removeAction = removeAction;
- this.load();
- //o2.widget.O2Identity.iditems.push(this);
- },
- setText: function(){
- this.node.set("text", this.data.name+"("+this.data.unitName+")");
- },
- load: function(){
- if (!this.options.lazy) this.getPersonData();
- this.node = new Element("div", {"styles": this.style.identityNode}).inject(this.container);
- this.setText();
- if (this.options.canRemove){
- this.removeNode = new Element("div", {"styles": this.style.identityRemoveNode}).inject(this.node);
- this.removeNode.addEvent("click", function(e){
- this.fireEvent("remove", [this, e]);
- e.stopPropagation();
- }.bind(this));
- }
- if (!this.options.lazy){
- this.createInforNode(function(){
- this.fireEvent("loadedInfor", [this]);
- }.bind(this));
- }else{
- this.node.addEvents({
- "mouseover": function(){
- if (!this.loadedInfor){
- this.getPersonData();
- this.createInforNode(function(){
- this.fireEvent("loadedInfor", [this]);
- }.bind(this));
- }
- }.bind(this)
- });
- }
- this.setEvent();
- this.node.addEvents({
- "mouseover": function(){
- this.node.setStyles(this.style.identityNode_over);
- }.bind(this),
- "mouseout": function(){
- this.node.setStyles(this.style.identityNode);
- }.bind(this)
- });
- },
- setEvent: function(){},
- getPersonData: function(){
- if (!this.data.dutys){
- var action = o2.Actions.get("x_organization_assemble_control");
- var id = this.data.distinguishedName || this.data.id || this.data.unique;
- if (id) action.listUnitdutyByIdentity(id, function(json){
- this.data.dutys = json.data;
- }.bind(this), null, false);
- }
- if (!this.data.woPerson){
- // var uri = "/jaxrs/person/{flag}";
- // //uri = uri.replace("{flag}", this.data.person);
- // var uriIdentity = "/jaxrs/identity/{id}";
- this.action.actions = {
- "getPerson": {"uri": "/jaxrs/person/{flag}"},
- "getIdentity": {"uri": "/jaxrs/identity/{id}"}
- };
- var woPerson;
- if (this.data.person){
- this.action.invoke({"name": "getPerson", "async": false, "parameter": {"flag": this.data.person}, "success": function(json){
- this.data.woPerson = woPerson;
- woPerson = json.data;
- }.bind(this)});
- }else{
- this.action.invoke({"name": "getIdentity", "async": false, "parameter": {"id": this.data.id || this.data.name}, "success": function(json){
- this.data = json.data;
- woPerson = json.data.woPerson;
- }.bind(this)});
- }
- return woPerson;
- }else{
- return this.data.woPerson;
- }
- //listDutyNameWithIdentity
- },
- createInforNode: function(callback){
- var person = this.getPersonData();
- if (person){
- this.inforNode = new Element("div", {
- "styles": this.style.identityInforNode
- });
- var nameNode = new Element("div", {
- "styles": this.style.identityInforNameNode
- }).inject(this.inforNode);
- var uri = "/jaxrs/person/{flag}/icon";
- uri = uri.replace("{flag}", person.id);
- this.action.getAddress();
- uri = this.action.address+uri;
- img = "<img width='50' height='50' border='0' src='"+uri+"' style='border-radius:25px'/>";
- var picNode = new Element("div", {
- "styles": this.style.identityInforPicNode,
- "html": img
- }).inject(nameNode);
- var rightNode = new Element("div", {
- "styles": this.style.identityInforRightTextNode
- }).inject(nameNode);
- var nameTextNode = new Element("div", {
- "styles": this.style.identityInforNameTextNode,
- "text": person.name
- }).inject(rightNode);
- var employeeTextNode = new Element("div", {
- "styles": this.style.identityInforEmployeeTextNode,
- "text": person.employee || ""
- }).inject(rightNode);
- // var phoneNode = new Element("div", {
- // "styles": this.style.identityInforPhoneNode,
- // "html": "<div style='width:30px; float:left'>"+o2.LP.desktop.person.personMobile+": </div><div style='width:90px; float:left; margin-left:10px'>"+(person.mobile || "")+"</div>"
- // }).inject(this.inforNode);
- // var mailNode = new Element("div", {
- // "styles": this.style.identityInforPhoneNode,
- // "html": "<div style='width:30px; float:left'>"+o2.LP.desktop.person.personMail+": </div><div style='width:90px; float:left; margin-left:10px'>"+(person.mail || "")+"</div>"
- // }).inject(this.inforNode);
- var dutys = [];
- if (this.data.dutys && this.data.dutys.length){
- this.data.dutys.each(function(d){
- var n = d.name+"("+d.woUnit.levelName+")";
- dutys.push(n);
- });
- }
- var dutyNode = new Element("div", {
- "styles": this.style.identityInforPhoneNode,
- "html": "<div style='width:30px; float:left'>"+o2.LP.desktop.person.duty+": </div><div style='width:160px; float:left; margin-left:10px'>"+(dutys.join(","))+"</div>"
- }).inject(this.inforNode);
- this.loadedInfor = true;
- this.tooltip = new mBox.Tooltip({
- content: this.inforNode,
- setStyles: {content: {padding: 15, lineHeight: 20}},
- attach: this.node,
- transition: 'flyin'
- });
- }
- if (callback) callback();
- },
- destroy: function(){
- if (this.tooltip) this.tooltip.destroy();
- this.node.destroy();
- o2.release(this);
- }
- });
- // o2.widget.Person = new Class({
- // Implements: [Options, Events],
- // Extends: o2.widget.Identity,
- // getPerson: function(callback){
- // if (this.data.name && this.data.id){
- // if (callback) callback({"data": this.data});
- // }else{
- // var key = this.data.name;
- // this.explorer.actions["getPerson"](function(json){
- // if (callback) callback(json);
- // }, null, key);
- // }
- // }
- // });
- o2.widget.O2Person = new Class({
- Extends: o2.widget.O2Identity,
- getPersonData: function(){
- if (!this.data.distinguishedName){
- this.action.actions = {"getPerson": {"uri": "/jaxrs/person/{id}"}};
- this.action.invoke({"name": "getPerson", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
- this.data = json.data;
- }.bind(this)});
- }
- return this.data;
- },
- setText: function(){
- this.node.set("text", this.data.name);
- }
- });
- o2.widget.O2Unit = new Class({
- Extends: o2.widget.O2Identity,
- getPersonData: function(){
- if (!this.data.distinguishedName){
- this.action.actions = {"getUnit": {"uri": "/jaxrs/unit/{id}"}};
- this.action.invoke({"name": "getUnit", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
- this.data = json.data;
- }.bind(this)});
- }
- },
- createInforNode: function(){
- this.inforNode = new Element("div", {
- "styles": this.style.identityInforNode
- });
- var nameNode = new Element("div", {
- "styles": this.style.identityInforNameNode,
- "text": this.data.levelName
- }).inject(this.inforNode);
- this.tooltip = new mBox.Tooltip({
- content: this.inforNode,
- setStyles: {content: {padding: 15, lineHeight: 20}},
- attach: this.node,
- transition: 'flyin'
- });
- },
- setText: function(){
- this.node.set("text", this.data.name);
- }
- });
- o2.widget.O2Duty = new Class({
- Extends: o2.widget.O2Identity,
- getPersonData: function(){
- if (!this.data.woUnit){
- this.action.actions = {"getUnitduty": {"uri": "/jaxrs/unitduty/{id}"}};
- this.action.invoke({"name": "getUnitduty", "async": false, "parameter": {"id": (this.data.dutyId || this.data.name)}, "success": function(json){
- this.data = json.data;
- }.bind(this)});
- }
- },
- createInforNode: function(){
- this.inforNode = new Element("div", {
- "styles": this.style.identityInforNode
- });
- var nameNode = new Element("div", {
- "styles": this.style.identityInforNameNode,
- "text": this.data.woUnit.levelName
- }).inject(this.inforNode);
- this.tooltip = new mBox.Tooltip({
- content: this.inforNode,
- setStyles: {content: {padding: 15, lineHeight: 20}},
- attach: this.node,
- transition: 'flyin'
- });
- },
- setText: function(){
- this.node.set("text", this.data.name);
- }
- });
- o2.widget.O2Group = new Class({
- Extends: o2.widget.O2Unit,
- getPersonData: function(){
- if (!this.data.distinguishedName){
- this.action.actions = {"getGroup": {"uri": "/jaxrs/group/{id}"}};
- this.action.invoke({"name": "getGroup", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
- this.data = json.data;
- }.bind(this)});
- }
- },
- setText: function(){
- this.node.set("text", this.data.name);
- },
- createInforNode: function(){
- return false;
- }
- });
- o2.widget.O2Application = new Class({
- Extends: o2.widget.O2Group,
- getPersonData: function(){
- if (!this.data.name){
- this.action = new o2.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
- this.action.actions = {"getApplication": {"uri": "/jaxrs/application/{id}"}};
- this.action.invoke({"name": "getApplication", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
- this.data = json.data;
- }.bind(this)});
- }
- }
- });
- o2.widget.O2CMSApplication = new Class({
- Extends: o2.widget.O2Group,
- getPersonData: function(){
- if (!this.data.name){
- o2.Actions.get("x_cms_assemble_control").getApplication((this.data.id || this.data.name), function(json){
- this.data = json.data;
- }.bind(this), null, false);
- // this.action = new o2.xDesktop.Actions.RestActions("", "x_cms_assemble_control", "");
- // this.action.actions = {"getApplication": {"uri": "/jaxrs/application/{id}"}};
- // this.action.invoke({"name": "getApplication", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
- // this.data = json.data;
- // }.bind(this)});
- }
- }
- });
- o2.widget.O2Process = new Class({
- Extends: o2.widget.O2Group,
- getPersonData: function(){
- if (!this.data.name){
- this.action = new o2.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
- this.action.actions = {"getProces": {"uri": "/jaxrs/process/{id}/complex"}};
- this.action.invoke({"name": "getProces", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
- this.data = json.data;
- }.bind(this)});
- }
- },
- createInforNode: function(){
- this.inforNode = new Element("div", {
- "styles": this.style.identityInforNode
- });
- var nameNode = new Element("div", {
- "styles": this.style.identityInforNameNode,
- "text": this.data.name || this.data.applicationName || this.data.appName
- }).inject(this.inforNode);
- this.tooltip = new mBox.Tooltip({
- content: this.inforNode,
- setStyles: {content: {padding: 15, lineHeight: 20}},
- attach: this.node,
- transition: 'flyin'
- });
- }
- });
- o2.widget.O2CMSCategory = new Class({
- Extends: o2.widget.O2Group,
- getPersonData: function(){
- if (!this.data.name){
- o2.Actions.get("x_cms_assemble_control").getCategory((this.data.id || this.data.name), function(json){
- this.data = json.data;
- }.bind(this), null, false);
- }
- },
- createInforNode: function(){
- this.inforNode = new Element("div", {
- "styles": this.style.identityInforNode
- });
- var nameNode = new Element("div", {
- "styles": this.style.identityInforNameNode,
- "text": this.data.applicationName || this.data.appName
- }).inject(this.inforNode);
- this.tooltip = new mBox.Tooltip({
- content: this.inforNode,
- setStyles: {content: {padding: 15, lineHeight: 20}},
- attach: this.node,
- transition: 'flyin'
- });
- }
- });
- o2.widget.O2View = new Class({
- Extends: o2.widget.O2Group,
- getPersonData: function(){
- if (!this.data.query){
- var data = null;
- o2.Actions.get("x_query_assemble_surface").getStatById(this.data.id, function(json){
- data = json.data
- }, null, false);
- this.data = data;
- return data;
- }else{
- return this.data;
- }
- },
- createInforNode: function(){
- this.inforNode = new Element("div", {
- "styles": this.style.identityInforNode
- });
- var nameNode = new Element("div", {
- "styles": this.style.identityInforNameNode,
- "text": this.data.applicationName || this.data.appName || this.data.name
- }).inject(this.inforNode);
- this.tooltip = new mBox.Tooltip({
- content: this.inforNode,
- setStyles: {content: {padding: 15, lineHeight: 20}},
- attach: this.node,
- transition: 'flyin'
- });
- }
- });
- o2.widget.O2CMSView = new Class({
- Extends: o2.widget.O2View
- });
- o2.widget.O2QueryView = new Class({
- Extends: o2.widget.O2View,
- getPersonData: function(){
- if (!this.data.query){
- var data = null;
- o2.Actions.get("x_query_assemble_surface").getViewById(this.data.id, function(json){
- data = json.data
- }, null, false);
- this.data = data;
- return data;
- }else{
- return this.data;
- }
- }
- });
- o2.widget.O2QueryStat = new Class({
- Extends: o2.widget.O2View,
- getPersonData: function(){
- if (!this.data.query){
- var data = null;
- o2.Actions.get("x_query_assemble_surface").getStatById(this.data.id, function(json){
- data = json.data
- }, null, false);
- this.data = data;
- return data;
- }else{
- return this.data;
- }
- }
- });
- o2.widget.O2FormField = new Class({
- Extends: o2.widget.O2Group,
- getPersonData: function(){
- return this.data;
- }
- });
- o2.widget.O2Role = new Class({
- Extends: o2.widget.O2Group,
- getPersonData: function(){
- if (!this.data.distinguishedName){
- this.action.actions = {"getRole": {"uri": "/jaxrs/role/{id}"}};
- this.action.invoke({"name": "getRole", "async": false, "parameter": {"id": (this.data.id || this.data.name)}, "success": function(json){
- this.data = json.data;
- }.bind(this)});
- }
- }
- });
- o2.widget.O2File = new Class({
- Extends: o2.widget.O2Group,
- createInforNode: function(){
- this.inforNode = new Element("div", {
- "styles": this.style.identityInforNode
- });
- var extName = this.data.fileName.substring(this.data.fileName.lastIndexOf(".")+1, this.data.fileName.length).toLowerCase();
- if (["png","jpg","bmp","gif","jpeg","jpe"].indexOf(extName)!==-1){
- var url = (this.data.portal) ? MWF.xDesktop.getPortalFileUr(this.data.id, this.data.portal) : MWF.xDesktop.getProcessFileUr(this.data.id, this.data.application);
- var img = new Element("img", {"src": url, "styles": {"max-width": "280px", "max-height": "140px"}}).inject(this.inforNode);
- }else{
- var nameNode = new Element("div", {
- "styles": this.style.identityInforNameNode,
- "text": this.data.applicationName || this.data.appName || this.data.name
- }).inject(this.inforNode);
- }
- this.tooltip = new mBox.Tooltip({
- content: this.inforNode,
- setStyles: {content: {padding: 15, lineHeight: 20}},
- attach: this.node,
- transition: 'flyin'
- });
- },
- getPersonData: function(){
- return this.data;
- }
- });
- o2.widget.O2Other = new Class({
- Extends: o2.widget.O2Group,
- getPersonData: function(){
- return this.data;
- }
- });
- // o2.widget.O2Identity.iditems = o2.widget.O2Identity.iditems || [];
- // o2.widget.O2Identity.intervalId = window.setInterval(function(){
- // if (o2.widget.O2Identity.iditems && o2.widget.O2Identity.iditems.length){
- // o2.widget.O2Identity.iditems.each(function(item){
- // if (item.tooltip){
- // debugger;
- // if (item.tooltip.options.attach){
- //
- // }
- // }
- // });
- // }
- // }, 10000);
|