Skip to content

Commit

Permalink
Merge pull request #5855 from pontus-osterdahl/make_pagination_value_…
Browse files Browse the repository at this point in the history
…configureable

Make pagination scope default value configureable
  • Loading branch information
solth authored Feb 26, 2024
2 parents e4a8a58 + 99af79f commit 22c6cd4
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public class User extends BaseBean {
@Column(name = "show_pagination_by_default")
private boolean showPaginationByDefault;

@Column(name = "paginate_from_first_page_by_default")
private boolean paginateFromFirstPageByDefault;

/**
* Constructor for User Entity.
*/
Expand Down Expand Up @@ -146,6 +149,7 @@ public User(User user) {
this.shortcuts = user.shortcuts;
this.showCommentsByDefault = user.showCommentsByDefault;
this.showPaginationByDefault = user.showPaginationByDefault;
this.paginateFromFirstPageByDefault = user.paginateFromFirstPageByDefault;
this.defaultGalleryViewMode = user.defaultGalleryViewMode;

if (user.roles != null) {
Expand All @@ -172,7 +176,6 @@ public User(User user) {
this.filters = user.filters;
}

// default values
if (Objects.nonNull(user.tableSize)) {
this.tableSize = user.tableSize;
}
Expand Down Expand Up @@ -493,6 +496,24 @@ public void setShowPaginationByDefault(boolean showPaginationByDefault) {
this.showPaginationByDefault = showPaginationByDefault;
}

/**
* Get paginateFromFirstPageByDefault.
*
* @return value of paginateFromFirstPageByDefault
*/
public boolean isPaginateFromFirstPageByDefault() {
return paginateFromFirstPageByDefault;
}

/**
* Set paginateFromFirstPageByDefault.
*
* @param paginateFromFirstPageByDefault as boolean
*/
public void setPaginateFromFirstPageByDefault(boolean paginateFromFirstPageByDefault) {
this.paginateFromFirstPageByDefault = paginateFromFirstPageByDefault;
}

/**
* Removes a user from the environment. Since the
* user ID may still be referenced somewhere, the user is not hard deleted from
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--
-- (c) Kitodo. Key to digital objects e. V. <[email protected]>
--
-- This file is part of the Kitodo project.
--
-- It is licensed under GNU General Public License version 3 or later.
--
-- For the full copyright and license information, please read the
-- GPL3-License.txt file that was distributed with this source code.
--

-- Add column "paginate_from_first_page_by_default" to "user" table
ALTER TABLE user ADD paginate_from_first_page_by_default TINYINT(1) DEFAULT 0;
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.kitodo.api.dataformat.View;
import org.kitodo.config.ConfigCore;
import org.kitodo.config.enums.ParameterCore;
import org.kitodo.data.database.beans.User;
import org.kitodo.exceptions.InvalidImagesException;
import org.kitodo.exceptions.InvalidMetadataValueException;
import org.kitodo.exceptions.MediaNotFoundException;
Expand Down Expand Up @@ -56,7 +57,7 @@ public class PaginationPanel {
private List<IllustratedSelectItem> selectPaginationModeItems;
private IllustratedSelectItem selectPaginationModeSelectedItem;
private Map<Boolean, String> selectPaginationScopeItems;
private Boolean selectPaginationScopeSelectedItem = Boolean.TRUE;
private Boolean selectPaginationScopeSelectedItem;

/**
* Constructor.
Expand Down Expand Up @@ -265,6 +266,11 @@ public void setFictitiousCheckboxChecked(boolean fictitiousCheckboxChecked) {
this.fictitiousCheckboxChecked = fictitiousCheckboxChecked;
}

private void prepareSelectPaginationScopeSelectedItem() {
selectPaginationScopeSelectedItem = ServiceManager.getUserService().getCurrentUser()
.isPaginateFromFirstPageByDefault();
}

private void preparePaginationSelectionItems() {
List<PhysicalDivision> physicalDivisions = dataEditor.getWorkpiece().getAllPhysicalDivisionChildrenSortedFilteredByPageAndTrack();
paginationSelectionItems = new ArrayList<>(physicalDivisions.size());
Expand Down Expand Up @@ -388,5 +394,6 @@ public void show() {
selectPaginationScopeSelectedItem = Boolean.TRUE;
preparePaginationSelectionItems();
preparePaginationSelectionSelectedItems();
prepareSelectPaginationScopeSelectedItem();
}
}
1 change: 1 addition & 0 deletions Kitodo/src/main/resources/messages/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,7 @@ userDN=User DN
userDocumentationLink=Anwenderdokumentation Kitodo.Production 3.X
userEdit.metadataEditorSettings = Metadateneditor
userEdit.metadataEditorSettings.defaultGalleryView = Standardansicht Galerie
userEdit.metadataEditorSettings.paginateFromFirstPageByDefault = Standardm\u00E4ssig ab erster markierten Seite paginieren
userEdit.metadataEditorSettings.showCommentsByDefault = Kommentare standardm\u00E4ssig einblenden
userEdit.metadataEditorSettings.showPaginationByDefault = Paginierung standardm\u00E4ssig einblenden
userInstruction=Bedienungshinweise
Expand Down
1 change: 1 addition & 0 deletions Kitodo/src/main/resources/messages/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,7 @@ userDN=User DN
userDocumentationLink=Kitodo.Production 3.X user documentation
userEdit.metadataEditorSettings = Metadata editor
userEdit.metadataEditorSettings.defaultGalleryView = Default gallery view
userEdit.metadataEditorSettings.paginateFromFirstPageByDefault = By default paginate from first selected page
userEdit.metadataEditorSettings.showCommentsByDefault = Show comments by default
userEdit.metadataEditorSettings.showPaginationByDefault = Show pagination by default
userInstruction=User instructions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@
value="#{UserForm.userObject.showPaginationByDefault}"
onchange="toggleSave()"/>
</div>
<div>
<p:outputLabel for="paginateFromFirstPageByDefault"
value="#{msgs['userEdit.metadataEditorSettings.paginateFromFirstPageByDefault']}"/>
<p:selectBooleanCheckbox id="paginateFromFirstPageByDefault"
styleClass="switch input"
disabled="#{isViewMode}"
value="#{UserForm.userObject.paginateFromFirstPageByDefault}"
onchange="toggleSave()"/>
</div>
</p:row>
</p:panelGrid>
</ui:composition>

0 comments on commit 22c6cd4

Please sign in to comment.