simplify UI for sharing

This commit is contained in:
Nariman Jelveh 2024-06-17 21:50:30 -07:00
parent e9af6358bb
commit 91b7f7db1e
2 changed files with 23 additions and 23 deletions

View File

@ -12,35 +12,24 @@ async function UIWindowShare(items){
// name // name
h += `<h2 style="font-size: 17px; margin-top:0; text-align:center; margin-bottom: 40px; font-weight: 400; color: #303d49; text-shadow: 1px 1px white;">${items.length > 1 ? `Share ${items.length} items` : `${items[0].name}`}</h2>`; h += `<h2 style="font-size: 17px; margin-top:0; text-align:center; margin-bottom: 40px; font-weight: 400; color: #303d49; text-shadow: 1px 1px white;">${items.length > 1 ? `Share ${items.length} items` : `${items[0].name}`}</h2>`;
// success
h += `<div class="window-give-item-access-success">`;
h += `<span class="hide-sharing-success-alert">✕</span>`
h += `<img src="${html_encode(window.icons['c-check.svg'])}" style="width:50px; height:50px; display: block; margin:10px auto;">`;
h += `<p style="text-align:center; margin-bottom:10px;">Shared with <strong class="access-recipient-print"></strong></p>`;
h+= `</div>`;
// form // form
h += `<form class="window-give-item-access-form">`; h += `<form class="window-give-item-access-form">`;
// Error msg // Error msg
h += `<div class="error"></div>`; h += `<div class="error"></div>`;
// Username/email // Username/email
h += `<div style="overflow: hidden;">`; h += `<div style="overflow: hidden;">`;
h += `<label style="margin-bottom: 10px;">Share with:</label>`; h += `<label style="font-size: 16px; font-weight: 600;">Share with:</label>`;
h += `<div style="display: flex;">`; h += `<div style="display: flex;">`;
// Username/email // Username/email
h += `<input placeholder="username" class="access-recipient" style="border-right: none; margin-bottom: 10px; border-top-right-radius: 0; border-bottom-right-radius: 0;" type="text" autocomplete="recipient_email_username" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>`; h += `<input placeholder="username" class="access-recipient" style="border-right: none; margin-bottom: 10px; border-top-right-radius: 0; border-bottom-right-radius: 0;" type="text" autocomplete="recipient_email_username" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>`;
// Share // Share
h += `<button class="give-access-btn button button-primary button-normal" style="border-top-left-radius: 0; border-bottom-left-radius: 0;">Share</button>` h += `<button class="give-access-btn button button-primary button-normal" style="border-top-left-radius: 0; border-bottom-left-radius: 0;" disabled>Share</button>`
h += `</div>`; h += `</div>`;
h += `</div>`; h += `</div>`;
h += `</form>`; h += `</form>`;
//recipients //recipients
h += `<h2 style="font-size: 17px; h += `<p style="font-size: 14px; margin-bottom: 0px; color: #303d49; text-shadow: 1px 1px white;">People with access</p>`;
margin-bottom: 0px;
font-weight: 400;
color: #303d49;
text-shadow: 1px 1px white;">People with access</h2>`;
h += `<div class="share-recipients">`; h += `<div class="share-recipients">`;
h += `</div>`; h += `</div>`;
h += `</div>`; h += `</div>`;
@ -137,13 +126,24 @@ async function UIWindowShare(items){
let recipient_id = $(el_window).find('.access-recipient').val(); let recipient_id = $(el_window).find('.access-recipient').val();
// todo do some basic validation client-side // todo do some basic validation client-side
if(recipient_id === null) if(recipient_id === '' || recipient_id === null || recipient_id === undefined)
return; return;
if(is_email(recipient_id)) if(is_email(recipient_id))
recipient_email = recipient_id; recipient_email = recipient_id;
else else
recipient_username = recipient_id; recipient_username = recipient_id;
// can't share with self
if(recipient_username === window.user.username){
$(el_window).find('.error').html('You can\'t share with yourself');
$(el_window).find('.error').fadeIn();
return;
}
else if(recipient_email && recipient_email === window.user.email){
$(el_window).find('.error').html('You can\'t share with yourself');
$(el_window).find('.error').fadeIn();
return;
}
// disable 'Give Access' button // disable 'Give Access' button
$(el_window).find('.give-access-btn').prop('disabled', true); $(el_window).find('.give-access-btn').prop('disabled', true);
@ -166,14 +166,13 @@ async function UIWindowShare(items){
paths: [ paths: [
{ {
path: items[0].path, path: items[0].path,
access_level: access_level, access: access_level,
} }
] ]
}), }),
success: function(response) { success: function(response) {
// show success message // show success message
$(el_window).find('.access-recipient-print').html(recipient_id); $(el_window).find('.access-recipient-print').html(recipient_id);
$(el_window).find('.window-give-item-access-success').show(100);
let perm_id = `fs:${items[0].uid}:${access_level}`; let perm_id = `fs:${items[0].uid}:${access_level}`;
// append recipient to list // append recipient to list
@ -185,9 +184,6 @@ async function UIWindowShare(items){
// append recipient to list // append recipient to list
$(el_window).find('.share-recipients').append(`${perm_list}`); $(el_window).find('.share-recipients').append(`${perm_list}`);
// add this user to the list of printed users
// printed_users.push(perm.user.username);
}, },
error: function(err) { error: function(err) {
// at this point 'username_not_found' and 'shared_with_self' are the only // at this point 'username_not_found' and 'shared_with_self' are the only
@ -213,8 +209,13 @@ async function UIWindowShare(items){
return false; return false;
}) })
$(el_window).find('.hide-sharing-success-alert').on('click', function(){ $(el_window).find('.access-recipient').on('input keypress keyup keydown paste', function(){
$(el_window).find('.window-give-item-access-success').hide(200); if($(this).val() === ''){
$(el_window).find('.give-access-btn').prop('disabled', true);
}
else{
$(el_window).find('.give-access-btn').prop('disabled', false);
}
}) })
}) })

View File

@ -2078,7 +2078,6 @@ label {
} }
.share-recipients { .share-recipients {
margin-top: 10px;
max-height: 200px; max-height: 200px;
overflow: scroll; overflow: scroll;
} }