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 ) function setServerLastSync( id, last )
{ {
var db = getDatabase(); var db = getDatabase();

View File

@ -98,6 +98,38 @@ Page {
id: listEntry id: listEntry
width: parent.width 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 { Item {
width: parent.width - 2 * Theme.horizontalPageMargin width: parent.width - 2 * Theme.horizontalPageMargin
x: Theme.horizontalPageMargin x: Theme.horizontalPageMargin
@ -105,7 +137,7 @@ Page {
Rectangle { Rectangle {
id: serverCountLabel id: serverCountLabel
height: listEntry.height - 1.5 * Theme.horizontalPageMargin height: Theme.fontSizeSmall * 1.5
width: height width: height
radius: 2 radius: 2
color: listEntry.highlighted ? Theme.primaryColor : Theme.highlightBackgroundColor color: listEntry.highlighted ? Theme.primaryColor : Theme.highlightBackgroundColor

View File

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