Changeset 683


Ignore:
Timestamp:
09/09/10 20:44:35 (14 years ago)
Author:
gaba
Message:
 
Location:
MDService2/trunk/MDService2/WebContent/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • MDService2/trunk/MDService2/WebContent/scripts/mdservice2_ui.js

    r676 r683  
    8787                                this.Queries[0] = jj;
    8888                            }
     89                        });
     90                       
     91                        $.each(jsonw["WorkspaceProfile"]["Querysets"], function(i,item){
     92                                if (String(this.Queries) != "null") {
     93                                        $.each(this.Queries, function(i,item){
     94                                                if (this.collections != "null") {
     95                                                        if (this.collections[0] == undefined){
     96                                                        var jj = this["collections"]["item"];
     97                                                                delete this["collections"]["item"];
     98                                                                this.collections = [{}];
     99                                                        this.collections[0] = jj;
     100                                                    }
     101                                                }
     102                                        });
     103                                }
    89104                        });
    90105                }
     
    503518                var qid = $(this).closest('.query_wrapper').attr("id");
    504519                var qstring = queryset.getquerystring(qid);     
    505                 var coll = queryset.getcollections(qid);
    506                 if (coll == "") {
    507                         coll = "null";
    508                 }
    509                
    510                 var id = $("#qts_select option:selected").val();
     520                var json_coll = queryset.getcollections(qid);
     521               
     522                var id = parseInt($("#qts_select option:selected").val());
    511523                var iq = $("#qs_select option").size();
    512524               
    513                 //var query = new Query("","");
    514525                if (iq == 0){
    515526                        jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"] = [{}];
    516527                }
    517                 jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq] = {"querystring":qstring,"searchclauses":"null" , "collections" : {"item":coll}};
    518                
     528                jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq] = {"querystring":qstring,"searchclauses":"null" , "collections" : json_coll};
    519529                saveWorkspace();
    520530               
     
    620630                var iq = parseInt($("#qs_select option:selected").val());
    621631               
     632                var collection_text = "";
     633                if (jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq].collections != "null"){
     634                        $.each(jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq].collections,function(i,item){
     635                                collection_text = collection_text + "," + item;
     636                        });
     637                        if (collection_text.length > 1) {
     638                                collection_text = collection_text.substring(1);
     639                        }
     640                }
     641               
    622642                var query = new Query("","");
    623643                query.load(jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][iq]);
     644                query.collection = collection_text;
    624645                queryset.addquery(query);
    625646               
    626647                searchclauseset.sctext = query.query;
    627648                searchclauseset.buildfromquerystring();
    628         });
    629         $('#qs_delete').click(function(){
     649
     650                $('#collection_list').attr("value",collection_text);
     651        });
     652        $('#qs_remove').click(function(){
    630653                var count = $("#qs_select option").size();
    631654                var id = parseInt($("#qts_select option:selected").val());
     
    634657               
    635658                for (var i=iq;i<size-1;i++){
    636                         jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][i] = jjsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][i+1];
     659                        jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][i] = jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"][i+1];
    637660                }
    638661       
     
    640663                jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"].length = size-1;
    641664               
     665                if (size == 1){
     666                        jsonw["WorkspaceProfile"]["Querysets"][id]["Queries"] = "null";
     667                }
    642668               
    643669                saveWorkspace();
     
    816842                        if (String(jsonq.Queries) != "null") {
    817843                                $.each(jsonw["WorkspaceProfile"].Querysets[id].Queries, function(i,item) {
    818                                         notifyUser(i + ',' + this.querystring + ',' + this.created,'debug');
     844                                        notifyUser(i + ',' + this.querystring + ',' + this.collections[0],'debug');
    819845                                        $('#qs_select').append(new Option(this.querystring, i));
    820846                                });
     
    833859                                if (String(jsonw["WorkspaceProfile"].Querysets[id].Queries) != "null") {
    834860                                        $.each(jsonw["WorkspaceProfile"].Querysets[id].Queries, function(i,item) {
    835                                                 notifyUser(i + ',' + this.querystring + ',' + this.created,'debug');
    836                                                 $('#qs_select').append(new Option(this.querystring, i));
     861                                       
     862                                                notifyUser(i + ',' + this.querystring + ',' + this.collections[0],'debug');
     863                                                $('#qs_select').append(new Option(this.querystring , i));
    837864                                        });
    838865                                }
     
    857884                                this.Queries = {};
    858885                                this.Queries["Query"] = jj;
    859                                        
    860886                            }
     887                            /*
     888                            $.each(this.Queries,function(i,item){
     889                                if (this.collections != "null"){
     890                                         if (this.collections[1] == undefined){
     891                                                        var jj = this["collections"][0];
     892                                                        delete this["collections"][0];
     893                                                        this.collections = {};
     894                                                        this.collections["item"] = jj;
     895                                                    }           
     896                                }
     897                            });
     898                            */
    861899                        }
    862900                });
  • MDService2/trunk/MDService2/WebContent/scripts/mdservice_model.js

    r676 r683  
    101101        getcollections: function(qid) {
    102102                var coll = "";
     103                var json_coll, json_temp;
    103104               
    104105                for (var i = 0; i < this.queries.length; i++) {
     
    107108                        }
    108109                }
    109                 return coll;
     110               
     111                if (coll == "") {
     112                        json_coll = {};
     113                        json_coll = "null";
     114                } else { 
     115                        var pos = coll.indexOf(",", 0);
     116                        var i = 0;
     117                       
     118                        json_coll = [{}];
     119                        while (pos > -1){
     120                                if (pos > -1){
     121                                        json_coll[i] = coll.substring(0,pos);
     122                                } else {
     123                                        json_coll[i] = coll;
     124                                }
     125                                coll = coll.substring(pos+1);
     126                                pos = coll.indexOf(",", 0);
     127                                i = i+1;
     128                        }
     129                       
     130                        json_coll[i] = coll;
     131
     132                       
     133                }
     134                return json_coll;
    110135        }
    111136};
Note: See TracChangeset for help on using the changeset viewer.