Ignore:
Timestamp:
04/18/12 15:27:13 (12 years ago)
Author:
vmipsl
Message:

BO insertion données _ insertion code medias package insertion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/web/backoffice/dataInsertion-script.jsp

    r476 r482  
    1515        // Containers 
    1616        this.generalContainerDatasets = $( "#generalContainerDatasets" ); 
     17        this.containerDatasetsNumber = $( "#nbResults" ); 
     18        this.containerErrors = $( "#errors" ); 
    1719        this.containerDatasets = $( "#containerDataSets" ); 
    18         this.containerErrors = $( "#errors" ); 
    19         this.containerDatasetsNumber = $( "#nbResults" ); 
    20         this.containerFilesMove = $( "#containerFilesMove" ); 
    21         this.containerResultFilesMove = $( "#resultFilesMove" ); 
     20        this.containerResultRemove = $( "#containerResultRemove" ); 
     21        this.containerMove = $( "#containerMove" ); 
     22        this.containerResultMove = $( "#containerResultMove" ); 
     23        this.containerInsert = $( "#containerInsert" ); 
     24        this.containerResultInsert = $( "#containerResultInsert" ); 
    2225 
    2326        this.containerSorts = $( "#containerSorts" ); 
     
    3437        this.loadingDataset.display(); 
    3538 
     39        var param = new Object(); 
     40        param.id = "loadingForDatasetRemove"; 
     41        param.parent = this.generalContainerDatasets; 
     42        param.className = "loading-data"; 
     43        this.loadingRemove = new Loading( param ); 
     44 
     45        var param = new Object(); 
     46        param.id = "loadingForDatasetInsert"; 
     47        param.parent = this.containerInsert; 
     48        param.className = "loading-data"; 
     49        this.loadingInsert = new Loading( param ); 
     50 
    3651        this.containerErrors.hide(); 
    3752        this.displaySorts(); 
    3853        this.managePagination(); 
    3954        this.displayDatasets(); 
     55 
     56        // Bind insert button 
     57        $( "#insert" ).bind( 'click', this, jQuery.proxy( this.onClickInsert, this ) ); 
    4058    }, 
    4159 
    4260    // REQUESTS ******************************************************** 
    43     requestRemoveRequest: function() 
    44     { 
     61    requestRemoveDataset: function() 
     62    { 
     63        this.loadingRemove.display(); 
    4564        if( this.dataset ) 
    4665            $.ajax( { 
    4766                url: "backoffice?methodName=removeJeu&id=" + this.dataset.id, 
    48                 success:jQuery.proxy( this.handleRequest, this ) 
     67                success:jQuery.proxy( this.handleRemoveDataset, this ), 
     68                error: jQuery.proxy( this.showErrors, [this] ) 
    4969            } ); 
    5070    }, 
     
    5777        var request = $.ajax( { 
    5878            url: "backoffice?methodName=sortJeu&" + parametersUrl, 
    59             success:jQuery.proxy( this.handleSortRequest, this ), 
     79            success:jQuery.proxy( this.handleSortDataset, this ), 
    6080            error: jQuery.proxy( this.showErrors, [this] ) 
    6181        } ); 
     
    6787            $.ajax( { 
    6888                url: "backoffice?methodName=moveJeu&id=" + this.dataset.id, 
    69                 success:jQuery.proxy( this.handleFilesMove, this ) 
     89                success:jQuery.proxy( this.handleFilesMove, this ), 
     90                error: jQuery.proxy( this.showErrors, [this] ) 
    7091            } ); 
    7192    }, 
    7293 
     94    requestDatasetInsert: function() 
     95    { 
     96        this.loadingInsert.display(); 
     97        if( "" != $( "#categoryNameInsert" ).val() && "" != $( "#datasetNameInsert" ).val() && "" != $( "#versionInsert" ).val() ) 
     98            $.ajax( { 
     99                url: "backoffice?methodName=insertJeu&categoryName=" + $( "#categoryNameInsert" ).val() + "&datasetName=" + $( "#datasetNameInsert" ).val() + "&version=" + $( "#versionInsert" ).val() , 
     100                success:jQuery.proxy( this.handleDatasetInsert, this ), 
     101                error: jQuery.proxy( this.showErrors, [this] ) 
     102            } ); 
     103    }, 
     104 
    73105    // HANDLES ******************************************************** 
    74     handleRequest: function() 
    75     { 
    76         this.requestSortDataset(); 
    77     }, 
    78  
    79     handleSortRequest: function( result ) 
     106    handleRemoveDataset: function( result ) 
     107    { 
     108        this.loadingRemove.hide(); 
     109        this.containerResultRemove.html( jQuery.parseJSON( result ).success + " " + this.dataset.categoryName + " / " + this.dataset.name ); 
     110        this.containerResultRemove.removeClass( "disable" ); 
     111        this.containerResultRemove.show(); 
     112        this.requestSortDataset(); 
     113    }, 
     114 
     115    handleSortDataset: function( result ) 
    80116    { 
    81117        this.jSonDatasets = jQuery.parseJSON( result ).jSonDatasets; 
    82118        this.nbDatasets = jQuery.parseJSON( result ).datasetNumber; 
    83119        this.displayDatasets(); 
    84         this.displayFilesMove(); 
    85120    }, 
    86121 
    87122    handleFilesMove: function( result ) 
    88123    { 
    89         this.containerResultFilesMove.html( "OK" ); 
     124        this.containerResultMove.html( jQuery.parseJSON( result ).success ); 
     125        this.containerResultMove.removeClass( "disable" ); 
     126        this.containerResultMove.show(); 
     127    }, 
     128 
     129    handleDatasetInsert: function( result ) 
     130    { 
     131        this.loadingInsert.hide(); 
     132        this.containerResultInsert.html( jQuery.parseJSON( result ).success + " " + this.dataset.categoryName + " / " + this.dataset.name ); 
     133        this.containerResultInsert.show(); 
     134        this.requestSortDataset(); 
    90135    }, 
    91136 
     
    115160        if( this.jSonDatasets && 0 < this.jSonDatasets.length ) 
    116161        { 
    117             jQuery.each( this.jSonDatasets, jQuery.proxy( function( i, request ) 
     162            jQuery.each( this.jSonDatasets, jQuery.proxy( function( i, dataset ) 
    118163            { 
    119                 var tr = this.displayTRForDataset( request ); 
     164                var tr = this.displayTRForDataset( dataset ); 
    120165 
    121166                // Buttons 
    122167                var tdRemove = $( document.createElement( "td" ) ); 
    123                 new Button( {value:interfaceTexts["bo.remove"], parent:tdRemove, id:"button_remove", className: "small negative action_button", contextToSave: request, onClick:jQuery.proxy( this.onClickRemove, this )} ); 
     168                new Button( {value:interfaceTexts["bo.remove"], parent:tdRemove, id:"button_remove", className: "small negative action_button", contextToSave: dataset, onClick:jQuery.proxy( this.onClickRemove, this )} ); 
    124169                tr.append( tdRemove ); 
    125170 
     
    176221        if( this.dataset && this.dataset.categoryName ) 
    177222        { 
    178             this.containerFilesMove.html( "MOVE <span style='color:#FBE3E4'>" + this.downloadDirectory + "<%=File.separatorChar%>" + this.dataset.categoryName + "<%=File.separatorChar%>" + this.dataset.name + "<%=File.separatorChar%>* </span> <BR/>" + 
     223            this.containerMove.html( "MOVE <span style='color:#FBE3E4'>" + this.downloadDirectory + "<%=File.separatorChar%>" + this.dataset.categoryName + "<%=File.separatorChar%>" + this.dataset.name + "<%=File.separatorChar%>* </span> <BR/>" + 
    179224                    "TO &nbsp;&nbsp;&nbsp;&nbsp; <span style='color:#FBE3E4'>" + this.uploadDirectory + "<%=File.separatorChar%>" + this.dataset.categoryName + "<%=File.separatorChar%>" + this.dataset.name + "<%=File.separatorChar%>* </span>" ); 
    180225 
    181             new Button( {value:interfaceTexts["bo.move"], parent:this.containerFilesMove, id:"button_move", className: "small negative action_button", onClick:jQuery.proxy( this.onClickMove, this )} ); 
     226            new Button( {value:interfaceTexts["bo.move"], parent:this.containerMove, id:"button_move", className: "small negative action_button", onClick:jQuery.proxy( this.onClickMove, this )} ); 
     227            this.containerMove.show(); 
    182228        } 
    183229    }, 
    184230 
    185231    // EVENTS ******************************************************** 
     232    onClickSort: function() 
     233    { 
     234        this.containerPage.html( 1 ); 
     235        this.requestSortDataset(); 
     236    }, 
     237 
     238    onClickPrevious: function() 
     239    { 
     240        decrementPage( this.containerPage, this.containerMaxPage ); 
     241        this.requestSortDataset(); 
     242    }, 
     243 
     244    onClickNext: function() 
     245    { 
     246        incrementPage( this.containerPage, this.containerMaxPage ); 
     247        this.requestSortDataset(); 
     248    }, 
     249 
    186250    onClickRemove: function( dataset ) 
    187251    { 
    188252        this.dataset = dataset; 
     253 
     254        this.containerErrors.hide(); 
     255        this.hideRemove(); 
     256        this.hideMove(); 
     257        this.hideInsert(); 
     258 
     259        this.displayFilesMove(); 
     260 
     261        $( "#categoryNameInsert" ).val( this.dataset.categoryName ); 
     262        $( "#datasetNameInsert" ).val( this.dataset.name ); 
     263 
    189264//        if( window.confirm( interfaceTexts["bo.dataset.remove.confirm"] + " " + dataset.name + " ?" ) ) 
    190         jQuery.proxy( this.requestRemoveRequest(), this ); 
    191     }, 
    192  
    193     onClickSort: function() 
    194     { 
    195         this.containerPage.html( 1 ); 
    196         this.requestSortDataset(); 
    197     }, 
    198  
    199     onClickPrevious: function() 
    200     { 
    201         decrementPage( this.containerPage, this.containerMaxPage ); 
    202         this.requestSortDataset(); 
    203     }, 
    204  
    205     onClickNext: function() 
    206     { 
    207         incrementPage( this.containerPage, this.containerMaxPage ); 
    208         this.requestSortDataset(); 
     265        this.requestRemoveDataset(); 
    209266    }, 
    210267 
    211268    onClickMove: function() 
    212269    { 
     270        this.containerErrors.hide(); 
     271        this.containerResultRemove.addClass( "disable" ); 
     272        this.hideMove(); 
     273        this.hideInsert(); 
    213274        this.requestFilesMove(); 
     275    }, 
     276 
     277    onClickInsert: function() 
     278    { 
     279        this.containerErrors.hide(); 
     280        this.containerResultMove.addClass( "disable" ); 
     281        this.hideInsert(); 
     282 
     283        if( "" != $( "#categoryNameInsert" ).val() && "" != $( "#datasetNameInsert" ).val() && "" != $( "#versionInsert" ).val() ) 
     284            this.requestDatasetInsert(); 
     285        else 
     286            this.showErrors( interfaceTexts["bo.dataset.fields"] ); 
    214287    }, 
    215288 
     
    217290    showErrors: function( result ) 
    218291    { 
    219         var context = this[0]; 
     292        var context = this[0] ? this[0] : this; 
    220293        var text = this[1]; 
    221294        context.containerErrors.show(); 
     
    224297        else if( interfaceTexts[result.responseText] ) 
    225298            context.containerErrors.html( interfaceTexts[result.responseText] ); 
     299        else if( result.responseText ) 
     300            context.containerErrors.html( result.responseText ); 
    226301        else 
    227             context.containerErrors.html( result.responseText ); 
     302            context.containerErrors.html( result ); 
    228303    }, 
    229304 
     
    232307        $( "#previous" ).bind( 'click', this, jQuery.proxy( this.onClickPrevious, this ) ); 
    233308        $( "#next" ).bind( 'click', this, jQuery.proxy( this.onClickNext, this ) ); 
     309    }, 
     310 
     311    hideRemove: function() 
     312    { 
     313        this.loadingRemove.hide(); 
     314        this.containerResultRemove.hide(); 
     315    }, 
     316 
     317    hideMove: function() 
     318    { 
     319        this.containerResultMove.hide(); 
     320    }, 
     321 
     322    hideInsert: function() 
     323    { 
     324        this.loadingInsert.hide(); 
     325        this.containerResultInsert.hide(); 
    234326    } 
    235327 
Note: See TracChangeset for help on using the changeset viewer.