1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-29 19:13:59 +02:00

Mobile: Resolves #2721: Added button to select all notes (#2744)

* added feature of select all and closes #2721

* added functionality of toggle select all button to deselect all notes
This commit is contained in:
Ishant Gupta 2020-03-14 04:11:56 +05:30 committed by GitHub
parent 115eb6f511
commit 02121f66de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -160,6 +160,10 @@ class ScreenHeaderComponent extends React.PureComponent {
}
}
selectAllButton_press() {
this.props.dispatch({ type: 'NOTE_SELECT_ALL_TOGGLE' });
}
searchButton_press() {
NavService.go('Search');
}
@ -244,6 +248,16 @@ class ScreenHeaderComponent extends React.PureComponent {
);
}
function selectAllButton(styles, onPress) {
return (
<TouchableOpacity onPress={onPress}>
<View style={styles.iconButton}>
<Icon name="md-checkmark-circle-outline" style={styles.topIcon} />
</View>
</TouchableOpacity>
);
}
function searchButton(styles, onPress) {
return (
<TouchableOpacity onPress={onPress}>
@ -405,6 +419,7 @@ class ScreenHeaderComponent extends React.PureComponent {
if (this.props.hasDisabledSyncItems) warningComps.push(this.renderWarningBox('Status', _('Some items cannot be synchronised. Press for more info.')));
const showSideMenuButton = !!this.props.showSideMenuButton && !this.props.noteSelectionEnabled;
const showSelectAllButton = this.props.noteSelectionEnabled;
const showSearchButton = !!this.props.showSearchButton && !this.props.noteSelectionEnabled;
const showContextMenuButton = this.props.showContextMenuButton !== false;
const showBackButton = !!this.props.noteSelectionEnabled || this.props.showBackButton !== false;
@ -415,6 +430,7 @@ class ScreenHeaderComponent extends React.PureComponent {
const titleComp = createTitleComponent();
const sideMenuComp = !showSideMenuButton ? null : sideMenuButton(this.styles(), () => this.sideMenuButton_press());
const backButtonComp = !showBackButton ? null : backButton(this.styles(), () => this.backButton_press(), backButtonDisabled);
const selectAllButtonComp = !showSelectAllButton ? null : selectAllButton(this.styles(), () => this.selectAllButton_press());
const searchButtonComp = !showSearchButton ? null : searchButton(this.styles(), () => this.searchButton_press());
const deleteButtonComp = this.props.noteSelectionEnabled ? deleteButton(this.styles(), () => this.deleteButton_press()) : null;
const duplicateButtonComp = this.props.noteSelectionEnabled ? duplicateButton(this.styles(), () => this.duplicateButton_press()) : null;
@ -452,6 +468,7 @@ class ScreenHeaderComponent extends React.PureComponent {
this.props.showSaveButton === true
)}
{titleComp}
{selectAllButtonComp}
{searchButtonComp}
{deleteButtonComp}
{duplicateButtonComp}

View File

@ -394,6 +394,16 @@ const reducer = (state = defaultState, action) => {
newState.selectedNoteIds = newState.notes.map(n => n.id);
break;
case 'NOTE_SELECT_ALL_TOGGLE': {
newState = Object.assign({}, state);
const allSelected = state.notes.every(n => state.selectedNoteIds.includes(n.id));
if (allSelected)
newState.selectedNoteIds = [];
else
newState.selectedNoteIds = newState.notes.map(n => n.id);
break;
}
case 'SMART_FILTER_SELECT':
newState = Object.assign({}, state);
newState.notesParentType = 'SmartFilter';