Project

General

Profile

Fonction pour affichage du Cut Fits Forms

Fonction à rajouter au cut fits form pour pouvoir l'afficher directement à partir du project graph

sitools.component.users.project.clickCutForm = function (url, type) {
    Ext.Ajax.request({
        method : "GET", 
        url : url, 
        success : function (ret) {
            var Json = Ext.decode(ret.responseText);
            if (showResponse(ret)) {
                var dataset = Json.dataset;
                var componentCfg, javascriptObject;
                var windowConfig = {
                    datasetName : dataset.name, 
                    type : type, 
                    saveToolbar : true, 
                    toolbarItems : []
                };
                if(type == "forms")
                 {
                    var menuForms = new Ext.menu.Menu();
                    Ext.Ajax.request({
                        method : "GET", 
                        url : dataset.sitoolsAttachementForUsers + "/forms", 
                        success : function (ret) {
                            try {
                                var Json = Ext.decode(ret.responseText);
                                if (! Json.success) {
                                    throw Json.message;
                                }
                                if (Json.total === 0) {
                                    throw "No Cut Fits form defined for this dataset";
                                }
                            javascriptObject = sitools.component.users.datasets.forms;
                                if (Json.total == 1 && Json.data[0].parameters[0].type == "CUTFITSFORMWITHNAME") {
                                    var form = Json.data[0];

                                    Ext.apply(windowConfig, {
                                        title : i18n.get('label.forms') + " : " + dataset.name + "." + form.name
                                    });

                                    Ext.apply(windowConfig, {
                                        id : type + dataset.id + form.id
                                    });
                                    componentCfg = {
                                        dataUrl : dataset.sitoolsAttachementForUsers,
                                        datasetId : dataset.id,
                                        datasetName : dataset.name,
                                        datasetCm : dataset.columnModel,
                                        formId : form.id,
                                        formName : form.name,
                                        formParameters : form.parameters,
                                        formWidth : form.width,
                                        formHeight : form.height, 
                                        formCss : form.css, 
                                        datasetView : dataset.datasetView
                                    };
                                    SitoolsDesk.app.addDesktopWindow(windowConfig, componentCfg, javascriptObject);

                                }else {

                                        var handler = null;
                                        var componentCfg = null;
                                        //boolean pour savoir si dans la liste des forms il y a un Cut Fits form
                                        var trouveCut = false;
                                        Ext.each(Json.data, function (form) {

                                            if(form.parameters[0].type == "CUTFITSFORMWITHNAME"){
                                                trouveCut = true;
                                                Ext.apply(windowConfig, {
                                                    title : i18n.get('label.forms') + " : " + dataset.name + "." + form.name
                                            });

                                           Ext.apply(windowConfig, {
                                               id : type + dataset.id + form.id
                                           });

                                           componentCfg = {
                                               dataUrl : dataset.sitoolsAttachementForUsers,
                                               datasetId : dataset.id,
                                               datasetName : dataset.name,
                                               datasetCm : dataset.columnModel,
                                               formId : form.id,
                                               formName : form.name,
                                               formParameters : form.parameters,
                                               formWidth : form.width,
                                               formHeight : form.height, 
                                               formCss : form.css, 
                                               datasetView : dataset.datasetView
                                            };

                                         }                        
                                        }, this);
                                        if(trouveCut){
                                            SitoolsDesk.app.addDesktopWindow(windowConfig, componentCfg, javascriptObject);
                                        }else{
                                            throw "No Cut Fits form defined for this dataset";            
                                        }
                                }                        
                            }
                            catch (err) {
                                var tmp = new Ext.ux.Notification({
                                    iconCls : 'x-icon-information',
                                    title : i18n.get('label.information'),
                                    html : i18n.get(err),
                                    autoDestroy : true,
                                    hideDelay : 1000
                                }).show(document);
                            }
                        }
                    });

                }
            }
        }, 
        failure : alertFailure
    });

Il faut également modifier légèrement la fonction clickIcone, pour que l'on ne fasse pas apparaitre le cut fits dans la liste des forms.

case "forms" : 
                    var menuForms = new Ext.menu.Menu();
                    Ext.Ajax.request({
                        method : "GET", 
                        url : dataset.sitoolsAttachementForUsers + "/forms", 
                        success : function (ret) {
                            try {
                                var Json = Ext.decode(ret.responseText);
                                if (! Json.success) {
                                    throw Json.message;
                                }
                                if (Json.total === 0) {
                                    throw i18n.get('label.noForms');
                                }
                                javascriptObject = sitools.component.users.datasets.forms;
                                if (Json.total == 1) {
                                    if(Json.data[0].parameters[0].type != "CUTFITSFORMWITHNAME"){
                                        var form = Json.data[0];
                                    Ext.apply(windowConfig, {
                                        title : i18n.get('label.forms') + " : " + dataset.name + "." + form.name
                                    });

                                    Ext.apply(windowConfig, {
                                        id : type + dataset.id + form.id
                                    });
                                    componentCfg = {
                                        dataUrl : dataset.sitoolsAttachementForUsers,
                                        datasetId : dataset.id,
                                        datasetName : dataset.name,
                                        datasetCm : dataset.columnModel,
                                        formId : form.id,
                                        formName : form.name,
                                        formParameters : form.parameters,
                                        formWidth : form.width,
                                        formHeight : form.height, 
                                        formCss : form.css, 
                                        datasetView : dataset.datasetView
                                    };
                                    SitoolsDesk.app.addDesktopWindow(windowConfig, componentCfg, javascriptObject);
                                    }else{
                                        throw i18n.get('label.noForms');
                                    }
                           }else {

                                    var handler = null;
                                    if(Json.data.length == 2){
                                        Ext.each(Json.data, function (form) {
                                            if(form.parameters[0].type != "CUTFITSFORMWITHNAME"){                                    
                                                Ext.apply(windowConfig, {
                                                title : i18n.get('label.forms') + " : " + dataset.name + "." + form.name
                                            });                    
                                            Ext.apply(windowConfig, {
                                                id : type + dataset.id + form.id
                                            });
                                            componentCfg = {
                                                dataUrl : dataset.sitoolsAttachementForUsers,
                                                datasetId : dataset.id,
                                                datasetName : dataset.name,
                                                datasetCm : dataset.columnModel,
                                                formId : form.id,
                                                formName : form.name,
                                                formParameters : form.parameters,
                                                formWidth : form.width,
                                                formHeight : form.height, 
                                                formCss : form.css, 
                                                datasetView : dataset.datasetView
                                            };
                                            SitoolsDesk.app.addDesktopWindow(windowConfig, componentCfg, javascriptObject);
                                        }    
                                        }, this);

                                    }else{
                                        Ext.each(Json.data, function (form) {
                                            if(form.parameters[0].type != "CUTFITSFORMWITHNAME" ){                                    
                                                handler = function (form, dataset) {
                                                    Ext.apply(windowConfig, {
                                                        title : i18n.get('label.forms') + " : " + dataset.name + "." + form.name
                                                });

                                               Ext.apply(windowConfig, {
                                                   id : type + dataset.id + form.id
                                               });
                                               componentCfg = {
                                                   dataUrl : dataset.sitoolsAttachementForUsers,
                                                   datasetId : dataset.id,
                                                   datasetName : dataset.name,
                                                   datasetCm : dataset.columnModel,
                                                   formId : form.id,
                                                   formName : form.name,
                                                   formParameters : form.parameters,
                                                   formWidth : form.width,
                                                   formHeight : form.height, 
                                                   formCss : form.css, 
                                                   datasetView : dataset.datasetView
                                               };
                                               SitoolsDesk.app.addDesktopWindow(windowConfig, componentCfg, javascriptObject);
                                                };
                                                menuForms.addItem({
                                                    text : form.name, 
                                                    handler : function () {
                                                        handler(form, dataset);
                                                    }, 
                                                    icon : "/sitools/common/res/images/icons/tree_forms.png" 
                                                });
                                        }    
                                        }, this);
                                        menuForms.showAt(Ext.EventObject.xy);
                                    }                        
                                }
                            }
                            catch (err) {
                                var tmp = new Ext.ux.Notification({
                                    iconCls : 'x-icon-information',
                                    title : i18n.get('label.information'),
                                    html : i18n.get(err),
                                    autoDestroy : true,
                                    hideDelay : 1000
                                }).show(document);
                            }
                        }
                    });

                    break;