Merge pull request #132 from michael-k/notes
[core][sailfish] Support for updating notes
This commit is contained in:
commit
643ccbb89a
4 changed files with 177 additions and 2 deletions
|
|
@ -246,6 +246,20 @@ ListModel {
|
|||
})
|
||||
}
|
||||
|
||||
function updateNote(note, callback) {
|
||||
var ttrss = rootWindow.getTTRSS()
|
||||
var index = root.selectedIndex
|
||||
var item = getSelectedItem()
|
||||
|
||||
ttrss.updateFeedNote(item.id, note, function(successful, errorMessage) {
|
||||
if (successful) {
|
||||
root.setProperty(index, "note", note)
|
||||
}
|
||||
|
||||
callback(successful, errorMessage)
|
||||
})
|
||||
}
|
||||
|
||||
function getLabels(callback) {
|
||||
var ttrss = rootWindow.getTTRSS()
|
||||
var item = getSelectedItem()
|
||||
|
|
|
|||
|
|
@ -913,6 +913,59 @@ function process_updateFeedUnread(callback, httpreq) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update articles' notes.
|
||||
* @param {int} The ids of the articles.
|
||||
* @param {string} The note.
|
||||
* @param {function} A callback function with parameters boolean (indicating
|
||||
* success) and string (an optional error message).
|
||||
*/
|
||||
function updateFeedNote(articleIds, note, callback) {
|
||||
if(responsesPending['feeditemnote']) {
|
||||
return;
|
||||
}
|
||||
|
||||
// needs to be logged in
|
||||
if(!state['token']) {
|
||||
requestsPending['feeditemnote'] = true;
|
||||
processPendingRequests(callback);
|
||||
return;
|
||||
}
|
||||
|
||||
responsesPending['feeditemnote'] = true;
|
||||
|
||||
var params = {
|
||||
'op': 'updateArticle',
|
||||
'sid': state['token'],
|
||||
'article_ids': articleIds,
|
||||
'field': 3,
|
||||
'data': note
|
||||
}
|
||||
|
||||
networkCall(params, function(http) { process_updateFeedNote(callback, http) });
|
||||
}
|
||||
|
||||
/** @private */
|
||||
function process_updateFeedNote(callback, httpreq) {
|
||||
var response = process_readyState(httpreq);
|
||||
|
||||
responsesPending['feeditemnote'] = false;
|
||||
|
||||
if (!response.successful) {
|
||||
trace(1, "Update feeditem note: " + response.errorMessage);
|
||||
if (callback) {
|
||||
callback(false, response.errorMessage);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(!processPendingRequests(callback) && callback) {
|
||||
// This action is complete (as there's no other requests to do)
|
||||
// Fire callback saying all ok
|
||||
callback(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of configured labels.
|
||||
* @param {int} The id of an arbitrary article.
|
||||
|
|
|
|||
|
|
@ -57,14 +57,27 @@ Page {
|
|||
enabled: url && (url != "")
|
||||
onClicked: Qt.openUrlExternally(url)
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: panel.open ? qsTr("Hide Dock") : qsTr("Open Dock")
|
||||
enabled: !panel.moving
|
||||
onClicked: panel.open ? panel.hide() : panel.show()
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("Edit Note")
|
||||
enabled: !network.loading
|
||||
onClicked: {
|
||||
var params = {
|
||||
previousNote: root.note,
|
||||
feedItemPage: root
|
||||
}
|
||||
pageStack.push(Qt.resolvedUrl("NoteEditor.qml"), params)
|
||||
}
|
||||
}
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("Assign Labels")
|
||||
|
||||
enabled: !network.loading
|
||||
onClicked: {
|
||||
feedItemModel.getLabels(function(successful, errorMessage,
|
||||
|
|
@ -76,7 +89,7 @@ Page {
|
|||
feedItemPage: root
|
||||
}
|
||||
pageStack.push(Qt.resolvedUrl("LabelUpdater.qml"),
|
||||
params);
|
||||
params)
|
||||
}
|
||||
|
||||
// TODO make use of errorMessage
|
||||
|
|
@ -382,6 +395,16 @@ Page {
|
|||
})
|
||||
}
|
||||
|
||||
function updateNote(note) {
|
||||
feedItemModel.updateNote(note, function(successful, errorMessage) {
|
||||
if (successful) {
|
||||
root.note = note
|
||||
}
|
||||
|
||||
// TODO make use of errorMessage
|
||||
})
|
||||
}
|
||||
|
||||
Binding {
|
||||
target: itemView
|
||||
property: "fontSize"
|
||||
|
|
|
|||
85
qml/ttrss/sailfish/pages/NoteEditor.qml
Normal file
85
qml/ttrss/sailfish/pages/NoteEditor.qml
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* This file is part of TTRss, a Tiny Tiny RSS Reader App
|
||||
* for MeeGo Harmattan and Sailfish OS.
|
||||
* Copyright (C) 2012–2014 Hauke Schade
|
||||
*
|
||||
* TTRss is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* TTRss is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with TTRss; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
|
||||
* http://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
import Sailfish.Silica 1.0
|
||||
|
||||
Dialog {
|
||||
id: page
|
||||
property string previousNote
|
||||
property var feedItemPage
|
||||
|
||||
canAccept: false
|
||||
onCanAcceptChanged: {
|
||||
menu.visible = page.canAccept
|
||||
}
|
||||
|
||||
SilicaFlickable {
|
||||
contentHeight: area.height + Theme.paddingMedium + header.height
|
||||
contentWidth: parent.width
|
||||
anchors.fill: parent
|
||||
|
||||
PullDownMenu {
|
||||
id: menu
|
||||
visible: false
|
||||
|
||||
MenuItem {
|
||||
text: qsTr("Reset")
|
||||
onClicked: {
|
||||
area.text = page.previousNote
|
||||
page.canAccept = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DialogHeader {
|
||||
id: header
|
||||
width: dialog.width
|
||||
title: qsTr("Edit Note")
|
||||
acceptText: qsTr("Save Note")
|
||||
cancelText: qsTr("Cancel")
|
||||
}
|
||||
|
||||
TextArea {
|
||||
id: area
|
||||
anchors {
|
||||
top: header.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
margins: Theme.paddingMedium
|
||||
}
|
||||
|
||||
focus: true
|
||||
text: page.previousNote
|
||||
|
||||
Component.onCompleted: {
|
||||
// We don't want to change page.canAccept during initialization.
|
||||
area.textChanged.connect(function() {
|
||||
page.canAccept = true
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onAccepted: {
|
||||
feedItemPage.updateNote(area.text)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue