Implement server deletion

pull/1/head
Grégory Oestreicher 2016-12-16 19:02:45 +01:00
parent 54d89f1841
commit 5cbae70c47
3 changed files with 51 additions and 1 deletions

View File

@ -166,6 +166,20 @@ function updateServer( id, props )
);
}
function deleteServer( id )
{
var db = getDatabase();
db.transaction(
function( tx ) {
console.debug( "Deleting server " + id );
// TODO: try/catch here when error management is in place in the UI
tx.executeSql( "DELETE FROM articles WHERE server=?", [ id ] );
tx.executeSql( "DELETE FROM servers WHERE id=?", [ id ] );
}
);
}
function setServerLastSync( id, last )
{
var db = getDatabase();

View File

@ -98,6 +98,38 @@ Page {
id: listEntry
width: parent.width
RemorseItem {
id: serverRemorse
}
function showRemorse( idx ) {
serverRemorse.execute(
listEntry,
qsTr( "Deleting" ),
function() {
var server = serversModel.get( idx )
WallaBase.deleteServer( server.id )
serversPage.updateServerList()
}
)
}
menu: ContextMenu {
id: serverMenu
width: listEntry.width
IconButton {
id: deleteButton
icon.source: "image://theme/icon-m-delete"
x: Theme.horizontalPageMargin
onClicked: {
serverMenu.hide()
listEntry.showRemorse( index )
}
}
}
Item {
width: parent.width - 2 * Theme.horizontalPageMargin
x: Theme.horizontalPageMargin
@ -105,7 +137,7 @@ Page {
Rectangle {
id: serverCountLabel
height: listEntry.height - 1.5 * Theme.horizontalPageMargin
height: Theme.fontSizeSmall * 1.5
width: height
radius: 2
color: listEntry.highlighted ? Theme.primaryColor : Theme.highlightBackgroundColor

View File

@ -123,6 +123,10 @@
<source>Resetting database</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Deleting</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SettingsPage</name>