Query widget : attribute edit

545
4
09-28-2016 09:06 AM
helenchu
Occasional Contributor II

Robert Scheitlin, GISP

Hi Robert,

I'm sorry if I take too much of your time being back and forth on this Edit subject but I couldn't do it without your help and I think I'm now pretty close to getting that function work for my need.  

With my stacked accounts issue:

1/  Edit from attribute table: Success!  Thank you!

I finally can work around by populating the Edit popup only, then double click on the attribute button to open the attribute edit window.  By doing this 1 extra click, the attribute edit popup always populate the account associated with the selected record from attribute table.  My users can live with that.

I commented out part of your codes that use feature.geometry -> it returns all points.  

if (this.wManager) {
var widgetCfg = this._getWidgetConfig('Edit');
if(widgetCfg){
this.wManager.triggerWidgetOpen(widgetCfg.id).then(lang.hitch(this, function(editWidget){
editWidget.disableWebMapPopup();
setTimeout(lang.hitch(this, function(){
var showEvent = {};

// commented out to disable attribute popup
      // var featurePoint;
      // if(result[0].geometry.type === 'point') {
      // featurePoint = result[0].geometry;
      // } else {
      // featurePoint = result[0].geometry.getExtent().getCenter();
      // }

      //console.info(featurePoint);
      //showEvent.mapPoint = featurePoint;
      //showEvent.graphic = result[0];
editWidget.reClickMap(showEvent);
}), 500);
}));
}
}
//end

2/  Edit from Query result: Still struggle!

I copied the above codes but it didn't give me the same behavior.  I still got the Edit popup however the attribute button on that window is inactive (from both query result window and attribute window).  I must have missed something.

In widgets/Query/SingleQueryResult.js

if(def){
def.then(lang.hitch(this, function(){
if(typeof this.map.infoWindow.setFeatures === 'function'){
this.map.infoWindow.setFeatures([feature]);
}
if(typeof this.map.infoWindow.reposition === 'function'){
this.map.infoWindow.reposition();
}

/*start edits*/
//this.map.infoWindow.show(centerPoint);
if (this.wManager) {
var widgetCfg = this._getWidgetConfig('Edit');
if (widgetCfg) {
this.wManager.triggerWidgetOpen(widgetCfg.id).then(lang.hitch(this, function (widget) {
setTimeout(lang.hitch(this, function () {
var showEvent = {}; //new

//change to this: populate Edit 
editWidget.reClickMap(showEvent);
}), 500);
//end

//how it was before
   var mpPt = feature.geometry;
   var scrPt = this.map.toScreen(mpPt);
   this.map.emit("click", { bubbles: true, cancelable: true, screenPoint: scrPt, mapPoint: mpPt });
   }), 1000);
//end

}));
}
}

}));
}
}
},

/*Added the new support function*/
_getWidgetConfig: function (widgetName) {
var widgetCnfg = null;
array.some(this.wManager.appConfig.widgetPool.widgets, function (aWidget) {
if (aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
if (!widgetCnfg) {
/*Check OnScreen widgets if not found in widgetPool*/
array.some(this.wManager.appConfig.widgetOnScreen.widgets, function (aWidget) {
if (aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
}
return widgetCnfg;
},
/* end new support function*/

_hideInfoWindow:function(){
if(this.map && this.map.infoWindow){
this.map.infoWindow.hide();
if(typeof this.map.infoWindow.setFeatures === 'function'){
this.map.infoWindow.setFeatures([]);
}
}
},

 

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Helen,

Attached is what works for me (you just had a lot of syntax issue i.e. curly braces and parentheses that did not match). 

0 Kudos
helenchu
Occasional Contributor II

I have that before and it worked fine.  Just that with stacked accounts, it will populate all records in that feature point.  (in my case it could be hundred of points: impossible for users to loop through to find the record they want to edit)

What I was trying to say is in attribute widget I can just use the below codes to populate the edit popup without the attribute popup.  Then click at the attribute button from Edit popup, it will populate the exact record for attribute edit.

Attribute widget: FeatureTable.js  (These codes works exactly as I want it)

if (this.wManager) {
var widgetCfg = this._getWidgetConfig('Edit');
if(widgetCfg){
this.wManager.triggerWidgetOpen(widgetCfg.id).then(lang.hitch(this, function(editWidget){
editWidget.disableWebMapPopup();
setTimeout(lang.hitch(this, function(){
var showEvent = {};
editWidget.reClickMap(showEvent);
}), 500);
}));
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Query widget: SingleQueryResult.js

if (this.wManager) {
var widgetCfg = this._getWidgetConfig('Edit');
if (widgetCfg) {
this.wManager.triggerWidgetOpen(widgetCfg.id).then(lang.hitch(this, function (widget) {
setTimeout(lang.hitch(this, function () {
var mpPt = feature.geometry;
var scrPt = this.map.toScreen(mpPt);
 this.map.emit("click", { bubbles: true, cancelable: true, screenPoint: scrPt, mapPoint: mpPt });
}), 1000);
}));

}‍‍‍‍‍‍‍‍‍‍‍‍

 

if I replace (in SingleQueryResult.js)

var mpPt = feature.geometry;
var scrPt = this.map.toScreen(mpPt);
this.map.emit("click", { bubbles: true, cancelable: true, screenPoint: scrPt, mapPoint: mpPt });
}), 1000);

with 

var showEvent = {}; 
editWidget.reClickMap(showEvent);
}), 500);

for some reasons, the attribute button on Edit popup is inactive. It didn't response at all.

I hope you could understand what's I'm trying to say ?  Sorry I don't know how to explain it better!

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Helen,

   I have not been successful find a solution for your exact workflow. Sorry I can not help more. 

0 Kudos
helenchu
Occasional Contributor II

Thanks Robert.  I appreciate it!

0 Kudos