require(["esri/widgets/Editor/EditorViewModel"], (EditorVM) => { /* code goes here */ });
import EditorVM from "@arcgis/core/widgets/Editor/EditorViewModel.js";
esri/widgets/Editor/EditorViewModel
Provides the logic for the Editor widget.
- See also
const editor = new Editor({
viewModel: { // autocasts as new EditorViewModel
layerInfos: [{
layer: featureLayer,
deleteEnabled: false // disables deleting features
}]
}
});
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
A property indicating the current active workflow. | EditorViewModel | ||
An array of string values which specifies what end users are allowed to edit. | EditorViewModel | ||
The AttachmentsViewModel for supporting the editor widget. | EditorViewModel | ||
Convenience property that indicates at least one layer supports a | EditorViewModel | ||
Convenience property that indicates at least one layer supports a | EditorViewModel | ||
The name of the class. | Accessor | ||
A read-only collection of editable item objects that match the feature being updated. | EditorViewModel | ||
A predominantly read-only collection of editor items that corresponds to the feature being updated. | EditorViewModel | ||
An array of objects containing information specific to any failed editing operations. | EditorViewModel | ||
The FeatureFormViewModel for supporting the editor widget. | EditorViewModel | ||
The FeatureTemplatesViewModel for supporting the editor widget. | EditorViewModel | ||
Options to configure the labels shown next to each segment of the geometry being created or updated. | EditorViewModel | ||
An array of editing configurations for individual layers. | EditorViewModel | ||
The SketchViewModel for supporting the editor widget. | EditorViewModel | ||
The SnappingOptions for sketching. | EditorViewModel | ||
The widget's state. | EditorViewModel | ||
Indicates if there is at least one edit request being processed. | EditorViewModel | ||
Options to configure the tooltip shown next to the cursor when creating or updating graphics. | EditorViewModel | ||
Options to configure how values are displayed and input when creating or updating graphics. | EditorViewModel | ||
EditorViewModel |
Property Details
-
activeWorkflow
activeWorkflow CreateFeaturesWorkflow |UpdateWorkflowreadonly
-
A property indicating the current active workflow. This is either CreateFeaturesWorkflow or UpdateWorkflow.
- See also
-
allowedWorkflows
allowedWorkflows String
Deprecated since version 4.29. Use Editor.visibleElements instead. -
An array of string values which specifies what end users are allowed to edit.
Possible Value Description create-features This allows the end user to create either individual or continuous features in the feature service. update This allows the end user to update and/or delete features in the feature service. These workflows are only enabled if the feature service allows these operations.
Possible Values:"create-features" |"update"
-
attachmentsViewModel
attachmentsViewModel AttachmentsViewModel
-
The AttachmentsViewModel for supporting the editor widget. Attachment editing is enabled by default if the layer has support for it.
-
canCreate
canCreate Booleanreadonly
-
Convenience property that indicates at least one layer supports a
create-features
workflow.
-
canUpdate
canUpdate Booleanreadonly
-
Convenience property that indicates at least one layer supports a
update
workflow. This includes the ability to delete features and modify attachments and/or related records.
-
editableItems
editableItems Collection<EditableItem>readonly
Deprecated since 4.29. Use editorItems instead. -
A read-only collection of editable item objects that match the feature being updated.
-
editorItems
editorItems Collection<EditorItem>readonly
Since: ArcGIS Maps SDK for JavaScript 4.29EditorViewModel since 4.11, editorItems added at 4.29. -
A predominantly read-only collection of editor items that corresponds to the feature being updated.
-
An array of objects containing information specific to any failed editing operations. In addition to the error(s), options to
retry()
orcancel()
are provided.- Property
-
error Error
The read-only error message.
-
featureFormViewModel
featureFormViewModel FeatureFormViewModel
-
The FeatureFormViewModel for supporting the editor widget.
-
featureTemplatesViewModel
featureTemplatesViewModel FeatureTemplatesViewModel
-
The FeatureTemplatesViewModel for supporting the editor widget.
-
labelOptions
labelOptions SketchLabelOptionsautocast
Since: ArcGIS Maps SDK for JavaScript 4.24EditorViewModel since 4.11, labelOptions added at 4.24. -
Options to configure the labels shown next to each segment of the geometry being created or updated.
Known Limitation
Sketch labels are currently only supported when working with a SceneView.
-
An array of editing configurations for individual layers.
For example, if you have an editable feature layer but do not want the end user to do any type of editing, you can limit this by setting the
enabled
property tofalse
.Exampleconst editorViewModel = new EditorViewModel({ layerInfos: [{ layer: featureLayer, // pass in the feature layer, formTemplate: { // autocasts to FormTemplate elements: [ { // autocasts to FieldElement type: "field", fieldName: "fulladdr", label: "Full Address" } ] }, enabled: true, // default is true, set to false to disable editing functionality addEnabled: true, // default is true, set to false to disable the ability to add a new feature updateEnabled: false // default is true, set to false to disable the ability to edit an existing feature deleteEnabled: false // default is true, set to false to disable the ability to delete features }] });
-
sketchViewModel
sketchViewModel SketchViewModel
-
The SketchViewModel for supporting the editor widget.
-
snappingOptions
snappingOptions SnappingOptionsautocast
Since: ArcGIS Maps SDK for JavaScript 4.19EditorViewModel since 4.11, snappingOptions added at 4.19. -
The SnappingOptions for sketching. It supports self and feature snapping.
-
state
state Stringreadonly
-
The widget's state. Possible values are in the table below.
Value Description ready Dependencies are met and has valid property values. disabled Dependencies are missing and cannot provide valid inputs. editing-existing-feature The Editor is currently editing an existing feature. awaiting-update-feature-candidate The period when the application is awaiting the user's input after clicking update and multiple features are returned. Specify the feature to update. awaiting-feature-creation-info This is the first step in the create-features
workflow. A CreationInfo is required.awaiting-feature-to-update This is the first step in the update
workflow. A feature is required.awaiting-feature-to-create The waiting period for when a feature is created before attribute/geometry edits can be performed. adding-attachment If currently editing-existing-feature
and adding an attachment to an existing feature.editing-attachment If currently editing-existing-feature
and updating an existing attachment to an existing feature.creating-features The Editor is currently creating multiple features. Possible Values:"adding-attachment" |"awaiting-feature-creation-info" |"awaiting-feature-to-create" |"awaiting-feature-to-update" |"awaiting-update-feature-candidate" |"creating-features" |"disabled" |"editing-attributes" |"editing-attachment" |"editing-existing-feature" |"editing-new-feature" |"awaiting-update-feature-candidate" |"ready"
-
syncing
syncing Booleanreadonly
-
Indicates if there is at least one edit request being processed.
-
tooltipOptions
tooltipOptions SketchTooltipOptionsautocast
Since: ArcGIS Maps SDK for JavaScript 4.24EditorViewModel since 4.11, tooltipOptions added at 4.24. -
Options to configure the tooltip shown next to the cursor when creating or updating graphics.
-
valueOptions
valueOptions SketchValueOptionsautocast
Since: ArcGIS Maps SDK for JavaScript 4.29EditorViewModel since 4.11, valueOptions added at 4.29. -
Options to configure how values are displayed and input when creating or updating graphics.
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
Promise<void> | Cancels any active workflow. | EditorViewModel | |
Promise<void> | This is applicable if there is an active update workflow with an active child workflow. | EditorViewModel | |
Returns true if a named group of handles exist. | Accessor | ||
Removes a group of handles owned by the object. | Accessor | ||
Promise<void> | Initiates the CreateFeaturesWorkflow by displaying the panel where feature creation begins. | EditorViewModel | |
Promise<void> | This method starts the CreateFeaturesWorkflow at the "creating-features" step with the provided feature. | EditorViewModel | |
Promise<void> | Initiates the CreateFeaturesWorkflow by displaying the FeatureTemplates panel. | EditorViewModel | |
Promise<void> | Starts the update workflow at the feature geometry and attribute editing panel. | EditorViewModel | |
Promise<void> | Starts the | EditorViewModel | |
Promise<void> | Starts the Editor workflow where it waits for multiple features to be selected. | EditorViewModel | |
Toggles the | EditorViewModel |
Method Details
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, addHandles added at 4.25. -
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
deleteFeatureFromWorkflow
deleteFeatureFromWorkflow(){Promise<void>}
-
This is applicable if there is an active update workflow with an active child workflow. In this case, this method deletes the feature associated with the active child workflow.
ReturnsType Description Promise<void> Resolves once the active UpdateWorkflow is deleted. - See also
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, removeHandles added at 4.25. -
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
-
startCreateFeaturesWorkflowAtFeatureCreation
startCreateFeaturesWorkflowAtFeatureCreation(creationInfo){Promise<void>}
Since: ArcGIS Maps SDK for JavaScript 4.23EditorViewModel since 4.11, startCreateFeaturesWorkflowAtFeatureCreation added at 4.23. -
Initiates the CreateFeaturesWorkflow by displaying the panel where feature creation begins. This method takes a CreationInfo object containing the layer(s) and template(s) to use.
ParametercreationInfo CreationInfoAn object containing information needed to create a new feature using the Editor widget. This object provides the feature template and layer for creating a new feature.
ReturnsType Description Promise<void> Resolves when the CreateFeaturesWorkflow initiates and displays the panel where feature creation begins.
-
startCreateFeaturesWorkflowAtFeatureEdit
startCreateFeaturesWorkflowAtFeatureEdit(params){Promise<void>}
Since: ArcGIS Maps SDK for JavaScript 4.28EditorViewModel since 4.11, startCreateFeaturesWorkflowAtFeatureEdit added at 4.28. -
This method starts the CreateFeaturesWorkflow at the "creating-features" step with the provided feature.
Any CreateFeaturesWorkflow instance generated by this method will only support creating a single feature per operation, (ie. batch creation is disabled).
ParametersReturnsType Description Promise<void> Resolves once the CreateFeaturesWorkflow initiates and displays the panel where additional edits can be made to the provided feature. - See also
-
startCreateFeaturesWorkflowAtFeatureTypeSelection
startCreateFeaturesWorkflowAtFeatureTypeSelection(){Promise<void>}
Since: ArcGIS Maps SDK for JavaScript 4.23EditorViewModel since 4.11, startCreateFeaturesWorkflowAtFeatureTypeSelection added at 4.23. -
Initiates the CreateFeaturesWorkflow by displaying the FeatureTemplates panel.
ReturnsType Description Promise<void> Resolves when the CreateFeaturesWorkflow is initiated and displays the FeatureTemplates panel.
-
startUpdateWorkflowAtFeatureEdit
startUpdateWorkflowAtFeatureEdit(feature){Promise<void>}
-
Starts the update workflow at the feature geometry and attribute editing panel.
Parameterfeature GraphicThe feature to be updated.
ReturnsType Description Promise<void> Resolves once the UpdateWorkflow initiates the feature geometry and attribute editing panel. - See also
-
startUpdateWorkflowAtFeatureSelection
startUpdateWorkflowAtFeatureSelection(){Promise<void>}
-
Starts the
update
workflow using the current selected feature.ReturnsType Description Promise<void> Resolves once the UpdateWorkflow is initiated using the current selected feature. - See also
-
startUpdateWorkflowAtMultipleFeatureSelection
startUpdateWorkflowAtMultipleFeatureSelection(){Promise<void>}
-
Starts the Editor workflow where it waits for multiple features to be selected.
ReturnsType Description Promise<void> Resolves once the UpdateWorkflow is initiated as it waits for multiple features to be selected. - See also
Type Definitions
-
The editable item available within the map. All the properties returned within it are read-only.
- Properties
-
The layer associated with the editable item.
supports StringThe workflow type that this item supports. Possible values are
create
,update
, ordelete
.hasAttachments BooleanIndicates whether this layer has attachments on it.
geometryUpdatesEnabled BooleanIndicates whether this layer enables or disables geometry updates.
attributeUpdatesEnabled BooleanIndicates whether this layer supports attribute editing while in the
update
workflow.attachmentsOnCreateEnabled BooleanIndicates whether this layer supports the ability to work with attachments while creating features.
attachmentsOnUpdateEnabled BooleanIndicates whether this layer supports the ability to work with attachments while updating or deleting features.
hasInvalidFormTemplate BooleanIndicates whether this layer's formTemplate is invalid. For example, removing or deleting a field within the layer that is still referenced in its original way and not updating the coinciding template.
Event Overview
Name | Type | Summary | Class |
---|---|---|---|
|
{type: "sketch-create",layer: FeatureLayer|SceneLayer|SubtypeSublayer,detail: Object,detail.graphic: Graphic,detail.state: "start"|"active"|"complete"|"cancel",detail.tool: "point"|"multipoint"|"polyline"|"polygon"|"circle"|"rectangle"|"mesh",detail.toolEventInfo: CreateToolEventInfo,detail.type: "create"} |
Fires when a user starts drawing a feature, is actively drawing a feature, and completes drawing a feature. |
EditorViewModel |
|
{type: "sketch-update",layer: FeatureLayer|SceneLayer|SubtypeSublayer,detail: Object,detail.aborted: Boolean,detail.graphics: Graphic[],detail.state: "start"|"active"|"complete",detail.tool: "move"|"transform"|"reshape",toolEventInfo: UpdateToolEventInfo,detail.type: "update"} |
Fires when a user starts updating a feature's geometry, is actively updating a feature's geometry, and completes updating a feature's geometry. |
EditorViewModel |
Event Details
-
Since: ArcGIS Maps SDK for JavaScript 4.29EditorViewModel since 4.11, sketch-create added at 4.29. -
Fires when a user starts drawing a feature, is actively drawing a feature, and completes drawing a feature.
- Properties
-
type String
The value is always "sketch-create".
The layer currently being edited.
detail ObjectDetailed information returned within the "sketch-create" event.
- Specification
-
graphic Graphic
The feature being created.
state StringThe current state of the event.
Value Description start State changes to start
when the first vertex is created. Not applicable when creatingpoints
.active State is active
while feature is being created. Not applicable when creatingpoints
.complete State changes to complete
after the complete() method is called, when the user double clicks, presses theEnter
key or clicks the first vertex of thepolygon
while creating a feature. Whenpoint
is created, the a singlesketch-create
event is fired with thecomplete
state.cancel State changes to cancel
if the user presses the escape key or the create() or cancel() methods are called during the create operation and before the state changes tocomplete
.Possible Values:"start"|"active"|"complete"|"cancel"
tool StringName of the create tool.
Possible Values:"point"|"multipoint"|"polyline"|"polygon"|"circle"|"rectangle"|"mesh"
toolEventInfo CreateToolEventInfoReturns additional information associated with the create operation.
type StringThe value is always "create".
Example// Listen to EditorViewModel's create event. editorViewModel.on("sketch-create", function(evt) { const { graphic, tool } = evt.detail; // Check if the tool used is a 'polyline' if (tool === "polyline") { // Set the active polyline symbol to white while drawing graphic.symbol.color = "#ffffff"; } });
-
Since: ArcGIS Maps SDK for JavaScript 4.29EditorViewModel since 4.11, sketch-update added at 4.29. -
Fires when a user starts updating a feature's geometry, is actively updating a feature's geometry, and completes updating a feature's geometry.
- Properties
-
type String
The value is always "sketch-update".
The layer currently being edited.
detail ObjectDetailed information returned within the "sketch-update" event.
- Specification
-
aborted Boolean
Indicates if the update operation was aborted. Returns
true
if the user pressed theesc
key, or when the update(), create() or cancel() method is called before theupdate
event'sstate
changes tocomplete
.An array of features that are being updated.
state StringThe state of the event.
Value Description start State changes to start
when a feature is selected to update.active State is active
while features are being updated andtoolEventInfo
parameter is notnull
.complete State changes to complete
after features are updated.Possible Values:"start"|"active"|"complete"
tool StringName of the update operation tool.
Possible Values:"move"|"transform"|"reshape"
toolEventInfo UpdateToolEventInfoUpdate operation tool info. Returns additional information associated with the update operation that is taking place for selected feature and what stage it is at. Value of this parameter changes to
null
when theupdate
event'sstate
changes tocomplete
.detail.type StringThe value is always "update".
Example// Listen to EditorViewModel's update event. editorViewModel.on("sketch-update", function(evt) { const { tool, graphics } = evt.detail; // Check if the layer's geometryType is a 'polyline' if (evt.layer?.geometryType === "polyline") { // For every feature, update the line symbol // width to emphasize the feature being updated graphics.forEach((graphic) => graphic.symbol.width = 5); } });