mirror of
https://github.com/bitwarden/android.git
synced 2024-12-20 08:12:26 +03:00
folder delete
This commit is contained in:
parent
08875f7c5a
commit
11f908aab2
3 changed files with 52 additions and 2 deletions
|
@ -10,5 +10,6 @@ namespace Bit.App.Abstractions
|
||||||
Task<Folder> GetByIdAsync(string id);
|
Task<Folder> GetByIdAsync(string id);
|
||||||
Task<IEnumerable<Folder>> GetAllAsync();
|
Task<IEnumerable<Folder>> GetAllAsync();
|
||||||
Task<ApiResult<FolderResponse>> SaveAsync(Folder folder);
|
Task<ApiResult<FolderResponse>> SaveAsync(Folder folder);
|
||||||
|
Task<ApiResult<object>> DeleteAsync(string folderId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,12 +38,15 @@ namespace Bit.App.Pages
|
||||||
var nameCell = new FormEntryCell(AppResources.Name);
|
var nameCell = new FormEntryCell(AppResources.Name);
|
||||||
nameCell.Entry.Text = folder.Name.Decrypt();
|
nameCell.Entry.Text = folder.Name.Decrypt();
|
||||||
|
|
||||||
|
var deleteCell = new ExtendedTextCell { Text = AppResources.Delete, TextColor = Color.Red };
|
||||||
|
deleteCell.Tapped += DeleteCell_Tapped;
|
||||||
|
|
||||||
var mainTable = new ExtendedTableView
|
var mainTable = new ExtendedTableView
|
||||||
{
|
{
|
||||||
Intent = TableIntent.Settings,
|
Intent = TableIntent.Settings,
|
||||||
EnableScrolling = false,
|
EnableScrolling = false,
|
||||||
HasUnevenRows = true,
|
|
||||||
EnableSelection = false,
|
EnableSelection = false,
|
||||||
|
HasUnevenRows = true,
|
||||||
Root = new TableRoot
|
Root = new TableRoot
|
||||||
{
|
{
|
||||||
new TableSection()
|
new TableSection()
|
||||||
|
@ -59,6 +62,20 @@ namespace Bit.App.Pages
|
||||||
mainTable.EstimatedRowHeight = 70;
|
mainTable.EstimatedRowHeight = 70;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var deleteTable = new ExtendedTableView
|
||||||
|
{
|
||||||
|
Intent = TableIntent.Settings,
|
||||||
|
EnableScrolling = false,
|
||||||
|
EnableSelection = true,
|
||||||
|
Root = new TableRoot
|
||||||
|
{
|
||||||
|
new TableSection()
|
||||||
|
{
|
||||||
|
deleteCell
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async () =>
|
var saveToolBarItem = new ToolbarItem(AppResources.Save, null, async () =>
|
||||||
{
|
{
|
||||||
if(!_connectivity.IsConnected)
|
if(!_connectivity.IsConnected)
|
||||||
|
@ -85,7 +102,7 @@ namespace Bit.App.Pages
|
||||||
}, ToolbarItemOrder.Default, 0);
|
}, ToolbarItemOrder.Default, 0);
|
||||||
|
|
||||||
Title = "Edit Folder";
|
Title = "Edit Folder";
|
||||||
Content = mainTable;
|
Content = new StackLayout { Children = { mainTable, deleteTable } };
|
||||||
ToolbarItems.Add(saveToolBarItem);
|
ToolbarItems.Add(saveToolBarItem);
|
||||||
if(Device.OS == TargetPlatform.iOS)
|
if(Device.OS == TargetPlatform.iOS)
|
||||||
{
|
{
|
||||||
|
@ -98,6 +115,27 @@ namespace Bit.App.Pages
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void DeleteCell_Tapped(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// TODO: Validate the delete operation. ex. Cannot delete a folder that has sites in it?
|
||||||
|
|
||||||
|
if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var deleteTask = _folderService.DeleteAsync(_folderId);
|
||||||
|
_userDialogs.ShowLoading("Deleting...", MaskType.Black);
|
||||||
|
await deleteTask;
|
||||||
|
_userDialogs.HideLoading();
|
||||||
|
|
||||||
|
if((await deleteTask).Succeeded)
|
||||||
|
{
|
||||||
|
await Navigation.PopModalAsync();
|
||||||
|
_userDialogs.SuccessToast("Folder deleted.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void AlertNoConnection()
|
private void AlertNoConnection()
|
||||||
{
|
{
|
||||||
DisplayAlert(AppResources.InternetConnectionRequiredTitle, AppResources.InternetConnectionRequiredMessage, AppResources.Ok);
|
DisplayAlert(AppResources.InternetConnectionRequiredTitle, AppResources.InternetConnectionRequiredMessage, AppResources.Ok);
|
||||||
|
|
|
@ -74,5 +74,16 @@ namespace Bit.App.Services
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<ApiResult<object>> DeleteAsync(string folderId)
|
||||||
|
{
|
||||||
|
ApiResult<object> response = await _folderApiRepository.DeleteAsync(folderId);
|
||||||
|
if(response.Succeeded)
|
||||||
|
{
|
||||||
|
await _folderRepository.DeleteAsync(folderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue