cmv-app icon indicating copy to clipboard operation
cmv-app copied to clipboard

Editing multiple layers

Open carrbrpoa opened this issue 7 years ago • 15 comments

Hello,

I have the following scenario: two protected services. Whenever I load the application, it asks for credentials (OK) twice (one for each protected service - OK, I suppose). The problem is that if I cancel the login box for one of them (let's say the one that I know I don't have the credentials for edition), the Editor widget just doesn't show the editable feature when I turn it on, so I can't edit anything. Any suggestions?

carrbrpoa avatar Sep 01 '16 14:09 carrbrpoa

Is https://github.com/cmv/cmv-app/issues/567 related?

green3g avatar Sep 01 '16 14:09 green3g

Hey @roemhildtg, good catch! Maybe. The difference is that in #567, I was interacting with a custom util/widget; now, I'm interacting with Editor Widget. See:

image

carrbrpoa avatar Sep 01 '16 14:09 carrbrpoa

My initial thought is that its not so much a cmv thing but a arcgis js api identity manager thing. afaik, cmv doesn't do the authenticating, that's baked into the api. Same with the editing, I'm pretty sure the editor widget is simply a cmv ui wrapped around the default api editor widget.

green3g avatar Sep 01 '16 14:09 green3g

Actually, error happens when I do authenticate in the first login dialog too, but seems to be a little different:

image

carrbrpoa avatar Sep 01 '16 14:09 carrbrpoa

@carrbrpoa what @roemhildtg says is correct. The authentication occurs within the Esri API's IdentityManager. CMV doesn't get involved.

If you do not enter credentials or you enter incorrect credentials, you will not be able to edit the layers. The Esri editor widget is expecting access to all of the feature layers for which you have included via editorLayerInfos.

tmcgee avatar Sep 01 '16 15:09 tmcgee

Do you guys think it is possible to workaround this behavior in some way?

carrbrpoa avatar Sep 01 '16 15:09 carrbrpoa

@carrbrpoa I want to make sure I am clear about what you are trying to do.

You want to be able to edit some of the features layers (layers for which you have authenticated successfully with that Feature Service) but exclude other layers for which the authentication has failed or the user cancelled. Is that correct?

tmcgee avatar Sep 01 '16 16:09 tmcgee

Yes, that's it. I want to be able to edit at least the layers that I'm successfully authenticated; in the Layers Widget, it is OK to me to show that empty checkbox for non authed layers, but I want to see the ones I authed in Editor Widget, which is not happening, because as I see and you said, the Editor wants access to all the feature layers.

carrbrpoa avatar Sep 01 '16 16:09 carrbrpoa

Another case to help to see this problem is to think about different staff that are able to edit different layers but access the same application.

carrbrpoa avatar Sep 01 '16 16:09 carrbrpoa

You can check your layers before passing them to the Esri editor widget. Somewhere around here. So you don't have to customize the Editor widget, an alternative is to create your own widget that receives the same editotLayerInfos, validates the layers and then instantiates the Editor widget.

Actually, this reminds of this prior discussion which is a potential cmv enhancement. Pull Request anyone? ;)

tmcgee avatar Sep 01 '16 16:09 tmcgee

Thanks for the help @tmcgee, I'll try something later and post the results!

carrbrpoa avatar Sep 01 '16 16:09 carrbrpoa

@carrbrpoa Did you get this resolved?

tmcgee avatar Sep 10 '16 01:09 tmcgee

Hey @tmcgee! Not yet; reading it more carefully, you talk about "validate the layer". Any tips on how to do it?

carrbrpoa avatar Sep 12 '16 12:09 carrbrpoa

@carrbrpoa by validate the layer, I mean check that the layer is available for editing (the user has authenticated successfully for that specific layer). There may be some code in the issue I linked to that could help but I am not sure. If you write the code in a custom editor widget, you only have to validate those layers that are passed to the widget through editorLayerInfos. Hope that helps clarify what I was suggesting.

tmcgee avatar Sep 12 '16 15:09 tmcgee

@carrbrpoa You could listen for the esri identity manager credential-create and dialog-cancel events to determine which layers are loaded. That could potentially solve both this and https://github.com/cmv/cmv-app/issues/567

https://developers.arcgis.com/javascript/3/jsapi/identitymanager-amd.html#event-credential-create

credential-create { credential: <Credential> } Fired when a credential is created. credentials-destroy Fired when all credentials are destroyed.

dialog-cancel { info: <Object> } Fired when the user clicks the cancel button on the dialog box widget. dialog-create

green3g avatar Dec 02 '16 02:12 green3g