1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-11 18:24:43 +02:00

Fixed note sorting and changed colour of header

This commit is contained in:
Laurent Cozic 2017-07-27 18:25:42 +01:00
parent 0d37167f39
commit bd06fa781e
13 changed files with 64 additions and 37 deletions

View File

@ -2,6 +2,7 @@ import fs from 'fs-extra';
import { BaseCommand } from './base-command.js'; import { BaseCommand } from './base-command.js';
import { app } from './app.js'; import { app } from './app.js';
import { _ } from 'lib/locale.js'; import { _ } from 'lib/locale.js';
import { vorpalUtils } from './vorpal-utils.js';
import { Folder } from 'lib/models/folder.js'; import { Folder } from 'lib/models/folder.js';
import { Note } from 'lib/models/note.js'; import { Note } from 'lib/models/note.js';
import { Setting } from 'lib/models/setting.js'; import { Setting } from 'lib/models/setting.js';
@ -46,6 +47,8 @@ class Command extends BaseCommand {
let note = await app().loadItem(BaseModel.TYPE_NOTE, title); let note = await app().loadItem(BaseModel.TYPE_NOTE, title);
if (!note) { if (!note) {
let ok = await vorpalUtils.cmdPromptConfirm(this, _('Note does not exist: "%s". Create it?', title))
if (!ok) return;
newNote = await Note.save({ title: title, parent_id: app().currentFolder().id }); newNote = await Note.save({ title: title, parent_id: app().currentFolder().id });
note = await Note.load(newNote.id); note = await Note.load(newNote.id);
} }

View File

@ -15,10 +15,6 @@ class Command extends BaseCommand {
return _('Switches to [notebook] - all further operations will happen within this notebook.'); return _('Switches to [notebook] - all further operations will happen within this notebook.');
} }
aliases() {
return ['cd'];
}
autocomplete() { autocomplete() {
return { data: autocompleteFolders }; return { data: autocompleteFolders };
} }

View File

@ -94,6 +94,10 @@ msgstr ""
msgid "No active notebook." msgid "No active notebook."
msgstr "" msgstr ""
#, javascript-format
msgid "Note does not exist: \"%s\". Create it?"
msgstr ""
msgid "Starting to edit note. Close the editor to get back to the prompt." msgid "Starting to edit note. Close the editor to get back to the prompt."
msgstr "" msgstr ""

View File

@ -14,8 +14,6 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.3\n" "X-Generator: Poedit 2.0.3\n"
"POT-Creation-Date: \n"
"PO-Revision-Date: \n"
msgid "No notebook selected." msgid "No notebook selected."
msgstr "Aucun carnet n'est sélectionné." msgstr "Aucun carnet n'est sélectionné."
@ -105,6 +103,10 @@ msgstr ""
msgid "No active notebook." msgid "No active notebook."
msgstr "Aucun carnet actif." msgstr "Aucun carnet actif."
#, fuzzy, javascript-format
msgid "Note does not exist: \"%s\". Create it?"
msgstr "Ce carnet n'existe pas : \"%s\". Le créer ?"
msgid "Starting to edit note. Close the editor to get back to the prompt." msgid "Starting to edit note. Close the editor to get back to the prompt."
msgstr "" msgstr ""
"Edition de la note en cours. Fermez l'éditeur de texte pour retourner à " "Edition de la note en cours. Fermez l'éditeur de texte pour retourner à "

View File

@ -94,6 +94,10 @@ msgstr ""
msgid "No active notebook." msgid "No active notebook."
msgstr "" msgstr ""
#, javascript-format
msgid "Note does not exist: \"%s\". Create it?"
msgstr ""
msgid "Starting to edit note. Close the editor to get back to the prompt." msgid "Starting to edit note. Close the editor to get back to the prompt."
msgstr "" msgstr ""

View File

@ -7,7 +7,7 @@
"url": "https://github.com/laurent22/joplin" "url": "https://github.com/laurent22/joplin"
}, },
"url": "git://github.com/laurent22/joplin.git", "url": "git://github.com/laurent22/joplin.git",
"version": "0.8.65", "version": "0.8.68",
"bin": { "bin": {
"joplin": "./main_launcher.js" "joplin": "./main_launcher.js"
}, },

View File

@ -90,8 +90,8 @@ android {
applicationId "net.cozic.joplin" applicationId "net.cozic.joplin"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 22 targetSdkVersion 22
versionCode 33 versionCode 34
versionName "0.9.20" versionName "0.9.21"
ndk { ndk {
abiFilters "armeabi-v7a", "x86" abiFilters "armeabi-v7a", "x86"
} }

View File

@ -8,6 +8,10 @@ const globalStyle = {
selectedColor: '#e5e5e5', selectedColor: '#e5e5e5',
disabledOpacity: 0.3, disabledOpacity: 0.3,
raisedBackgroundColor: "#0072D5",
raisedColor: "#003363",
raisedHighlightedColor: "#ffffff",
// For WebView - must correspond to the properties above // For WebView - must correspond to the properties above
htmlFontSize: '14px', htmlFontSize: '14px',
htmlColor: 'black', // Note: CSS in WebView component only seem to work if the colour is written in full letters (so no hexadecimal) htmlColor: 'black', // Note: CSS in WebView component only seem to work if the colour is written in full letters (so no hexadecimal)

View File

@ -16,7 +16,7 @@ let styleObject = {
flexDirection: 'row', flexDirection: 'row',
paddingTop: 10, paddingTop: 10,
paddingBottom: 10, paddingBottom: 10,
backgroundColor: globalStyle.backgroundColor, backgroundColor: globalStyle.raisedBackgroundColor,
alignItems: 'center', alignItems: 'center',
shadowColor: '#000000', shadowColor: '#000000',
elevation: 5, elevation: 5,
@ -24,7 +24,7 @@ let styleObject = {
folderPicker: { folderPicker: {
height: 30, height: 30,
flex:1, flex:1,
color: globalStyle.color, color: globalStyle.raisedHighlightedColor,
// Note: cannot set backgroundStyle as that would remove the arrow in the component // Note: cannot set backgroundStyle as that would remove the arrow in the component
}, },
divider: { divider: {
@ -35,14 +35,14 @@ let styleObject = {
sideMenuButton: { sideMenuButton: {
flex: 1, flex: 1,
alignItems: 'center', alignItems: 'center',
backgroundColor: globalStyle.backgroundColor, backgroundColor: globalStyle.raisedBackgroundColor,
paddingLeft: globalStyle.marginLeft, paddingLeft: globalStyle.marginLeft,
paddingRight: 5, paddingRight: 5,
marginRight: 2, marginRight: 2,
}, },
iconButton: { iconButton: {
flex: 1, flex: 1,
backgroundColor: globalStyle.backgroundColor, backgroundColor: globalStyle.raisedBackgroundColor,
paddingLeft: 15, paddingLeft: 15,
paddingRight: 15, paddingRight: 15,
}, },
@ -70,11 +70,11 @@ let styleObject = {
contextMenuTrigger: { contextMenuTrigger: {
fontSize: 25, fontSize: 25,
paddingRight: globalStyle.marginRight, paddingRight: globalStyle.marginRight,
color: globalStyle.color, color: globalStyle.raisedColor,
fontWeight: 'bold', fontWeight: 'bold',
}, },
contextMenu: { contextMenu: {
backgroundColor: globalStyle.backgroundColor, backgroundColor: globalStyle.raisedBackgroundColor,
}, },
contextMenuItem: { contextMenuItem: {
backgroundColor: globalStyle.backgroundColor, backgroundColor: globalStyle.backgroundColor,
@ -91,13 +91,15 @@ let styleObject = {
titleText: { titleText: {
flex: 1, flex: 1,
marginLeft: 0, marginLeft: 0,
color: globalStyle.color, color: globalStyle.raisedHighlightedColor,
fontWeight: 'bold',
} }
}; };
styleObject.topIcon = Object.assign({}, globalStyle.icon); styleObject.topIcon = Object.assign({}, globalStyle.icon);
styleObject.topIcon.flex = 1; styleObject.topIcon.flex = 1;
styleObject.topIcon.textAlignVertical = 'center'; styleObject.topIcon.textAlignVertical = 'center';
styleObject.topIcon.color = globalStyle.raisedColor;
styleObject.backButton = Object.assign({}, styleObject.iconButton); styleObject.backButton = Object.assign({}, styleObject.iconButton);
styleObject.backButton.marginRight = 1; styleObject.backButton.marginRight = 1;

View File

@ -167,12 +167,6 @@ class SideMenuContentComponent extends Component {
return <View style={{ marginTop: 15, marginBottom: 15, flex: -1, borderBottomWidth: 1, borderBottomColor: globalStyle.dividerColor }} key={key}></View> return <View style={{ marginTop: 15, marginBottom: 15, flex: -1, borderBottomWidth: 1, borderBottomColor: globalStyle.dividerColor }} key={key}></View>
} }
// onLayout(event) {
// const newWidth = event.nativeEvent.layout.width;
// if (this.state.width == newWidth) return;
// this.setState({ width: newWidth });
// }
render() { render() {
let items = []; let items = [];
@ -202,6 +196,7 @@ class SideMenuContentComponent extends Component {
if (items.length) items.push(this.makeDivider('divider_2')); if (items.length) items.push(this.makeDivider('divider_2'));
let lines = Synchronizer.reportToLines(this.props.syncReport); let lines = Synchronizer.reportToLines(this.props.syncReport);
while (lines.length < 10) lines.push(''); // Add blank lines so that height of report text is fixed and doesn't affect scrolling
const syncReportText = lines.join("\n"); const syncReportText = lines.join("\n");
items.push(this.synchronizeButton(this.props.syncStarted ? 'cancel' : 'sync')); items.push(this.synchronizeButton(this.props.syncStarted ? 'cancel' : 'sync'));

View File

@ -43,7 +43,7 @@ class Note extends BaseItem {
static geolocationUrl(note) { static geolocationUrl(note) {
if (!('latitude' in note) || !('longitude' in note)) throw new Error('Latitude or longitude is missing'); if (!('latitude' in note) || !('longitude' in note)) throw new Error('Latitude or longitude is missing');
if (!note.latitude && !note.longitude) throw new Error(_('This note does not have geolocation information.')); if (!Number(note.latitude) && !Number(note.longitude)) throw new Error(_('This note does not have geolocation information.'));
return sprintf('https://www.openstreetmap.org/?lat=%s&lon=%s&zoom=20', note.latitude, note.longitude) return sprintf('https://www.openstreetmap.org/?lat=%s&lon=%s&zoom=20', note.latitude, note.longitude)
} }
@ -63,14 +63,28 @@ class Note extends BaseItem {
return output; return output;
} }
// static sortNotes(notes, order) { static sortNotes(notes, orders, uncompletedTodosOnTop) {
// return notes.sort((a, b) => { const noteOnTop = (note) => {
// // let r = -1; return uncompletedTodosOnTop && note.is_todo && !note.todo_completed;
// // if (a[order.orderBy] < b[order.orderBy]) r = +1; }
// // if (order.orderByDir == 'ASC') r = -r;
// // return r; return notes.sort((a, b) => {
// }); if (noteOnTop(a) && !noteOnTop(b)) return -1;
// } if (!noteOnTop(a) && noteOnTop(b)) return +1;
let r = 0;
for (let i = 0; i < orders.length; i++) {
const order = orders[i];
if (a[order.by] < b[order.by]) r = +1;
if (a[order.by] > b[order.by]) r = -1;
if (order.dir == 'ASC') r = -r;
if (r) break;
}
return r;
});
}
static previewFields() { static previewFields() {
return ['id', 'title', 'body', 'is_todo', 'todo_completed', 'parent_id', 'updated_time']; return ['id', 'title', 'body', 'is_todo', 'todo_completed', 'parent_id', 'updated_time'];
@ -96,6 +110,9 @@ class Note extends BaseItem {
} }
static async previews(parentId, options = null) { static async previews(parentId, options = null) {
// Note: ordering logic must be duplicated in sortNotes, which
// is used to sort already loaded notes.
if (!options) options = {}; if (!options) options = {};
if (!options.order) options.order = { by: 'updated_time', dir: 'DESC' }; if (!options.order) options.order = { by: 'updated_time', dir: 'DESC' };
if (!options.conditions) options.conditions = []; if (!options.conditions) options.conditions = [];

View File

@ -159,14 +159,14 @@ reg.syncStarted = async () => {
} }
reg.setupRecurrentSync = () => { reg.setupRecurrentSync = () => {
if (this.recurrentSyncId_) { if (reg.recurrentSyncId_) {
PoorManIntervals.clearInterval(this.recurrentSyncId_); PoorManIntervals.clearInterval(reg.recurrentSyncId_);
this.recurrentSyncId_ = null; reg.recurrentSyncId_ = null;
} }
console.info('Setting up recurrent sync with interval ' + Setting.value('sync.interval')); reg.logger().debug('Setting up recurrent sync with interval ' + Setting.value('sync.interval'));
this.recurrentSyncId_ = PoorManIntervals.setInterval(() => { reg.recurrentSyncId_ = PoorManIntervals.setInterval(() => {
reg.logger().info('Running background sync on timer...'); reg.logger().info('Running background sync on timer...');
reg.scheduleSync(0); reg.scheduleSync(0);
}, 1000 * Setting.value('sync.interval')); }, 1000 * Setting.value('sync.interval'));

View File

@ -245,7 +245,7 @@ const reducer = (state = defaultState, action) => {
if (!found && ('parent_id' in modNote) && modNote.parent_id == state.selectedFolderId) newNotes.push(modNote); if (!found && ('parent_id' in modNote) && modNote.parent_id == state.selectedFolderId) newNotes.push(modNote);
//newNotes = Note.sortNotes(newNotes, state.notesOrder); newNotes = Note.sortNotes(newNotes, state.notesOrder, newState.settings.uncompletedTodosOnTop);
newState = Object.assign({}, state); newState = Object.assign({}, state);
newState.notes = newNotes; newState.notes = newNotes;
break; break;