Skip to content
This repository was archived by the owner on Feb 12, 2023. It is now read-only.

Issue 370 fix date format on dialogs #376

Merged
merged 3 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 45 additions & 42 deletions src/main/java/org/opendatakit/aggregate/AggregateUI.gwt.xml
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN"
"https://raw.githubusercontent.com/gwtproject/gwt/2.7.0/distro-source/core/src/gwt-module.dtd">
<module rename-to="aggregateui">

<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>

<inherits name='com.google.gwt.user.theme.standard.StandardResources'/>
<!-- include JSON and HTTP RequestBuilder (for changing passwords) -->
<inherits name="com.google.gwt.json.JSON"/>
<inherits name="com.google.gwt.http.HTTP"/>
<inherits name='com.google.gwt.maps.Maps'/>
<!-- v2 <inherits name='com.google.gwt.maps.GoogleMaps' /> -->
<inherits name='com.google.gwt.visualization.Visualization'/>
<!-- Generic extended widget classes -->
<inherits name='org.opendatakit.common.web.Web'/>

<!-- Our access denied exception class and security interfaces -->
<inherits name='org.opendatakit.common.security.Security'/>

<!-- Persistence layer exception class -->
<inherits name='org.opendatakit.common.persistence.Persistence'/>

<!-- <set-property name="user.agent" value="gecko1_8" /> -->
<set-configuration-property name="UiBinder.useSafeHtmlTemplates" value="true"/>

<!-- Specify the app entry point class. -->
<entry-point class='org.opendatakit.aggregate.client.AggregateUI'/>

<source path='client'/>
<source path='client/exception'/>
<source path='client/filter'/>
<source path='client/form'/>
<source path='client/permissions'/>
<source path='client/popups'/>
<source path='client/preferences'/>
<source path='client/submission'/>
<source path='client/table'/>
<source path='client/widgets'/>
<source path='constants/common'/>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN"
"https://raw.githubusercontent.com/gwtproject/gwt/2.7.0/distro-source/core/src/gwt-module.dtd">
<module rename-to="aggregateui">

<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>

<inherits name='com.google.gwt.user.theme.standard.StandardResources'/>
<!-- include JSON and HTTP RequestBuilder (for changing passwords) -->
<inherits name="com.google.gwt.json.JSON"/>
<inherits name="com.google.gwt.http.HTTP"/>
<inherits name='com.google.gwt.maps.Maps'/>
<!-- v2 <inherits name='com.google.gwt.maps.GoogleMaps' /> -->
<inherits name='com.google.gwt.visualization.Visualization'/>

<inherits name='org.opendatakit.common.utils.Utils'/>

<!-- Generic extended widget classes -->
<inherits name='org.opendatakit.common.web.Web'/>

<!-- Our access denied exception class and security interfaces -->
<inherits name='org.opendatakit.common.security.Security'/>

<!-- Persistence layer exception class -->
<inherits name='org.opendatakit.common.persistence.Persistence'/>

<!-- <set-property name="user.agent" value="gecko1_8" /> -->
<set-configuration-property name="UiBinder.useSafeHtmlTemplates" value="true"/>

<!-- Specify the app entry point class. -->
<entry-point class='org.opendatakit.aggregate.client.AggregateUI'/>

<source path='client'/>
<source path='client/exception'/>
<source path='client/filter'/>
<source path='client/form'/>
<source path='client/permissions'/>
<source path='client/popups'/>
<source path='client/preferences'/>
<source path='client/submission'/>
<source path='client/table'/>
<source path='client/widgets'/>
<source path='constants/common'/>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.opendatakit.aggregate.client.form.FormSummary;
import org.opendatakit.aggregate.client.widgets.AggregateButton;
import org.opendatakit.aggregate.client.widgets.ClosePopupButton;
import org.opendatakit.common.utils.GwtShims;

public class ConfirmPurgeUpToDatePopup extends AbstractPopupBase {

Expand All @@ -56,7 +57,7 @@ public ConfirmPurgeUpToDatePopup(FormSummary summary, Date earliest) {
.appendEscaped("Delete submissions data of ")
.appendHtmlConstant("<b>" + summary.getTitle() + " [" + summary.getId() + "]</b>")
.appendEscaped(" up through ")
.appendEscaped(earliest.toGMTString())
.appendEscaped(GwtShims.gwtFormatDateHuman(earliest))
.appendEscaped(". Incomplete submissions will not be deleted.")
.toSafeHtml();
layout.setWidget(0, 0, new HTML(content));
Expand All @@ -76,12 +77,12 @@ public void onClick(ClickEvent event) {
"Successful commencement of the purge of:\n" +
summary.getTitle() + " [" + summary.getId() + "].\n" +
"Deleting all submission data through\n " +
result.toGMTString() + "\n" +
GwtShims.gwtFormatDateHuman(result) + "\n" +
"Incomplete submissions will not be deleted.");
},
cause -> AggregateUI.getUI().reportError("Failed purge of submission data: ", cause)
);
hide();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package org.opendatakit.aggregate.client.table;

import static org.opendatakit.common.utils.GwtShims.gwtFormatDateTimeHuman;

import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.HTML;
Expand Down Expand Up @@ -61,7 +63,7 @@ public void updateExportPanel(ArrayList<ExportSummary> eS) {
this.setText(i + STARTING_ROW, FILE_TYPE, e.getFileType().getDisplayText());
}
if (e.getTimeCompleted() != null) {
this.setText(i + STARTING_ROW, TIME_COMPLETED, e.getTimeCompleted().toString());
this.setText(i + STARTING_ROW, TIME_COMPLETED, gwtFormatDateTimeHuman(e.getTimeCompleted()));
}

if (e.getStatus() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.opendatakit.aggregate.client.table;

import static org.opendatakit.aggregate.constants.common.ExternalServiceType.JSON_SERVER;
import static org.opendatakit.common.utils.GwtShims.gwtFormatDateTimeHuman;

import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.ui.FlexTable;
Expand Down Expand Up @@ -91,8 +92,8 @@ public void updatePublishPanel(String formId, ExternServSummary[] eSS) {
if (d == null) {
d = e.getTimeLastUploadCursor();
}
this.setText(i + STARTING_ROW, LAST_PUBLISHED, (d == null) ? "" : d.toString());
this.setText(i + STARTING_ROW, TIME_PUBLISH_START, e.getTimeEstablished().toString());
this.setText(i + STARTING_ROW, LAST_PUBLISHED, (d == null) ? "" : gwtFormatDateTimeHuman(d));
this.setText(i + STARTING_ROW, TIME_PUBLISH_START, gwtFormatDateTimeHuman(e.getTimeEstablished()));
this.setText(i + STARTING_ROW, ACTION, e.getPublicationOption().getDescriptionOfOption());
this.setText(i + STARTING_ROW, TYPE, e.getExternalServiceType().getName());
this.setWidget(i + STARTING_ROW, OWNERSHIP, new HTML(new SafeHtmlBuilder().appendEscaped(e.getOwnership()).toSafeHtml()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.opendatakit.aggregate.client.externalserv.ExternServSummary;
import org.opendatakit.aggregate.client.popups.ConfirmPurgePopup;
import org.opendatakit.aggregate.constants.common.ExternalServicePublicationOption;
import org.opendatakit.common.utils.GwtShims;

public final class PurgeButton extends AggregateButton implements ClickHandler {

Expand Down Expand Up @@ -85,11 +86,12 @@ public void onClick(ClickEvent event) {
}
b.appendEscaped("Click to confirm purge of ")
.appendHtmlConstant("<b>").appendEscaped(formId).appendHtmlConstant("</b>")
.appendEscaped(" submissions older than " + earliest.toString());
.appendEscaped(" submissions older than " + GwtShims.gwtFormatDateTimeHuman(earliest));

// TODO: display pop-up with text from b...
final ConfirmPurgePopup popup = new ConfirmPurgePopup(externServ, earliest, b.toSafeHtml());
popup.setPopupPositionAndShow(popup.getPositionCallBack());
}
}
}

}
30 changes: 30 additions & 0 deletions src/main/java/org/opendatakit/common/utils/GwtShims.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (C) 2019 Nafundi
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package org.opendatakit.common.utils;

import com.google.gwt.i18n.client.DateTimeFormat;
import java.util.Date;

public class GwtShims {
public static String gwtFormatDateHuman(Date date) {
return DateTimeFormat.getFormat("MMM dd, yyyy").format(date);
}

public static String gwtFormatDateTimeHuman(Date date) {
return DateTimeFormat.getFormat("MMM dd, yyyy HH:mm:ss a").format(date);
}
}
24 changes: 24 additions & 0 deletions src/main/java/org/opendatakit/common/utils/Utils.gwt.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2019 Nafundi
~
~ Licensed under the Apache License, Version 2.0 (the "License"); you may not
~ use this file except in compliance with the License. You may obtain a copy of
~ the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
~ License for the specific language governing permissions and limitations under
~ the License.
-->

<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.7.0//EN"
"https://raw.githubusercontent.com/gwtproject/gwt/2.7.0/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.google.gwt.user.User"/>

<source path="" includes="GwtShims.java"/>
</module>