Skip to content

Commit

Permalink
Code improvement 2
Browse files Browse the repository at this point in the history
  • Loading branch information
IkramMaalej committed Feb 4, 2022
1 parent 82943ad commit 8949d6c
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.kitodo.production.process.NewspaperProcessesGenerator;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.calendar.CalendarService;
import org.kitodo.production.services.data.ImportService;
import org.primefaces.PrimeFaces;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
Expand Down Expand Up @@ -883,7 +884,7 @@ public String getTextMetadataValue(CountableMetadata metadata, LocalDate date, I
* @param block the block to get the metadata for
* @return list of pairs containing the metadata type and the date of its earliest occurrence
*/
public List<Pair<String, LocalDate>> getMetadataSummary(Block block) {
public List<Pair<ProcessDetail, LocalDate>> getMetadataSummary(Block block) {
return CalendarService.getMetadataSummary(block);
}

Expand All @@ -902,6 +903,17 @@ public String getMetadataTranslation(String key) {
}
}

/**
* Get the value of the given processDetail.
*
* @param processDetail
* as ProcessDetail
* @return the value as a java.lang.String
*/
public String getMetadataValue(ProcessDetail processDetail) {
return ImportService.getProcessDetailValue(processDetail);
}

/**
* Check if process with the same processtitle already exists.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public Issue addIssue() {
* metadata to add
*/
public void addMetadata(CountableMetadata countableMetadata) {
metadata.add(countableMetadata);
metadata.add(0, countableMetadata);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.kitodo.production.model.bibliography.course.metadata.MetadataEditMode;
import org.kitodo.production.security.SecurityUserDetails;
import org.kitodo.production.services.ServiceManager;
import org.kitodo.production.services.data.ImportService;

public class CalendarService {

Expand Down Expand Up @@ -123,7 +124,7 @@ public static List<MetadataViewInterface> getAddableMetadata(Process completeEdi
*/
public static String getMetadataTranslation(List<ProcessDetail> metadataList, String metadataKey) {
for (ProcessDetail selectItem : metadataList) {
if (selectItem.getLabel().equals(metadataKey)) {
if (selectItem.getMetadataID().equals(metadataKey)) {
return selectItem.getLabel();
}
}
Expand Down Expand Up @@ -159,16 +160,16 @@ public static List<CountableMetadata> getMetadata(Block block, LocalDate date, I
* @param block the block to get the metadata for
* @return list of pairs containing the metadata type and the date of its earliest occurrence
*/
public static List<Pair<String, LocalDate>> getMetadataSummary(Block block) {
Map<String, LocalDate> metadataMap = new HashMap<>();
public static List<Pair<ProcessDetail, LocalDate>> getMetadataSummary(Block block) {
Map<ProcessDetail, LocalDate> metadataMap = new HashMap<>();
if (Objects.nonNull(block)) {
for (CountableMetadata metadata : block.getMetadata()) {
if (metadataMap.containsKey(metadata.getMetadataType())) {
if (metadata.getCreate().getLeft().isBefore(metadataMap.get(metadata.getMetadataType()))) {
metadataMap.replace(metadata.getMetadataType(), metadata.getCreate().getKey());
metadataMap.replace(metadata.getMetadataDetail(), metadata.getCreate().getKey());
}
} else {
metadataMap.put(metadata.getMetadataType(), metadata.getCreate().getKey());
metadataMap.put(metadata.getMetadataDetail(), metadata.getCreate().getKey());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Kitodo/src/main/resources/messages/errors_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ docketMissing=Die Konfigurationsdatei zur Laufzettelgenerierung existiert nicht
docketNotFound=Die angegebene Datei konnte nicht gefunden werden.
docketTitleDuplicated=Der Laufzettel mit den gleichen Titel existiert schon.
docTypeNotFound=docType ''{0}'' wurde nicht im selektierten Regelsatz gefunden
duplicatedTitles=Es wurden duplizierte Titel gefunden
duplicatedTitles=Es wurden dublette Ausgabe-Bezeichnungen gefunden. Dies erzeugt gegebenenfalls dublette Vorgangstitel!
emptySourceFolder=Der Quellordner zur Bildgenerierung ist leer
errorDataIncomplete=Unvollst\u00E4ndige Daten\:
errorDatabaseReading=Fehler beim Datenbanklesen von ''{0}'' with ID {1}.
Expand Down
2 changes: 1 addition & 1 deletion Kitodo/src/main/resources/messages/errors_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ docketMissing=the configuration file for docket creation is missing
docketNotFound=The specified file could not be found.
docketTitleDuplicated=The docket with the same title exists already.
docTypeNotFound=docType ''{0}'' could not be found in selected ruleset
duplicatedTitles=Duplicated titles found
duplicatedTitles=Duplicate issue designations were found. This may produce duplicate process titles!
emptySourceFolder=The source folder is empty
errorDataIncomplete=Incomplete data\:
errorDatabaseReading=Error on reading database for ''{0}'' with ID {1}.
Expand Down
7 changes: 4 additions & 3 deletions Kitodo/src/main/resources/messages/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ calendar.issue.add=Ausgabe hinzuf\u00FCgen
calendar.issue.delete=Ausgabe l\u00F6schen
calendar.issue.delete.query=Wollen Sie die Augabe l\u00F6schen?
calendar.jumpToDay=Zu Tag springen
calendar.metadata.add=Metadatum hinzuf\u00FCgen
calendar.metadata.global.add=Metadatum zu allen erschienen Ausgaben hinzuf\u00FCgen
calendar.metadata.issue.add=Metadatum zu allen erschienen Ausgaben ab dieser hinzuf\u00FCgen
calendar.metadata.global.add=Metadatum allen Ausgaben hinzuf\u00FC</h4>gen
calendar.metadata.issue.add=Metadatum hinzuf\u00FCgen
calendar.metadata.global.add.tooltip=Metadatum zu allen erschienen Ausgaben hinzuf\u00FCgen
calendar.metadata.issue.add.tooltip=Metadatum zu allen erschienen Ausgaben ab dieser hinzuf\u00FCgen
calendar.metadata.currentValue=Aktueller Wert
calendar.metadata.firstAppearance=von
calendar.metadata.lastAppearance=bis
Expand Down
7 changes: 4 additions & 3 deletions Kitodo/src/main/resources/messages/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ calendar.issue.add=Add issue
calendar.issue.delete=Delete issue
calendar.issue.delete.query=Do you want to delete the issue?
calendar.jumpToDay=Jump to day
calendar.metadata.add=Add metadata
calendar.metadata.global.add=Add metadata to all appeared issues
calendar.metadata.issue.add=Add metadata to all appeared issues from this one onwards
calendar.metadata.global.add=Add metadata to all issues
calendar.metadata.issue.add=Add metadata
calendar.metadata.global.add.tooltip=Add metadata to all appeared issues
calendar.metadata.issue.add.tooltip=Add metadata to all appeared issues from this one onwards
calendar.metadata.currentValue=Current value
calendar.metadata.firstAppearance=from
calendar.metadata.lastAppearance=up to
Expand Down
24 changes: 22 additions & 2 deletions Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,6 @@ h3#headerText.calendar-heading {

#editForm\:calendarTabView .metadata-list .ui-dataview-row {
border: solid var(--default-border-width) var(--cloudy-gray);
height: calc(var(--input-height) + 2 * var(--default-border-width));
line-height: calc(var(--input-height) + 2 * var(--default-border-width));
}

Expand Down Expand Up @@ -1604,6 +1603,17 @@ h3#headerText.calendar-heading {
color: var(--carbon-blue);
}

#calendarDayDialog {
width: 80% !important;
height: 80% !important;
overflow-y: hidden ;
}

#calendarDayDialog_content {
height: 100% !important;
overflow-y: hidden ;
}

#calendarDayDialog .ui-dialog-content,
#calendarDayDialog form,
#calendarDayDialog form > .ui-panelgrid,
Expand All @@ -1613,20 +1623,30 @@ h3#headerText.calendar-heading {

#calendarDayDialog form {
height: calc(100% - 100px);
overflow-y: scroll;
overflow-y: auto;
}

#calendarDayDialog .dialogButtonWrapper {
bottom: var(--default-full-size);
display: inline-block;
height: 60px;
position: absolute;
width: calc(100% - var(--default-double-size));
}

#calendarDayDialog .dialogFieldWrapper {
min-height: 100%;
margin-bottom: 0;
overflow-y: hidden;
}

#calendarDayDialogHeader {
width: 100%;
padding-left: var(--default-double-size);
padding-right: var(--default-double-size);
padding-bottom: var(--default-full-size);
}

#calendarDayDialog .issue-wrapper:not(:last-child) {
border-bottom: solid var(--default-border-width) var(--cloudy-gray);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@
value="#{CalendarForm.getMetadataSummary(block)}">
<p:dataViewListItem>
<h:outputText styleClass="label"
value="#{CalendarForm.getMetadataTranslation(metadata.key)}
value="#{CalendarForm.getMetadataTranslation(metadata.key.metadataID)}
#{msgs.metadataWithValue}
'#{CalendarForm.getMetadataValue(metadata.key)}'
#{msgs['calendar.metadata.firstAppearance']}
#{metadata.value}"/>
<p:commandButton action="#{CalendarForm.setSelectedDate(metadata.value)}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
<p:dialog id="calendarDayDialog"
widgetVar="calendarDayDialog"
resizable="false"
width="800"
height="480"
showHeader="false"
dynamic="true"
position="center center"
modal="true">
<!--@elvariable id="date" type="java.time.LocalDate"-->
<ui:param name="date" value="#{CalendarForm.selectedDate}"/>
<p:panelGrid columns="2" id="header" style="width: 95%">
<p:row style="display: inherit">
<h:panelGrid columns="2" id="calendarDayDialogHeader">
<p:row>
<h3>
#{msgs['calendar.day.'.concat(date.dayOfWeek.value)]}
#{date.toString()}
Expand All @@ -39,15 +36,15 @@
<p:commandButton id="addMetadataGlobal"
action="#{CalendarForm.addMetadataToAllMatchIssues()}"
rendered="#{CalendarForm.getFirstMatchIssue() ne null}"
value="#{msgs['calendar.metadata.add']}"
title="#{msgs['calendar.metadata.global.add']}"
value="#{msgs['calendar.metadata.global.add']}"
title="#{msgs['calendar.metadata.global.add.tooltip']}"
icon="fa fa-plus"
iconPos="right"
styleClass="callto right"
style="padding: 5px"
update="calendarDayForm"/>
</p:row>
</p:panelGrid>
</h:panelGrid>
<h:form id="calendarDayForm">
<h:panelGroup layout="block"
styleClass="dialogFieldWrapper">
Expand All @@ -65,12 +62,12 @@
icon="#{issue.isMatch(date) ? 'fa fa-trash' : 'fa fa-plus'}"
iconPos="right"
styleClass="secondary"
update="editForm:calendarTabView:calendarDetailsLayout header calendarDayForm"/>
update="editForm:calendarTabView:calendarDetailsLayout calendarDayDialogHeader calendarDayForm"/>
<!-- Add metadata-->
<p:commandButton id="addMetadata"
action="#{CalendarForm.addMetadata(issue)}"
value="#{msgs['calendar.metadata.add']}"
title="#{msgs['calendar.metadata.issue.add']}"
value="#{msgs['calendar.metadata.issue.add']}"
title="#{msgs['calendar.metadata.issue.add.tooltip']}"
icon="fa fa-plus"
iconPos="right"
rendered="#{issue.isMatch(date)}"
Expand Down Expand Up @@ -231,6 +228,8 @@
</p:repeat>
</p:panelGrid>
</h:panelGroup>
</h:form>
<p:panelGrid>
<h:panelGroup layout="block"
styleClass="dialogButtonWrapper">
<p:commandButton id="close"
Expand All @@ -241,6 +240,6 @@
iconPos="right"
styleClass="primary right"/>
</h:panelGroup>
</h:form>
</p:panelGrid>
</p:dialog>
</ui:composition>

0 comments on commit 8949d6c

Please sign in to comment.