0001-Bug-669-Prevent-confirm-dialog-autoclose.patch

Hector Sanjuan, 06/15/2011 01:45 PM

Download (4.11 KB)

View differences:

src/sunstone/public/js/sunstone.js
149 149

  
150 150
    //Runs a predefined action. Wraps the calls to opennebula.js and
151 151
    //can be use to run action depending on conditions and notify them
152
    //if desired.
152
    //if desired. Returns 1 if some problem has been detected: i.e
153
    //the condition to run the action is not met, the action is not found
153 154
    "runAction" : function(action, data_arg, extra_param){
154 155

  
155 156
        var actions = SunstoneCfg["actions"];
156 157
        if (!actions[action]){
157 158
            notifyError("Action "+action+" not defined");
158
            return;
159
            return 1;
159 160
        }
160 161

  
161 162
        var action_cfg = actions[action];
......
169 170
            if (notify) {
170 171
            notifyError("This action cannot be run");
171 172
            }
172
            return;
173
            return 1;
173 174
        }
174 175

  
175 176
        var call = action_cfg["call"];
176 177
        var callback = action_cfg["callback"];
177 178
        var err = action_cfg["error"];
178 179

  
179

  
180
        //Time to close any confirmation dialogs, as the execution may have
181
        //come from them.
182
        $('div#confirm_with_select_dialog').dialog("close");
183
        $('div#confirm_dialog').dialog("close");
184

  
185

  
186 180
        //We ease the use of:
187 181
        // * "create" calls to opennebula.js
188 182
        // * "single" element calls to opennebula.js
......
261 255
            notifySubmit(action,data_arg,extra_param);
262 256
        }
263 257

  
264

  
258
        return 0;
265 259
    },
266 260

  
267 261
    //returns a button object from the desired tab
......
305 299
    //"multiple" it runs that action on the elements of a datatable.
306 300
    $('.action_button').live("click",function(){
307 301

  
302
        var error = 0;
308 303
        var table = null;
309 304
        var value = $(this).attr("value");
310 305
        var action = SunstoneCfg["actions"][value];
......
315 310
        switch (action.type){
316 311
        case "multiple": //find the datatable
317 312
            var nodes = action.elements();
318
            Sunstone.runAction(value,nodes);
313
            error = Sunstone.runAction(value,nodes);
319 314
            break;
320 315
        default:
321
            Sunstone.runAction(value);
316
            error = Sunstone.runAction(value);
322 317
        }
318

  
319
        if (!error){
320
            //proceed to close confirm dialog in
321
            //case it was open
322
            $('div#confirm_dialog').dialog("close");
323
        };
324

  
323 325
        return false;
324 326
    });
325 327

  
......
621 623
    //find out if we are running an action with a parametre on a datatable
622 624
    //items or if its just an action
623 625
    $('button#confirm_with_select_proceed').click(function(){
626
        var error = 0;
624 627
        var value = $(this).val();
625 628
        var action = SunstoneCfg["actions"][value];
626 629
        var param = $('select#confirm_select').val();
......
628 631
        switch (action.type){
629 632
        case "multiple": //find the datatable
630 633
            var nodes = action.elements();
631
            Sunstone.runAction(value,nodes,param);
634
            error = Sunstone.runAction(value,nodes,param);
632 635
            break;
633 636
        default:
634
            Sunstone.runAction(value,param);
637
            error = Sunstone.runAction(value,param);
635 638
            break;
636 639
        }
640

  
641
        if (!error){
642
            $('div#confirm_with_select_dialog').dialog("close");
643
        }
644

  
637 645
        return false;
638 646
    });
639 647
}
640
-