Editing Time in DateTime Field in 2.0 DE?

4029
6
Jump to solution
04-10-2016 02:58 PM
SethLewis1
Occasional Contributor III

For v1.3 Robert provided some additional code that enables editing of time in a date time field (I can't find the discussion at the moment)

Has anyone gotten this to work in 2.0? I've attempted to re-enable this functionality but it doesn't appear that 2.0 DE is recognizing my changes. There could also have been other changes from 1.3 to 2.0 that are neutering this but I want to get some feedback from others.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Seth,

  Here is the fix for 2.0 (line 12 - 21 and 32 - 41):

array.forEach(layerInfo.fieldInfos, function(fieldInfo) {
            // compitible with old version of config,
            // to decide which file will display in inspector.
            var webmapFieldInfo = getFieldInfoFromWebmapFieldInfos(webmapFieldInfos, fieldInfo);
            if(fieldInfo.visible === undefined) {
              // compatible with old version field Info that does not defined
              // the visible attribute.
              if(webmapFieldInfo) {
                if( webmapFieldInfo.isEditable ||
                    webmapFieldInfo.isEditableSettingInWebmap ||
                    webmapFieldInfo.visible) {
                  if (webmapFieldInfo.format !== null) {
                    if (webmapFieldInfo.format.dateFormat !== null) {
                      if (webmapFieldInfo.format.dateFormat === "shortDateShortTime" ||
                        webmapFieldInfo.format.dateFormat === "shortDateShortTime24" ||
                        webmapFieldInfo.format.dateFormat === "shortDateLEShortTime" ||
                        webmapFieldInfo.format.dateFormat === "shortDateLEShortTime24") {
                        webmapFieldInfo.format.time = true;
                      }
                    }
                  }
                  newFieldInfos.push(webmapFieldInfo);
                }
              } else {
                newFieldInfos.push(fieldInfo);
              }
            } else {
              // the fieldInfo has defined the visble attribute(since online4.1).
              if(fieldInfo.visible || fieldInfo.isEditable) {
                //push to newFieldInfos
                if(webmapFieldInfo) {
                  if (webmapFieldInfo.format !== null) {
                    if (webmapFieldInfo.format.dateFormat !== null) {
                      if (webmapFieldInfo.format.dateFormat === "shortDateShortTime" ||
                        webmapFieldInfo.format.dateFormat === "shortDateShortTime24" ||
                        webmapFieldInfo.format.dateFormat === "shortDateLEShortTime" ||
                        webmapFieldInfo.format.dateFormat === "shortDateLEShortTime24") {
                        webmapFieldInfo.format.time = true;
                      }
                    }
                  }
                  newFieldInfos.push(webmapFieldInfo);
                } else {
                  newFieldInfos.push(fieldInfo);
                }
              }
            }
          }, this);

Junshan Liu​ This would be a great thing to add to the WAB core so that editing dates with time is more in line with the AGOL Map Viewer experience.

View solution in original post

6 Replies
RobertScheitlin__GISP
MVP Emeritus

Seth,

I have wrote so much code I don't remember that one. If you can show me the code it may refresh my memory and I should be able to get that working for 2.0

0 Kudos
SethLewis1
Occasional Contributor III

Hi Robert,

Of course. Thank you for replying and for assisting the rest of us.

Here's the discussion: Edit Widget - time not visible when DateTime field has time enabled

In the Edit Widget's widget.js file I made an identical insertion to the _converConfiguredLayerInfos function.

But I'm not seeing my time editing reflected in 2.0 DE.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Seth,

  Here is the fix for 2.0 (line 12 - 21 and 32 - 41):

array.forEach(layerInfo.fieldInfos, function(fieldInfo) {
            // compitible with old version of config,
            // to decide which file will display in inspector.
            var webmapFieldInfo = getFieldInfoFromWebmapFieldInfos(webmapFieldInfos, fieldInfo);
            if(fieldInfo.visible === undefined) {
              // compatible with old version field Info that does not defined
              // the visible attribute.
              if(webmapFieldInfo) {
                if( webmapFieldInfo.isEditable ||
                    webmapFieldInfo.isEditableSettingInWebmap ||
                    webmapFieldInfo.visible) {
                  if (webmapFieldInfo.format !== null) {
                    if (webmapFieldInfo.format.dateFormat !== null) {
                      if (webmapFieldInfo.format.dateFormat === "shortDateShortTime" ||
                        webmapFieldInfo.format.dateFormat === "shortDateShortTime24" ||
                        webmapFieldInfo.format.dateFormat === "shortDateLEShortTime" ||
                        webmapFieldInfo.format.dateFormat === "shortDateLEShortTime24") {
                        webmapFieldInfo.format.time = true;
                      }
                    }
                  }
                  newFieldInfos.push(webmapFieldInfo);
                }
              } else {
                newFieldInfos.push(fieldInfo);
              }
            } else {
              // the fieldInfo has defined the visble attribute(since online4.1).
              if(fieldInfo.visible || fieldInfo.isEditable) {
                //push to newFieldInfos
                if(webmapFieldInfo) {
                  if (webmapFieldInfo.format !== null) {
                    if (webmapFieldInfo.format.dateFormat !== null) {
                      if (webmapFieldInfo.format.dateFormat === "shortDateShortTime" ||
                        webmapFieldInfo.format.dateFormat === "shortDateShortTime24" ||
                        webmapFieldInfo.format.dateFormat === "shortDateLEShortTime" ||
                        webmapFieldInfo.format.dateFormat === "shortDateLEShortTime24") {
                        webmapFieldInfo.format.time = true;
                      }
                    }
                  }
                  newFieldInfos.push(webmapFieldInfo);
                } else {
                  newFieldInfos.push(fieldInfo);
                }
              }
            }
          }, this);

Junshan Liu​ This would be a great thing to add to the WAB core so that editing dates with time is more in line with the AGOL Map Viewer experience.

SethLewis1
Occasional Contributor III

Thank you Robert! You've been a great help, as always.

0 Kudos
JunshanLiu
Occasional Contributor III

@rescheitlin Thanks very much for your fix code!

@Xiaodong Wang I copy this email to Edit widget developer to fix this issue.

0 Kudos
JunshanLiu
Occasional Contributor III

Talked with the Edit widget developer, this issue has been fixed in the latest code, will be available in UC release.

The fix code is almost the same with your code. Thanks very much!@ Robert.