Skip to content

Commit

Permalink
add time required field.
Browse files Browse the repository at this point in the history
  • Loading branch information
wildone committed Jun 2, 2021
1 parent 9580868 commit a692775
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,32 @@ This component has the following variants
</tbody>
</table>

# ISO 8601 duration format

Time Required field uses ISO 8601 duration format and allows representing schema for an article or a page.

Source: [ISO 8601 duration format](https://www.digi.com/resources/documentation/digidocs/90001437-13/reference/r_iso_8601_duration_format.htm)

ISO 8601 Durations are expressed using the following format, where (n) is replaced by the value for each of the date and time elements that follow the (n):

`P(n)Y(n)M(n)DT(n)H(n)M(n)S`

Where:

- `P` is the duration designator (referred to as "period"), and is always placed at the beginning of the duration.
- `Y` is the year designator that follows the value for the number of years.
- `M` is the month designator that follows the value for the number of months.
- `W` is the week designator that follows the value for the number of weeks.
- `D` is the day designator that follows the value for the number of days.
- `T` is the time designator that precedes the time components.
- `H` is the hour designator that follows the value for the number of hours.
- `M` is the minute designator that follows the value for the number of minutes.
- `S` is the second designator that follows the value for the number of seconds.

For example:

- `P3Y6M4DT12H30M5S` - Represents a duration of three years, six months, four days, twelve hours, thirty minutes, and five seconds.
- `PT1M` - Represents a duration of time required to complete something which is one minute
- `PT1H1M` - Represents a duration of time required to complete something which is one hour and one minute

<p></p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template data-sly-template.field="${@ componentProperties}">
<span itemprop="timeRequired" content="${componentProperties.timeRequiredText}">${componentProperties.timeRequiredText}</span>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,32 @@ This component has the following variants
</tbody>
</table>

# ISO 8601 duration format

Time Required field uses ISO 8601 duration format and allows representing schema for an article or a page.

Source: [ISO 8601 duration format](https://www.digi.com/resources/documentation/digidocs/90001437-13/reference/r_iso_8601_duration_format.htm)

<p></p>
ISO 8601 Durations are expressed using the following format, where (n) is replaced by the value for each of the date and time elements that follow the (n):

`P(n)Y(n)M(n)DT(n)H(n)M(n)S`

Where:

- `P` is the duration designator (referred to as "period"), and is always placed at the beginning of the duration.
- `Y` is the year designator that follows the value for the number of years.
- `M` is the month designator that follows the value for the number of months.
- `W` is the week designator that follows the value for the number of weeks.
- `D` is the day designator that follows the value for the number of days.
- `T` is the time designator that precedes the time components.
- `H` is the hour designator that follows the value for the number of hours.
- `M` is the minute designator that follows the value for the number of minutes.
- `S` is the second designator that follows the value for the number of seconds.

For example:

- `P3Y6M4DT12H30M5S` - Represents a duration of three years, six months, four days, twelve hours, thirty minutes, and five seconds.
- `PT1M` - Represents a duration of time required to complete something which is one minute
- `PT1H1M` - Represents a duration of time required to complete something which is one hour and one minute

<p></p>
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@
resourceType="granite/ui/components/foundation/form/hidden"
sling:resourceType="granite/ui/components/coral/foundation/include"/>

<timeRequired
jcr:primaryType="nt:unstructured"
jcr:title="Time Required / Time To Read Value"
path="/apps/aemdesign/global/dialog/touch/page/content/items/pageBasicTab/items/column/items/metadata/items/timeRequired"
resourceType="granite/ui/components/coral/foundation/form/textfield"
sling:resourceType="granite/ui/components/coral/foundation/include"/>

<timeRequiredText
jcr:primaryType="nt:unstructured"
jcr:title="Time Required / Time To Read Text"
path="/apps/aemdesign/global/dialog/touch/page/content/items/pageBasicTab/items/column/items/metadata/items/timeRequiredText"
resourceType="granite/ui/components/coral/foundation/form/textfield"
sling:resourceType="granite/ui/components/coral/foundation/include"/>

</items>
</column2>
</items>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ValueMap;
import org.apache.sling.api.wrappers.ValueMapDecorator;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.stream.Collectors;

import static design.aem.utils.components.CommonUtil.*;
import static design.aem.utils.components.ComponentDetailsUtil.isComponentRenderedByList;
Expand Down Expand Up @@ -70,6 +67,10 @@ public class GenericDetails extends BaseComponent {
protected static final String DEFAULT_TITLE_TAG_TYPE = "h1";
protected static final String DEFAULT_I18N_LABEL = "variantHiddenLabel";

protected static final String FIELD_TIME_REQUIRED = "timeRequired";
protected static final String FIELD_TIME_REQUIRED_TEXT = "timeRequiredText";


protected void ready() {
componentProperties = ComponentsUtil.getComponentProperties(
this,
Expand Down Expand Up @@ -166,6 +167,8 @@ protected void setFields() {
{"showParsys", true},
{FIELD_CONTENTFRAGMENT_VARIATION, DEFAULT_CONTENTFRAGMENT_VARIATION},
{FIELD_CONTENTFRAGMENT_FRAGMENTPATH, StringUtils.EMPTY},
{FIELD_TIME_REQUIRED, StringUtils.EMPTY},
{FIELD_TIME_REQUIRED_TEXT, StringUtils.EMPTY},
});
}

Expand Down

0 comments on commit a692775

Please sign in to comment.