Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date/time formatting simplifications #5923

Draft
wants to merge 37 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c7148a6
Date/time formatting simplifications
labkey-adam Oct 7, 2024
ac05c7a
Add inheritance UI
labkey-adam Oct 7, 2024
7955c5c
Persist inheritance based on new posted values, handle NONE properly,…
labkey-adam Oct 7, 2024
a318433
Comments
labkey-adam Oct 8, 2024
e1de5ff
Merge remote-tracking branch 'origin/develop' into fb_datetime_formats
labkey-adam Oct 8, 2024
49b2f0e
Fix restrict charting columns inheritance
labkey-adam Oct 8, 2024
eb7fa45
Warnings
labkey-adam Oct 9, 2024
a6235ea
Display inputs for inherited properties. Allow empty number format.
labkey-adam Oct 9, 2024
f66a1e6
Inherited help pop-up
labkey-adam Oct 10, 2024
1cf9a17
Eliminate SettingsForm interface and remove duplicate getters & sette…
labkey-adam Oct 10, 2024
37ec4c4
Migrate UpdateProjectSettingsAction to use FolderSettingsForm and sav…
labkey-adam Oct 10, 2024
1360ace
Merge remote-tracking branch 'origin/develop' into fb_datetime_formats
labkey-adam Oct 10, 2024
a30a63c
Checkpoint for project settings migration
labkey-adam Oct 10, 2024
e536dcb
System description, short name, and theme
labkey-adam Oct 10, 2024
d4bec9b
Folder navigation, app menu, help menu, discussions
labkey-adam Oct 10, 2024
61a429a
App UI
XingY Oct 11, 2024
5709469
fix site settings
XingY Oct 11, 2024
9e03dc3
Finish project settings
labkey-adam Oct 12, 2024
52964e6
Clean up. Show all errors instead of one at a time.
labkey-adam Oct 12, 2024
b9e329d
Unused import
labkey-adam Oct 12, 2024
6ead3a0
Merge remote-tracking branch 'origin/develop' into fb_datetime_formats
labkey-adam Oct 12, 2024
8b875d3
Merge branch 'develop' into fb_datetime_formats
XingY Oct 14, 2024
07cbdff
Merge branch 'develop' into fb_datetime_formats
XingY Oct 14, 2024
ccc20f3
update style
XingY Oct 14, 2024
db33f93
Simplify inheritCheckbox() and clarify "Reset" button caption & confi…
labkey-adam Oct 15, 2024
2bb3c95
Merge branch 'develop' into fb_datetime_formats
XingY Oct 15, 2024
2ca3285
code review changes
XingY Oct 15, 2024
c93fd7e
code review changes
XingY Oct 15, 2024
8b94ec5
jest
XingY Oct 16, 2024
b6ad1ba
Code review feedback. LookAndFeelFolderProperties delegate to the fol…
labkey-adam Oct 16, 2024
5d24ee4
Double encoding is better than no encoding... but single encoding is …
labkey-adam Oct 16, 2024
c80df7c
Extra <td>. Extra colspan.
labkey-adam Oct 16, 2024
55cf293
Update splitting and handling of non-standard date-time formats
labkey-adam Oct 16, 2024
78e3cf4
Display full non-standard date-time in date select
labkey-adam Oct 16, 2024
7717d02
Merging develop into fb_datetime_formats.
labkey-danield Oct 16, 2024
7ea8210
Merge branch 'develop' into fb_datetime_formats
XingY Oct 16, 2024
aaf88e7
Merge branch 'develop' into fb_datetime_formats
XingY Oct 16, 2024
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
5 changes: 3 additions & 2 deletions api/src/org/labkey/api/admin/FolderWriterImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ private void writeFolderXml(Container c, FolderExportContext ctx, VirtualFile vf
if (null != extraTimeParsingPattern)
folderXml.setExtraTimeParsingPattern(extraTimeParsingPattern);

if (props.areRestrictedColumnsEnabled())
folderXml.setRestrictedColumnsEnabled(true);
Boolean areRestricted = props.areRestrictedColumnsEnabledStored();
if (null != areRestricted)
folderXml.setRestrictedColumnsEnabled(areRestricted);

// Save the folder.xml file. This gets called last, after all other writers have populated the other sections.
vf.saveXmlBean("folder.xml", ctx.getDocument());
Expand Down
26 changes: 22 additions & 4 deletions api/src/org/labkey/api/data/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.labkey.api.util.ContainerContext;
import org.labkey.api.util.DateUtil;
import org.labkey.api.util.FileUtil;
import org.labkey.api.util.Formats;
import org.labkey.api.util.GUID;
import org.labkey.api.util.NetworkDrive;
import org.labkey.api.util.PageFlowUtil;
Expand Down Expand Up @@ -1368,10 +1369,10 @@ private Container findDescendant(Container parent, String name)

public Map<String, Object> toJSON(User user)
{
return toJSON(user, true, true);
return toJSON(user, true, true, false);
}

public Map<String, Object> toJSON(User user, boolean includePermissions, boolean includeStandardProps)
public Map<String, Object> toJSON(User user, boolean includePermissions, boolean includeStandardProps, boolean includeParentFormatProps)
{
Map<String, Object> containerProps = new HashMap<>();
Container parent = getParent();
Expand All @@ -1384,10 +1385,27 @@ public Map<String, Object> toJSON(User user, boolean includePermissions, boolean

LookAndFeelProperties props = LookAndFeelProperties.getInstance(this);
Map<String, Object> formats = new HashMap<>();
formats.put("dateFormat", DateUtil.getDateFormatString(this));
formats.put("dateFormat", props.getDefaultDateFormat()); // when to use DateUtil.getDateFormatString vs laf.getDefaultDateFormat?
labkey-adam marked this conversation as resolved.
Show resolved Hide resolved
formats.put("dateTimeFormat", props.getDefaultDateTimeFormat());
formats.put("numberFormat", props.getDefaultNumberFormat());
formats.put("timeFormat", DateUtil.getTimeFormatString(this));
formats.put("timeFormat", props.getDefaultTimeFormat());

if (includeParentFormatProps)
{
formats.put("dateFormatInherited", StringUtils.isEmpty(props.getDefaultDateFormatStored()));
labkey-adam marked this conversation as resolved.
Show resolved Hide resolved
formats.put("dateTimeFormatInherited", StringUtils.isEmpty(props.getDefaultDateTimeFormatStored()));
formats.put("numberFormatInherited", StringUtils.isEmpty(props.getDefaultNumberFormatStored()));
formats.put("timeFormatInherited", StringUtils.isEmpty(props.getDefaultTimeFormatStored()));

if (!isRoot())
{
Container parentContainer = getParent(); // when to use DateUtil.getDateFormatString vs laf.getDefaultDateFormat?
labkey-adam marked this conversation as resolved.
Show resolved Hide resolved
formats.put("parentDateFormat", DateUtil.getDateFormatString(parentContainer));
formats.put("parentDateTimeFormat", DateUtil.getDateTimeFormatString(parentContainer));
formats.put("parentNumberFormat", Formats.getNumberFormatString(parentContainer));
formats.put("parentTimeFormat", DateUtil.getTimeFormatString(parentContainer));
}
}
containerProps.put("formats", formats);
}

Expand Down
2 changes: 1 addition & 1 deletion api/src/org/labkey/api/jsp/JspBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ protected HtmlString getScriptNonce()
return _pageConfig.getScriptNonce();
}

protected void addHandler(String id, String event, String handler)
public void addHandler(String id, String event, String handler)
{
_pageConfig.addHandler(id,event,handler);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public static void appendDiffRow(StringBuilder html, String key, String oldValue

private static String obscureValue(String value)
{
if(null == value || value.length() == 0)
if(null == value || value.isEmpty())
return "";
else
return "*******"; //use fixed number to obscure num characters
Expand Down
118 changes: 70 additions & 48 deletions api/src/org/labkey/api/settings/LookAndFeelFolderProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.labkey.api.data.Container;
import org.labkey.api.util.DateUtil;

import java.util.Map;

import static org.labkey.api.settings.LookAndFeelProperties.Properties.extraDateParsingPattern;
import static org.labkey.api.settings.LookAndFeelProperties.Properties.extraDateTimeParsingPattern;
import static org.labkey.api.settings.LookAndFeelProperties.Properties.extraTimeParsingPattern;
Expand All @@ -38,7 +40,6 @@ public class LookAndFeelFolderProperties extends AbstractWriteableSettingsGroup
protected static final String defaultNumberFormatString = "defaultNumberFormatString";
protected static final String defaultTimeFormatString = "defaultTimeFormatString";


protected final Container _c;

protected LookAndFeelFolderProperties(Container c)
Expand All @@ -58,12 +59,6 @@ protected String getGroupName()
return LOOK_AND_FEEL_SET_NAME;
}

public boolean isPropertyInherited(Container c, String name)
{
String value = super.lookupStringValue(c, name, null);
return null == value;
}

@Override
protected String lookupStringValue(String name, @Nullable String defaultValue)
{
Expand All @@ -84,6 +79,19 @@ protected String lookupStringValue(Container c, String name, @Nullable String de
return value;
}

// Get the actual stored value in this container; no default handling, no walking the hierarchy
protected String getStoredValue(Container c, String name)
{
Map<String, String> props = getProperties(c);
return props.get(name);
}

// Get the actual stored value in this container; no default handling, no walking the hierarchy
protected String getStoredValue(Container c, Enum<?> e)
{
return getStoredValue(c, e.name());
}

// TODO: consider enforcing usage of lookupBooleanValue with container
/*@Override
protected boolean lookupBooleanValue(String name, boolean defaultValue)
Expand All @@ -93,91 +101,105 @@ protected boolean lookupBooleanValue(String name, boolean defaultValue)

public String getDefaultDateFormat()
{
// Look up this value starting from the current container (unlike most look & feel settings)
// Look up this value starting from the current container
return lookupStringValue(_c, defaultDateFormatString, DateUtil.getStandardDateFormatString());
}

// Get the value that's actually stored in this container or null if inherited; don't look up the hierarchy
// This is useful for export and showing inheritance status in the UI.
public String getDefaultDateFormatStored()
{
return getStoredValue(_c, defaultDateFormatString);
}

public String getDefaultDateTimeFormat()
{
// Look up this value starting from the current container (unlike most look & feel settings)
// Look up this value starting from the current container
return lookupStringValue(_c, defaultDateTimeFormatString, DateUtil.getStandardDateTimeFormatString());
}

public String getDefaultTimeFormat()
// Get the value that's actually stored in this container or null if inherited; don't look up the hierarchy.
// This is useful for export and showing inheritance status in the UI.
public String getDefaultDateTimeFormatStored()
{
// Look up this value starting from the current container (unlike most look & feel settings)
return lookupStringValue(_c, defaultTimeFormatString, DateUtil.getStandardTimeFormatString());
return getStoredValue(_c, defaultDateTimeFormatString);
}

public String getDefaultNumberFormat()
public String getDefaultTimeFormat()
{
// Look up this value starting from the current container (unlike most look & feel settings)
return lookupStringValue(_c, defaultNumberFormatString, null);
// Look up this value starting from the current container
return lookupStringValue(_c, defaultTimeFormatString, DateUtil.getStandardTimeFormatString());
}

public String getExtraDateParsingPattern()
// Get the value that's actually stored in this container or null if inherited; don't look up the hierarchy.
// This is useful for export and showing inheritance status in the UI.
public String getDefaultTimeFormatStored()
{
// Look up this value starting from the current container (unlike most look & feel settings)
return lookupStringValue(_c, extraDateParsingPattern, null);
return getStoredValue(_c, defaultTimeFormatString);
}

public String getExtraDateTimeParsingPattern()
public String getDefaultNumberFormat()
{
// Look up this value starting from the current container (unlike most look & feel settings)
return lookupStringValue(_c, extraDateTimeParsingPattern, null);
// Look up this value starting from the current container
return lookupStringValue(_c, defaultNumberFormatString, null);
}

public String getExtraTimeParsingPattern()
// Get the value that's actually stored in this container or null if inherited; don't look up the hierarchy.
// This is useful for export and showing inheritance status in the UI.
public String getDefaultNumberFormatStored()
{
// Look up this value starting from the current container (unlike most look & feel settings)
return lookupStringValue(_c, extraTimeParsingPattern, null);
return getStoredValue(_c, defaultNumberFormatString);
}

public boolean areRestrictedColumnsEnabled()
public String getExtraDateParsingPattern()
{
return lookupBooleanValue(_c, restrictedColumnsEnabled, false);
// Look up this value starting from the current container
return lookupStringValue(_c, extraDateParsingPattern, null);
}

// Get the value that's actually stored in this container; don't look up the hierarchy. This is useful only for export.
public String getDefaultDateFormatStored()
// Get the value that's actually stored in this container or null if inherited; don't look up the hierarchy.
// This is useful for export and showing inheritance status in the UI.
public String getExtraDateParsingPatternStored()
{
return super.lookupStringValue(_c, defaultDateFormatString, null);
return getStoredValue(_c, extraDateParsingPattern);
}

// Get the value that's actually stored in this container; don't look up the hierarchy. This is useful only for export.
public String getDefaultDateTimeFormatStored()
public String getExtraDateTimeParsingPattern()
{
return super.lookupStringValue(_c, defaultDateTimeFormatString, null);
// Look up this value starting from the current container
return lookupStringValue(_c, extraDateTimeParsingPattern, null);
}

// Get the value that's actually stored in this container; don't look up the hierarchy. This is useful only for export.
public String getDefaultNumberFormatStored()
// Get the value that's actually stored in this container or null if inherited; don't look up the hierarchy.
// This is useful for export and showing inheritance status in the UI.
public String getExtraDateTimeParsingPatternStored()
{
return super.lookupStringValue(_c, defaultNumberFormatString, null);
return getStoredValue(_c, extraDateTimeParsingPattern);
}

// Get the value that's actually stored in this container; don't look up the hierarchy. This is useful only for export.
public String getDefaultTimeFormatStored()
public String getExtraTimeParsingPattern()
{
return super.lookupStringValue(_c, defaultTimeFormatString, null);
// Look up this value starting from the current container
return lookupStringValue(_c, extraTimeParsingPattern, null);
}


// Get the value that's actually stored in this container; don't look up the hierarchy. This is useful only for export.
public String getExtraDateParsingPatternStored()
// Get the value that's actually stored in this container or null if inherited; don't look up the hierarchy.
// This is useful for export and showing inheritance status in the UI.
public String getExtraTimeParsingPatternStored()
{
return super.lookupStringValue(_c, extraDateParsingPattern, null);
return getStoredValue(_c, extraTimeParsingPattern);
}

// Get the value that's actually stored in this container; don't look up the hierarchy. This is useful only for export.
public String getExtraDateTimeParsingPatternStored()
public boolean areRestrictedColumnsEnabled()
{
return super.lookupStringValue(_c, extraDateTimeParsingPattern, null);
return lookupBooleanValue(_c, restrictedColumnsEnabled, false);
}

// Get the value that's actually stored in this container; don't look up the hierarchy. This is useful only for export.
public String getExtraTimeParsingPatternStored()
// Get the value that's actually stored in this container or null if inherited; don't look up the hierarchy.
// This is useful for export and showing inheritance status in the UI.
public Boolean areRestrictedColumnsEnabledStored()
{
return super.lookupStringValue(_c, extraTimeParsingPattern, null);
String stored = getStoredValue(_c, restrictedColumnsEnabled);
return null == stored ? null : "TRUE".equals(stored);
}
}
Loading