Improvements in contact import dialog

- Fix Import button state on import errors
- Focus Cancel button on form submission
- Don't reload contacts list when import failed
pull/6583/head
Aleksander Machniak 6 years ago
parent 2f9ea5e078
commit 829395ed13

@ -1403,8 +1403,7 @@ function rcube_webmail()
break;
case 'import':
var reload = false,
dialog = $('<iframe>').attr('src', this.url('import', {_framed: 1, _target: this.env.source})),
var dialog = $('<iframe>').attr('src', this.url('import', {_framed: 1, _target: this.env.source})),
import_func = function(e) {
var win = dialog[0].contentWindow,
form = win.rcmail.gui_objects.importform;
@ -1421,17 +1420,17 @@ function rcube_webmail()
form.submit();
win.rcmail.lock_form(form, true);
// disable Import button
$(e.target).attr('disabled', true);
reload = true;
$(e.target).attr('disabled', true).next().focus();
}
},
close_func = function(event, ui) {
$(this).remove();
if (reload)
if (ref.import_state == 'reload')
ref.command('list');
};
this.simple_dialog(dialog, this.gettext('importcontacts'), import_func, {
this.import_state = null;
this.import_dialog = this.simple_dialog(dialog, this.gettext('importcontacts'), import_func, {
close: close_func,
button: 'import',
width: 500,
@ -5771,6 +5770,17 @@ function rcube_webmail()
head.append($('<style id="image-style">').text('img { transform: ' + style.join(' ') + '}'));
};
// Update import dialog state
this.import_state_set = function(state)
{
if (this.import_dialog) {
this.import_state = state;
// activate Import button depending on state
$(this.import_dialog).parent().find('.ui-dialog-buttonset > button:first').attr('disabled', state != 'error');
}
};
/*********************************************************/
/********* keyboard live-search methods *********/
/*********************************************************/

@ -86,6 +86,8 @@ if (is_array($_FILES['_file'])) {
else {
$OUTPUT->show_message('importformaterror', 'error');
}
$OUTPUT->command('parent.import_state_set', 'error');
}
else {
$IMPORT_STATS = new stdClass;
@ -172,6 +174,8 @@ if (is_array($_FILES['_file'])) {
}
$importstep = 'rcmail_import_confirm';
$OUTPUT->command('parent.import_state_set', $IMPORT_STATS->inserted ? 'reload' : 'ok');
}
}

Loading…
Cancel
Save