Improvements in folder sharing dialog
This commit is contained in:
parent
06528c12fd
commit
2463f86b17
3 changed files with 145 additions and 11 deletions
|
@ -191,7 +191,7 @@ function kolab_files_init()
|
|||
file_api.request('folder_info', {folder: file_api.file_path(rcmail.env.file), sessions: 1}, 'folder_info_response');
|
||||
}
|
||||
else if (rcmail.env.action == 'share') {
|
||||
// do nothing
|
||||
kolab_files_share_form_init();
|
||||
}
|
||||
else {
|
||||
file_api.env.init_folder = rcmail.env.folder;
|
||||
|
@ -1324,6 +1324,22 @@ function kolab_files_progress_str(param)
|
|||
.replace(/\$total/, total);
|
||||
};
|
||||
|
||||
function kolab_files_share_form_init()
|
||||
{
|
||||
$('fieldset > table', rcmail.gui_objects.shareform).each(function() {
|
||||
var mode = $(this).data('mode');
|
||||
$('tbody > tr', this).each(function(i, row) {
|
||||
if (!i) {
|
||||
$('button.submit', row).on('click', function() { file_api.sharing_submit(rcmail.env.folder, row, mode); });
|
||||
}
|
||||
else {
|
||||
$('button.delete', row).on('click', function() { file_api.sharing_delete(rcmail.env.folder, row, mode); });
|
||||
$('select,input[type=text]', row).on('change', function() { file_api.sharing_update(rcmail.env.folder, row, mode); });
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**********************************************************/
|
||||
/********* document editor functionality **********/
|
||||
|
@ -2694,6 +2710,103 @@ function kolab_files_ui()
|
|||
this.quota();
|
||||
};
|
||||
|
||||
this.sharing_submit = function(folder, row, mode)
|
||||
{
|
||||
var post = this.sharing_data(row, {action: 'submit', folder: folder, mode: mode});
|
||||
|
||||
this.sharing_submit_post = post;
|
||||
this.sharing_submit_row = row;
|
||||
this.req = this.set_busy(true, 'kolab_files.updatingfolder' + mode);
|
||||
this.post('sharing', post, 'sharing_submit_response');
|
||||
};
|
||||
|
||||
this.sharing_submit_response = function(response)
|
||||
{
|
||||
if (!this.response(response))
|
||||
return;
|
||||
|
||||
// reset inputs
|
||||
$(this.sharing_submit_row).find('input[type=text]').val('');
|
||||
|
||||
var hidden = [],
|
||||
post = $.extend({}, this.sharing_submit_post, response.data || {}),
|
||||
form_info = rcmail.env.form_info[post.mode],
|
||||
row = $('<tr>'),
|
||||
btn = $('<button type="button" class="btn btn-secondary delete">')
|
||||
.text(rcmail.gettext('delete'))
|
||||
.on('click', function() { file_api.sharing_delete(post.folder, $(this).closest('tr'), post.mode); });
|
||||
|
||||
$.each(form_info.form || [], function(i, v) {
|
||||
var content, opts = [];
|
||||
|
||||
if (v.type == 'select') {
|
||||
content = $('<select>').attr('name', i)
|
||||
.on('change', function() { file_api.sharing_update(post.folder, $(this).closest('tr'), post.mode); });
|
||||
$.each(v.options, function(i, v) {
|
||||
opts.push($('<option>').attr('value', i).text(v));
|
||||
});
|
||||
|
||||
content.append(opts).val(post[i]);
|
||||
}
|
||||
else {
|
||||
content = $('<span class="name">').text(post[i]);
|
||||
hidden.push($('<input>').attr({type: 'hidden', name: i, value: post[i] || ''}));
|
||||
}
|
||||
|
||||
row.append($('<td>').append(content));
|
||||
});
|
||||
|
||||
$.each(form_info.extra_fields || [], function(i, v) {
|
||||
hidden.push($('<input>').attr({type: 'hidden', name: i, value: post[i] || ''}));
|
||||
});
|
||||
|
||||
row.append($('<td>').append(btn).append(hidden));
|
||||
|
||||
$(this.sharing_submit_row).parent().append(row);
|
||||
};
|
||||
|
||||
this.sharing_update = function(folder, row, mode)
|
||||
{
|
||||
var post = this.sharing_data(row, {action: 'update', folder: folder, mode: mode});
|
||||
|
||||
this.req = this.set_busy(true, 'kolab_files.updatingfolder' + mode);
|
||||
this.post('sharing', post, 'sharing_update_response');
|
||||
};
|
||||
|
||||
this.sharing_update_response = function(response)
|
||||
{
|
||||
if (!this.response(response))
|
||||
return;
|
||||
|
||||
// todo: on error reset fields?
|
||||
};
|
||||
|
||||
this.sharing_delete = function(folder, row, mode)
|
||||
{
|
||||
var post = this.sharing_data(row, {action: 'delete', folder: folder, mode: mode});
|
||||
|
||||
this.sharing_delete_row = row;
|
||||
this.req = this.set_busy(true, 'kolab_files.updatingfolder' + mode);
|
||||
this.post('sharing', post, 'sharing_delete_response');
|
||||
};
|
||||
|
||||
this.sharing_delete_response = function(response)
|
||||
{
|
||||
if (!this.response(response))
|
||||
return;
|
||||
|
||||
$(this.sharing_delete_row).remove();
|
||||
};
|
||||
|
||||
this.sharing_data = function(row, data)
|
||||
{
|
||||
$('select,input', row).each(function() {
|
||||
data[this.name] = $(this).val();
|
||||
});
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
// quota request
|
||||
this.quota = function()
|
||||
{
|
||||
|
|
|
@ -367,16 +367,19 @@ class kolab_files_engine
|
|||
|
||||
$info = $this->get_share_info($folder);
|
||||
|
||||
$this->rc->output->set_env('folder', $folder);
|
||||
|
||||
if (empty($info) || empty($info['form'])) {
|
||||
return;
|
||||
$msg = $this->plugin->gettext($info === false ? 'sharepermissionerror' : 'sharestorageerror');
|
||||
return html::div(array('class' => 'boxerror', 'id' => 'share-notice'), rcube::Q($msg));
|
||||
}
|
||||
|
||||
if (empty($attrib['id'])) {
|
||||
$attrib['id'] = 'foldershareform';
|
||||
}
|
||||
|
||||
$out = '';
|
||||
|
||||
foreach ($info['form'] as $mode => $tab) {
|
||||
$table = new html_table(array('cols' => count($tab['form']) + 1));
|
||||
$table = new html_table(array('cols' => count($tab['form']) + 1, 'data-mode' => $mode));
|
||||
$submit = new html_button(array('class' => 'btn btn-secondary submit'));
|
||||
$delete = new html_button(array('class' => 'btn btn-secondary delete'));
|
||||
$fields = array();
|
||||
|
@ -402,7 +405,14 @@ class kolab_files_engine
|
|||
$table->add(null, $ff->show());
|
||||
$fields[$index] = $ff;
|
||||
}
|
||||
$table->add(null, $submit->show(rcube::Q($this->plugin->gettext('submit'))));
|
||||
|
||||
$hidden = '';
|
||||
foreach ((array) $tab['extra_fields'] as $key => $default) {
|
||||
$h = new html_hiddenfield(array('name' => $key, 'value' => $default));
|
||||
$hidden .= $h->show();
|
||||
}
|
||||
|
||||
$table->add(null, $hidden . $submit->show(rcube::Q($this->plugin->gettext('submit'))));
|
||||
|
||||
// Existing entries
|
||||
foreach ((array) $info['rights'] as $entry) {
|
||||
|
@ -412,15 +422,15 @@ class kolab_files_engine
|
|||
$table->add(null, $fields[$index]->show($entry[$index]));
|
||||
}
|
||||
else if ($fields[$index] instanceof html_inputfield) {
|
||||
$table->add(null, $fields[$index]->show($entry[$index], array('readonly' => true, 'class' => 'form-control-plaintext')));
|
||||
$table->add(null, html::span('name', rcube::Q($entry[$index])));
|
||||
}
|
||||
}
|
||||
|
||||
$hidden = '';
|
||||
foreach (array('type', 'id') as $key) {
|
||||
foreach ((array) $tab['extra_fields'] as $key => $default) {
|
||||
if (isset($entry[$key])) {
|
||||
$h = new html_hiddenfield(array('name' => $key));
|
||||
$hidden .= $h->show($entry[$key]);
|
||||
$h = new html_hiddenfield(array('name' => $key, 'value' => $entry[$key]));
|
||||
$hidden .= $h->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,9 +438,14 @@ class kolab_files_engine
|
|||
}
|
||||
}
|
||||
|
||||
$out .= html::tag('fieldset', $idx, html::tag('legend', null, rcube::Q($tab['title'])) . $table->show()) . "\n";
|
||||
$out .= html::tag('fieldset', $mode, html::tag('legend', null, rcube::Q($tab['title'])) . $table->show()) . "\n";
|
||||
}
|
||||
|
||||
$this->rc->output->set_env('folder', $folder);
|
||||
$this->rc->output->set_env('form_info', $info['form']);
|
||||
$this->rc->output->add_gui_object('shareform', $attrib['id']);
|
||||
$this->rc->output->add_label('kolab_files.submit', 'delete', 'kolab_files.updatingfoldershares');
|
||||
|
||||
return html::div($attrib, $out);
|
||||
}
|
||||
|
||||
|
@ -1659,6 +1674,9 @@ class kolab_files_engine
|
|||
if ($status == 200 && $body['status'] == 'OK') {
|
||||
$info = $body['result'];
|
||||
}
|
||||
else if ($body['code'] == 530) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
throw new Exception($body['reason'] ?: "Failed to get sharing form information. Status: $status");
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ $labels['filedeletenotice'] = 'File(s) deleted successfully.';
|
|||
$labels['filemovenotice'] = 'File(s) moved successfully.';
|
||||
$labels['filecopynotice'] = 'File(s) copied successfully.';
|
||||
$labels['uploadsizeerror'] = 'Maximum file size ($size) exceeded!';
|
||||
$labels['updatingfoldershares'] = 'Updating folder permissions...';
|
||||
|
||||
$labels['listpermanent'] = 'List permanently';
|
||||
$labels['additionalfolders'] = 'Additional folders';
|
||||
|
@ -159,6 +160,8 @@ $labels['invitationrequesting'] = 'Requesting an invitation...';
|
|||
$labels['storepasswords'] = 'remember password';
|
||||
$labels['storepasswordsdesc'] = 'Stored passwords will be encrypted. Enable this if you do not want to be asked for the password on every login or you want this storage to be available via WebDAV.';
|
||||
$labels['storageautherror'] = 'Authentication failed for $title storage.';
|
||||
$labels['sharepermissionerror'] = 'You do not have permission to manage this folder sharing.';
|
||||
$labels['sharestorageerror'] = 'Failed to get folder sharing information.';
|
||||
|
||||
$labels['arialabelsearchform'] = 'Files search form';
|
||||
$labels['arialabelquicksearchbox'] = 'Search input';
|
||||
|
|
Loading…
Add table
Reference in a new issue